SundanceSumOfIntegrals.hpp
Go to the documentation of this file.
00001 
00002 /* @HEADER@ */
00003 // ************************************************************************
00004 // 
00005 //                             Sundance
00006 //                 Copyright 2011 Sandia Corporation
00007 // 
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Kevin Long (kevin.long@ttu.edu)
00039 // 
00040 
00041 /* @HEADER@ */
00042 
00043 #ifndef SUNDANCE_SUMOFINTEGRALS_H
00044 #define SUNDANCE_SUMOFINTEGRALS_H
00045 
00046 #include "SundanceDefs.hpp"
00047 #include "SundanceExpr.hpp"
00048 #include "SundanceScalarExpr.hpp"
00049 #include "SundanceQuadratureFamilyStub.hpp"
00050 #include "SundanceCellFilterStub.hpp"
00051 #include "SundanceOrderedHandle.hpp"
00052 #include "Teuchos_Array.hpp"
00053 #include "SundanceMap.hpp"
00054 #include "SundanceWatchFlag.hpp"
00055 #include "SundanceRegionQuadCombo.hpp"
00056 #include "SundanceParametrizedCurve.hpp"
00057 
00058 
00059 namespace Sundance
00060 {
00061 using namespace Sundance;
00062 using namespace Teuchos;
00063 
00064 using Sundance::Map;
00065 
00066 class SpatiallyConstantExpr;
00067 
00068 /** 
00069  * SumOfIntegrals represents a sum of integrals,
00070  * grouped by region and quadrature rule
00071  *
00072  * \f[
00073  * \sum_{d=0}^{N_d-1} \left[\sum_{q=0}^{N_{q,d}-1} 
00074  * \int_{\Omega_d,Q_{q,d}} g_{d,q}\right] 
00075  * \f] 
00076  *
00077  * 
00078  * 
00079  */
00080 class SumOfIntegrals : public ScalarExpr
00081 {
00082 public:
00083   /** Construct given an integral over a single region */
00084   SumOfIntegrals(const RCP<CellFilterStub>& region,
00085     const Expr& expr,
00086     const RCP<QuadratureFamilyStub>& quad,
00087     const WatchFlag& watch);
00088 
00089   /** Construct given an integral over a single region */
00090   SumOfIntegrals(const RCP<CellFilterStub>& region,
00091     const Expr& expr,
00092     const RCP<QuadratureFamilyStub>& quad,
00093     const ParametrizedCurve& curve,
00094     const WatchFlag& watch);
00095 
00096   /** */
00097   virtual ~SumOfIntegrals(){;}
00098 
00099   /** Add another term to this integral */
00100   void addTerm(const RCP<CellFilterStub>& region,
00101     const Expr& expr,
00102     const RCP<QuadratureFamilyStub>& quad,
00103     const ParametrizedCurve& paramCurve,
00104     const WatchFlag& watch,
00105     int sign) ;
00106 
00107   /** Add this sum of integrals to another sum of integrals */
00108   void merge(const SumOfIntegrals* other, int sign) ;
00109 
00110   /** Multiply all terms in the sum by a constant */
00111   void multiplyByConstant(const SpatiallyConstantExpr* expr) ;
00112 
00113   /** Change the sign of all terms in the sum */
00114   void changeSign() ;
00115 
00116   /** Return the number of subregions */
00117   int numRQC() const {return rqcToExprMap_.size();}
00118 
00119   /** */
00120   const Sundance::Map<RegionQuadCombo, Expr>& rqcToExprMap() const
00121     {return rqcToExprMap_;}
00122 
00123   /** Return the set of unknown or variational
00124    * functions defined on region d */
00125   Set<int> funcsOnRegion(const OrderedHandle<CellFilterStub>& d, 
00126     const Set<int>& funcsSet) const ;
00127 
00128   /** Indicate whether the integral over 
00129    * region d contains any test functions */
00130   bool integralHasTestFunctions(const OrderedHandle<CellFilterStub>& d) const ;
00131 
00132   /** Return a null cell filter of a type consistent with the
00133    * other filters in this integral */
00134   RCP<CellFilterStub> nullRegion() const ;
00135 
00136   /** Indicate whether the expression is independent of the given 
00137    * functions */
00138   virtual bool isIndependentOf(const Expr& u) const ;
00139 
00140   /** Indicate whether the expression is linear in the given 
00141    * functions */
00142   virtual bool isLinearForm(const Expr& u) const ;
00143 
00144   /** Indicate whether the expression is quadratic in the given 
00145    * functions */
00146   virtual bool isQuadraticForm(const Expr& u) const ;
00147 
00148   /** 
00149    * Indicate whether the expression is nonlinear 
00150    * with respect to test functions */
00151   virtual bool isLinearInTests() const ;
00152 
00153   /** 
00154    * Indicate whether every term in the expression contains test functions */
00155   virtual bool everyTermHasTestFunctions() const ;
00156 
00157   /** 
00158    * Indicate whether the expression contains test functions */
00159   virtual bool hasTestFunctions() const ;
00160   
00161 
00162   /** Write a simple text description suitable 
00163    * for output to a terminal */
00164   virtual std::ostream& toText(std::ostream& os, bool paren) const ;
00165 
00166 
00167   /** Write in XML */
00168   virtual XMLObject toXML() const ;
00169 
00170   /** */
00171   virtual RCP<ExprBase> getRcp() {return rcp(this);}
00172 
00173   /** Ordering operator for use in transforming exprs to standard form */
00174   virtual bool lessThan(const ScalarExpr* other) const ;
00175 
00176   /** Look for a term with an active watchpoint */
00177   bool hasWatchedTerm() const ;
00178 
00179   /** Find the maximum setup verbosity of the terms */
00180   int eqnSetSetupVerb() const ;
00181   
00182 
00183 protected:
00184   /** */
00185   Expr filterSpectral(const Expr& ex) const ;
00186 private:
00187 
00188   Sundance::Map<RegionQuadCombo, Expr> rqcToExprMap_;
00189 };
00190 }
00191 
00192 #endif

Site Contact