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

Site Contact