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