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

Site Contact