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_MAPBUNDLE_H 00032 #define SUNDANCE_MAPBUNDLE_H 00033 00034 #include "SundanceDefs.hpp" 00035 #include "SundanceLocalDOFMap.hpp" 00036 #include "SundanceIntegrationCellSpecifier.hpp" 00037 00038 namespace Sundance 00039 { 00040 using namespace Teuchos; 00041 00042 class DOFMapBase; 00043 class StdFwkEvalMediator; 00044 00045 00046 /** 00047 * MapBundle collects several data structures needed for DOF mapping. For 00048 * each variable/equation block, it contains: 00049 * <ul> 00050 * <li> A DOFMapBase object 00051 * <li> An array indicating whether each local index is a BC index. BC 00052 * indices are skipped during fill, except for EssentialBC expressions. 00053 * <li> The lowest local index owned by this processor. 00054 * </ul> 00055 * 00056 * The main reason for this class is the need to maintain in some cases 00057 * two local maps: one based on a set of cells, another based on a set of cofacets. 00058 * In a given calculation both might be needed. The chooseMap() method is used 00059 * to select the correct map for a given calculation. 00060 * 00061 * A cofacet-based map will be needed when evaluating a boundary integral involving 00062 * a non-Lagrange basis or a derivative of a Lagrange basis. The most common integrals 00063 * are over interior cells, for which the non-cofacet map is used regardless of basis 00064 * (because an interior cell has no cofacets and has all information needed for DOF mapping). 00065 */ 00066 class MapBundle 00067 { 00068 public: 00069 /** */ 00070 MapBundle( 00071 const Array<RCP<DOFMapBase> >& dofMap, 00072 const Array<RCP<Array<int> > >& isBCIndex, 00073 const Array<int>& lowestLocalIndex, 00074 bool partitionBCs, 00075 int verb 00076 ); 00077 00078 /** 00079 * Build fast lookup tables of DOFs for local cells. 00080 */ 00081 void buildLocalDOFMaps( 00082 const RCP<StdFwkEvalMediator>& mediator, 00083 IntegrationCellSpecifier intCellSpec, 00084 const Array<Set<int> >& requiredFuncs, 00085 int verbosity) ; 00086 00087 /** 00088 * 00089 */ 00090 RCP<const Array<int> > workSet(int block, bool useCofacets) const ; 00091 00092 /** 00093 * Return the global DOF map for the b-th block 00094 */ 00095 const RCP<DOFMapBase>& dofMap(int b) const {return dofMap_[b];} 00096 00097 /** 00098 * Return the bc indicator array for the b-th block 00099 */ 00100 const RCP<Array<int> >& isBCIndex(int b) const 00101 {return isBCIndex_[b];} 00102 00103 /** 00104 * Return the lowest index owned by the b-th block 00105 */ 00106 int lowestLocalIndex(int b) const {return lowestLocalIndex_[b];} 00107 00108 /** */ 00109 int nCells() const ; 00110 00111 /** 00112 * Select a local DOF map according to whether cofacet cells or ordinary 00113 * cells should be used. 00114 */ 00115 const RCP<LocalDOFMap>& chooseMap( 00116 int block, bool useCofacets) const ; 00117 00118 /** 00119 * 00120 */ 00121 const RCP<const MapStructure>& mapStruct( 00122 int block, 00123 bool useCofacetCells) const 00124 { 00125 const RCP<const LocalDOFMap>& choice = chooseMap(block, useCofacetCells); 00126 return choice->mapStruct(block); 00127 } 00128 00129 /** 00130 * 00131 */ 00132 const Array<int>& localDOFs( 00133 int block, 00134 bool useCofacetCells, 00135 int chunk) const 00136 { 00137 const RCP<const LocalDOFMap>& choice = chooseMap(block, useCofacetCells); 00138 return choice->localDOFs(block)[chunk]; 00139 } 00140 00141 /** 00142 * 00143 */ 00144 int nNodesInChunk( 00145 int block, 00146 bool useCofacetCells, 00147 int chunk) const 00148 { 00149 const RCP<const LocalDOFMap>& choice = chooseMap(block, useCofacetCells); 00150 return choice->nLocalNodesPerChunk(block)[chunk]; 00151 } 00152 00153 /** 00154 * Return the verbosity setting 00155 */ 00156 int verb() const {return verb_;} 00157 00158 private: 00159 int verb_; 00160 Array<RCP<DOFMapBase> > dofMap_; 00161 Array<RCP<Array<int> > > isBCIndex_; 00162 Array<int> lowestLocalIndex_; 00163 00164 /** localDOFMap is the compact map built w/o cofacet DOFs. Either 00165 * this map or the cofacet map might be used in a given calculation */ 00166 RCP<LocalDOFMap> localDOFMap_; 00167 /** localDOFMap is the compact map built with cofacet DOFs */ 00168 RCP<LocalDOFMap> cofacetLocalDOFMap_; 00169 }; 00170 00171 00172 00173 } 00174 00175 00176 00177 #endif