SundanceSumOfIntegrals.hpp
Go to the documentation of this file.
00001 
00002 /* @HEADER@ */
00003 // ************************************************************************
00004 // 
00005 //                              Sundance
00006 //                 Copyright (2005) Sandia Corporation
00007 // 
00008 // Copyright (year first published) Sandia Corporation.  Under the terms 
00009 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00010 // retains certain rights in this software.
00011 // 
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //  
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //                                                                                 
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA                                                                                
00026 // Questions? Contact Kevin Long (krlong@sandia.gov), 
00027 // Sandia National Laboratories, Livermore, California, USA
00028 // 
00029 // ************************************************************************
00030 /* @HEADER@ */
00031 
00032 #ifndef SUNDANCE_SUMOFINTEGRALS_H
00033 #define SUNDANCE_SUMOFINTEGRALS_H
00034 
00035 #include "SundanceDefs.hpp"
00036 #include "SundanceExpr.hpp"
00037 #include "SundanceScalarExpr.hpp"
00038 #include "SundanceQuadratureFamilyStub.hpp"
00039 #include "SundanceCellFilterStub.hpp"
00040 #include "SundanceOrderedHandle.hpp"
00041 #include "Teuchos_Array.hpp"
00042 #include "SundanceMap.hpp"
00043 #include "SundanceWatchFlag.hpp"
00044 #include "SundanceRegionQuadCombo.hpp"
00045 #include "SundanceParametrizedCurve.hpp"
00046 
00047 
00048 namespace Sundance
00049 {
00050 using namespace Sundance;
00051 using namespace Teuchos;
00052 
00053 using Sundance::Map;
00054 
00055 class SpatiallyConstantExpr;
00056 
00057 /** 
00058  * SumOfIntegrals represents a sum of integrals,
00059  * grouped by region and quadrature rule
00060  *
00061  * \f[
00062  * \sum_{d=0}^{N_d-1} \left[\sum_{q=0}^{N_{q,d}-1} 
00063  * \int_{\Omega_d,Q_{q,d}} g_{d,q}\right] 
00064  * \f] 
00065  *
00066  * 
00067  * 
00068  */
00069 class SumOfIntegrals : public ScalarExpr
00070 {
00071 public:
00072   /** Construct given an integral over a single region */
00073   SumOfIntegrals(const RCP<CellFilterStub>& region,
00074     const Expr& expr,
00075     const RCP<QuadratureFamilyStub>& quad,
00076     const WatchFlag& watch);
00077 
00078   /** Construct given an integral over a single region */
00079   SumOfIntegrals(const RCP<CellFilterStub>& region,
00080     const Expr& expr,
00081     const RCP<QuadratureFamilyStub>& quad,
00082     const ParametrizedCurve& curve,
00083     const WatchFlag& watch);
00084 
00085   /** */
00086   virtual ~SumOfIntegrals(){;}
00087 
00088   /** Add another term to this integral */
00089   void addTerm(const RCP<CellFilterStub>& region,
00090     const Expr& expr,
00091     const RCP<QuadratureFamilyStub>& quad,
00092     const ParametrizedCurve& paramCurve,
00093     const WatchFlag& watch,
00094     int sign) ;
00095 
00096   /** Add this sum of integrals to another sum of integrals */
00097   void merge(const SumOfIntegrals* other, int sign) ;
00098 
00099   /** Multiply all terms in the sum by a constant */
00100   void multiplyByConstant(const SpatiallyConstantExpr* expr) ;
00101 
00102   /** Change the sign of all terms in the sum */
00103   void changeSign() ;
00104 
00105   /** Return the number of subregions */
00106   int numRQC() const {return rqcToExprMap_.size();}
00107 
00108   /** */
00109   const Sundance::Map<RegionQuadCombo, Expr>& rqcToExprMap() const
00110     {return rqcToExprMap_;}
00111 
00112   /** Return the set of unknown or variational
00113    * functions defined on region d */
00114   Set<int> funcsOnRegion(const OrderedHandle<CellFilterStub>& d, 
00115     const Set<int>& funcsSet) const ;
00116 
00117   /** Indicate whether the integral over 
00118    * region d contains any test functions */
00119   bool integralHasTestFunctions(const OrderedHandle<CellFilterStub>& d) const ;
00120 
00121   /** Return a null cell filter of a type consistent with the
00122    * other filters in this integral */
00123   RCP<CellFilterStub> nullRegion() const ;
00124 
00125   /** Indicate whether the expression is independent of the given 
00126    * functions */
00127   virtual bool isIndependentOf(const Expr& u) const ;
00128 
00129   /** Indicate whether the expression is linear in the given 
00130    * functions */
00131   virtual bool isLinearForm(const Expr& u) const ;
00132 
00133   /** Indicate whether the expression is quadratic in the given 
00134    * functions */
00135   virtual bool isQuadraticForm(const Expr& u) const ;
00136 
00137   /** 
00138    * Indicate whether the expression is nonlinear 
00139    * with respect to test functions */
00140   virtual bool isLinearInTests() const ;
00141 
00142   /** 
00143    * Indicate whether every term in the expression contains test functions */
00144   virtual bool everyTermHasTestFunctions() const ;
00145 
00146   /** 
00147    * Indicate whether the expression contains test functions */
00148   virtual bool hasTestFunctions() const ;
00149   
00150 
00151   /** Write a simple text description suitable 
00152    * for output to a terminal */
00153   virtual std::ostream& toText(std::ostream& os, bool paren) const ;
00154 
00155 
00156   /** Write in XML */
00157   virtual XMLObject toXML() const ;
00158 
00159   /** */
00160   virtual RCP<ExprBase> getRcp() {return rcp(this);}
00161 
00162   /** Ordering operator for use in transforming exprs to standard form */
00163   virtual bool lessThan(const ScalarExpr* other) const ;
00164 
00165   /** Look for a term with an active watchpoint */
00166   bool hasWatchedTerm() const ;
00167 
00168   /** Find the maximum setup verbosity of the terms */
00169   int eqnSetSetupVerb() const ;
00170   
00171 
00172 protected:
00173   /** */
00174   Expr filterSpectral(const Expr& ex) const ;
00175 private:
00176 
00177   Sundance::Map<RegionQuadCombo, Expr> rqcToExprMap_;
00178 };
00179 }
00180 
00181 #endif

Site Contact