SundanceGaussLobattoQuadrature.hpp
Go to the documentation of this file.
00001 /*
00002  * SundanceGaussLobattoQuadrature.hpp
00003  *
00004  *  Created on: Jan 20, 2011
00005  *      Author: benk
00006  */
00007 
00008 #ifndef SUNDANCEGAUSSLOBATTOQUADRATURE_HPP_
00009 #define SUNDANCEGAUSSLOBATTOQUADRATURE_HPP_
00010 
00011 #include "SundanceDefs.hpp"
00012 #include "PlayaTabs.hpp"
00013 #include "SundanceQuadratureFamilyBase.hpp"
00014 
00015 namespace Sundance {
00016 
00017 class GaussLobattoQuadrature : public QuadratureFamilyBase {
00018 
00019 public:
00020 
00021   /** In this case the */
00022   GaussLobattoQuadrature(int order);
00023 
00024   /** */
00025   virtual ~GaussLobattoQuadrature()
00026   {;}
00027 
00028   /** */
00029   virtual XMLObject toXML() const;
00030 
00031   /** Describable interface */
00032   virtual std::string description() const
00033   {
00034     return "GaussLobattoQuadrature[order=" + Teuchos::toString(order()) + "]";
00035   }
00036 
00037   /* handleable boilerplate */
00038   GET_RCP(QuadratureFamilyStub);
00039 
00040 protected:
00041   /** compute a rule for the reference line cell */
00042   virtual void getLineRule(Array<Point>& quadPointsL,
00043       Array<double>& quadWeights) const;
00044 
00045   /** compute a rule for the reference triangle cell */
00046   virtual void getTriangleRule(Array<Point>& quadPoints,
00047       Array<double>& quadWeights) const;
00048 
00049   /** compute a rule for the reference quad cell */
00050   virtual void getQuadRule(Array<Point>& quadPoints,
00051       Array<double>& quadWeights) const;
00052 
00053   /** compute a rule for the reference tet cell */
00054   virtual void getTetRule(Array<Point>& quadPoints,
00055       Array<double>& quadWeights) const ;
00056 
00057   /** compute a rule for the reference brick cell */
00058   virtual void getBrickRule(Array<Point>& quadPoints,
00059       Array<double>& quadWeights) const;
00060 
00061   /**
00062    * Compute adapted weights according to curve
00063    *
00064    * @param cellType
00065    * @param cellDim
00066    * @param cellLID
00067    * @param facetIndex
00068    * @param mesh
00069    * @param globalCurve
00070    * @param quadPoints
00071    * @param quadWeights
00072    * @param changedWeights
00073    */
00074   virtual void getAdaptedWeights(const CellType& cellType, int cellDim,
00075       int cellLID, int facetIndex, const Mesh& mesh,
00076       const ParametrizedCurve& globalCurve,
00077       Array<Point>& quadPoints, Array<double>& quadWeights,
00078       bool &weightsChanged) const;
00079 
00080   /** Get the weights for one quad */
00081   virtual void getAdaptedQuadWeights(int cellLID, const Mesh& mesh,
00082       const ParametrizedCurve& globalCurve, Array<Point>& quadPoints,
00083       Array<double>& quadWeights, bool& weightsChanged) const;
00084 
00085   /** Get the weights for one quad knowing that the curve is a 2D polygon */
00086   virtual void getAdaptedQuadWeights_polygon(int cellLID, const Mesh& mesh,
00087       const ParametrizedCurve& globalCurve, Array<Point>& quadPoints,
00088       Array<double>& quadWeights, bool& weightsChanged) const;
00089 
00090   /** Get the weights for one quad knowing that the curve is a 3D surface */
00091   virtual void getAdaptedQuadWeights_surf(int cellLID, const Mesh& mesh,
00092       const ParametrizedCurve& globalCurve, Array<Point>& quadPoints,
00093       Array<double>& quadWeights, bool& weightsChanged) const;
00094 
00095 private:
00096 
00097   /** get the triangle quadrature points for the adaptive integration*/
00098   void getTriangleQuadPoints(Array<Point>& pnt , Array<double>& weight ) const;
00099 
00100   /**
00101    * @param i , the i-th point
00102    * @param pnt 1D points where we interpolate
00103    * @param x the position where we evaluate */
00104   inline double evalLagrangePol(int i , Array<Point>& pnt , double x) const{
00105     int m = pnt.size();
00106     double p = 1.0;
00107     for (int j = 0 ; (j <= i-1)&&(j<m) ; j++){
00108      p = p *( x - pnt[j][0] )/(pnt[i][0] - pnt[j][0]);
00109     }
00110     for (int j = i+1 ; j < m ; j++){
00111      p = p *( x - pnt[j][0] )/(pnt[i][0] - pnt[j][0]);
00112     }
00113       return p;
00114   }
00115 
00116   /** this function applies quadrature to the Lagrange functions <br>
00117    * all the coordinates are in the reference coordinates */
00118   inline void makeInterpolantQuad( double px, double py, double ofx, double ofy,
00119                                int nr1DPoints , int nr2DPoints ,
00120                                Array<Point>& linePoints ,
00121                                Array<Point>& quadPoints ,
00122                                Array<double>& pointWeights ,
00123                                Array<double>& weightsOut ,
00124                                double areFakt ) const {
00125     int xi,yi;
00126     double xc,yc, intR , valTmp , valBasisX , valBasisY ;
00127 
00128     // if the area of integration is not significant then just return
00129     if ( fabs(ofx*ofy) < 1e-14 ) return;
00130 
00131         //SUNDANCE_MSG3(verb_, "px="<<px<<",py="<<py<<",ofx="<<ofx<<",ofy="<<ofy <<
00132         //    " , nr2DPoints:" << nr2DPoints << " , pointWeights.size():" <<
00133         //    pointWeights.size() << " , areFakt:" << areFakt);
00134 
00135     for (int i = 0 ; i < nr2DPoints ; i++){
00136       // we should add the integration values, and we not set the values //weightsOut[i] = 0.0;
00137       yi = i % nr1DPoints; xi = i / nr1DPoints; intR = 0.0;
00138       // for each quadrature point
00139       for (int q = 0 ; q < pointWeights.size() ; q++){
00140         xc = px + quadPoints[q][0]*ofx;
00141         yc = py + quadPoints[q][1]*ofy;
00142         valBasisX = evalLagrangePol(xi , linePoints , xc);
00143         valBasisY = evalLagrangePol(yi , linePoints , yc);
00144         valTmp = pointWeights[q] * ( valBasisX *  valBasisY);
00145         intR = intR + valTmp;
00146         //SUNDANCE_MSG3(verb_, "i="<<i<< " , valBasisX=" << valBasisX  << " , valBasisY=" << valBasisY << " , valBasis="
00147         //    << valBasisX*valBasisY <<" , val=" << valTmp*::fabs(ofx*ofy/areFakt) );
00148         //SUNDANCE_MSG3(verb_, "i="<<i<<",xi="<<xi<<",yi="<<yi<<",q="<<q<<",xc="<<xc<<",yc="<<yc<<
00149         //    ",pointWeights[q]=" << pointWeights[q]);
00150       }
00151       intR = intR * ::fabs(ofx*ofy/areFakt);
00152       weightsOut[i] = weightsOut[i] + intR;
00153     }
00154   }
00155 
00156 
00157   /** this function applies quadrature to the Lagrange functions <br>
00158    * all the coordinates are in the reference coordinates */
00159   inline void makeInterpolantBrick(int nr1DPoints , int nr3DPoints ,
00160                                Array<Point>& linePoints ,
00161                                Array<Point>& quadPoints ,
00162                                Array<double>& pointWeights ,
00163                                Array<double>& weightsOut ,
00164                                double areFakt ) const {
00165     int xi,yi,zi;
00166     double xc,yc,zc, intR , valTmp , valBasisX , valBasisY , valBasisZ;
00167 
00168     for (int i = 0 ; i < nr3DPoints ; i++){
00169       zi = i/(nr1DPoints*nr1DPoints); yi = (i%(nr1DPoints*nr1DPoints)) / nr1DPoints;
00170       xi = (i%(nr1DPoints*nr1DPoints)) % nr1DPoints; intR = 0.0;
00171       // for each quadrature point
00172       for (int q = 0 ; q < pointWeights.size() ; q++){
00173         xc = quadPoints[q][0]; yc = quadPoints[q][1]; zc = quadPoints[q][2];
00174         valBasisX = evalLagrangePol(xi , linePoints , xc);
00175         valBasisY = evalLagrangePol(yi , linePoints , yc);
00176         valBasisZ = evalLagrangePol(zi , linePoints , zc);
00177         valTmp = pointWeights[q] * ( valBasisX * valBasisY * valBasisZ );
00178         intR = intR + valTmp;
00179         //SUNDANCE_MSG3(4, "i="<<i<< " , valBasisX=" << valBasisX  << " , valBasisY=" << valBasisY << " , valBasisZ=" << valBasisZ <<
00180         //    " , valBasis=" << valBasisX*valBasisY <<" , val=" << valTmp );
00181         //SUNDANCE_MSG3(4, "i="<<i<<",xi="<<xi<<",yi="<<yi<<",q="<<q<<",xc="<<xc<<",yc="<<yc<<",zc="<<zc<<
00182         //    ",pointWeights["<<q<<"]=" << pointWeights[q]);
00183       }
00184       intR = intR * areFakt ;
00185       weightsOut[i] = weightsOut[i] + intR;
00186     }
00187   }
00188 
00189 
00190 
00191   /** nr of points in 1D, the rest should be tensor product */
00192   int nrPointin1D_;
00193 
00194   /** the verbosity of the object*/
00195   int verb_;
00196 
00197   static const int quadsEdgesPoints[4][2];
00198 
00199   /** qvasi information for the 3D cut-cell integral*/
00200   static const int edge3DProjection[12];
00201 };
00202 
00203 }
00204 
00205 #endif /* SUNDANCEGAUSSLOBATTOQUADRATURE_HPP_ */

Site Contact