SundanceAssembler.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                              Sundance
00005 //                 Copyright (2005) Sandia Corporation
00006 // 
00007 // Copyright (year first published) Sandia Corporation.  Under the terms 
00008 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00009 // retains certain rights in this software.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //                                                                                 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA                                                                                
00025 // Questions? Contact Kevin Long (krlong@sandia.gov), 
00026 // Sandia National Laboratories, Livermore, California, USA
00027 // 
00028 // ************************************************************************
00029 /* @HEADER@ */
00030 
00031 #ifndef SUNDANCE_ASSEMBLER_H
00032 #define SUNDANCE_ASSEMBLER_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "TSFLoadableVector.hpp"
00036 #include "TSFLoadableMatrix.hpp"
00037 #include "TSFLinearOperatorDecl.hpp"
00038 #include "TSFVectorDecl.hpp"
00039 #include "TSFVectorType.hpp"
00040 #include "Teuchos_HashSet.hpp"
00041 #include "Teuchos_ParameterList.hpp"
00042 #include "TSFIncrementallyConfigurableMatrixFactory.hpp"
00043 #include "TSFCollectivelyConfigurableMatrixFactory.hpp"
00044 #include "TSFPartitionedMatrixFactory.hpp"
00045 #include "TSFPartitionedToMonolithicConverter.hpp"
00046 #include "SundanceRegionQuadCombo.hpp"
00047 #include "SundanceMesh.hpp"
00048 #include "SundanceEvalContext.hpp"
00049 #include "SundanceIntegrationCellSpecifier.hpp"
00050 #include "SundanceComputationType.hpp"
00051 
00052 
00053 namespace Sundance
00054 {
00055 using namespace Teuchos;
00056 
00057 class EquationSet;
00058 class EvaluatableExpr;
00059 class EvalManager;
00060 class EvalVector;
00061 class DiscreteSpace;
00062 class DiscreteFunction;
00063 class CellFilter;
00064 class DOFMapBase;
00065 class IntegralGroup;
00066 class StdFwkEvalMediator;
00067 class AssemblyKernelBase;
00068 
00069 
00070 typedef std::set<int> ColSetType;
00071 
00072 /** 
00073  * 
00074  */
00075 class Assembler 
00076 {
00077 public:
00078   /** */
00079   Assembler(
00080     const Mesh& mesh, 
00081     const RCP<EquationSet>& eqn,
00082     const Array<VectorType<double> >& rowVectorType,
00083     const Array<VectorType<double> >& colVectorType,
00084     bool partitionBCs);
00085 
00086 
00087   /** */
00088   Assembler(
00089     const Mesh& mesh, 
00090     const RCP<EquationSet>& eqn);
00091       
00092   /** */
00093   const Array<RCP<DOFMapBase> >& rowMap() const 
00094     {return rowMap_;}
00095 
00096   /** */
00097   const Array<RCP<DOFMapBase> >& colMap() const 
00098     {return colMap_;}
00099 
00100   /** */
00101   const Array<RCP<DiscreteSpace> >& solutionSpace() const 
00102     {return externalColSpace_;}
00103 
00104   /** */
00105   const Array<RCP<DiscreteSpace> >& rowSpace() const 
00106     {return externalRowSpace_;}
00107 
00108   /** */
00109   VectorSpace<double> solnVecSpace() const ;
00110 
00111   /** */
00112   VectorSpace<double> rowVecSpace() const ;
00113 
00114   /** */
00115   const Array<RCP<Set<int> > >& bcRows() {return bcRows_;}
00116 
00117   /** Allocate, but do not fill, the matrix */
00118   TSFExtended::LinearOperator<double> allocateMatrix() const ;
00119 
00120   /** */
00121   void assemble(TSFExtended::LinearOperator<double>& A,
00122     Array<Vector<double> >& b) const ;
00123 
00124   /** */
00125   void assembleSensitivities(TSFExtended::LinearOperator<double>& A,
00126     Array<Vector<double> >& b) const ;
00127 
00128 
00129   /** */
00130   void assemble(Array<Vector<double> >& b) const ;
00131 
00132   /** */
00133   void evaluate(double& value,
00134     Array<Vector<double> >& gradient) const ;
00135 
00136   /** */
00137   void evaluate(double& value) const ;
00138 
00139   /** */
00140   static int& workSetSize() ;
00141 
00142       
00143   /** */
00144   void getGraph(int br, int bc,
00145     Array<int>& graphData,
00146     Array<int>& rowPtrs,
00147     Array<int>& nnzPerRow) const ;
00148       
00149   /** */
00150   void incrementalGetGraph(int br, int bc, 
00151     IncrementallyConfigurableMatrixFactory* mf) const ;
00152 
00153   /** */
00154   void flushConfiguration() 
00155     {
00156       numConfiguredColumns_ = 0;
00157       matNeedsConfiguration_ = true;
00158     }
00159 
00160   /** */
00161   Vector<double> convertToMonolithicVector(
00162     const Array<Vector<double> >& internalBlock,
00163     const Array<Vector<double> >& bcBlock) 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   /** */
00224   void configureMatrix(LinearOperator<double>& A,
00225     Array<Vector<double> >& b) const ;
00226 
00227   /** */
00228   void configureVector(Array<Vector<double> >& b) const ;
00229 
00230   /** */
00231   void configureMatrixBlock(int br, int bc, 
00232     LinearOperator<double>& A) const ;
00233 
00234   /** */
00235   void configureVectorBlock(int br, Vector<double>& b) const ;
00236 
00237   /** */
00238   Array<Array<int> > findNonzeroBlocks() const ;
00239 
00240   /** */
00241   IntegrationCellSpecifier whetherToUseCofacets(
00242     const Array<RCP<IntegralGroup> >& groups,
00243     const EvaluatableExpr* ee,
00244     bool isMaximalCell,
00245     int verb) const ;
00246 
00247   
00248   
00249   /** */
00250   static int defaultWorkSetSize() {static int rtn=100; return rtn;}
00251 
00252   bool partitionBCs_;
00253       
00254   mutable bool matNeedsConfiguration_;
00255       
00256   mutable bool matNeedsFinalization_;
00257 
00258   mutable int numConfiguredColumns_;
00259 
00260   Mesh mesh_;
00261 
00262   RCP<EquationSet> eqn_;
00263 
00264   Array<RCP<DOFMapBase> > rowMap_;
00265 
00266   Array<RCP<DOFMapBase> > colMap_;
00267 
00268   Array<RCP<DiscreteSpace> > externalRowSpace_;
00269 
00270   Array<RCP<DiscreteSpace> > externalColSpace_;
00271 
00272   Array<RCP<DiscreteSpace> > privateRowSpace_;
00273 
00274   Array<RCP<DiscreteSpace> > privateColSpace_;
00275 
00276   Array<RCP<Set<int> > > bcRows_;
00277 
00278   Array<RCP<Set<int> > > bcCols_;
00279 
00280   Array<RegionQuadCombo> rqc_;
00281 
00282   Map<ComputationType, Array<EvalContext> > contexts_;
00283 
00284   Map<ComputationType, Array<int> > skipRqc_;
00285 
00286   Array<int> isBCRqc_;
00287 
00288   Array<int> isInternalBdry_;
00289 
00290   Map<ComputationType, Array<Array<RCP<IntegralGroup> > > > groups_;
00291 
00292   Array<RCP<StdFwkEvalMediator> > mediators_;
00293 
00294   Map<ComputationType, Array<const EvaluatableExpr*> > evalExprs_;
00295 
00296   RCP<EvalManager> evalMgr_;
00297 
00298   Array<RCP<Array<int> > > isBCRow_;
00299 
00300   Array<RCP<Array<int> > > isBCCol_;
00301 
00302   Array<RCP<std::set<int> > > remoteBCCols_;
00303 
00304   Array<int> lowestRow_;
00305 
00306   Array<int> lowestCol_;
00307 
00308   Array<VectorType<double> > rowVecType_;
00309 
00310   Array<VectorType<double> > colVecType_;
00311 
00312   Map<int, int> testIDToBlockMap_;
00313 
00314   Map<int, int> unkIDToBlockMap_;
00315 
00316   Map<int, int> fixedParamIDToVectorNumber_;
00317 
00318   Map<ComputationType, Array<IntegrationCellSpecifier> > rqcRequiresMaximalCofacets_;
00319 
00320   Array<RCP<PartitionedToMonolithicConverter> > converter_;
00321 
00322 };
00323 
00324 }
00325 
00326 
00327 
00328 #endif

Site Contact