Exemplo n.º 1
0
        public TripleBandLinearOp(int direction, FdmMesher mesher)
        {
            direction_    = direction;
            i0_           = new InitializedList <int>(mesher.layout().size());
            i2_           = new InitializedList <int>(mesher.layout().size());
            reverseIndex_ = new InitializedList <int>(mesher.layout().size());
            lower_        = new InitializedList <double>(mesher.layout().size());
            diag_         = new InitializedList <double>(mesher.layout().size());
            upper_        = new InitializedList <double>(mesher.layout().size());
            mesher_       = mesher;

            FdmLinearOpLayout   layout  = mesher.layout();
            FdmLinearOpIterator endIter = layout.end();

            int        tmp;
            List <int> newDim = new List <int>(layout.dim());

            tmp = newDim[direction_];
            newDim[direction_] = newDim[0];
            newDim[0]          = tmp;

            List <int> newSpacing = new FdmLinearOpLayout(newDim).spacing();

            tmp = newSpacing[direction_];
            newSpacing[direction_] = newSpacing[0];
            newSpacing[0]          = tmp;

            for (FdmLinearOpIterator iter = layout.begin(); iter != endIter; ++iter)
            {
                int i = iter.index();

                i0_[i] = layout.neighbourhood(iter, direction, -1);
                i2_[i] = layout.neighbourhood(iter, direction, 1);

                List <int> coordinates = iter.coordinates();

                int newIndex = coordinates.inner_product(0, coordinates.Count, 0, newSpacing, 0);
                reverseIndex_[newIndex] = i;
            }
        }
Exemplo n.º 2
0
        public NinePointLinearOp(int d0, int d1, FdmMesher mesher)
        {
            d0_     = d0;
            d1_     = d1;
            i00_    = new InitializedList <int>(mesher.layout().size());
            i10_    = new InitializedList <int>(mesher.layout().size());
            i20_    = new InitializedList <int>(mesher.layout().size());
            i01_    = new InitializedList <int>(mesher.layout().size());
            i21_    = new InitializedList <int>(mesher.layout().size());
            i02_    = new InitializedList <int>(mesher.layout().size());
            i12_    = new InitializedList <int>(mesher.layout().size());
            i22_    = new InitializedList <int>(mesher.layout().size());
            a00_    = new InitializedList <double>(mesher.layout().size());
            a10_    = new InitializedList <double>(mesher.layout().size());
            a20_    = new InitializedList <double>(mesher.layout().size());
            a01_    = new InitializedList <double>(mesher.layout().size());
            a11_    = new InitializedList <double>(mesher.layout().size());
            a21_    = new InitializedList <double>(mesher.layout().size());
            a02_    = new InitializedList <double>(mesher.layout().size());
            a12_    = new InitializedList <double>(mesher.layout().size());
            a22_    = new InitializedList <double>(mesher.layout().size());
            mesher_ = mesher;

            Utils.QL_REQUIRE(d0_ != d1_ &&
                             d0_ < mesher.layout().dim().Count &&
                             d1_ < mesher.layout().dim().Count,
                             () => "inconsistent derivative directions");

            FdmLinearOpLayout   layout  = mesher.layout();
            FdmLinearOpIterator endIter = layout.end();

            for (FdmLinearOpIterator iter = layout.begin(); iter != endIter; ++iter)
            {
                int i = iter.index();

                i10_[i] = layout.neighbourhood(iter, d1_, -1);
                i01_[i] = layout.neighbourhood(iter, d0_, -1);
                i21_[i] = layout.neighbourhood(iter, d0_, 1);
                i12_[i] = layout.neighbourhood(iter, d1_, 1);
                i00_[i] = layout.neighbourhood(iter, d0_, -1, d1_, -1);
                i20_[i] = layout.neighbourhood(iter, d0_, 1, d1_, -1);
                i02_[i] = layout.neighbourhood(iter, d0_, -1, d1_, 1);
                i22_[i] = layout.neighbourhood(iter, d0_, 1, d1_, 1);
            }
        }