43 #include "PanzerDofMgr_config.hpp"
49 std::vector<Teuchos::RCP<const GlobalIndexer>>
52 std::vector<Teuchos::RCP<const GlobalIndexer>> vec;
54 for(std::size_t blk=0;blk<ugis.size();blk++)
55 vec.push_back(ugis[blk]);
64 for(std::size_t blk=0;blk<ugis.size();blk++) {
65 fieldNum = ugis[blk]->getFieldNum(fieldName);
77 for(std::size_t blk=0;blk<ugis.size();blk++) {
78 fieldNum = ugis[blk]->getFieldNum(fieldName);
88 std::vector<int> & blockOffsets)
90 blockOffsets.resize(ugis.size()+1);
93 for(std::size_t blk=0;blk<ugis.size();blk++) {
94 blockOffsets[blk] = offset;
95 offset += ugis[blk]->getElementBlockGIDCount(blockId);
97 blockOffsets[ugis.size()] = offset;
102 std::vector<int> & blockOffsets)
104 blockOffsets.resize(ugis.size()+1);
107 for(std::size_t blk=0;blk<ugis.size();blk++) {
108 blockOffsets[blk] = offset;
109 offset += ugis[blk]->getElementBlockGIDCount(blockId);
111 blockOffsets[ugis.size()] = offset;
117 std::size_t myOwnedCount =
static_cast<std::size_t
>(ugi.
getNumOwned());
118 std::size_t sum=0,min=0,max=0;
126 double dev2 = (double(myOwnedCount)-double(sum)/double(ugi.
getComm()->getSize()));
129 double variance = 0.0;
132 double mean = sum / double(ugi.
getComm()->getSize());
133 variance = variance / double(ugi.
getComm()->getSize());
136 std::stringstream ss;
137 ss <<
"Max, Min, Mean, StdDev = " << max <<
", " << min <<
", " << mean <<
", " << std::sqrt(variance);
145 std::vector<std::string> block_ids;
148 for(std::size_t b=0;b<block_ids.size();b++) {
150 const std::vector<panzer::LocalOrdinal> & elements = ugi.
getElementBlock(block_ids[b]);
152 os <<
"Element Block: \"" << block_ids[b] <<
"\"" << std::endl;
155 for(std::size_t e=0;e<elements.size();e++) {
160 std::vector<panzer::GlobalOrdinal> gids;
163 os <<
" local element id = " << elements[e] <<
", ";
166 for(std::size_t i=0;i<gids.size();i++)
167 os <<
" " << gids[i];
170 for(std::size_t i=0;i<gids.size();i++)
171 os <<
" " << lids[i];
180 typedef Tpetra::Map<int,panzer::GlobalOrdinal,panzer::TpetraNodeType> Map;
181 typedef Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> IntVector;
183 std::vector<panzer::GlobalOrdinal> indices;
184 std::vector<std::string> blocks;
189 std::vector<int> fieldNumbers(indices.size(),-1);
196 for(std::size_t blk=0;blk<blocks.size();blk++) {
197 std::string blockId = blocks[blk];
199 const std::vector<panzer::LocalOrdinal> & elements = ugi.
getElementBlock(blockId);
203 std::vector<panzer::GlobalOrdinal> gids(fields.size());
204 for(std::size_t e=0;e<elements.size();e++) {
207 for(std::size_t f=0;f<fields.size();f++) {
208 int fieldNum = fields[f];
209 panzer::GlobalOrdinal gid = gids[f];
210 std::size_t lid = ghostedMap->getLocalElement(gid);
212 fieldNumbers[lid] = fieldNum;
218 std::vector<panzer::GlobalOrdinal> reducedIndices;
219 std::vector<int> reducedFieldNumbers;
220 for(std::size_t i=0;i<fieldNumbers.size();i++) {
221 if(fieldNumbers[i]>-1) {
222 reducedIndices.push_back(indices[i]);
223 reducedFieldNumbers.push_back(fieldNumbers[i]);
230 return Teuchos::rcp(
new IntVector(reducedMap,Teuchos::arrayViewFromVector(reducedFieldNumbers)));
234 std::vector<int> & fieldNumbers,
235 const Teuchos::RCP<
const Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> > & reducedVec)
237 typedef Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> IntVector;
241 fieldNumbers.resize(dest->getLocalLength());
242 dest->get1dCopy(Teuchos::arrayViewFromVector(fieldNumbers));
247 const Teuchos::RCP<
const Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> > & reducedVec)
249 typedef Tpetra::Map<int,panzer::GlobalOrdinal,panzer::TpetraNodeType> Map;
250 typedef Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> IntVector;
251 typedef Tpetra::Import<int,panzer::GlobalOrdinal,panzer::TpetraNodeType> Importer;
259 std::vector<panzer::GlobalOrdinal> indices;
266 if(source==Teuchos::null)
275 Importer importer(sourceMap,destMap);
277 dest->doImport(*source,importer,Tpetra::INSERT);
284 getFieldMap(
int fieldNum,
const Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> & fieldTVector)
287 std::vector<int> fieldVector(fieldTVector.getLocalLength());
288 fieldTVector.get1dCopy(Teuchos::arrayViewFromVector(fieldVector));
290 std::vector<panzer::GlobalOrdinal> mapVector;
291 for(std::size_t i=0;i<fieldVector.size();i++) {
292 if(fieldVector[i]==fieldNum)
293 mapVector.push_back(origMap->getGlobalElement(i));
297 =
Teuchos::rcp(
new Tpetra::Map<int,panzer::GlobalOrdinal,panzer::TpetraNodeType>(
315 std::vector<panzer::GlobalOrdinal> indices;
316 ugi_->getOwnedIndices(indices);
323 Tpetra::Import<int,panzer::GlobalOrdinal> importer(source.getMap(),destMap);
324 localFieldVector->doImport(source,importer,Tpetra::INSERT);
353 namespace orientation_helpers {
357 const std::vector<panzer::GlobalOrdinal> & topology,
359 std::vector<signed char> & orientation)
371 for(std::size_t e=0;e<topEdgeIndices.size();e++) {
373 const std::pair<int,int> nodes = topEdgeIndices[e];
376 panzer::GlobalOrdinal v0 = topology[nodes.first];
377 panzer::GlobalOrdinal v1 = topology[nodes.second];
380 signed char edgeOrientation = 1;
384 edgeOrientation = -1;
389 const std::vector<int> & edgeIndices = fieldPattern.
getSubcellIndices(edgeDim,e);
390 for(std::size_t s=0;s<edgeIndices.size();s++)
391 orientation[edgeIndices[s]] = edgeOrientation;
396 const std::vector<panzer::GlobalOrdinal> & topology,
398 std::vector<signed char> & orientation)
418 for(std::size_t f=0;f<topFaceIndices.size();f++) {
420 const std::vector<int> & nodes = topFaceIndices[f];
421 std::vector<panzer::GlobalOrdinal> globals(nodes.size());
422 for(std::size_t n=0;n<nodes.size();n++)
423 globals[n] = topology[nodes[n]];
425 typename std::vector<panzer::GlobalOrdinal>::const_iterator itr
426 = std::min_element(globals.begin(),globals.end());
429 "panzer::orientation_helpers::computeCellFaceOrientations: A face index array "
438 panzer::GlobalOrdinal vbefore = itr==globals.begin() ? *(globals.end()-1) : *(itr-1);
439 panzer::GlobalOrdinal vafter = (itr+1)==globals.end() ? *globals.begin() : *(itr+1);
459 signed char faceOrientation = 1;
461 faceOrientation = -1;
462 else if(vbefore>vafter)
468 const std::vector<int> & faceIndices = fieldPattern.
getSubcellIndices(faceDim,f);
469 for(std::size_t s=0;s<faceIndices.size();s++)
470 orientation[faceIndices[s]] = faceOrientation;
478 for(
unsigned e=0;e<cellTopo.getEdgeCount();e++) {
480 unsigned local_v0 = cellTopo.getNodeMap(dim,e,0);
481 unsigned local_v1 = cellTopo.getNodeMap(dim,e,1);
491 edgeIndices.push_back(std::make_pair(v0_indices[0],v1_indices[0]));
500 unsigned node_dim = 0;
501 unsigned subcell_dim = 2;
506 faceIndices.resize(cellTopo.getSubcellCount(subcell_dim));
508 for(
unsigned f=0;f<cellTopo.getSubcellCount(subcell_dim);f++) {
509 shards::CellTopology faceTopo(cellTopo.getBaseCellTopologyData(subcell_dim,f));
511 for(
unsigned v=0;v<faceTopo.getNodeCount();v++) {
513 unsigned local_v = cellTopo.getNodeMap(subcell_dim,f,v);
516 const std::vector<int> & v_indices = pattern.
getSubcellIndices(node_dim,local_v);
521 faceIndices[f].push_back(v_indices[0]);
528 faceIndices.resize(1);
530 for(
unsigned v=0;v<cellTopo.getNodeCount();v++)
531 faceIndices[0].push_back(v);
std::map< int, Teuchos::RCP< const Map > > fieldMaps_
(unghosted) field vector (as needed)
virtual Teuchos::RCP< Teuchos::Comm< int > > getComm() const =0
virtual int getDimension() const =0
const Kokkos::View< const panzer::LocalOrdinal *, Kokkos::LayoutRight, PHX::Device > getElementLIDs(panzer::LocalOrdinal localElmtId) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< const IntVector > gh_reducedFieldVector_
virtual const std::vector< panzer::LocalOrdinal > & getElementBlock(const std::string &blockId) const =0
Teuchos::RCP< Tpetra::Vector< int, int, panzer::GlobalOrdinal, panzer::TpetraNodeType > > buildGhostedFieldReducedVector(const GlobalIndexer &ugi)
virtual void getElementBlockIds(std::vector< std::string > &elementBlockIds) const =0
Teuchos::RCP< const IntVector > gh_fieldVector_
ghosted reduced field vector
Teuchos::RCP< const Tpetra::Map< int, panzer::GlobalOrdinal, panzer::TpetraNodeType > > getFieldMap(int fieldNum, const Tpetra::Vector< int, int, panzer::GlobalOrdinal, panzer::TpetraNodeType > &fieldTVector)
void computeBlockOffsets(const std::string &blockId, const std::vector< Teuchos::RCP< GlobalIndexer >> &ugis, std::vector< int > &blockOffsets)
virtual int numberIds() const
Tpetra::Vector< int, int, panzer::GlobalOrdinal, panzer::TpetraNodeType > IntVector
Kokkos::View< const LO **, PHX::Device > lids
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< const GlobalIndexer > ugi_
DOF mapping.
std::vector< Teuchos::RCP< const GlobalIndexer > > nc2c_vector(const std::vector< Teuchos::RCP< GlobalIndexer > > &ugis)
int getFieldBlock(const std::string &fieldName, const std::vector< Teuchos::RCP< const GlobalIndexer >> &ugis)
void computeCellEdgeOrientations(const std::vector< std::pair< int, int > > &topEdgeIndices, const std::vector< panzer::GlobalOrdinal > &topology, const FieldPattern &fieldPattern, std::vector< signed char > &orientation)
virtual void getOwnedAndGhostedIndices(std::vector< panzer::GlobalOrdinal > &indices) const =0
Get the set of owned and ghosted indices for this processor.
void computePatternFaceIndices(const FieldPattern &pattern, std::vector< std::vector< int > > &faceIndices)
virtual int getNumOwned() const =0
Get the number of indices owned by this processor.
void computeCellFaceOrientations(const std::vector< std::vector< int > > &topFaceIndices, const std::vector< panzer::GlobalOrdinal > &topology, const FieldPattern &fieldPattern, std::vector< signed char > &orientation)
Tpetra::Map< int, panzer::GlobalOrdinal, panzer::TpetraNodeType > Map
virtual shards::CellTopology getCellTopology() const =0
Teuchos::RCP< const Tpetra::Map< int, panzer::GlobalOrdinal, panzer::TpetraNodeType > > getFieldMap(const std::string &fieldName) const
virtual const std::vector< int > & getBlockFieldNumbers(const std::string &blockId) const =0
virtual void getElementGIDs(panzer::LocalOrdinal localElmtId, std::vector< panzer::GlobalOrdinal > &gids, const std::string &blockIdHint="") const =0
Get the global IDs for a particular element. This function overwrites the gids variable.
virtual const std::vector< int > & getSubcellIndices(int dim, int cellIndex) const =0
void buildFieldVector(const Tpetra::Vector< int, int, panzer::GlobalOrdinal, panzer::TpetraNodeType > &source) const
build unghosted field vector from ghosted field vector
#define TEUCHOS_ASSERT(assertion_test)
Teuchos::RCP< const IntVector > fieldVector_
Maps for each field (as needed)
void printMeshTopology(std::ostream &os, const panzer::GlobalIndexer &ugi)
void computePatternEdgeIndices(const FieldPattern &pattern, std::vector< std::pair< int, int > > &edgeIndices)
void buildGhostedFieldVector(const GlobalIndexer &ugi, std::vector< int > &fieldNumbers, const Teuchos::RCP< const Tpetra::Vector< int, int, panzer::GlobalOrdinal, panzer::TpetraNodeType > > &reducedVec)
ArrayToFieldVector()
Maps for each field (as needed)
std::string printUGILoadBalancingInformation(const GlobalIndexer &ugi)