SundanceAssemblyKernelBase.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                             Sundance
00005 //                 Copyright 2011 Sandia Corporation
00006 // 
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Kevin Long (kevin.long@ttu.edu)
00038 // 
00039 
00040 /* @HEADER@ */
00041 
00042 #ifndef SUNDANCE_ASSEMBLYKERNELBASE_H
00043 #define SUNDANCE_ASSEMBLYKERNELBASE_H
00044 
00045 #include "SundanceDefs.hpp"
00046 #include "SundanceDOFMapBase.hpp"
00047 #include "SundanceEquationSet.hpp"
00048 #include "SundanceDiscreteSpace.hpp"
00049 #include "SundanceDiscreteFunction.hpp"
00050 #include "SundanceIntegralGroup.hpp"
00051 #include "SundanceElementIntegral.hpp"
00052 #include "SundanceGrouperBase.hpp"
00053 #include "SundanceEvalManager.hpp"
00054 #include "SundanceStdFwkEvalMediator.hpp"
00055 #include "SundanceEvaluatableExpr.hpp"
00056 #include "PlayaLoadableVector.hpp"
00057 #include "PlayaLoadableMatrix.hpp"
00058 #include "PlayaLinearOperatorDecl.hpp"
00059 #include "PlayaVectorDecl.hpp"
00060 #include "PlayaVectorType.hpp"
00061 #include "Teuchos_HashSet.hpp"
00062 #include "Teuchos_ParameterList.hpp"
00063 #include "PlayaIncrementallyConfigurableMatrixFactory.hpp"
00064 #include "PlayaCollectivelyConfigurableMatrixFactory.hpp"
00065 
00066 namespace Sundance
00067 {
00068 using namespace Teuchos;
00069 
00070 class StdFwkEvalMediator;
00071 class IntegralGroup;
00072 
00073 /** 
00074  * AssemblyKernelBase abstracts the operations that must be done in an
00075  * assembly loop. Regardless of whether the assembly loop is doing
00076  * matrix/vector fill, vector fill, functional/gradient evaluation,
00077  * or functional evaluation, the assembly loop will involve
00078  * <ul>
00079  * <li> A preprocessing step before the main assembly loop
00080  * <li> A preprocessing step before each work set is started
00081  * <li> A fill step after each integral group is done
00082  * <li> A postprocessing step after the main assembly loop is done
00083  * </ul>
00084  * The first of these is done by the subclass constructor. The others
00085  * are done using the pure virtual functions of this class.
00086  *
00087  * It is assumed that any data structures to be filled -- such as a matrix,
00088  * a vector, or simply a number -- are stored internally in the assembly
00089  * kernel subclass, and that they persist between preprocessing and fill 
00090  * calls.
00091  */
00092 class AssemblyKernelBase
00093 {
00094 public:
00095   /** */
00096   AssemblyKernelBase(int verb) : verb_(verb) {;}
00097 
00098   /** */
00099   virtual ~AssemblyKernelBase(){;}
00100 
00101   /**  
00102    * Do preprocessing steps needed before integrating the current
00103    * work set. 
00104    *
00105    * The default implementation does nothing. 
00106    */
00107   virtual void prepareForWorkSet(
00108     const Array<Set<int> >& requiredTests,
00109     const Array<Set<int> >& requiredUnks,
00110     RCP<StdFwkEvalMediator> mediator) {;}
00111 
00112   /** 
00113    * Adds the results of the current integral
00114    * group into the assembly results. 
00115    * \param isBC whether the current group is a replace-style 
00116    * boundary condition
00117    * \param group the current integral group
00118    * \param localValues the results of integrating the current integral group
00119    */
00120   virtual void fill(bool isBC,
00121     const IntegralGroup& group,
00122     const RCP<Array<double> >& localValues) = 0 ;  
00123 
00124   /** 
00125    * Hook to do any finalization steps after the main assembly loop, 
00126    * for example, doing an all-reduce on locally computed functional values. 
00127    * The default implementation does nothing. */
00128   virtual void postLoopFinalization() {;}
00129 
00130   /** verbosity level */
00131   int verb() const {return verb_;}
00132 
00133   /** set verbosity level.
00134    * (This function needs to be virtual because certain subclasses need specialized
00135    * implementations that propagate verbosity to children 
00136   */
00137   virtual void setVerb(int verb) {verb_=verb;}
00138 
00139 private:
00140   int verb_;
00141 };
00142 
00143 
00144 
00145 }
00146 
00147 
00148 
00149 
00150 #endif

Site Contact