Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef SUNDANCE_ASSEMBLER_H
00043 #define SUNDANCE_ASSEMBLER_H
00044
00045 #include "SundanceDefs.hpp"
00046 #include "PlayaLoadableVector.hpp"
00047 #include "PlayaLoadableMatrix.hpp"
00048 #include "PlayaLinearOperatorDecl.hpp"
00049 #include "PlayaVectorDecl.hpp"
00050 #include "PlayaVectorType.hpp"
00051 #include "Teuchos_HashSet.hpp"
00052 #include "Teuchos_ParameterList.hpp"
00053 #include "PlayaIncrementallyConfigurableMatrixFactory.hpp"
00054 #include "PlayaCollectivelyConfigurableMatrixFactory.hpp"
00055 #include "SundanceRegionQuadCombo.hpp"
00056 #include "SundanceMesh.hpp"
00057 #include "SundanceEvalContext.hpp"
00058 #include "SundanceIntegrationCellSpecifier.hpp"
00059 #include "SundanceComputationType.hpp"
00060
00061
00062 namespace Sundance
00063 {
00064 using namespace Teuchos;
00065 using namespace Playa;
00066
00067 class EquationSet;
00068 class EvaluatableExpr;
00069 class EvalManager;
00070 class EvalVector;
00071 class DiscreteSpace;
00072 class DiscreteFunction;
00073 class CellFilter;
00074 class DOFMapBase;
00075 class IntegralGroup;
00076 class StdFwkEvalMediator;
00077 class AssemblyKernelBase;
00078
00079 typedef std::set<int> ColSetType;
00080
00081
00082
00083
00084 class Assembler
00085 {
00086 public:
00087
00088 Assembler(
00089 const Mesh& mesh,
00090 const RCP<EquationSet>& eqn,
00091 const Array<VectorType<double> >& rowVectorType,
00092 const Array<VectorType<double> >& colVectorType,
00093 bool partitionBCs);
00094
00095
00096
00097 Assembler(
00098 const Mesh& mesh,
00099 const RCP<EquationSet>& eqn);
00100
00101
00102 const Array<RCP<DOFMapBase> >& rowMap() const
00103 {return rowMap_;}
00104
00105
00106 const Array<RCP<DOFMapBase> >& colMap() const
00107 {return colMap_;}
00108
00109
00110 const Array<RCP<DiscreteSpace> >& solutionSpace() const
00111 {return externalColSpace_;}
00112
00113
00114 const Array<RCP<DiscreteSpace> >& rowSpace() const
00115 {return externalRowSpace_;}
00116
00117
00118 VectorSpace<double> solnVecSpace() const ;
00119
00120
00121 VectorSpace<double> rowVecSpace() const ;
00122
00123
00124 const Array<RCP<Set<int> > >& bcRows() const { return bcRows_; }
00125
00126
00127 Playa::LinearOperator<double> allocateMatrix() const ;
00128
00129
00130 void assemble(Playa::LinearOperator<double>& A,
00131 Array<Vector<double> >& b) const ;
00132
00133
00134 void assembleSensitivities(Playa::LinearOperator<double>& A,
00135 Array<Vector<double> >& b) const ;
00136
00137
00138
00139 void assemble(Array<Vector<double> >& b) const ;
00140
00141
00142 void evaluate(double& value,
00143 Array<Vector<double> >& gradient) const ;
00144
00145
00146 void evaluate(double& value) const ;
00147
00148
00149 static int& workSetSize() ;
00150
00151
00152
00153 void getGraph(int br, int bc,
00154 Array<int>& graphData,
00155 Array<int>& rowPtrs,
00156 Array<int>& nnzPerRow) const ;
00157
00158
00159 void incrementalGetGraph(int br, int bc,
00160 IncrementallyConfigurableMatrixFactory* mf) const ;
00161
00162
00163 void flushConfiguration() const;
00164
00165
00166 static int& numAssembleCalls() {static int rtn=0; return rtn;}
00167
00168
00169 static bool& matrixEliminatesRepeatedCols() {static bool x = false; return x;}
00170
00171
00172 const RCP<EquationSet>& eqnSet() const
00173 {return eqn_;}
00174
00175
00176 int maxWatchFlagSetting(const std::string& param) const ;
00177
00178
00179 static Time& assemblyTimer()
00180 {
00181 static RCP<Time> rtn
00182 = TimeMonitor::getNewTimer("assembly");
00183 return *rtn;
00184 }
00185
00186
00187 static Time& configTimer()
00188 {
00189 static RCP<Time> rtn
00190 = TimeMonitor::getNewTimer("matrix config");
00191 return *rtn;
00192 }
00193
00194
00195 static Time& fillTimer()
00196 {
00197 static RCP<Time> rtn
00198 = TimeMonitor::getNewTimer("matrix/vector fill");
00199 return *rtn;
00200 }
00201
00202
00203 private:
00204
00205
00206 void init(const Mesh& mesh, const RCP<EquationSet>& eqn);
00207
00208
00209 bool detectInternalBdry(int cellDim, const CellFilter& filter) const ;
00210
00211
00212 void displayEvaluationResults(
00213 const EvalContext& context,
00214 const EvaluatableExpr* evalExpr,
00215 const Array<double>& constantCoeffs,
00216 const Array<RCP<EvalVector> >& vectorCoeffs) const ;
00217
00218
00219 void assemblyLoop(const ComputationType& compType,
00220 RCP<AssemblyKernelBase> kernel) const ;
00221
00222
00223 bool matNeedsConfiguration() const;
00224
00225
00226 void configureMatrix(LinearOperator<double>& A,
00227 Array<Vector<double> >& b) const ;
00228
00229
00230 void configureVector(Array<Vector<double> >& b) const ;
00231
00232
00233 void configureMatrixBlock(int br, int bc,
00234 LinearOperator<double>& A) const ;
00235
00236
00237 void configureVectorBlock(int br, Vector<double>& b) const ;
00238
00239
00240 Array<Array<int> > findNonzeroBlocks() const ;
00241
00242
00243 IntegrationCellSpecifier whetherToUseCofacets(
00244 const Array<RCP<IntegralGroup> >& groups,
00245 const EvaluatableExpr* ee,
00246 bool isMaximalCell,
00247 int verb) const ;
00248
00249
00250
00251
00252 static int defaultWorkSetSize() {static int rtn=100; return rtn;}
00253
00254 bool partitionBCs_;
00255
00256 mutable int numConfiguredColumns_;
00257
00258 Mesh mesh_;
00259
00260 RCP<EquationSet> eqn_;
00261
00262 Array<RCP<DOFMapBase> > rowMap_;
00263
00264 Array<RCP<DOFMapBase> > colMap_;
00265
00266 Array<RCP<DiscreteSpace> > externalRowSpace_;
00267
00268 Array<RCP<DiscreteSpace> > externalColSpace_;
00269
00270 Array<RCP<DiscreteSpace> > privateRowSpace_;
00271
00272 Array<RCP<DiscreteSpace> > privateColSpace_;
00273
00274 Array<RCP<Set<int> > > bcRows_;
00275
00276 Array<RegionQuadCombo> rqc_;
00277
00278 Map<ComputationType, Array<EvalContext> > contexts_;
00279
00280 Map<ComputationType, Array<int> > skipRqc_;
00281
00282 Array<int> isBCRqc_;
00283
00284 Array<int> isInternalBdry_;
00285
00286 Map<ComputationType, Array<Array<RCP<IntegralGroup> > > > groups_;
00287
00288 Array<RCP<StdFwkEvalMediator> > mediators_;
00289
00290 Map<ComputationType, Array<const EvaluatableExpr*> > evalExprs_;
00291
00292 RCP<EvalManager> evalMgr_;
00293
00294 Array<RCP<Array<int> > > isBCRow_;
00295
00296 Array<RCP<Array<int> > > isBCCol_;
00297
00298 Array<RCP<std::set<int> > > remoteBCCols_;
00299
00300 Array<int> lowestRow_;
00301
00302 Array<int> lowestCol_;
00303
00304 Array<VectorType<double> > rowVecType_;
00305
00306 Array<VectorType<double> > colVecType_;
00307
00308 Map<int, int> testIDToBlockMap_;
00309
00310 Map<int, int> unkIDToBlockMap_;
00311
00312 Map<int, int> fixedParamIDToVectorNumber_;
00313
00314 Map<ComputationType, Array<IntegrationCellSpecifier> > rqcRequiresMaximalCofacets_;
00315
00316
00317
00318 mutable LinearOperator<double> cachedAssembledMatrix_;
00319 };
00320
00321 }
00322
00323
00324
00325 #endif