SundanceElementIntegral.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_ELEMENTINTEGRAL_H
00043 #define SUNDANCE_ELEMENTINTEGRAL_H
00044 
00045 #include "SundanceDefs.hpp"
00046 #include "SundanceCellJacobianBatch.hpp"
00047 #include "SundanceQuadratureFamily.hpp"
00048 #include "SundanceBasisFamily.hpp"
00049 #include "SundanceParametrizedCurve.hpp"
00050 #include "SundanceMesh.hpp"
00051 #include "Teuchos_Array.hpp"
00052 
00053 
00054 namespace Sundance
00055 {
00056 using namespace Sundance;
00057 using namespace Teuchos;
00058 
00059 /** 
00060  * ElementIntegral encapsulates the common data needed for the
00061  * integration of groups of related zero-forms, one-forms, and two-forms.
00062  */
00063 class ElementIntegral
00064 {
00065 public:
00066   /** Construct a zero-form */
00067   ElementIntegral(int spatialDim,
00068     const CellType& maxCellType,
00069     int dim, 
00070     const CellType& cellType,
00071     bool isInternalBdry,
00072     const ParametrizedCurve& globalCurve,
00073     const Mesh& mesh,
00074     int verb);
00075 
00076   /** Construct a one-form */
00077   ElementIntegral(int spatialDim,
00078     const CellType& maxCellType,
00079     int dim, 
00080     const CellType& cellType,
00081     const BasisFamily& testBasis,
00082     int alpha,
00083     int testDerivOrder,
00084     bool isInternalBdry,
00085     const ParametrizedCurve& globalCurve,
00086     const Mesh& mesh,
00087     int verb);
00088 
00089   /** Construct a two-form */
00090   ElementIntegral(int spatialDim,
00091     const CellType& maxCellType,
00092     int dim,
00093     const CellType& cellType,
00094     const BasisFamily& testBasis,
00095     int alpha,
00096     int testDerivOrder,
00097     const BasisFamily& unkBasis,
00098     int beta,
00099     int unkDerivOrder,
00100     bool isInternalBdry,
00101     const ParametrizedCurve& globalCurve,
00102     const Mesh& mesh,
00103     int verb);
00104 
00105   /** virtual dtor */
00106   virtual ~ElementIntegral(){;}
00107 
00108   /** Indicate whether this element integral is a 
00109    *  zero, one, or two form */
00110   int order() const {return order_;}
00111       
00112   /** Return the number of nodes associated with the test function */
00113   int nNodesTest() const {return nNodesTest_;}
00114       
00115   /** Return the number of nodes associated with the test function */
00116   int nNodesUnk() const {return nNodesUnk_;}
00117 
00118   /** Return the total number of elements in this local stiffness
00119    * matrix */
00120   int nNodes() const {return nNodes_;}
00121 
00122   /** Return the number of different facets for which integrals 
00123    * must be tabulated in the cases where an integral must be done 
00124    * by referring back to a maximal cell */
00125   int nFacetCases() const {return nFacetCases_;}
00126 
00127   /** Whether this is an integral on an internal boundary */
00128   bool isInternalBdry() const {return isInternalBdry_;}
00129 
00130   /** */
00131   static bool& alwaysUseCofacets();
00132 
00133   /** */
00134   void setVerb(
00135     int integrationVerb,
00136     int transformVerb);
00137 
00138   /** */
00139   int setupVerb() const {return setupVerb_;}
00140     
00141   /** */
00142   int integrationVerb() const {return integrationVerb_;}
00143     
00144   /** */
00145   int transformVerb() const {return transformVerb_;}
00146 
00147   /** */
00148   void describe(std::ostream& os) const ;
00149 
00150   /** */
00151   static int& transformationMatrixIsValid(int alpha);
00152 
00153 
00154   /** */
00155   static int& transformationMatrixIsValid(int alpha, int beta);
00156 
00157   /** */
00158   static void invalidateTransformationMatrices();
00159 
00160   /** */
00161   static double& totalFlops() {static double rtn = 0; return rtn;}
00162 
00163   BasisFamily &getTestBasis() { return testBasis_; }
00164   BasisFamily &getUnknownBasis() { return unkBasis_; }
00165 
00166 protected:
00167 
00168   /** */
00169   void assertBilinearForm() const ;
00170 
00171   /** */
00172   void assertLinearForm() const ;
00173 
00174   /** */
00175   static void addFlops(const double& flops) {totalFlops() += flops;}
00176 
00177   /** The dimension of the cell being integrated */
00178   int dim() const {return dim_;}
00179 
00180   /** The dimension of the space in which the cell is embedded */
00181   int spatialDim() const {return spatialDim_;}
00182       
00183   /** Number of test function derivatives wrt reference coordinates that
00184    * are needed to evaluate this integral. Will always be equal to 
00185    * ipow(element dimension, differentiation order). */
00186   int nRefDerivTest() const {return nRefDerivTest_;}
00187       
00188   /** Number of unknown function derivatives wrt reference coordinates that
00189    * are needed to evaluate this integral. Will always be equal to 
00190    * ipow(element dimension, differentiation order). */
00191   int nRefDerivUnk() const {return nRefDerivUnk_;}
00192 
00193   /** The order to which the test function is differentiated in this
00194    * integral. */
00195   int testDerivOrder() const {return testDerivOrder_;}
00196 
00197   /** The order to which the unknown function is differentiated in this
00198    * integral. */
00199   int unkDerivOrder() const {return unkDerivOrder_;}
00200 
00201   /** */
00202   int alpha() const {return alpha_;}
00203 
00204   /** */
00205   int beta() const {return beta_;}
00206 
00207   /** */
00208   const CellType& cellType() const {return cellType_;}
00209 
00210   /** */
00211   const CellType& maxCellType() const {return maxCellType_;}
00212 
00213   /** */
00214   const CellType& evalCellType() const {return evalCellType_;}
00215 
00216   /** */
00217   const BasisFamily& testBasis() const {return testBasis_;}
00218 
00219   /** */
00220   const BasisFamily& unkBasis() const {return unkBasis_;}
00221 
00222   /** Workspace for element transformations involving one derivative*/
00223   static Array<double>& G(int gamma) ;
00224 
00225   /** Workspace for element transformations involving two derivatives */
00226   static Array<double>& G(int gamma, int delta) ;
00227 
00228   /** return base to the given power */
00229   static int ipow(int base, int power);
00230 
00231   /** The value below which chop() sets numbers to zero */
00232   static double chopVal() {static double rtn=1.0e-14; return rtn;}
00233 
00234   /** Chop a number to zero if it is smaller in magnitude than
00235    * the value chopVal() */
00236   static double chop(const double& x) 
00237     {
00238       if (::fabs(x) > chopVal()) return x;
00239       else return 0.0;
00240     }
00241 
00242   /** */
00243   void getQuad(const QuadratureFamily& quad, int evalCase,
00244     Array<Point>& quadPts, Array<double>& quadWeights) const ;
00245 
00246   /** */
00247   void createTwoFormTransformationMatrix(const CellJacobianBatch& JTrans,
00248     const CellJacobianBatch& JVol) const;
00249   /** */
00250   void createOneFormTransformationMatrix(const CellJacobianBatch& JTrans,
00251     const CellJacobianBatch& JVol) const;
00252 
00253   /** */
00254   const Mesh& mesh() const {return mesh_;}
00255 
00256   /** */
00257   const ParametrizedCurve& globalCurve() const {return globalCurve_;}
00258 
00259 private:
00260 
00261   int setupVerb_;
00262   int integrationVerb_;
00263   int transformVerb_;
00264 
00265   int spatialDim_;
00266 
00267   int dim_;
00268 
00269   bool isInternalBdry_;
00270 
00271   int nFacetCases_;
00272 
00273   int testDerivOrder_;
00274 
00275   int nRefDerivTest_;
00276 
00277   int nNodesTest_;
00278 
00279   int unkDerivOrder_;
00280 
00281   int nRefDerivUnk_;
00282 
00283   int nNodesUnk_;
00284 
00285   int nNodes_;
00286 
00287   int order_;
00288 
00289   int alpha_;
00290 
00291   int beta_;
00292 
00293   CellType cellType_;
00294 
00295   CellType maxCellType_;
00296 
00297   CellType evalCellType_;
00298 
00299   BasisFamily testBasis_;
00300 
00301   BasisFamily unkBasis_;
00302       
00303   /** The curve which might be used for adaptive integration method */
00304   const ParametrizedCurve globalCurve_;
00305 
00306   /** The curve which might be used for adaptive integration method */
00307   const Mesh mesh_;
00308 
00309 };
00310 }
00311 
00312 
00313 #endif

Site Contact