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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 class EquationSet
00042 {
00043 public:
00044
00045 EquationSet();
00046
00047
00048
00049
00050
00051
00052 EquationSet(const ExprArray& test, const ExprArray& unk,
00053 const Expr& integral);
00054
00055
00056
00057
00058 EquationSet(const ExprArray& test, const ExprArray& unk,
00059 const Expr& integral, const EssentialBC& bc);
00060
00061
00062 const TSFArray<CellSet>& getCellSets() const {return cellSets_;}
00063
00064
00065 const TSFArray<WeakForm>& oneFormList(int cellSet) const
00066 {return oneForms_[cellSet];}
00067
00068
00069 const TSFArray<WeakForm>& twoFormList(int cellSet) const
00070 {return twoForms_[cellSet];}
00071
00072
00073 const TSFArray<ParametricMatrixElement>& getParametricElements(int br,
00074 int bc) const
00075 {return parametricMatrixBlocks_[br][bc];}
00076
00077
00078 const TSFArray<ParametricVectorElement>& getParametricElements(int br) const
00079 {return parametricVectorBlocks_[br];}
00080
00081
00082
00083
00084
00085 AbstractFunctionSpace createRowSpace(int blockRow,
00086 const Mesh& mesh) const ;
00087
00088
00089
00090 AbstractFunctionSpace createColSpace(int blockCol,
00091 const Mesh& mesh) const ;
00092
00093
00094 int numBlockRows() const {return test_.length();}
00095
00096
00097 int numBlockCols() const {return unk_.length();}
00098
00099
00100
00101 int getReducedTestID(int blockRow, int testID) const ;
00102
00103
00104
00105 int getReducedUnkID(int blockCol, int unkID) const ;
00106
00107
00108 int numTestParameters(int blockRow) const
00109 {return numTestParameters_[blockRow];}
00110
00111
00112 int numUnknownParameters(int blockCol) const
00113 {return numUnknownParameters_[blockCol];}
00114
00115
00116
00117 bool isParametricRow(int blockRow) const
00118 {return isParametricRow_[blockRow];}
00119
00120
00121
00122 bool isParametricColumn(int blockCol) const
00123 {return isParametricColumn_[blockCol];}
00124
00125
00126
00127
00128
00129 bool isZeroBlock(int blockRow, int blockCol) const
00130 {return isZeroBlockMatrix_[blockRow][blockCol];}
00131
00132
00133
00134
00135 bool isZeroBlock(int blockRow) const
00136 {return isZeroBlockVector_[blockRow];}
00137
00138
00139 XMLObject toXML() const ;
00140
00141 private:
00142
00143
00144 void init(const Expr& integral, const EssentialBC& bc);
00145
00146
00147 void addOneForm(int cs, int blockRow, const Expr& var,
00148 const Expr& coeff, const QuadratureFamily& quad,
00149 bool isBC);
00150
00151
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
00159 void groupByCellSet(const Expr& eqns,
00160 TSFArray<TSFArray<QuadratureFamily> >& quad,
00161 TSFArray<ExprArray>& exprs,
00162 ExprArray& parametricTermsInsideIntegrals,
00163 ExprArray& fieldTermsOutsideIntegrals);
00164
00165
00166
00167
00168 TSFArray<CellSet> cellSets_;
00169
00170
00171 ExprArray test_;
00172
00173
00174 ExprArray unk_;
00175
00176
00177 TSFArray<TSFArray<WeakForm> > oneForms_;
00178
00179
00180 TSFArray<TSFArray<WeakForm> > twoForms_;
00181
00182
00183 TSFArray<TSFArray<TSFArray<ParametricMatrixElement> > >
00184 parametricMatrixBlocks_;
00185
00186
00187 TSFArray<TSFArray<ParametricVectorElement> >
00188 parametricVectorBlocks_;
00189
00190
00191
00192
00193 TSFArray<TSFHashtable<int, int> > testIDToReducedIDMap_;
00194
00195
00196
00197 TSFArray<TSFHashtable<int, int> > unkIDToReducedIDMap_;
00198
00199
00200 TSFArray<bool> isParametricRow_;
00201
00202
00203 TSFArray<bool> isParametricColumn_;
00204
00205
00206 TSFArray<int> numTestParameters_;
00207
00208
00209 TSFArray<int> numUnknownParameters_;
00210
00211
00212 TSFArray<TSFArray<bool> > isZeroBlockMatrix_;
00213
00214
00215 TSFArray<bool> isZeroBlockVector_;
00216
00217
00218 TSFArray<TSFArray<TSFNonDupArray<BasisFamily> > > testBasisList_;
00219
00220
00221 TSFArray<TSFArray<TSFNonDupArray<BasisFamily> > > unkBasisList_;
00222
00223
00224 TSFArray<TSFArray<TSFNonDupArray<CellSet> > > testDomainList_;
00225
00226
00227 TSFArray<TSFArray<TSFNonDupArray<CellSet> > > unkDomainList_;
00228
00229
00230 static bool verbose_;
00231 };
00232
00233
00234 inline ostream& operator<<(ostream& os, EquationSet& eqnSet)
00235 {
00236 return os << eqnSet.toXML();
00237 }
00238
00239 }
00240 #endif