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

Site Contact