Go to the documentation of this file.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
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "SundanceOut.hpp"
00043 #include "PlayaTabs.hpp"
00044 #include "SundanceDOFMapBase.hpp"
00045 #include "SundanceLocalDOFMap.hpp"
00046
00047
00048 using namespace Sundance;
00049 using namespace Sundance;
00050 using namespace Sundance;
00051 using namespace Teuchos;
00052
00053
00054 using std::endl;
00055 using std::setw;
00056
00057
00058 LocalDOFMap::LocalDOFMap(int numBlocks, int verb)
00059 : verb_(verb),
00060 isUsed_(numBlocks),
00061 hasCells_(false),
00062 nLocalNodesPerChunk_(rcp(new Array<Array<int> >(numBlocks))),
00063 mapStruct_(rcp(new Array<RCP<const MapStructure> >(numBlocks))),
00064 localDOFs_(rcp(new Array<Array<Array<int> > >(numBlocks))),
00065 cellLID_(),
00066 activeCellDim_(-1),
00067 maxCellDim_(-1)
00068 {}
00069
00070 int LocalDOFMap::nCells() const
00071 {
00072 TEUCHOS_TEST_FOR_EXCEPTION(!hasCells(), std::runtime_error,
00073 "cells not valid when LocalDOFMap::nCells() called");
00074 return cellLID_->size();
00075 }
00076
00077 void LocalDOFMap::markAsUnused()
00078 {
00079 for (int b=0; b<numBlocks(); b++)
00080 {
00081 isUsed_[b] = 0;
00082 }
00083 hasCells_ = false;
00084 }
00085
00086
00087 bool LocalDOFMap::isUnused() const
00088 {
00089 for (int b=0; b<numBlocks(); b++)
00090 {
00091 if (isUsed_[b]) return false;
00092 }
00093 return true;
00094 }
00095
00096 void LocalDOFMap::verifyValidBlock(int b) const
00097 {
00098 TEUCHOS_TEST_FOR_EXCEPTION(b < 0 || b>=numBlocks(), std::runtime_error,
00099 "block index " << b << " out of range [0," << numBlocks() << ")");
00100 }
00101
00102 void LocalDOFMap::setCells(
00103 int activeCellDim,
00104 int maxCellDim,
00105 const RCP<const Array<int> >& cellLID)
00106 {
00107 activeCellDim_ = activeCellDim;
00108 maxCellDim_ = maxCellDim_;
00109 cellLID_ = cellLID;
00110 hasCells_=true;
00111 }
00112
00113
00114 void LocalDOFMap::fillBlock(int b, const RCP<DOFMapBase>& globalMap,
00115 const Array<Set<int> >& requiredFuncs)
00116 {
00117 Tabs tab;
00118 verifyValidBlock(b);
00119
00120 SUNDANCE_MSG2(verb_, tab << "getting local DOFs for block=" << b
00121 << ", active cell dim="
00122 << activeCellDim_);
00123
00124 mapStruct(b) = globalMap->getDOFsForCellBatch(
00125 activeCellDim_,
00126 *cellLID_,
00127 requiredFuncs[b],
00128 localDOFs(b),
00129 nLocalNodesPerChunk(b),
00130 verb_);
00131 }
00132
00133 std::ostream& LocalDOFMap::print(std::ostream& os) const
00134 {
00135 Tabs tab0;
00136 bool noneAreUsed=true;
00137 for (int b=0; b<numBlocks(); b++)
00138 {
00139 if (isUsed(b)) {noneAreUsed = false; break;}
00140 }
00141 if (noneAreUsed)
00142 {
00143 os << std::endl << tab0 << "[empty local DOF map]";
00144 }
00145 else
00146 {
00147 os << std::endl << tab0 << "LocalDOFMap[" << std::endl;
00148 Tabs tab;
00149 os << tab << "num cells=" << cellLID_->size() << ", active cellDim="
00150 << activeCellDim_ << ", maxCellDim=" << maxCellDim_ << std::endl;
00151 os << tab << "num blocks=" << numBlocks() << std::endl << std::endl;
00152
00153 for (int b=0; b<numBlocks(); b++)
00154 {
00155 Tabs tab1;
00156 os << tab1 << "block " << b << " of " << numBlocks()
00157 << *mapStruct(b) << std::endl;
00158 const Array<Array<int> >& dofs = localDOFs(b);
00159 int nChunks = mapStruct(b)->numBasisChunks();
00160
00161 for (int c=0; c<cellLID_->size(); c++)
00162 {
00163 Tabs tab2;
00164 os << tab2 << "cell LID=" << (*cellLID_)[c] << std::endl;
00165 for (int chunk=0; chunk<nChunks; chunk++)
00166 {
00167 Tabs tab3;
00168 int nFuncs = mapStruct(b)->numFuncs(chunk);
00169 const Array<int>& funcs = mapStruct(b)->funcs(chunk);
00170 int nNodes = nLocalNodesPerChunk(b)[chunk];
00171 for (int f=0; f<nFuncs; f++)
00172 {
00173 os << tab3 << "fid=" << funcs[f] << " dofs=";
00174 int funcOffset = mapStruct(b)->indexForFuncID(funcs[f]);
00175 for (int n=0; n<nNodes; n++)
00176 {
00177 int dof = dofs[chunk][(c*nFuncs+funcOffset)*nNodes+n];
00178 os << setw(6) << dof;
00179 if (n < nNodes-1) os << ", ";
00180 }
00181 os << std::endl;
00182 }
00183 }
00184 }
00185
00186 }
00187 os << tab0 << "] ### End LocalDOFMap" << std::endl;
00188 }
00189 return os;
00190 }