SundanceMapBundle.cpp
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 #include "SundanceOut.hpp"
00043 #include "PlayaTabs.hpp"
00044 #include "SundanceMapBundle.hpp"
00045 #include "SundanceDOFMapBase.hpp"
00046 #include "SundanceStdFwkEvalMediator.hpp"
00047 
00048 using namespace Sundance;
00049 using namespace Sundance;
00050 using namespace Sundance;
00051 using namespace Sundance;
00052 using namespace Sundance;
00053 using namespace Sundance;
00054 using namespace Sundance;
00055 using namespace Teuchos;
00056 
00057       
00058 
00059 MapBundle::MapBundle(
00060   const Array<RCP<DOFMapBase> >& dofMap,
00061   const Array<RCP<Array<int> > >& isBCIndex,
00062   const Array<int>& lowestLocalIndex,
00063   bool partitionBCs,
00064   int verb
00065   )
00066   : verb_(verb),
00067     dofMap_(dofMap),
00068     isBCIndex_(isBCIndex),
00069     lowestLocalIndex_(lowestLocalIndex),
00070     localDOFMap_(rcp(new LocalDOFMap(dofMap_.size(), verb))),
00071     cofacetLocalDOFMap_(rcp(new LocalDOFMap(dofMap_.size(), verb)))
00072 {}
00073 
00074 int MapBundle::nCells() const 
00075 {
00076   TEUCHOS_TEST_FOR_EXCEPTION(localDOFMap_->isUnused() 
00077     && cofacetLocalDOFMap_->isUnused(), std::runtime_error,
00078     "no local DOF maps defined in call to MapBundle::nCells()");
00079 
00080   
00081   if (cofacetLocalDOFMap_->isUnused())
00082   {
00083     return localDOFMap_->nCells();
00084   }
00085   else if (localDOFMap_->isUnused())
00086   {
00087     return cofacetLocalDOFMap_->nCells();
00088   }
00089   else
00090   {
00091     TEUCHOS_TEST_FOR_EXCEPTION(localDOFMap_->nCells() != cofacetLocalDOFMap_->nCells(),
00092       std::runtime_error,
00093       "mismatched cell counts in MapBundle::nCells()");
00094     return cofacetLocalDOFMap_->nCells();
00095   }
00096 }
00097 
00098 RCP<const Array<int> > MapBundle::workSet(int block,
00099   bool useCofacets) const
00100 {
00101   return chooseMap(block, useCofacets)->cellLIDs();
00102 }
00103 
00104 
00105 const RCP<LocalDOFMap>& MapBundle::chooseMap(
00106   int block, bool useCofacets) const
00107 {
00108   if (useCofacets)
00109   {
00110     TEUCHOS_TEST_FOR_EXCEPTION(cofacetLocalDOFMap_->isUnused(block),
00111       std::runtime_error,
00112       "request for unavailable cofacet-based local map for block = " << block);
00113     return cofacetLocalDOFMap_;
00114   }
00115   else
00116   {
00117     TEUCHOS_TEST_FOR_EXCEPTION(localDOFMap_->isUnused(block),
00118       std::runtime_error,
00119       "request for unavailable local map for block = " << block);
00120     return localDOFMap_;
00121   }
00122 }
00123 
00124 
00125 
00126 
00127 void MapBundle::buildLocalDOFMaps(
00128   const RCP<StdFwkEvalMediator>& mediator,
00129   IntegrationCellSpecifier intCellSpec,
00130   const Array<Set<int> >& requiredFuncs,
00131   int verbosity)
00132 {
00133   Tabs tab;
00134 
00135   int numBlocks = dofMap_.size();
00136 
00137   localDOFMap_->markAsUnused();
00138   cofacetLocalDOFMap_->markAsUnused();
00139   localDOFMap_->setVerb(verbosity);
00140   cofacetLocalDOFMap_->setVerb(verbosity);
00141 
00142   int maxCellDim = mediator->maxCellDim();
00143   int cellDim = mediator->cellDim();
00144 
00145   SUNDANCE_MSG3(verbosity, tab << "cell dim=" << cellDim);
00146   SUNDANCE_MSG3(verbosity, tab << "max cell dim=" << maxCellDim);
00147 
00148   for (int b=0; b<numBlocks; b++)
00149   {   
00150     Tabs tab2;
00151     SUNDANCE_MSG3(verbosity, tab2 << "getting dofs for block " 
00152       << b << " of " << numBlocks);
00153         
00154     if (intCellSpec != AllTermsNeedCofacets)
00155     {
00156       Tabs tab3;
00157       SUNDANCE_MSG3(verbosity, tab3 << "getting ordinary dofs");
00158 
00159       if (!localDOFMap_->hasCells()) 
00160       {
00161         SUNDANCE_MSG3(verbosity, tab3 << "setting cells of dim " 
00162           << cellDim);
00163         localDOFMap_->setCells(cellDim, maxCellDim, mediator->cellLID());
00164       }     
00165       localDOFMap_->fillBlock(b, dofMap_[b], requiredFuncs);
00166       localDOFMap_->markAsUsed(b);
00167     }
00168     else
00169     {
00170       Tabs tab3;
00171       SUNDANCE_MSG3(verbosity, tab3 << "ordinary dofs not needed for block " << b);
00172     }
00173 
00174         
00175     if (intCellSpec != NoTermsNeedCofacets)
00176     {
00177       Tabs tab3;
00178       SUNDANCE_MSG3(verbosity, tab3 << "getting cofacet dofs");
00179       SUNDANCE_MSG3(verbosity, tab3 << "cofacet cells="
00180         << *(mediator->cofacetCellLID()));
00181 
00182       if (!cofacetLocalDOFMap_->hasCells()) 
00183         cofacetLocalDOFMap_->setCells(maxCellDim, 
00184           maxCellDim, mediator->cofacetCellLID());
00185 
00186       cofacetLocalDOFMap_->fillBlock(b, dofMap_[b], requiredFuncs);
00187       cofacetLocalDOFMap_->markAsUsed(b);
00188     }
00189     else
00190     {
00191       Tabs tab3;
00192       SUNDANCE_MSG3(verbosity, tab3 << "cofacet dofs not needed for block " << b);
00193     }
00194         
00195   }
00196 
00197   if (intCellSpec != AllTermsNeedCofacets)
00198   {
00199     SUNDANCE_MSG4(verbosity, tab << "local DOF values " << *localDOFMap_);
00200   }
00201 
00202   if (intCellSpec != NoTermsNeedCofacets)
00203   {
00204     SUNDANCE_MSG4(verbosity, tab << "local cofacet DOF values " 
00205       << *cofacetLocalDOFMap_);
00206   }
00207 }

Site Contact