SundanceBasisFamily.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_BASISFAMILY_H
00032 #define SUNDANCE_BASISFAMILY_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceBasisFamilyBase.hpp"
00036 #include "SundanceOrderedHandle.hpp"
00037 #include "Teuchos_Array.hpp"
00038 
00039 namespace Sundance
00040 {
00041 using Teuchos::XMLObject;
00042 using Teuchos::tuple;
00043 using Teuchos::Array;
00044 
00045 class CommonFuncDataStub;
00046 
00047 /** 
00048  * BasisFamily is the user-level handle class for specifying the basis with
00049  * which a test, unknown, or discrete function is represented.  Basis
00050  * functions can be vector-valued, as is the case with, for example, the
00051  * Nedelec basis in electromagnetics; the dim() method returns the spatial
00052  * dimension of the basis functions. Scalar-valued bases naturally have
00053  * dim()=1.
00054 
00055 */
00056 class BasisFamily : public OrderedHandle<BasisFamilyBase>
00057 {
00058 public:
00059   /* handle ctor boilerplate */
00060   ORDERED_HANDLE_CTORS(BasisFamily, BasisFamilyBase);
00061 
00062   /** write to XML */
00063   XMLObject toXML() const ;
00064 
00065   /** 
00066    * \brief Return the polynomial order of the basis functions, for use in
00067    * determining the quadrature rule required to integrate a product of
00068    * basis functions exactly. The polynomial order will be the smallest
00069    * integer for which all mixed partial derivatives vanish exactly.
00070    *  
00071    * Note: in H(div) and H(curl) spaces the order of accuracy is not
00072    * always an integer, and the relationship between the order of accuracy
00073    * and the return value of the order() method is not necessarily simple
00074    * (for instance, it can depend on things such as the convexity of the
00075    * boundary). Thus it is better to think of this method as specifying
00076    * the required order of quadrature, and not the order of accuracy of
00077    * approximation nor the order to which the space is complete.
00078    */
00079   int order() const ;
00080 
00081   /** \brief
00082    * Return the number of DOFs for this basis on the given 
00083    * reference cell type, including its facets.
00084    */
00085   int nReferenceDOFsWithFacets(const CellType& maximalCellType,
00086     const CellType& cellType) const ;
00087 
00088   /** \brief
00089    * Return the number of DOFs for this basis on the given 
00090    * reference cell type, not including those on facets.
00091    */
00092   int nReferenceDOFsWithoutFacets(const CellType& maximalCellType,
00093     const CellType& cellType) const ;
00094 
00095   /** 
00096    * \brief Return the dimension of the members of 
00097    * a vector-valued basis. Return 1 if the basis
00098    * is scalar-valued. Otherwise, return the spatial dimension.
00099    */
00100   int dim() const ;
00101 
00102   /** 
00103    * \brief Return the tensor order of the members of 
00104    * a basis.
00105    */
00106   int tensorOrder() const {return ptr()->tensorOrder();}
00107 
00108   /** */
00109   bool operator==(const BasisFamily& other) const ;
00110 
00111   
00112 
00113   /** \brief Inform caller as to whether I am a scalar basis. */
00114   bool isScalarBasis() const {return ptr()->isScalarBasis();}
00115 
00116   /** \brief Inform caller as to whether I am an H(div) basis. */
00117   bool isHDivBasis() const {return ptr()->isHDivBasis();}
00118 
00119   /** \brief Inform caller as to whether I am an H(curl) basis. */
00120   bool isHCurlBasis() const {return ptr()->isHCurlBasis();}
00121 
00122   /** Sum up the dim() values for array of bases. */
00123   static int size(const Array<BasisFamily>& b) ;
00124 
00125   /** Extract the basis from an expression */
00126   static BasisFamily getBasis(const RCP<const CommonFuncDataStub>& funcData);
00127 
00128   /** Extract the basis from an expression */
00129   static RCP<BasisDOFTopologyBase> getBasisTopology(const RCP<const CommonFuncDataStub>& funcData);
00130 
00131   /** */
00132   void refEval(
00133     const CellType& cellType,
00134     const Array<Point>& pts,
00135     const SpatialDerivSpecifier& deriv,
00136     Array<Array<Array<double> > >& result,
00137     int verbosity) const ;
00138 
00139   /**  */
00140   void getConstrainsForHNDoF( const int indexInParent,
00141             const int maxCellDim,
00142             const int maxNrChild,
00143             const int facetDim,
00144             const int facetIndex,
00145             const int nodeIndex,
00146             Array<int>& localDoFs,
00147             Array<int>& parentFacetDim,
00148             Array<int>& parentFacetIndex,
00149             Array<int>& parentFacetNode,
00150             Array<double>& coefs
00151             ) const;
00152 
00153 
00154 
00155   /** \brief Inform caller whether basis requires an element transformation */
00156   bool requiresBasisTransformation() const { return ptr()->requiresBasisTransformation(); }
00157 
00158 
00159   /** */
00160   virtual void preApplyTransformation( const CellType &maxCellType ,
00161                const Mesh &mesh,
00162                const Array<int> &cellLIDs,
00163                const CellJacobianBatch& JVol,
00164                RCP<Array<double> >& A
00165                ) const 
00166   { 
00167     ptr()->preApplyTransformation( maxCellType ,
00168            mesh,
00169            cellLIDs,
00170            JVol,
00171            A);
00172   }
00173   /**  */
00174   virtual void postApplyTransformation( const CellType &maxCellType ,
00175           const Mesh &mesh,
00176           const Array<int> &cellLIDs,
00177           const CellJacobianBatch& JVol,
00178           RCP<Array<double> >& A ) const
00179   {
00180     ptr()->postApplyTransformation( maxCellType ,
00181             mesh ,
00182             cellLIDs ,
00183             JVol,
00184             A);
00185   }
00186   
00187   virtual void preApplyTransformationTranspose( const CellType &maxCellType ,
00188             const Mesh &mesh,
00189             const Array<int> &cellLIDs,
00190             const CellJacobianBatch& JVol,
00191             Array<double>& A ) const
00192   {
00193     ptr()->preApplyTransformationTranspose( maxCellType ,
00194               mesh ,
00195               cellLIDs ,
00196               JVol ,
00197               A );
00198   }
00199 
00200 };
00201 
00202 /** \relates BasisFamily */
00203 inline Array<BasisFamily> List(const BasisFamily& a, const BasisFamily& b)
00204 {
00205   return Array<BasisFamily>(tuple(a,b));
00206 }
00207 
00208 /** \relates BasisFamily */
00209 inline Array<BasisFamily> List(const BasisFamily& a, const BasisFamily& b,
00210   const BasisFamily& c)
00211 {
00212   return tuple(a,b,c);
00213 }
00214 
00215 /** \relates BasisFamily */
00216 inline Array<BasisFamily> List(const BasisFamily& a, const BasisFamily& b,
00217   const BasisFamily& c, const BasisFamily& d)
00218 {
00219   return tuple(a,b,c,d);
00220 }
00221 
00222 /** \relates BasisFamily */
00223 inline Array<BasisFamily> List(const BasisFamily& a, const BasisFamily& b,
00224   const BasisFamily& c, const BasisFamily& d, 
00225   const BasisFamily& e)
00226 {
00227   return tuple(a,b,c,d,e);
00228 }
00229 
00230 
00231 /** \relates BasisFamily */
00232 inline Array<BasisFamily> List(const BasisFamily& a, const BasisFamily& b,
00233   const BasisFamily& c, const BasisFamily& d, 
00234   const BasisFamily& e, const BasisFamily& f)
00235 {
00236   return tuple(a,b,c,d,e,f);
00237 }
00238 
00239 /** \relates BasisFamily */
00240 inline Array<BasisFamily> List(const BasisFamily& a, const BasisFamily& b,
00241   const BasisFamily& c, const BasisFamily& d, 
00242   const BasisFamily& e, const BasisFamily& f, 
00243   const BasisFamily& g)
00244 {
00245   return tuple(a,b,c,d,e,f,g);
00246 }
00247 
00248 /** \relates BasisFamily */
00249 inline Array<BasisFamily> List(const BasisFamily& a, const BasisFamily& b,
00250   const BasisFamily& c, const BasisFamily& d, 
00251   const BasisFamily& e, const BasisFamily& f, 
00252   const BasisFamily& g, const BasisFamily& h)
00253 {
00254   return tuple(a,b,c,d,e,f,g,h);
00255 }
00256 
00257 /** \relates BasisFamily */
00258 inline Array<BasisFamily> List(const BasisFamily& a, const BasisFamily& b,
00259   const BasisFamily& c, const BasisFamily& d, 
00260   const BasisFamily& e, const BasisFamily& f, 
00261   const BasisFamily& g, const BasisFamily& h, 
00262   const BasisFamily& i)
00263 {
00264   return tuple(a,b,c,d,e,f,g,h,i);
00265 }
00266 
00267 /** \relates BasisFamily */
00268 inline Array<BasisFamily> List(const BasisFamily& a, const BasisFamily& b,
00269   const BasisFamily& c, const BasisFamily& d, 
00270   const BasisFamily& e, const BasisFamily& f, 
00271   const BasisFamily& g, const BasisFamily& h, 
00272   const BasisFamily& i, const BasisFamily& j)
00273 {
00274   return tuple(a,b,c,d,e,f,g,h,i,j);
00275 }
00276 
00277 /** */
00278 inline Array<BasisFamily> replicate(const BasisFamily& b, int n)
00279 {
00280   Array<BasisFamily> rtn(n);
00281   for (int i=0; i<n; i++) rtn[i] = b;
00282   return rtn;
00283 }
00284 
00285 
00286 /** */
00287 inline Array<BasisFamily> replicate(const Array<BasisFamily>& b, int n)
00288 {
00289   Array<BasisFamily> rtn(n*b.size());
00290   for (int i=0; i<n*b.size(); i++) rtn[i] = b[0];
00291   return rtn;
00292 }
00293 
00294 class BasisArray : public Array<BasisFamily>
00295 {
00296 public:
00297   BasisArray() : Array<BasisFamily>() {;}
00298 
00299   BasisArray(int n) : Array<BasisFamily>(n) {;}
00300 
00301   BasisArray(const Array<BasisFamily>& a) 
00302     : Array<BasisFamily>(a) 
00303     {;}
00304 
00305 };
00306 
00307 
00308 /** \relates BasisFamily */
00309 Array<std::pair<int, int> > vectorDimStructure(const Array<BasisFamily>& basis);
00310 
00311 
00312 /** \relates BasisFamily */
00313 Array<std::pair<int, int> > vectorDimStructure(const BasisFamily& basis);
00314 
00315 
00316 /** \relates BasisFamily 
00317  * Indicate whether members of a basis have support on a boundary only
00318  * if their associated dofs live on the boundary. This will return true
00319  * for Lagrange, false for P1NC, RT, Nedelec, and most other bases. 
00320  *
00321  * This is used to simplify boundary integrals.
00322  */
00323 bool basisRestrictableToBoundary(const BasisFamily& b);
00324 
00325 
00326 }
00327 
00328 #endif

Site Contact