11 #include "PanzerDofMgr_config.hpp"
17 std::vector<Teuchos::RCP<const GlobalIndexer>>
20 std::vector<Teuchos::RCP<const GlobalIndexer>> vec;
22 for(std::size_t blk=0;blk<ugis.size();blk++)
23 vec.push_back(ugis[blk]);
32 for(std::size_t blk=0;blk<ugis.size();blk++) {
33 fieldNum = ugis[blk]->getFieldNum(fieldName);
45 for(std::size_t blk=0;blk<ugis.size();blk++) {
46 fieldNum = ugis[blk]->getFieldNum(fieldName);
56 std::vector<int> & blockOffsets)
58 blockOffsets.resize(ugis.size()+1);
61 for(std::size_t blk=0;blk<ugis.size();blk++) {
62 blockOffsets[blk] = offset;
63 offset += ugis[blk]->getElementBlockGIDCount(blockId);
65 blockOffsets[ugis.size()] = offset;
70 std::vector<int> & blockOffsets)
72 blockOffsets.resize(ugis.size()+1);
75 for(std::size_t blk=0;blk<ugis.size();blk++) {
76 blockOffsets[blk] = offset;
77 offset += ugis[blk]->getElementBlockGIDCount(blockId);
79 blockOffsets[ugis.size()] = offset;
85 std::size_t myOwnedCount =
static_cast<std::size_t
>(ugi.
getNumOwned());
86 std::size_t sum=0,min=0,max=0;
94 double dev2 = (double(myOwnedCount)-double(sum)/double(ugi.
getComm()->getSize()));
97 double variance = 0.0;
100 double mean = sum / double(ugi.
getComm()->getSize());
101 variance = variance / double(ugi.
getComm()->getSize());
104 std::stringstream ss;
105 ss <<
"Max, Min, Mean, StdDev = " << max <<
", " << min <<
", " << mean <<
", " << std::sqrt(variance);
113 std::vector<std::string> block_ids;
116 for(std::size_t b=0;b<block_ids.size();b++) {
118 const std::vector<panzer::LocalOrdinal> & elements = ugi.
getElementBlock(block_ids[b]);
120 os <<
"Element Block: \"" << block_ids[b] <<
"\"" << std::endl;
123 for(std::size_t e=0;e<elements.size();e++) {
127 auto lids_host = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),lids);
130 std::vector<panzer::GlobalOrdinal> gids;
133 os <<
" local element id = " << elements[e] <<
", ";
136 for(std::size_t i=0;i<gids.size();i++)
137 os <<
" " << gids[i];
140 for(std::size_t i=0;i<gids.size();i++)
141 os <<
" " << lids_host(i);
150 using Map = Tpetra::Map<int,panzer::GlobalOrdinal,panzer::TpetraNodeType>;
151 using IntVector = Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType>;
153 std::vector<panzer::GlobalOrdinal> indices;
154 std::vector<std::string> blocks;
159 std::vector<int> fieldNumbers(indices.size(),-1);
166 for(std::size_t blk=0;blk<blocks.size();blk++) {
167 std::string blockId = blocks[blk];
169 const std::vector<panzer::LocalOrdinal> & elements = ugi.
getElementBlock(blockId);
173 std::vector<panzer::GlobalOrdinal> gids(fields.size());
174 for(std::size_t e=0;e<elements.size();e++) {
177 for(std::size_t f=0;f<fields.size();f++) {
178 int fieldNum = fields[f];
179 panzer::GlobalOrdinal gid = gids[f];
180 std::size_t lid = ghostedMap->getLocalElement(gid);
182 fieldNumbers[lid] = fieldNum;
188 std::vector<panzer::GlobalOrdinal> reducedIndices;
189 std::vector<int> reducedFieldNumbers;
190 for(std::size_t i=0;i<fieldNumbers.size();i++) {
191 if(fieldNumbers[i]>-1) {
192 reducedIndices.push_back(indices[i]);
193 reducedFieldNumbers.push_back(fieldNumbers[i]);
200 return Teuchos::rcp(
new IntVector(reducedMap,Teuchos::arrayViewFromVector(reducedFieldNumbers)));
204 std::vector<int> & fieldNumbers,
205 const Teuchos::RCP<
const Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> > & reducedVec)
207 using IntVector = Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType>;
210 auto host_values = dest->getLocalViewHost(Tpetra::Access::ReadOnly);
212 fieldNumbers.resize(dest->getLocalLength());
213 for (
size_t i=0; i < fieldNumbers.size(); ++i)
214 fieldNumbers[i] = host_values(i,0);
219 const Teuchos::RCP<
const Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> > & reducedVec)
221 using Map = Tpetra::Map<int,panzer::GlobalOrdinal,panzer::TpetraNodeType>;
222 using IntVector = Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType>;
223 using Importer = Tpetra::Import<int,panzer::GlobalOrdinal,panzer::TpetraNodeType>;
231 std::vector<panzer::GlobalOrdinal> indices;
238 if(source==Teuchos::null)
247 Importer importer(sourceMap,destMap);
249 dest->doImport(*source,importer,Tpetra::INSERT);
250 PHX::Device::execution_space().fence();
257 getFieldMap(
int fieldNum,
const Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> & fieldTVector)
260 std::vector<int> fieldVector(fieldTVector.getLocalLength());
261 fieldTVector.get1dCopy(Teuchos::arrayViewFromVector(fieldVector));
263 std::vector<panzer::GlobalOrdinal> mapVector;
264 for(std::size_t i=0;i<fieldVector.size();i++) {
265 if(fieldVector[i]==fieldNum)
266 mapVector.push_back(origMap->getGlobalElement(i));
270 =
Teuchos::rcp(
new Tpetra::Map<int,panzer::GlobalOrdinal,panzer::TpetraNodeType>(
288 std::vector<panzer::GlobalOrdinal> indices;
289 ugi_->getOwnedIndices(indices);
296 Tpetra::Import<int,panzer::GlobalOrdinal,panzer::TpetraNodeType> importer(source.getMap(),destMap);
297 localFieldVector->doImport(source,importer,Tpetra::INSERT);
326 namespace orientation_helpers {
330 const std::vector<panzer::GlobalOrdinal> & topology,
332 std::vector<signed char> & orientation)
344 for(std::size_t e=0;e<topEdgeIndices.size();e++) {
346 const std::pair<int,int> nodes = topEdgeIndices[e];
349 panzer::GlobalOrdinal v0 = topology[nodes.first];
350 panzer::GlobalOrdinal v1 = topology[nodes.second];
353 signed char edgeOrientation = 1;
357 edgeOrientation = -1;
362 const std::vector<int> & edgeIndices = fieldPattern.
getSubcellIndices(edgeDim,e);
363 for(std::size_t s=0;s<edgeIndices.size();s++)
364 orientation[edgeIndices[s]] = edgeOrientation;
369 const std::vector<panzer::GlobalOrdinal> & topology,
371 std::vector<signed char> & orientation)
391 for(std::size_t f=0;f<topFaceIndices.size();f++) {
393 const std::vector<int> & nodes = topFaceIndices[f];
394 std::vector<panzer::GlobalOrdinal> globals(nodes.size());
395 for(std::size_t n=0;n<nodes.size();n++)
396 globals[n] = topology[nodes[n]];
398 typename std::vector<panzer::GlobalOrdinal>::const_iterator itr
399 = std::min_element(globals.begin(),globals.end());
402 "panzer::orientation_helpers::computeCellFaceOrientations: A face index array "
411 panzer::GlobalOrdinal vbefore = itr==globals.begin() ? *(globals.end()-1) : *(itr-1);
412 panzer::GlobalOrdinal vafter = (itr+1)==globals.end() ? *globals.begin() : *(itr+1);
432 signed char faceOrientation = 1;
434 faceOrientation = -1;
435 else if(vbefore>vafter)
441 const std::vector<int> & faceIndices = fieldPattern.
getSubcellIndices(faceDim,f);
442 for(std::size_t s=0;s<faceIndices.size();s++)
443 orientation[faceIndices[s]] = faceOrientation;
451 for(
unsigned e=0;e<cellTopo.getEdgeCount();e++) {
453 unsigned local_v0 = cellTopo.getNodeMap(dim,e,0);
454 unsigned local_v1 = cellTopo.getNodeMap(dim,e,1);
464 edgeIndices.push_back(std::make_pair(v0_indices[0],v1_indices[0]));
473 unsigned node_dim = 0;
474 unsigned subcell_dim = 2;
479 faceIndices.resize(cellTopo.getSubcellCount(subcell_dim));
481 for(
unsigned f=0;f<cellTopo.getSubcellCount(subcell_dim);f++) {
482 shards::CellTopology faceTopo(cellTopo.getBaseCellTopologyData(subcell_dim,f));
484 for(
unsigned v=0;v<faceTopo.getNodeCount();v++) {
486 unsigned local_v = cellTopo.getNodeMap(subcell_dim,f,v);
489 const std::vector<int> & v_indices = pattern.
getSubcellIndices(node_dim,local_v);
494 faceIndices[f].push_back(v_indices[0]);
501 faceIndices.resize(1);
503 for(
unsigned v=0;v<cellTopo.getNodeCount();v++)
504 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 **, Kokkos::LayoutRight, 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)