SundanceMixedDOFMapHN.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_MIXEDDOFMAPHN_H
00032 #define SUNDANCE_MIXEDDOFMAPHN_H
00033 
00034 
00035 #include "SundanceDefs.hpp"
00036 #include "SundanceMesh.hpp"
00037 #include "SundanceCellSet.hpp"
00038 #include "SundanceCellFilter.hpp"
00039 #include "SundanceHNDoFMapBaseHomogeneous.hpp"
00040 #include "SundanceBasisFamilyBase.hpp"
00041 #include "SundanceMatrixStore.hpp"
00042 
00043 namespace Sundance
00044 {
00045 using namespace Teuchos;
00046 
00047 class BasisDOFTopologyBase;
00048 
00049 /** 
00050  * A MixedDOFMapHN is a DOF map for the case where
00051  * every function is defined
00052  * on every cell in the mesh, but where functions may have different bases. <br>
00053  * MixedDOFMapHN is defined on meshes with hanging nodes,
00054  * it builds the restriction matrix where it is needed.
00055  */
00056 class MixedDOFMapHN : public HNDoFMapBaseHomogeneous
00057 {
00058 public:
00059   /** */
00060   MixedDOFMapHN(const Mesh& mesh,
00061     const Array<RCP<BasisDOFTopologyBase> >& basis,
00062     const CellFilter& maxCells, 
00063     int setupVerb);
00064                         
00065   /** */
00066   virtual ~MixedDOFMapHN(){;}
00067 
00068   /** */
00069   RCP<const MapStructure> 
00070   getDOFsForCellBatch(int cellDim,
00071     const Array<int>& cellLID,
00072     const Set<int>& requestedFuncSet,
00073     Array<Array<int> >& dofs,
00074     Array<int>& nNodes,
00075     int verbosity) const ;
00076 
00077   /** Returns the
00078    * @param cellLID [in] the maxCell LID input
00079    * @param funcID [in]
00080    * @param trafoMatrixSize [in/out]
00081    * @param doTransform [out]
00082    * @param transfMatrix [out] row major matrix*/
00083   void getTrafoMatrixForCell(
00084       int cellLID,
00085       int funcID,
00086       int& trafoMatrixSize,
00087       bool& doTransform,
00088       Array<double>& transfMatrix ) const;
00089 
00090   /** Function to apply transformation for facets
00091    * @param cellDim , the facet dimension
00092    * @param cellLID , facet LID
00093    * @param facetIndex , facet index in the maxCofacet
00094    * @param funcID  [in] the function ID
00095    * @param trafoMatrixSize [in/out]
00096    * @param doTransform [out]
00097    * @param transfMatrix [out] (we assume that the array is already pre-sized )*/
00098      void getTrafoMatrixForFacet(
00099       int cellDim,
00100       int cellLID,
00101       int facetIndex,
00102       int funcID,
00103       int& trafoMatrixSize,
00104       bool& doTransform,
00105       Array<double>& transfMatrix ) const;
00106 
00107   /** See subclass for docu
00108    * We can be sure that this is used only for nodal data (for VTK plotting)<br>
00109    * This is implemented only for Nodal data call !!! */
00110   void getDOFsForHNCell(
00111     int cellDim,
00112     int cellLID,
00113       int funcID,
00114       Array<int>& dofs ,
00115       Array<double>& coefs ) const;
00116 
00117   /** */
00118   RCP<const MapStructure> mapStruct() const 
00119     {return structure_;}
00120 
00121   /** */
00122   int chunkForFuncID(int funcID) const
00123     {return structure_->chunkForFuncID(funcID);}
00124 
00125   /** */
00126   int indexForFuncID(int funcID) const 
00127     {return structure_->indexForFuncID(funcID);}
00128       
00129   /** */
00130   int nFuncs(int basisChunk) const
00131     {return nFuncs_[basisChunk];}
00132 
00133   /** */
00134   int nBasisChunks() const 
00135     {return nFuncs_.size();}
00136 
00137   /** */
00138   const RCP<BasisDOFTopologyBase>& basis(int basisChunk) const
00139     {return structure_->basis(basisChunk);}
00140 
00141   /** */
00142   const Array<int>& funcID(int basisChunk) const 
00143     {return structure_->funcs(basisChunk);}
00144 
00145 
00146 private:
00147 
00148   /** */
00149   void checkTable() const ;
00150 
00151   /** */
00152   inline int getInitialDOFForCell(int cellDim, int cellLID, int basisChunk) const
00153     {
00154       return dofs_[cellDim][basisChunk][cellLID*nDofsPerCell_[basisChunk][cellDim]];
00155     }
00156 
00157   inline int* getInitialDOFPtrForCell(int cellDim, int cellLID, int basisChunk)
00158     {
00159       return &(dofs_[cellDim][basisChunk][cellLID*nDofsPerCell_[basisChunk][cellDim]]);
00160     }
00161 
00162   inline const int* getInitialDOFPtrForCell(int cellDim, int cellLID, 
00163     int basisChunk) const 
00164     {
00165       return &(dofs_[cellDim][basisChunk][cellLID*nDofsPerCell_[basisChunk][cellDim]]);
00166     }
00167 
00168   /** */
00169   void allocate(const Mesh& mesh);
00170       
00171   /** */
00172   void buildMaximalDofTable();
00173 
00174   bool hasBeenAssigned(int cellDim, int cellLID) const 
00175     {return hasBeenAssigned_[cellDim][cellLID];}
00176 
00177   void markAsAssigned(int cellDim, int cellLID)
00178     {hasBeenAssigned_[cellDim][cellLID] = true;}
00179 
00180   /** */
00181   void initMap();
00182 
00183   /** */
00184   void setDOFs(int basisChunk, int cellDim, int cellLID, 
00185     int& nextDOF, bool isRemote=false);
00186 
00187   /** */
00188   void shareDOFs(int cellDim,
00189     const Array<Array<int> >& outgoingCellRequests);
00190 
00191   /** */
00192   void computeOffsets(int dim, int localCount);
00193 
00194   /** */
00195   static int uninitializedVal() {return -1;}
00196 
00197   /** */
00198   CellFilter maxCells_;
00199 
00200   /** spatial dimension */
00201   int dim_;
00202 
00203   /** Tables of DOFs, indexed by dimension and chunk number.
00204    *
00205    * dof(cellDim, cellLID, chunk, func, node) 
00206    * = dofs_[cellDim][chunk][(cellLID*nFunc + func)*nNode + node]
00207    */
00208   Array<Array<Array<int> > > dofs_;
00209 
00210   /** DOFs for maximal cells, indexed by basis chunk number 
00211    *
00212    * dof(cellLID, chunk, func, node) 
00213    * = maximalDofs_[chunk][(cellLID*nFunc + func)*nNode + node];
00214    */
00215   mutable Array<Array<int> > maximalDofs_;
00216 
00217   /** whether maximal DOFs have been tabulated */
00218   mutable bool haveMaximalDofs_;
00219 
00220   /** 
00221    * localNodePtrs_[basisChunk][cellDim][facetDim][facetNumber][nodeNumber]
00222    */
00223   Array<Array<Array<Array<Array<int> > > > > localNodePtrs_;
00224 
00225 /* ========= Hanging node treatment ============= */
00226 
00227    /** Nr of points, needed only by plotting */
00228    int nPoints_;
00229 
00230    /** Is true if the cell has hanging node */
00231    Array<bool> hasCellHanging_;
00232 
00233    /** Flag per element showing if the element is a hanging element*/
00234    Array< Array<bool> > isElementHanging_;
00235 
00236    /** store the facetLIDs of the points [nPoints*b + facetID]*/
00237    Sundance::Map< int , Array<int>  > HN_To_globalFacetsLID_;
00238 
00239    /** store the facetDim of the points [nPoints*b + facetID]*/
00240    Sundance::Map< int , Array<int>  > HN_To_globalFacetsDim_;
00241 
00242    /** store the coefs [nPoints*b + facetID]*/
00243    Sundance::Map< int , Array<double>  > HN_To_coeffs_;
00244 
00245    /** Maps one maxCell LID to one transformation matrix, only maxDim elements and basisChunck ID
00246     * with hanging nodes should have transformation matrix
00247     * [maxCellLID].get -> [basisChunckID][] is the index of trafo matrix */
00248    Sundance::Map< int , Array < int > > maxCellLIDwithHN_to_TrafoMatrix_;
00249 
00250    /** The object to store all the transformation matrixes */
00251    MatrixStore                          matrixStore_;
00252 
00253    /** The basis for the transformation */
00254    mutable Array<RCP<BasisFamilyBase> > basis_;
00255 
00256 /* ========= END hanging node treatment ======== */
00257 
00258   /** The number of nodes per cell, for each basis function type, 
00259    * <i>not</i> including the nodes of the facets of the cell. Indexed as 
00260    * nNodesPerCell_[basis][dimension] */
00261   Array<Array<int> > nNodesPerCell_;
00262 
00263   /** The number of DOFs per cell, for each basis function type, 
00264    * <i>not</i> including the DOFs of the facets of the cell. Indexed as 
00265    * nDofsPerCell_[basis][dimension] */
00266   Array<Array<int> > nDofsPerCell_;
00267 
00268   /** The number of nodes per cell, for each basis function type, including
00269    * the nodes of the facets of the cell. Indexed as 
00270    * nNodesPerCell_[basis][dimension] */
00271   Array<Array<int> > totalNNodesPerCell_;
00272 
00273   /** The number of DOFs per cell, for each basis function type, including
00274    * the DOFs of the facets of the cell. Indexed as 
00275    * nDofsPerCell_[basis][dimension] */
00276   Array<Array<int> > totalNDofsPerCell_;
00277 
00278   /** Indicates whether the cells of each dimension have any DOFs in this
00279    * map, for any chunk. */
00280   Array<int> cellHasAnyDOFs_;
00281 
00282   /** number of facets of dimension facetDim for cells of dimension cellDim.
00283    * Indexed as numFacets_[cellDim][facetDim]
00284    */
00285   Array<Array<int> > numFacets_;
00286 
00287   /** Orientation of each edge or face as seen by the maximal cell
00288    * from which its DOFs were originally assigned. */
00289   Array<Array<int> > originalFacetOrientation_;
00290 
00291   /** */
00292   Array<Array<int> > hasBeenAssigned_;
00293 
00294   /** */
00295   RCP<const MapStructure> structure_;
00296 
00297   /** */
00298   Array<int> nFuncs_;
00299 };
00300 }
00301 
00302                   
00303 #endif

Site Contact