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

Site Contact