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_ASSEMBLYKERNELBASE_H 00032 #define SUNDANCE_ASSEMBLYKERNELBASE_H 00033 00034 #include "SundanceDefs.hpp" 00035 #include "SundanceDOFMapBase.hpp" 00036 #include "SundanceEquationSet.hpp" 00037 #include "SundanceDiscreteSpace.hpp" 00038 #include "SundanceDiscreteFunction.hpp" 00039 #include "SundanceIntegralGroup.hpp" 00040 #include "SundanceElementIntegral.hpp" 00041 #include "SundanceGrouperBase.hpp" 00042 #include "SundanceEvalManager.hpp" 00043 #include "SundanceStdFwkEvalMediator.hpp" 00044 #include "SundanceEvaluatableExpr.hpp" 00045 #include "TSFLoadableVector.hpp" 00046 #include "TSFLoadableMatrix.hpp" 00047 #include "TSFLinearOperatorDecl.hpp" 00048 #include "TSFVectorDecl.hpp" 00049 #include "TSFVectorType.hpp" 00050 #include "Teuchos_HashSet.hpp" 00051 #include "Teuchos_ParameterList.hpp" 00052 #include "TSFIncrementallyConfigurableMatrixFactory.hpp" 00053 #include "TSFCollectivelyConfigurableMatrixFactory.hpp" 00054 #include "TSFPartitionedMatrixFactory.hpp" 00055 #include "TSFPartitionedToMonolithicConverter.hpp" 00056 00057 namespace Sundance 00058 { 00059 using namespace Teuchos; 00060 00061 class StdFwkEvalMediator; 00062 class IntegralGroup; 00063 00064 /** 00065 * AssemblyKernelBase abstracts the operations that must be done in an 00066 * assembly loop. Regardless of whether the assembly loop is doing 00067 * matrix/vector fill, vector fill, functional/gradient evaluation, 00068 * or functional evaluation, the assembly loop will involve 00069 * <ul> 00070 * <li> A preprocessing step before the main assembly loop 00071 * <li> A preprocessing step before each work set is started 00072 * <li> A fill step after each integral group is done 00073 * <li> A postprocessing step after the main assembly loop is done 00074 * </ul> 00075 * The first of these is done by the subclass constructor. The others 00076 * are done using the pure virtual functions of this class. 00077 * 00078 * It is assumed that any data structures to be filled -- such as a matrix, 00079 * a vector, or simply a number -- are stored internally in the assembly 00080 * kernel subclass, and that they persist between preprocessing and fill 00081 * calls. 00082 */ 00083 class AssemblyKernelBase 00084 { 00085 public: 00086 /** */ 00087 AssemblyKernelBase(int verb) : verb_(verb) {;} 00088 00089 /** */ 00090 virtual ~AssemblyKernelBase(){;} 00091 00092 /** 00093 * Do preprocessing steps needed before integrating the current 00094 * work set. 00095 * 00096 * The default implementation does nothing. 00097 */ 00098 virtual void prepareForWorkSet( 00099 const Array<Set<int> >& requiredTests, 00100 const Array<Set<int> >& requiredUnks, 00101 RCP<StdFwkEvalMediator> mediator) {;} 00102 00103 /** 00104 * Adds the results of the current integral 00105 * group into the assembly results. 00106 * \param isBC whether the current group is a replace-style 00107 * boundary condition 00108 * \param group the current integral group 00109 * \param localValues the results of integrating the current integral group 00110 */ 00111 virtual void fill(bool isBC, 00112 const IntegralGroup& group, 00113 const RCP<Array<double> >& localValues) = 0 ; 00114 00115 /** 00116 * Hook to do any finalization steps after the main assembly loop, 00117 * for example, doing an all-reduce on locally computed functional values. 00118 * The default implementation does nothing. */ 00119 virtual void postLoopFinalization() {;} 00120 00121 /** verbosity level */ 00122 int verb() const {return verb_;} 00123 00124 /** set verbosity level. 00125 * (This function needs to be virtual because certain subclasses need specialized 00126 * implementations that propagate verbosity to children 00127 */ 00128 virtual void setVerbosity(int verb) {verb_=verb;} 00129 00130 private: 00131 int verb_; 00132 }; 00133 00134 00135 00136 } 00137 00138 00139 00140 00141 #endif