SundanceEquationSet.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_EQUATIONSET_H
00043 #define SUNDANCE_EQUATIONSET_H
00044 
00045 #include "SundanceDefs.hpp"
00046 #include "SundanceExpr.hpp"
00047 #include "SundanceDerivSet.hpp"
00048 #include "SundanceComputationType.hpp"
00049 #include "SundanceRegionQuadCombo.hpp"
00050 #include "SundanceEvalContext.hpp"
00051 #include "SundanceObjectWithVerbosity.hpp"
00052 
00053 
00054 namespace Sundance
00055 {
00056 using namespace Teuchos;
00057 
00058 class FunctionSupportResolver;
00059 class CommonFuncDataStub;
00060 
00061 
00062 /** 
00063  * Source: SundanceEquationSet.cpp
00064  *
00065  * Header: SundanceEquationSet.hpp
00066  *
00067  * EquationSet is an object in which the symbolic specification 
00068  * of a problem or functional, its BCs, its test 
00069  * and unknown functions, and the
00070  * point about which it is to be linearized are all gathered. 
00071  * With this information we can compile lists of which functions
00072  * are defined on which regions of the domain, which is what is 
00073  * required for the building of DOF maps. We can't build the
00074  * DOF map here because in the Sundance core we know nothing
00075  * of the mesh, so we provide accessors to the information collected
00076  * by the EquationSet.
00077  *
00078  * This is <em>NOT</em> normally a user-level object. However,
00079  * EquationSet is one of the most important classes for the
00080  * inner workings of Sundance, so it is critical for a developer
00081  * to understand it. It is used
00082  * internally in the operation of user-level classes such
00083  * as LinearProblem, NonlinearProblem, and Functional. 
00084  *
00085  * There are several modes in which one might construct an equation set.
00086  * The first is where one has written out a weak form in terms
00087  * of test functions. The second is where one is taking variations
00088  * of some functional. 
00089  *
00090  * Note that "EquationSet" is a bit of a misnomer. It was originally
00091  * written to deal with setting up forward problems, but it has since
00092  * been extended to encompass functionals and variations. The name
00093  * persists for historical reasons; there is no particular need to
00094  * change it.
00095  *
00096  * \section intSection Integrals (weak equations and functionals)
00097  *
00098  * \see Integral
00099  *
00100  * \subsection regionSection Specifying regions of integration
00101  *
00102  * Weak equations or functionals are written in terms of integrals;
00103  * the regions on which integration is done must be defined somehow.
00104  * Because the symbolic core knows nothing of how geometry is
00105  * represented in whatever frameworks it's interacting with, the
00106  * region of integration can be represented only with stub classes.
00107  *
00108  * \subsection quadSection Specifying quadrature
00109  *
00110  * \section varSection Specifying variables
00111  *
00112  * \subsection multipleVarSection Multiple variables: Lists and Blocks 
00113  *
00114  * In a multivariable problem it may be useful to group variables
00115  * into blocks; for example, in a segregated Navier-Stokes preconditioner
00116  * the linearized equations are set up as a block system with
00117  * the velocities and the pressure put into different blocks:
00118  * \f[
00119  \left[ \left(u_x, u_y, u_z\right), \left(p\right)\right]^T
00120  * \f]
00121  * We use the following convention for specifying block structure:
00122  * variables aggregated by Expr's listing operations are considered
00123  * to be within a single block. The Teuchos Array object is then
00124  * used to aggregate multiple blocks. 
00125  *
00126  * \subsection variationSection Specifying which variations are taken
00127  *
00128  * The EquationSet class can be used to define a functional, and
00129  * one can then take variations of that functional with respect to 
00130  * some subset of the unknown functions appearing in the functional.
00131  * We'll refer to these as the variational functions. For each
00132  * variational function it is necessary to specify an evaluation
00133  * point, which is simply the value about which variations are taken.
00134  *
00135  * This variational capability can be used to take gradients in
00136  * an optimization problem, or to derive state or adjoint equations. 
00137  *
00138  * \subsection fixedSection Specifying which fields are held fixed
00139  *
00140  * Some variables may remain fixed when variations are taken. For
00141  * example, in PDE-constrained optimization, the state equations
00142  * are derived by taking variations of the Lagrangian with respect
00143  * to the adjoint variables, holding the state and design variables
00144  * constant. 
00145  *
00146  * \subsection evalSection Specifying points at which functions are evaluated
00147  *
00148  * Every field variable given to an equation set must also be given
00149  * an evaluation point. The evaluation point is another expression,
00150  * which must be of one of two types: a discrete function (subtype
00151  * of DiscreteFunctionStub) or a zero expression. 
00152  *
00153  * \subsection updateSection Updating evaluation points
00154  *
00155  * It is important to understand how values of evaluation points
00156  * are updated. This is <em>NOT</em> done by rebuilding the
00157  * EquationSet object with new evaluation points. Rather, it is
00158  * done by resetting the functions' internal data; because the
00159  * EquationSet has stored shallow copies of the evaluation points,
00160  * the EquationSet is updated automatically to follow any external
00161  * changes.
00162  *
00163  * \section internalSection 
00164  *
00165  * \subsection funcIDSection Reduced and unreduced function IDs 
00166  *
00167  * Every symbolic (i.e., test or unknown) function and unknown parameter 
00168  * has a unique integer ID known as its function ID, or funcID for
00169  * short. This ID remains associated with the function, never
00170  * changing, throughout the life of the function. These IDs need
00171  * not be contiguous nor ordered (they are, however, guaranteed to
00172  * be unique). 
00173  * 
00174  * In building an EquationSet, we will also create other ID numbers
00175  * for each function based on the position of each function within
00176  * the lists of functions given as input arguments to the equation
00177  * set ctor. These IDs are contiguous and ordered, with the ordering
00178  * defined by position in the input argument list. We will call these
00179  * "reduced IDs." The ID intrinsic to a function is called here its
00180  * "unreduced ID." EquationSet provided methods for converting
00181  * between reduced and unreduced IDs. 
00182  *
00183  * Note that a function that appears in several equation sets
00184  * might have different reduced IDs in the different equation sets,
00185  * but its unreduced ID will always be the same.
00186  *
00187  */
00188 class EquationSet : public ParameterControlledObjectWithVerbosity<EquationSet>
00189 {
00190 public:
00191   /** \name Constructors */
00192   //@{
00193   /** Set up a functional to be integrated, where all 
00194    * field variables are fixed to specified values. This ctor should
00195    * be used when setting up a functional for evaluation without
00196    * differentiation.
00197    * 
00198    * @param eqns The expression defining which integrals are
00199    * to be done to evaluate the functional
00200    *
00201    * @param bcs The expression defining any BC-like terms that
00202    * strongly replace the ordinary equations on certain subdomains.
00203    * If no BC terms are appropriate for a problem, simply enter an
00204    * empty expression for this argument.
00205    *
00206    * @param params Any unknown parameters appearing in the functional.
00207    * Multiple parameters should be entered as a List expression.
00208    * If no parameters are present, enter an empty expression.
00209    *
00210    * @param paramValues Values of the parameters en
00211    *
00212    * @param fields The field variables (i.e., unknown functions)
00213    * appearing in the functional.
00214    *
00215    * @param fieldValues Evaluation points for
00216    * the variables entered in the fields
00217    * argument. 
00218    */
00219   EquationSet(const Expr& eqns, 
00220     const Expr& bcs,
00221     const Expr& params,
00222     const Expr& paramValues,
00223     const Array<Expr>& fields,
00224     const Array<Expr>& fieldValues);
00225 
00226   /** Set up equations written in weak form with test functions. This
00227    * ctor should be used when setting up an ordinary forward problem.
00228    * 
00229    * \param eqns The expression defining the weak equations. This
00230    * can be linear or nonlinear.
00231    *
00232    * \param bcs The expression defining any BC-like terms that
00233    * strongly replace the ordinary equations on certain subdomains.
00234    * If no BC terms are appropriate for a problem, simply enter an
00235    * empty expression for this argument.
00236    *
00237    * \param testFunctions The test functions used in defining the weak
00238    * problem. The evaluation points for these functions are zero, and
00239    * need not be given as arguments. These should be subtypes of
00240    * TestFunctionStub, or lists thereof.
00241    *
00242    * \param unks The unknown functions for which the weak equation
00243    * will be solved. These should be subtypes of
00244    * UnknownFunctionStub, or lists thereof.
00245    *
00246    * \param unkLinearizationPts The values of the unknown function
00247    * about which the equations are linearized.
00248    *
00249    * \param unkParams The unknown parameters for which the weak equation
00250    * will be solved. These should of type
00251    * UnknownParameter, or a list thereof.
00252    *
00253    * \param unkParamEvalPts The values of the unknown parameters
00254    * about which the equations are linearized.
00255    *
00256    * \param params Any parameters whose values are held fixed (i.e,
00257    * not solved for). These should be of type 
00258    * UnknownParameter, or a list thereof.
00259    *
00260    * \param paramValues Values of the parameters entered in the params
00261    * argument. 
00262    *
00263    * \param fixedFields  Any field variables whose values are held 
00264    * fixed. These should be subtypes of
00265    * UnknownFunctionStub, or lists thereof.
00266    *
00267    * \param fixedFieldValues Values of the fixed field variables.
00268    * argument. 
00269    * 
00270    * \todo If unknown parameters are present, sensitivity equations 
00271    * should be set up as well. This is partially implemented
00272    * but not finished.
00273    */
00274   EquationSet(const Expr& eqns, 
00275     const Expr& bcs,
00276     const Array<Expr>& testFunctions, 
00277     const Array<Expr>& unks,
00278     const Array<Expr>& unkLinearizationPts,
00279     const Expr& unkParams,
00280     const Expr& unkParamEvalPts, 
00281     const Expr& params,
00282     const Expr& paramValues,
00283     const Array<Expr>& fixedFields,
00284     const Array<Expr>& fixedFieldValues);
00285 
00286 
00287   /* Set up calculation of a functional and its first derivative wrt a 
00288    * specified set of functions, to evaluated at a specified
00289    * point. Other functions can be specified as fixed during the 
00290    * calculation of these derivatives. 
00291    * 
00292    * \param eqns The expression defining which integrals are
00293    * to be done to evaluate the functional.
00294    *
00295    * \param bcs The expression defining any BC-like terms that
00296    * strongly replace the ordinary equations on certain subdomains.
00297    * If no BC terms are appropriate for a problem, simply enter an
00298    * empty expression for this argument.
00299    *
00300    * \param vars The functions with which variations are
00301    * to be taken. These should be subtypes of
00302    * UnknownFunctionStub, or lists thereof.
00303    *
00304    * \param varLinearizationPts The values of the variational
00305    * functions at which variations are taken.
00306    *
00307    * \param params Any parameters whose values are held fixed (i.e,
00308    * not solved for). These should be of type 
00309    * UnknownParameter, or a list thereof.
00310    *
00311    * \param paramValues Values of the parameters entered in the params
00312    * argument. 
00313    *
00314    * \param fixedFields  Any field variables whose values are held 
00315    * fixed. These should be subtypes of
00316    * UnknownFunctionStub, or lists thereof.
00317    *
00318    * \param fixedFieldValues Values of the fixed field variables.
00319    * argument. 
00320    */
00321   EquationSet(const Expr& eqns, 
00322     const Expr& bcs,
00323     const Array<Expr>& vars,
00324     const Array<Expr>& varLinearizationPts, 
00325     const Expr& params,
00326     const Expr& paramValues,
00327     const Array<Expr>& fixedFields,
00328     const Array<Expr>& fixedFieldValues);
00329 
00330   /** Set up calculation of first and second variations of 
00331    * a functional. This ctor should be used when deriving the
00332    * linearized form of a variational problem. */
00333   EquationSet(const Expr& eqns, 
00334     const Expr& bcs,
00335     const Array<Expr>& vars, 
00336     const Array<Expr>& varLinearizationPts,
00337     const Array<Expr>& unks,
00338     const Array<Expr>& unkLinearizationPts, 
00339     const Expr& params,
00340     const Expr& paramValues,
00341     const Array<Expr>& fixedFields,
00342     const Array<Expr>& fixedFieldValues);
00343 
00344   /** */
00345   EquationSet(const RCP<FunctionSupportResolver>& fsr,
00346     const Array<Expr>& varLinearizationPts,
00347     const Array<Expr>& unkLinearizationPts, 
00348     const Expr& paramValues,
00349     const Array<Expr>& fixedFieldValues);
00350 
00351   //@}
00352 
00353   /** \name Finding integration regions for the equation set */
00354   //@{
00355   /** Returns the number of regions on which pieces of the equation
00356    * or BCs are defined. */
00357   int numRegions() const ;
00358       
00359   /** Returns the d-th region for this equation set */
00360   const RCP<CellFilterStub>& region(int d) const ;
00361 
00362   /** Returns the index of the given region */
00363   int indexForRegion(const OrderedHandle<CellFilterStub>& region) const ;
00364 
00365   /** Indicate whether the given region has an essential BC expression */
00366   bool isBCRegion(int d) const ;
00367 
00368   /** Return the set of regions on which the specified 
00369    * test func appears. */
00370   const Set<OrderedHandle<CellFilterStub> >& 
00371   regionsForTestFunc(int unreducedTestID) const ;
00372       
00373   /** Return the set of regions on which the specified 
00374    * unknown func appears */
00375   const Set<OrderedHandle<CellFilterStub> >& 
00376   regionsForUnkFunc(int unreducedUnkID) const ;
00377 
00378   /** Returns the list of distinct subregion-quadrature combinations
00379    * appearing in the equation set. */
00380   const Array<RegionQuadCombo>& regionQuadCombos() const 
00381     {return regionQuadCombos_;}
00382 
00383   /** Returns the list of distinct subregion-quadrature combinations
00384    * appearing in the boundary conditions */
00385   const Array<RegionQuadCombo>& bcRegionQuadCombos() const 
00386     {return bcRegionQuadCombos_;}
00387       
00388   /** Indicates whether any var-unk pairs appear in the given domain */
00389   bool hasVarUnkPairs(const OrderedHandle<CellFilterStub>& domain) const 
00390     {return varUnkPairsOnRegions_.containsKey(domain);}
00391 
00392 
00393   /** Indicates whether any BC var-unk pairs appear in the given domain */
00394   bool hasBCVarUnkPairs(const OrderedHandle<CellFilterStub>& domain) const 
00395     {return bcVarUnkPairsOnRegions_.containsKey(domain);}
00396 
00397   /** Returns the (var, unk) pairs appearing on the given domain.
00398    * This is required for determining the sparsity structure of the
00399    * matrix */
00400   const RCP<Set<OrderedPair<int, int> > >& varUnkPairs(const OrderedHandle<CellFilterStub>& domain) const 
00401     {return varUnkPairsOnRegions_.get(domain);}
00402       
00403 
00404   /** Returns the (var, unk) pairs appearing on the given domain.
00405    * This is required for determining the sparsity structure of the
00406    * matrix */
00407   const RCP<Set<OrderedPair<int, int> > >& bcVarUnkPairs(const OrderedHandle<CellFilterStub>& domain) const ;
00408 
00409 
00410   /** Returns the integrand on the rqc r. */
00411   const Expr& expr(const RegionQuadCombo& r) const 
00412     {return regionQuadComboExprs_.get(r);}
00413 
00414   /** Returns the BC integrand on rqc r. */
00415   const Expr& bcExpr(const RegionQuadCombo& r) const 
00416     {return bcRegionQuadComboExprs_.get(r);}
00417 
00418   /** Indicates whether any watch flags are active */
00419   bool hasActiveWatchFlag() const ;
00420 
00421   /** Finds the maximum setting of the named watch type (e.g., "fill") across
00422    * all terms in the equation */
00423   int maxWatchFlagSetting(const std::string& param) const ;
00424 
00425   /** */
00426   const RCP<FunctionSupportResolver>& fsr() const {return fsr_;}
00427 
00428   //@}
00429       
00430 
00431   /** \name Creation of evaluation context objects */
00432   //@{
00433   /** Map RQC to the context for the derivs of the given compType */
00434   EvalContext rqcToContext(ComputationType compType, 
00435     const RegionQuadCombo& r) const ;
00436 
00437 
00438   /** Map BC RQC to the context for the derivs of the given compType */
00439   EvalContext bcRqcToContext(ComputationType compType, 
00440     const RegionQuadCombo& r) const ; 
00441   //@}
00442 
00443   /** \name Identification of RQCs to skip for given compType */
00444   //@{
00445   /** Map RQC to the context for the derivs of the given compType */
00446   bool skipRqc(ComputationType compType, 
00447     const RegionQuadCombo& r) const ;
00448 
00449 
00450   /** Map BC RQC to the context for the derivs of the given compType */
00451   bool skipBCRqc(ComputationType compType, 
00452     const RegionQuadCombo& r) const ;
00453   
00454   //@}
00455 
00456 
00457   /** \name Getting information about functions */
00458   //@{
00459   /** Returns the number of variational function blocks */
00460   int numVarBlocks() const ;
00461 
00462   /** Returns the number of unknown function blocks */
00463   int numUnkBlocks() const ;
00464 
00465   /** Returns the number of unknown parameters */
00466   int numUnkParams() const ;
00467 
00468   /** Returns the number of fixed parameters */
00469   int numFixedParams() const ;
00470 
00471   /** Returns the number of variational functions in this block */
00472   int numVars(int block) const ;
00473 
00474   /** Returns the number of unk functions in this block */
00475   int numUnks(int block) const ;
00476 
00477   /** Returns the number of variational function IDs in this block.
00478    * See the comment in FSR.hpp for an explanation of the difference 
00479    * between this and numVars(). */
00480   int numVarIDs(int block) const ;
00481 
00482   /** Returns the number of unk function IDs in this block.
00483    * See the comment in FSR.hpp for an explanation of the difference 
00484    * between this and numVars().  */
00485   int numUnkIDs(int block) const ;
00486 
00487   /** Returns the i-th variational function in block b */
00488   RCP<const CommonFuncDataStub> varFuncData(int b, int i) const ;
00489 
00490   /** Returns the i-th unknown function in block b */
00491   RCP<const CommonFuncDataStub> unkFuncData(int b, int i) const ;
00492 
00493   /** Returns the i-th unknown parameter */
00494   const Expr& unkParam(int i) const ;
00495 
00496   /** Returns the i-th unknown parameter */
00497   const Expr& fixedParam(int i) const ;
00498 
00499   /** Determine whether a given func ID is listed as a 
00500    * variational function in this equation set */
00501   bool hasVarID(int fid) const ;
00502 
00503   /** Determine whether a given func ID is listed as a unk function 
00504    * in this equation set */
00505   bool hasUnkID(int fid) const ;
00506 
00507   /** Determine whether a given func ID is listed as a unk parameter 
00508    * in this equation set */
00509   bool hasUnkParamID(int fid) const ;
00510 
00511   /** Determine whether a given func ID is listed as a fixed parameter 
00512    * in this equation set */
00513   bool hasFixedParamID(int fid) const ;
00514 
00515   /** get the block number for the variational function having the
00516    * specified unreduced funcID */
00517   int blockForVarID(int varID) const ;
00518 
00519   /** get the block number for the unknown function having the
00520    * specified unreduced funcID */
00521   int blockForUnkID(int unkID) const ;
00522   //@}
00523 
00524 
00525   /** \name Finding the functions that appear on regions */
00526   //@{
00527   /** Returns the variational functions that appear explicitly
00528    * on the d-th region */
00529   const Set<int>& varsOnRegion(int d) const ;
00530 
00531   /** Returns the unknown functions that appear explicitly on the
00532    * d-th region. */
00533   const Set<int>& unksOnRegion(int d) const ;
00534 
00535   /** Returns the variational functions that 
00536    * appear in BCs on the d-th region.
00537    * We can use this information to tag certain rows as BC rows */
00538   const Set<int>& bcVarsOnRegion(int d) const ;
00539 
00540   /** Returns the unknown functions that appear in BCs on the d-th region.
00541    * We can use this information to tag certain columns as BC
00542    * columns in the event we're doing symmetrized BC application */
00543   const Set<int>& bcUnksOnRegion(int d) const ;
00544 
00545 
00546   /** Returns the reduced variational functions that appear explicitly
00547    * on the d-th region */
00548   const Array<Set<int> >& reducedVarsOnRegion(const OrderedHandle<CellFilterStub>& r) const ;
00549 
00550 
00551   /** Returns the reduced unknown functions that appear explicitly on the
00552    * d-th region. */
00553   const Array<Set<int> >& reducedUnksOnRegion(const OrderedHandle<CellFilterStub>& r) const ;
00554   //@}
00555 
00556       
00557 
00558 
00559   /** \name Transforming between unreduced and reduced function IDs */
00560   //@{
00561   /** get the reduced ID for the variational function having the
00562    * specified unreduced funcID */
00563   int reducedVarID(int varID) const ;
00564 
00565   /** get the reduced ID for the unknown 
00566    * function having the given funcID */
00567   int reducedUnkID(int unkID) const ;
00568 
00569   /** get the reduced ID for the unk parameter
00570    * having the given funcID */
00571   int reducedUnkParamID(int unkID) const ;
00572 
00573   /** get the reduced ID for the fixed parameter
00574    * having the given funcID */
00575   int reducedFixedParamID(int unkID) const ;
00576 
00577   /** get the unreduced funcID for a variational function
00578    * as specified by a reduced ID and block index */
00579   int unreducedVarID(int block, int reducedVarID) const ;
00580 
00581 
00582   /** get the unreduced funcID for an unknown function
00583    * as specified by a reduced ID and block index */
00584   int unreducedUnkID(int block, int reducedUnkID) const ;
00585 
00586   /** get the unreduced funcID for an unknown parameter
00587    * as specified by a reduced ID and block index */
00588   int unreducedUnkParamID(int reducedUnkParamID) const ;
00589 
00590   /** get the unreduced funcID for a fixed parameter
00591    * as specified by a reduced ID and block index */
00592   int unreducedFixedParamID(int reducedFixedParamID) const ;
00593 
00594   //@}
00595 
00596 
00597   /** \name Information about which calculations can be done */
00598   //@{
00599   /** */
00600   bool isFunctionalCalculator() const {return isFunctionalCalculator_;}
00601 
00602   /** */
00603   bool isSensitivityCalculator() const {return isSensitivityProblem_;}
00604       
00605   /** Indicate whether this equation set will do the
00606    * given computation type */
00607   bool hasComputationType(ComputationType compType) const 
00608     {return compTypes_.contains(compType);}
00609 
00610   /** Return the types of computations this object can perform */
00611   const Set<ComputationType>& computationTypes() const 
00612     {return compTypes_;}
00613   //@}
00614 
00615       
00616 
00617   /** \name Information about which functional derivatives will be computed */
00618   //@{
00619   /** Returns the set of nonzero functional derivatives appearing
00620    * in the equation set at the given subregion-quadrature combination */
00621   const DerivSet& nonzeroFunctionalDerivs(ComputationType compType,
00622     const RegionQuadCombo& r) const ;
00623 
00624   /** Returns the set of nonzero functional derivatives appearing
00625    * in the boundary conditions
00626    *  at the given subregion-quadrature combination */
00627   const DerivSet& nonzeroBCFunctionalDerivs(ComputationType compType,
00628     const RegionQuadCombo& r) const;
00629   //@}
00630 
00631 
00632 
00633 private:
00634 
00635   /**
00636    * Flatten a spectral expression into a list of its coefficients
00637    */
00638   Expr flattenSpectral(const Expr& input) const ;
00639   /**
00640    * Flatten a spectral expression into a list of its coefficients
00641    */
00642   Array<Expr> flattenSpectral(const Array<Expr>& input) const ;
00643 
00644   /** 
00645    * Common initialization function called by all constructors
00646    */
00647   void init(const Array<Expr>& varLinearizationPts,
00648     const Array<Expr>& unkLinearizationPts,
00649     const Expr& unkParamEvalPts, 
00650     const Expr& fixedParamValues,
00651     const Array<Expr>& fixedFieldValues);
00652 
00653   /** Helper that converts an array of expr to a list expression */
00654   static Expr toList(const Array<Expr>& e);
00655 
00656   /** */
00657   void addToVarUnkPairs(const OrderedHandle<CellFilterStub>& domain,
00658     const Set<int>& vars,
00659     const Set<int>& unks,
00660     const DerivSet& nonzeros, 
00661     bool isBC,
00662     int verb);
00663 
00664   /** The FunctionSupportResolver deals with associating functions with
00665    * subdomains */
00666   RCP<FunctionSupportResolver> fsr_;
00667 
00668   /** Map from cell filter to pairs of (varID, unkID) appearing
00669    * on those cells. This is needed to construct the sparsity pattern
00670    * of the matrix. */
00671   Map<OrderedHandle<CellFilterStub>, RCP<Set<OrderedPair<int, int> > > > varUnkPairsOnRegions_;
00672 
00673   /** Map from cell filter to pairs of (varID, unkID) appearing
00674    * on those cells. This is needed to construct the sparsity pattern
00675    * of the matrix. */
00676   Map<OrderedHandle<CellFilterStub>, RCP<Set<OrderedPair<int, int> > > > bcVarUnkPairsOnRegions_;
00677 
00678   /** */
00679   Array<RegionQuadCombo> regionQuadCombos_;
00680 
00681   /** */
00682   Array<RegionQuadCombo> bcRegionQuadCombos_;
00683 
00684   /** */
00685   Map<RegionQuadCombo, Expr> regionQuadComboExprs_;
00686 
00687   /** */
00688   Map<RegionQuadCombo, Expr> bcRegionQuadComboExprs_;
00689 
00690   /** List of the sets of nonzero functional derivatives at 
00691    * each regionQuadCombo */
00692   Map<ComputationType, Map<RegionQuadCombo, DerivSet> > regionQuadComboNonzeroDerivs_;
00693 
00694   /** List of the sets of nonzero functional derivatives at 
00695    * each regionQuadCombo */
00696   Map<ComputationType, Map<RegionQuadCombo, DerivSet> > bcRegionQuadComboNonzeroDerivs_;
00697 
00698   /** List of the contexts for
00699    * each regionQuadCombo */
00700   Map<ComputationType, Map<RegionQuadCombo, EvalContext> > rqcToContext_;
00701 
00702   /** List of the contexts for
00703    * each BC regionQuadCombo */
00704   Map<ComputationType, Map<RegionQuadCombo, EvalContext> > bcRqcToContext_;
00705 
00706   /** List the RQCs that should be skipped for each computation type. 
00707    * This is needed in cases such as when a domain has matrix terms
00708    * but no vector terms. */
00709   Map<ComputationType, Set<RegionQuadCombo> > rqcToSkip_;
00710 
00711   /** List the BC RQCs that should be skipped for each computation type. */
00712   Map<ComputationType, Set<RegionQuadCombo> > bcRqcToSkip_;
00713 
00714 
00715   /** The point in function space about which the equations
00716    * are linearized */
00717   Array<Expr> unkLinearizationPts_;
00718 
00719   /** unknown parameter evaluation points for this equation set */
00720   Expr unkParamEvalPts_;
00721 
00722   /** fixed parameter evaluation points for this equation set */
00723   Expr fixedParamEvalPts_;
00724 
00725   /** Set of the computation types supported here */
00726   Set<ComputationType> compTypes_;
00727 
00728       
00729   /** Flag indicating whether this equation set is nonlinear */
00730   bool isNonlinear_;
00731       
00732   /** Flag indicating whether this equation set is 
00733    * a variational problem */
00734   bool isVariationalProblem_;
00735 
00736   /** Flag indicating whether this equation set is a functional
00737    * calculator */
00738   bool isFunctionalCalculator_;
00739       
00740   /** Flag indicating whether this equation set is 
00741    * a sensitivity problem */
00742   bool isSensitivityProblem_;
00743 
00744 };
00745 }
00746 
00747 #endif

Site Contact