Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Examples  

EquationSet.h

Go to the documentation of this file.
00001 #ifndef EQUATIONSET_H
00002 #define EQUATIONSET_H
00003 
00004 #include "SundanceDefs.h"
00005 
00006 
00007 #include "EssentialBC.h"
00008 #include "WeakForm.h"
00009 #include "AbstractFunctionSpace.h"
00010 #include "GaussLegendre.h"
00011 #include "TSFNonDupArray.h"
00012 #include "BasisFamily.h"
00013 #include "TSFHashtable.h"
00014 #include "ParametricVectorElement.h"
00015 #include "ParametricMatrixElement.h"
00016 
00017 
00018 namespace Sundance
00019 {
00020 
00021   using namespace TSF;
00022   using std::string;
00023 
00024   using std::ostream;
00025 
00026   /** \ingroup LowLevelFE
00027    * Equation set is a collection of all
00028    * variational equations and boundary conditions pertinent to a
00029    * problem, listed by CellSet.  An equationSet also contains a
00030    * specification of the block structure of the unknown and test
00031    * function spaces.
00032    *
00033    * The information contained in an equation set is sufficient to build
00034    * a table of weak forms for the problem. However, the equation set
00035    * contains no information about the mesh and thus cannot by itself produce
00036    * discrete function spaces or DOF maps. The discrete function spaces
00037    * are created in the createRowSpace and createColSpace methods which take
00038    * the problem mesh as an argument.
00039    */
00040 
00041   class EquationSet
00042     {
00043     public:
00044       /** empty ctor */
00045       EquationSet();
00046 
00047       /** construct an EquationSet given a variational equation with
00048        * no replace-style essential boundary conditions. The ExprArray
00049        * arguments specify the block structure of the unknown
00050        * and test spaces.*/
00051 
00052       EquationSet(const ExprArray& test, const ExprArray& unk,
00053                   const Expr& integral);
00054       /** construct an EquationSet given a variational equation plus
00055        * replace-style essential boundary conditions. The ExprArray
00056        * arguments specify the block structure of the unknown and test
00057        * spaces.*/
00058       EquationSet(const ExprArray& test, const ExprArray& unk,
00059                   const Expr& integral, const EssentialBC& bc);
00060 
00061       /** get the list of cell sets used by the equations */
00062       const TSFArray<CellSet>& getCellSets() const {return cellSets_;}
00063 
00064       /** get the list of one-forms that apply on the given cell set */
00065       const TSFArray<WeakForm>& oneFormList(int cellSet) const
00066         {return oneForms_[cellSet];}
00067 
00068       /** get the list of two-forms that apply on the given cell set */
00069       const TSFArray<WeakForm>& twoFormList(int cellSet) const
00070         {return twoForms_[cellSet];}
00071 
00072       /** get the unmeshed matrix elements for a block */
00073       const TSFArray<ParametricMatrixElement>& getParametricElements(int br,
00074                                                                      int bc) const
00075         {return parametricMatrixBlocks_[br][bc];}
00076 
00077       /** get the unmeshed vector elements for a block */
00078       const TSFArray<ParametricVectorElement>& getParametricElements(int br) const
00079         {return parametricVectorBlocks_[br];}
00080 
00081 
00082 
00083       /** create a discrete function space for the blockRow-th block
00084        * of the row space. */
00085       AbstractFunctionSpace createRowSpace(int blockRow,
00086                                            const Mesh& mesh) const ;
00087 
00088       /** create a discrete function space for the blockCol-th block
00089        * of the column space. */
00090       AbstractFunctionSpace createColSpace(int blockCol,
00091                                            const Mesh& mesh) const ;
00092 
00093       /** return the number of block rows */
00094       int numBlockRows() const {return test_.length();}
00095 
00096       /** return the number of block columns */
00097       int numBlockCols() const {return unk_.length();}
00098 
00099       /** map a funcID of a test function to the reduced testID on
00100        * the blockRow-th block */
00101       int getReducedTestID(int blockRow, int testID) const ;
00102 
00103       /** map a funcID of a unknown function to the reduced unkID on
00104        * the blockCol-th block */
00105       int getReducedUnkID(int blockCol, int unkID) const ;
00106 
00107       /** return the number of parametric equations in a block row */
00108       int numTestParameters(int blockRow) const
00109         {return numTestParameters_[blockRow];}
00110 
00111       /** return the number of parametric unknowns in a block col */
00112       int numUnknownParameters(int blockCol) const
00113         {return numUnknownParameters_[blockCol];}
00114 
00115       /** indicate whether the blockRow-th row is a
00116        * parametric constraint */
00117       bool isParametricRow(int blockRow) const
00118         {return isParametricRow_[blockRow];}
00119 
00120       /** indicate whether the blockCol-th column is a
00121        * parametric variable */
00122       bool isParametricColumn(int blockCol) const
00123         {return isParametricColumn_[blockCol];}
00124 
00125 
00126       /** indicate whether the (blockRow, blockCol) block of the system
00127        * matrix is identically zero. Zero blocks are identified
00128        * during parsing of the symbolic equation at build time  */
00129       bool isZeroBlock(int blockRow, int blockCol) const
00130         {return isZeroBlockMatrix_[blockRow][blockCol];}
00131 
00132       /** indicate whether the blockRow-th block of the system vector
00133        * is identically zero. Zero blocks are identified
00134        * during parsing of the symbolic equation at build time  */
00135       bool isZeroBlock(int blockRow) const
00136         {return isZeroBlockVector_[blockRow];}
00137 
00138       /** write to XML */
00139       XMLObject toXML() const ;
00140 
00141     private:
00142 
00143       /** initialization steps common to all ctors */
00144       void init(const Expr& integral, const EssentialBC& bc);
00145 
00146       /** add a new one-form to the one-form list. */
00147       void addOneForm(int cs, int blockRow, const Expr& var,
00148                       const Expr& coeff, const QuadratureFamily& quad,
00149                       bool isBC);
00150 
00151       /** add a new two-form to the one-form list. */
00152       void addTwoForm(int cs, int blockRow, int blockCol,
00153                       const Expr& var, const Expr& unk,
00154                       const Expr& coeff, const QuadratureFamily& quad,
00155                       bool isBC);
00156 
00157 
00158       /** group quadrature rules and expressions by cell set */
00159       void groupByCellSet(const Expr& eqns,
00160                           TSFArray<TSFArray<QuadratureFamily> >& quad,
00161                           TSFArray<ExprArray>& exprs,
00162                           ExprArray& parametricTermsInsideIntegrals,
00163                           ExprArray& fieldTermsOutsideIntegrals);
00164 
00165 
00166       /* list of all the cell sets that appear in the equation set. This
00167        * list is shared by all blocks. */
00168       TSFArray<CellSet> cellSets_;
00169 
00170       /* array giving the list of functions that are in each block row */
00171       ExprArray test_;
00172 
00173       /* array giving the list of functions that are in each block column */
00174       ExprArray unk_;
00175 
00176       /* list of one-forms for each cell set */
00177       TSFArray<TSFArray<WeakForm> > oneForms_;
00178 
00179       /* list of two-forms for each cell set */
00180       TSFArray<TSFArray<WeakForm> > twoForms_;
00181 
00182       /* matrix elements for unmeshed equations, listed by block index */
00183       TSFArray<TSFArray<TSFArray<ParametricMatrixElement> > >
00184         parametricMatrixBlocks_;
00185 
00186       /* vector elements for unmeshed equations, listed by block index */
00187       TSFArray<TSFArray<ParametricVectorElement> >
00188         parametricVectorBlocks_;
00189 
00190 
00191       /* map from test function funcID to position in the test array.
00192        * The array is a list of maps, one for each block row */
00193       TSFArray<TSFHashtable<int, int> > testIDToReducedIDMap_;
00194 
00195       /* map from unk function funcID to position in the unk array.
00196        * The array is a list of maps, one for each block column */
00197       TSFArray<TSFHashtable<int, int> > unkIDToReducedIDMap_;
00198 
00199       /* flags indicating whether each block row is a global constraint */
00200       TSFArray<bool> isParametricRow_;
00201 
00202       /* flags indicating whether each block column is a global unknown */
00203       TSFArray<bool> isParametricColumn_;
00204 
00205       /* number of parametric equations per block row */
00206       TSFArray<int> numTestParameters_;
00207 
00208       /* number of parametric unknowns per block column */
00209       TSFArray<int> numUnknownParameters_;
00210 
00211       /* flags indicating whether each block matrix has any nonzero terms */
00212       TSFArray<TSFArray<bool> > isZeroBlockMatrix_;
00213 
00214       /* flags indicating whether each block vector has any nonzero terms */
00215       TSFArray<bool>  isZeroBlockVector_;
00216 
00217       /* list of basis functions for each (cellSet, blockRow) pair */
00218       TSFArray<TSFArray<TSFNonDupArray<BasisFamily> > > testBasisList_;
00219 
00220       /* list of basis functions for each (cellSet, blockCol) pair */
00221       TSFArray<TSFArray<TSFNonDupArray<BasisFamily> > > unkBasisList_;
00222 
00223       /* list of domains for each function on each block row */
00224       TSFArray<TSFArray<TSFNonDupArray<CellSet> > > testDomainList_;
00225 
00226       /* list of domains for each function on each block col */
00227       TSFArray<TSFArray<TSFNonDupArray<CellSet> > > unkDomainList_;
00228 
00229       /* */
00230       static bool verbose_;
00231     };
00232 
00233   /** \relates EquationSet write to a stream */
00234   inline ostream& operator<<(ostream& os, EquationSet& eqnSet)
00235     {
00236       return os << eqnSet.toXML();
00237     }
00238 
00239 }
00240 #endif

Contact:
Kevin Long (krlong@ca.sandia.gov)


Documentation generated by