SundanceCurveQuadratureIntegral.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                              Sundance
00005 //                 Copyright (2005) Sandia Corporation
00006 // 
00007 // Copyright (year first published) Sandia Corporation.  Under the terms 
00008 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00009 // retains certain rights in this software.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //                                                                                 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA                                                                                
00025 // Questions? Contact Kevin Long (krlong@sandia.gov), 
00026 // Sandia National Laboratories, Livermore, California, USA
00027 // 
00028 // ************************************************************************
00029 /* @HEADER@ */
00030 
00031 #ifndef SUNDANCE_CURVEQUADRATUREINTEGRAL_H
00032 #define SUNDANCE_CURVEQUADRATUREINTEGRAL_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceQuadratureIntegralBase.hpp"
00036 
00037 namespace Sundance
00038 {
00039 
00040 using namespace Teuchos;
00041 
00042 /** 
00043  * Integration by quadrature over a maximal cell  
00044  */
00045 class CurveQuadratureIntegral : public ElementIntegral
00046 {
00047 public:
00048   /** Construct a zero-form to be computed by quadrature */
00049   CurveQuadratureIntegral(
00050     const CellType& maxCellType,
00051     const bool isConstantIntegral,
00052     const QuadratureFamily& quad,
00053     const ParametrizedCurve& globalCurve,
00054     const Mesh& mesh,
00055     int verb);
00056 
00057   /** Construct a one form to be computed by quadrature */
00058   CurveQuadratureIntegral(
00059     const CellType& maxCellType,
00060     const bool isConstantIntegral,
00061     const BasisFamily& testBasis,
00062     int alpha,
00063     int testDerivOrder,
00064     const QuadratureFamily& quad,
00065     const ParametrizedCurve& globalCurve,
00066     const Mesh& mesh,
00067     int verb);
00068 
00069   /** Construct a two-form to be computed by quadrature */
00070   CurveQuadratureIntegral(
00071     const CellType& maxCellType,
00072     const bool isConstantIntegral,
00073     const BasisFamily& testBasis,
00074     int alpha,
00075     int testDerivOrder,
00076     const BasisFamily& unkBasis,
00077     int beta,
00078     int unkDerivOrder,
00079     const QuadratureFamily& quad,
00080     const ParametrizedCurve& globalCurve,
00081     const Mesh& mesh,
00082     int verb);
00083 
00084   /** virtual dtor */
00085   virtual ~CurveQuadratureIntegral(){;}
00086       
00087      /** */
00088   virtual void transform(const CellJacobianBatch& JTrans,
00089     const CellJacobianBatch& JVol,
00090     const Array<int>& isLocalFlag,
00091     const Array<int>& facetNum,
00092     const RCP<Array<int> >& cellLIDs,
00093     const double constCoeff,
00094     const double* const coeff,
00095     RCP<Array<double> >& A) const 
00096     {
00097       if (order()==2) transformTwoForm(JTrans, JVol, facetNum, cellLIDs, constCoeff, coeff, A);
00098       else if (order()==1) transformOneForm(JTrans, JVol, facetNum, cellLIDs, constCoeff, coeff, A);
00099       else transformZeroForm(JTrans, JVol, isLocalFlag, facetNum, cellLIDs, constCoeff, coeff, A);
00100     }
00101 
00102   /** */
00103   virtual void transformZeroForm(const CellJacobianBatch& JTrans,
00104     const CellJacobianBatch& JVol,
00105     const Array<int>& isLocalFlag,
00106     const Array<int>& facetIndex,
00107     const RCP<Array<int> >& cellLIDs,
00108     const double constCoeff,
00109     const double* const coeff,
00110     RCP<Array<double> >& A) const ;
00111   
00112   /** */
00113   virtual void transformTwoForm(const CellJacobianBatch& JTrans,
00114     const CellJacobianBatch& JVol,
00115     const Array<int>& facetIndex,
00116     const RCP<Array<int> >& cellLIDs,
00117     const double constCoeff,
00118     const double* const coeff,
00119     RCP<Array<double> >& A) const ;
00120   
00121   /** */
00122   void transformOneForm(const CellJacobianBatch& JTrans,
00123     const CellJacobianBatch& JVol,
00124     const Array<int>& facetIndex,
00125     const RCP<Array<int> >& cellLIDs,
00126     const double constCoeff,
00127     const double* const coeff,
00128     RCP<Array<double> >& A) const ;
00129   
00130 private:
00131 
00132   /** updates the reference cell information (quadPoints,derivatives,normals)*/
00133   void updateRefCellInformation(int maxCellLID , const ParametrizedCurve& curve) const;
00134 
00135   /** updates the W_ for the given cell for one form Integral */
00136   void updateRefCellIntegralOneForm(int maxCellLID , int cellInBatch) const ;
00137 
00138   /** updates the W_ for the given cell for two form Integral */
00139   void updateRefCellIntegralTwoForm(int maxCellLID , int cellInBatch) const ;
00140 
00141   /** Do the integration by summing reference quantities over quadrature
00142    * points and then transforming the sum to physical quantities.  */
00143   void transformSummingFirst(int nCells,
00144   const CellJacobianBatch& JVol,
00145     const Array<int>& facetIndex,
00146     const RCP<Array<int> >& cellLIDs,
00147     const double constCoeff,
00148     const double* const GPtr,
00149     const double* const coeff,
00150     RCP<Array<double> >& A) const ;
00151 
00152   /** Do the integration by transforming to physical coordinates 
00153    * at each quadrature point, and then summing */
00154   void transformSummingLast(int nCells,
00155     const Array<int>& facetIndex,
00156     const RCP<Array<int> >& cellLIDs,
00157     const double* const GPtr,
00158     const double* const coeff,
00159     RCP<Array<double> >& A) const ;
00160 
00161   /** Determine whether to do this batch of integrals using the
00162    * sum-first method or the sum-last method */
00163   bool useSumFirstMethod() const {return useSumFirstMethod_;}
00164       
00165   /** */
00166   inline double& wValue(int q, int testDerivDir, int testNode,
00167     int unkDerivDir, int unkNode) const
00168     {return W_[unkNode
00169         + nNodesUnk()
00170         *(testNode + nNodesTest()
00171           *(unkDerivDir + nRefDerivUnk()
00172             *(testDerivDir + nRefDerivTest()*q)))];}
00173 
00174       
00175 
00176   /** */
00177   inline const double& wValue(int facetCase, 
00178     int q, 
00179     int testDerivDir, int testNode,
00180     int unkDerivDir, int unkNode) const 
00181     {
00182       return W_[unkNode
00183         + nNodesUnk()
00184         *(testNode + nNodesTest()
00185           *(unkDerivDir + nRefDerivUnk()
00186             *(testDerivDir + nRefDerivTest()*q)))];
00187     }
00188       
00189   /** */
00190   inline double& wValue(int q, int testDerivDir, int testNode) const
00191     {return W_[testNode + nNodesTest()*(testDerivDir + nRefDerivTest()*q)];}
00192 
00193   /** The quadrature family needed for curve integration */
00194   QuadratureFamily quad_;
00195 
00196   /** The quadrature points*/
00197   mutable Array<Point> quadPts_;
00198 
00199   /** The standard weights */
00200   Array<double> quadWeights_;
00201 
00202   /* this must be changeable, because each cell will have different reference cell values <br>
00203    * here we store the result from the reference basis evaluation*/
00204   mutable Array<double> W_;
00205 
00206   /* */
00207   bool useSumFirstMethod_;
00208 
00209   /** weather to use constant coefficients */
00210   bool useConstCoeff_;
00211 
00212   /** The derivative of the curve at the curve */
00213   mutable Array<Point> quadCurveDerivs_;
00214 
00215   /** The derivative of the curve at the curve */
00216   mutable Array<Point> quadCurveNormals_;
00217 
00218 };
00219 }
00220 
00221 
00222 #endif /* SUNDANCE_CURVEQUADRATUREINTEGRAL_H */

Site Contact