SundanceReducedIntegral.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_REDUCED_INTEGRAL_H
00043 #define SUNDANCE_REDUCED_INTEGRAL_H
00044 
00045 #include "SundanceDefs.hpp"
00046 #include "SundanceElementIntegral.hpp"
00047 
00048 namespace Sundance
00049 {
00050 
00051 using namespace Teuchos;
00052 
00053 /** 
00054  * 
00055  */
00056 class ReducedIntegral : public ElementIntegral
00057 {
00058 public:
00059   /** Construct a zero-form to be computed by reference integration
00060    * with coefficients that are piecewise constant */
00061   ReducedIntegral(int spatialDim,
00062     const CellType& maxCellType,
00063     int dim, 
00064     const CellType& cellType,
00065     const QuadratureFamily& quad,
00066     bool isInternalBdry,
00067     const ParametrizedCurve& globalCurve,
00068     const Mesh& mesh,
00069     int verb);
00070 
00071   /** Construct a one form to be computed by reference integration
00072    * with coefficients that are piecewise constant  */
00073   ReducedIntegral(int spatialDim,
00074     const CellType& maxCellType,
00075     int dim, 
00076     const CellType& cellType,
00077     const BasisFamily& testBasis,
00078     int alpha,
00079     int testDerivOrder,
00080     const QuadratureFamily& quad,
00081     bool isInternalBdry,
00082     const ParametrizedCurve& globalCurve,
00083     const Mesh& mesh,
00084     int verb);
00085 
00086   /** Construct a two-form to be computed by reference integration
00087    * with coefficients that are piecewise constant */
00088   ReducedIntegral(int spatialDim,
00089     const CellType& maxCellType,
00090     int dim,
00091     const CellType& cellType,
00092     const BasisFamily& testBasis,
00093     int alpha,
00094     int testDerivOrder,
00095     const BasisFamily& unkBasis,
00096     int beta,
00097     int unkDerivOrder,
00098     const QuadratureFamily& quad,
00099     bool isInternalBdry,
00100     const ParametrizedCurve& globalCurve,
00101     const Mesh& mesh,
00102     int verb);
00103 
00104   /** virtual dtor */
00105   virtual ~ReducedIntegral(){;}
00106 
00107   /** */
00108   void transform(const CellJacobianBatch& JTrans,
00109     const CellJacobianBatch& JVol,
00110     const Array<int>& isLocalFlag,
00111     const Array<int>& facetNum,
00112     const RCP<Array<int> >& cellLIDs,
00113     const double* const coeffs,
00114     RCP<Array<double> >& A) const
00115     {
00116       if (order()==2) transformTwoForm(JTrans, JVol, facetNum, cellLIDs, coeffs, A);
00117       else if (order()==1) transformOneForm(JTrans, JVol, facetNum, cellLIDs, coeffs, A);
00118       else transformZeroForm(JTrans, JVol, isLocalFlag, facetNum,
00119         cellLIDs, coeffs, A);
00120     }
00121 
00122   /** */
00123   virtual void transformZeroForm(const CellJacobianBatch& JTrans,
00124     const CellJacobianBatch& JVol,
00125     const Array<int>& isLocalFlag,
00126     const Array<int>& facetIndex,
00127     const RCP<Array<int> >& cellLIDs,
00128     const double* const coeffs,
00129     RCP<Array<double> >& A) const ;
00130       
00131   /** */
00132   virtual void transformTwoForm(const CellJacobianBatch& JTrans,
00133     const CellJacobianBatch& JVol,
00134     const Array<int>& facetIndex,
00135     const RCP<Array<int> >& cellLIDs,
00136     const double* const coeffs,
00137     RCP<Array<double> >& A) const ;
00138       
00139   /** */
00140   void transformOneForm(const CellJacobianBatch& JTrans,
00141     const CellJacobianBatch& JVol,
00142     const Array<int>& facetIndex,
00143     const RCP<Array<int> >& cellLIDs,
00144     const double* const coeffs,
00145     RCP<Array<double> >& A) const ;
00146 
00147 private:
00148 
00149   
00150 
00151   /** */
00152   inline double& value(int facetCase, int testDerivDir, int testNode,
00153     int unkDerivDir, int unkNode)
00154     {return W_[facetCase][unkNode + nNodesUnk()*testNode 
00155         + nNodes()*(unkDerivDir 
00156           + nRefDerivUnk()*testDerivDir)];}
00157 
00158   /** */
00159   inline const double& value(int facetCase, 
00160     int testDerivDir, int testNode,
00161     int unkDerivDir, int unkNode) const 
00162     {
00163       return W_[facetCase][unkNode + nNodesUnk()*testNode 
00164         + nNodes()*(unkDerivDir 
00165           + nRefDerivUnk()*testDerivDir)];
00166     }
00167       
00168   /** */
00169   inline double& value(int facetCase, int testDerivDir, int testNode)
00170     {return W_[facetCase][nNodesTest()*testDerivDir + testNode];}
00171 
00172   /** */
00173   inline const double& value(int facetCase, 
00174     int testDerivDir, int testNode) const 
00175     {return W_[facetCase][nNodesTest()*testDerivDir + testNode];}
00176 
00177   static double& totalFlops() {static double rtn = 0; return rtn;}
00178 
00179 protected:
00180 
00181   static void addFlops(const double& flops) {totalFlops() += flops;}
00182       
00183 private:
00184 
00185   Array<Array<double> > W_;
00186 
00187 };
00188 }
00189 
00190 
00191 #endif

Site Contact