43 #include <PanzerAdaptersSTK_config.hpp>
50 #include <stk_mesh/base/FieldBase.hpp>
51 #include <stk_mesh/base/Comm.hpp>
52 #include <stk_mesh/base/Selector.hpp>
53 #include <stk_mesh/base/GetEntities.hpp>
54 #include <stk_mesh/base/GetBuckets.hpp>
55 #include <stk_mesh/base/CreateAdjacentEntities.hpp>
62 #include <stk_util/parallel/ParallelReduce.hpp>
63 #include <stk_util/parallel/CommSparse.hpp>
65 #ifdef PANZER_HAVE_IOSS
66 #include <Ionit_Initializer.h>
67 #include <stk_io/IossBridge.hpp>
70 #ifdef PANZER_HAVE_PERCEPT
71 #include <percept/PerceptMesh.hpp>
72 #include <adapt/UniformRefinerPattern.hpp>
73 #include <adapt/UniformRefiner.hpp>
83 namespace panzer_stk {
87 : gid_(gid), nodes_(nodes) {}
104 : dimension_(0), initialized_(false), currentLocalId_(0), initialStateTime_(0.0), currentStateTime_(0.0), useFieldCoordinates_(false)
110 : dimension_(0), initialized_(false), currentLocalId_(0), initialStateTime_(0.0), currentStateTime_(0.0), useFieldCoordinates_(false)
116 : dimension_(dim), initialized_(false), currentLocalId_(0), useFieldCoordinates_(false)
118 std::vector<std::string> entity_rank_names = stk::mesh::entity_rank_names();
119 entity_rank_names.push_back(
"FAMILY_TREE");
131 stk::mesh::Part * sideset =
metaData_->get_part(name);
133 sideset = &
metaData_->declare_part_with_topology(name,
134 stk::mesh::get_topology(shards::CellTopology(ctData),
dimension_));
135 sidesets_.insert(std::make_pair(name,sideset));
143 stk::mesh::Part * nodeset =
metaData_->get_part(name);
144 if(nodeset==
nullptr) {
145 const CellTopologyData * ctData = shards::getCellTopologyData<shards::Node>();
146 nodeset = &
metaData_->declare_part_with_topology(name,
147 stk::mesh::get_topology(shards::CellTopology(ctData),
dimension_));
149 nodesets_.insert(std::make_pair(name,nodeset));
155 "Unknown element block \"" << blockId <<
"\"");
156 std::pair<std::string,std::string> key = std::make_pair(fieldName,blockId);
165 stk::mesh::FieldTraits<SolutionFieldType>::data_type* init_sol =
nullptr;
166 stk::mesh::put_field_on_mesh(*field,
metaData_->universal_part(),init_sol );
175 "Unknown element block \"" << blockId <<
"\"");
176 std::pair<std::string,std::string> key = std::make_pair(fieldName,blockId);
186 stk::mesh::FieldTraits<SolutionFieldType>::data_type* init_sol =
nullptr;
187 stk::mesh::put_field_on_mesh(*field,
metaData_->universal_part(),init_sol );
194 const std::vector<std::string> & coordNames,
195 const std::string & dispPrefix)
201 "Unknown element block \"" << blockId <<
"\"");
205 "STK_Interface::addMeshCoordFields: Can't set more than one set of coordinate "
206 "fields for element block \""+blockId+
"\".");
219 std::pair<std::string,std::string> key = std::make_pair(coordNames[i],blockId);
220 std::string dispName = dispPrefix+coordNames[i];
222 dispFields[i] = dispName;
238 const bool buildRefinementSupport)
249 stk::mesh::FieldTraits<VectorFieldType>::data_type* init_vf =
nullptr;
250 stk::mesh::FieldTraits<ProcIdFieldType>::data_type* init_pid =
nullptr;
251 stk::mesh::FieldTraits<SolutionFieldType>::data_type* init_sol =
nullptr;
262 #ifdef PANZER_HAVE_IOSS
269 std::map<std::string, stk::mesh::Part*>::iterator itr;
271 if(!stk::io::is_part_io_part(*itr->second))
272 stk::io::put_io_part_attribute(*itr->second);
277 std::map<std::string, stk::mesh::Part*>::iterator itr;
279 if(!stk::io::is_part_io_part(*itr->second))
280 stk::io::put_io_part_attribute(*itr->second);
285 std::map<std::string, stk::mesh::Part*>::iterator itr;
287 if(!stk::io::is_part_io_part(*itr->second))
288 stk::io::put_io_part_attribute(*itr->second);
296 stk::io::set_field_role(*
edgesField_, Ioss::Field::MESH);
298 stk::io::set_field_role(*
facesField_, Ioss::Field::MESH);
304 if (buildRefinementSupport) {
305 #ifdef PANZER_HAVE_PERCEPT
310 breakPattern_ =
Teuchos::rcp(
new percept::URP_Heterogeneous_3D(*refinedMesh_));
313 "ERROR: Uniform refinement requested. This requires the Percept package to be enabled in Trilinos!");
328 std::set<SolutionFieldType*> uniqueFields;
329 std::map<std::pair<std::string,std::string>,
SolutionFieldType*>::const_iterator fieldIter;
330 for(fieldIter=nameToField.begin();fieldIter!=nameToField.end();++fieldIter)
331 uniqueFields.insert(fieldIter->second);
334 std::set<SolutionFieldType*>::const_iterator uniqueFieldIter;
335 stk::mesh::FieldTraits<SolutionFieldType>::data_type* init_sol =
nullptr;
336 for(uniqueFieldIter=uniqueFields.begin();uniqueFieldIter!=uniqueFields.end();++uniqueFieldIter)
337 stk::mesh::put_field_on_mesh(*(*uniqueFieldIter),
metaData_->universal_part(),init_sol);
340 #ifdef PANZER_HAVE_IOSS
343 std::set<SolutionFieldType*>::const_iterator uniqueFieldIter;
344 for(uniqueFieldIter=uniqueFields.begin();uniqueFieldIter!=uniqueFields.end();++uniqueFieldIter)
345 stk::io::set_field_role(*(*uniqueFieldIter), Ioss::Field::TRANSIENT);
362 "STK_Interface: Must call \"initialized\" or \"instantiateBulkData\" before \"beginModification\"");
370 "STK_Interface: Must call \"initialized\" or \"instantiateBulkData\" before \"endModification\"");
377 stk::CommSparse comm(
bulkData_->parallel());
379 for (
int phase=0;phase<2;++phase) {
380 for (
int i=0;i<
bulkData_->parallel_size();++i) {
382 const stk::mesh::BucketVector& buckets =
bulkData_->buckets(stk::topology::NODE_RANK);
383 for (
size_t j=0;j<buckets.size();++j) {
384 const stk::mesh::Bucket& bucket = *buckets[j];
385 if ( bucket.owned() ) {
386 for (
size_t k=0;k<bucket.size();++k) {
387 stk::mesh::EntityKey key =
bulkData_->entity_key(bucket[k]);
388 comm.send_buffer(i).pack<stk::mesh::EntityKey>(key);
396 comm.allocate_buffers();
403 for (
int i=0;i<
bulkData_->parallel_size();++i) {
405 while(comm.recv_buffer(i).remaining()) {
406 stk::mesh::EntityKey key;
407 comm.recv_buffer(i).unpack<stk::mesh::EntityKey>(key);
408 stk::mesh::Entity node =
bulkData_->get_entity(key);
426 "STK_Interface::addNode: STK_Interface must be modifiable to add a node");
428 "STK_Interface::addNode: number of coordinates in vector must mation dimension");
430 "STK_Interface::addNode: STK has STUPID restriction of no zero GIDs, pick something else");
437 for(std::size_t i=0;i<coord.size();++i)
438 fieldCoords[i] = coord[i];
443 std::vector<stk::mesh::Part*> sidesetV;
444 sidesetV.push_back(sideset);
446 bulkData_->change_entity_parts(entity,sidesetV);
451 std::vector<stk::mesh::Part*> nodesetV;
452 nodesetV.push_back(nodeset);
454 bulkData_->change_entity_parts(entity,nodesetV);
459 std::vector<stk::mesh::Part*> blockVec;
460 blockVec.push_back(block);
464 stk::mesh::Entity element =
bulkData_->declare_entity(elementRank,ed->getGID(),blockVec);
467 const std::vector<stk::mesh::EntityId> & nodes = ed->getNodes();
468 for(std::size_t i=0;i<nodes.size();++i) {
470 stk::mesh::Entity node =
bulkData_->get_entity(nodeRank,nodes[i]);
472 bulkData_->declare_relation(element,node,i);
476 procId[0] = Teuchos::as<ProcIdData>(
procRank_);
484 std::vector<stk::mesh::Entity> localElmts;
486 std::vector<stk::mesh::Entity>::const_iterator itr;
487 for(itr=localElmts.begin();itr!=localElmts.end();++itr) {
488 stk::mesh::Entity element = (*itr);
489 stk::mesh::EntityId gid =
bulkData_->identifier(element);
490 std::vector<stk::mesh::EntityId> subcellIds;
493 for(std::size_t i=0;i<subcellIds.size();++i) {
494 stk::mesh::Entity edge =
bulkData_->get_entity(edgeRank,subcellIds[i]);
495 stk::mesh::Entity
const* relations =
bulkData_->begin_nodes(edge);
501 double * edgeCoords = stk::mesh::field_data(*
edgesField_,edge);
503 edgeCoords[j] = (node_coord_1[j]+node_coord_2[j])/2.0;
512 std::vector<stk::mesh::Entity> localElmts;
514 std::vector<stk::mesh::Entity>::const_iterator itr;
515 for(itr=localElmts.begin();itr!=localElmts.end();++itr) {
516 stk::mesh::Entity element = (*itr);
518 std::vector<stk::mesh::EntityId> subcellIds;
521 for(std::size_t i=0;i<subcellIds.size();++i) {
522 stk::mesh::Entity face =
bulkData_->get_entity(faceRank,subcellIds[i]);
523 stk::mesh::Entity
const* relations =
bulkData_->begin_nodes(face);
524 const size_t num_relations =
bulkData_->num_nodes(face);
527 double * faceCoords = stk::mesh::field_data(*
facesField_,face);
530 for(std::size_t k=0;k<num_relations;++k)
532 faceCoords[j] /= double(num_relations);
540 const size_t num_rels =
bulkData_->num_connectivity(src, tgt_rank);
541 stk::mesh::Entity
const* relations =
bulkData_->begin(src, tgt_rank);
542 stk::mesh::ConnectivityOrdinal
const* ordinals =
bulkData_->begin_ordinals(src, tgt_rank);
543 for (
size_t i = 0; i < num_rels; ++i) {
544 if (ordinals[i] == static_cast<stk::mesh::ConnectivityOrdinal>(rel_id)) {
549 return stk::mesh::Entity();
560 const std::string& filename)
574 const std::string& filename)
576 using std::runtime_error;
577 using stk::io::StkMeshIoBroker;
578 using stk::mesh::FieldVector;
579 using stk::ParallelMachine;
581 PANZER_FUNC_TIME_MONITOR(
"STK_Interface::setupExodusFile(filename)");
582 #ifdef PANZER_HAVE_IOSS
584 ParallelMachine comm = *
mpiComm_->getRawMpiComm();
585 meshData_ =
rcp(
new StkMeshIoBroker(comm));
587 meshIndex_ = meshData_->create_output_mesh(filename, stk::io::WRITE_RESULTS);
588 const FieldVector& fields =
metaData_->get_fields();
589 for (
size_t i(0); i < fields.size(); ++i) {
595 auto role = stk::io::get_field_role(*fields[i]);
596 if (role !=
nullptr) {
597 if (*role != Ioss::Field::MESH)
598 meshData_->add_field(meshIndex_, *fields[i]);
600 meshData_->add_field(meshIndex_, *fields[i]);
621 using Teuchos::rcpFromRef;
622 PANZER_FUNC_TIME_MONITOR(
"STK_Interface::writeToExodus(timestep)");
623 #ifdef PANZER_HAVE_IOSS
624 if (not meshData_.is_null())
627 globalToExodus(GlobalVariable::ADD);
629 meshData_->write_defined_output_fields(meshIndex_);
630 globalToExodus(GlobalVariable::WRITE);
631 meshData_->end_output_step(meshIndex_);
636 out.setOutputToRootOnly(0);
637 out <<
"WARNING: Exodus I/O has been disabled or not setup properly; "
638 <<
"not writing to Exodus." << endl;
653 const GlobalVariable& flag)
655 using std::invalid_argument;
662 for (
auto i = globalData_.begin(); i != globalData_.end(); ++i)
664 const string& name = globalData_.name(i);
667 if (globalData_.isType<
int>(name))
669 const auto& value = globalData_.get<
int>(name);
670 if (flag == GlobalVariable::ADD)
674 meshData_->add_global(meshIndex_, name, value,
675 stk::util::ParameterType::INTEGER);
683 meshData_->write_global(meshIndex_, name, value,
684 stk::util::ParameterType::INTEGER);
688 else if (globalData_.isType<
double>(name))
690 const auto& value = globalData_.get<
double>(name);
691 if (flag == GlobalVariable::ADD)
695 meshData_->add_global(meshIndex_, name, value,
696 stk::util::ParameterType::DOUBLE);
704 meshData_->write_global(meshIndex_, name, value,
705 stk::util::ParameterType::DOUBLE);
709 else if (globalData_.isType<Array<int>>(name))
711 const auto& value = globalData_.get<Array<int>>(name).toVector();
712 if (flag == GlobalVariable::ADD)
716 meshData_->add_global(meshIndex_, name, value,
717 stk::util::ParameterType::INTEGERVECTOR);
725 meshData_->write_global(meshIndex_, name, value,
726 stk::util::ParameterType::INTEGERVECTOR);
730 else if (globalData_.isType<Array<double>>(name))
732 const auto& value = globalData_.get<Array<double>>(name).toVector();
733 if (flag == GlobalVariable::ADD)
737 meshData_->add_global(meshIndex_, name, value,
738 stk::util::ParameterType::DOUBLEVECTOR);
746 meshData_->write_global(meshIndex_, name, value,
747 stk::util::ParameterType::DOUBLEVECTOR);
753 "STK_Interface::globalToExodus(): The global variable to be added " \
754 "to the Exodus output file is of an invalid type. Valid types are " \
755 "int and double, along with std::vectors of those types.")
767 const std::string& key,
770 globalData_.set(key, value);
781 const std::string& key,
784 globalData_.set(key, value);
795 const std::string& key,
796 const std::vector<int>& value)
799 globalData_.set(key, Array<int>(value));
810 const std::string& key,
811 const std::vector<double>& value)
814 globalData_.set(key, Array<double>(value));
819 #ifdef PANZER_HAVE_IOSS
831 stk::mesh::Entity node =
bulkData_->get_entity(nodeRank,nodeId);
832 const size_t numElements =
bulkData_->num_elements(node);
833 stk::mesh::Entity
const* relations =
bulkData_->begin_elements(node);
836 elements.insert(elements.end(), relations, relations + numElements);
840 std::vector<int> & relIds)
const
843 const size_t numElements =
bulkData_->num_elements(node);
844 stk::mesh::Entity
const* relations =
bulkData_->begin_elements(node);
845 stk::mesh::ConnectivityOrdinal
const* rel_ids =
bulkData_->begin_element_ordinals(node);
848 for (
size_t i = 0; i < numElements; ++i) {
849 stk::mesh::Entity element = relations[i];
853 elements.push_back(element);
854 relIds.push_back(rel_ids[i]);
860 std::vector<int> & relIds,
unsigned int matchType)
const
862 stk::mesh::EntityRank rank;
865 else if(matchType == 1)
867 else if(matchType == 2)
872 stk::mesh::Entity node =
bulkData_->get_entity(rank,nodeId);
879 std::vector<stk::mesh::Entity> current;
882 std::sort(current.begin(),current.end());
885 for(std::size_t n=1;n<nodeIds.size();++n) {
887 std::vector<stk::mesh::Entity> nextNode;
889 std::sort(nextNode.begin(),nextNode.end());
892 std::vector<stk::mesh::Entity> intersection(std::min(nextNode.size(),current.size()));
893 std::vector<stk::mesh::Entity>::const_iterator endItr
894 = std::set_intersection(current.begin(),current.end(),
895 nextNode.begin(),nextNode.end(),
896 intersection.begin());
897 std::size_t newLength = endItr-intersection.begin();
898 intersection.resize(newLength);
902 current = intersection;
911 stk::mesh::Entity
const* nodeRel =
getBulkData()->begin_nodes(element);
912 const size_t numNodes =
getBulkData()->num_nodes(element);
914 nodeIds.reserve(numNodes);
915 for(
size_t i = 0; i < numNodes; ++i) {
930 const auto entityRankCount =
metaData_->entity_rank_count();
931 const size_t commCount = 10;
936 stk::ParallelMachine mach = *
mpiComm_->getRawMpiComm();
938 std::vector<stk::mesh::EntityId> local(commCount,0);
941 stk::mesh::Selector ownedPart =
metaData_->locally_owned_part();
942 for(stk::mesh::EntityRank i=stk::topology::NODE_RANK;
943 i < static_cast<stk::mesh::EntityRank>(entityRankCount); ++i) {
944 std::vector<stk::mesh::Entity> entities;
946 stk::mesh::get_selected_entities(ownedPart,
bulkData_->buckets(i),entities);
949 std::vector<stk::mesh::Entity>::const_iterator itr;
950 for(itr=entities.begin();itr!=entities.end();++itr) {
951 stk::mesh::EntityId
id =
bulkData_->identifier(*itr);
958 stk::all_reduce(mach,stk::ReduceMax<10>(&local[0]));
959 maxEntityId_.assign(local.begin(),local.begin()+entityRankCount+1);
965 "STK_Interface::getEntityCounts: Entity counts do not include rank: " << entityRank);
973 "STK_Interface::getMaxEntityId: Max entity ids do not include rank: " << entityRank);
980 stk::mesh::PartVector emptyPartVector;
981 stk::mesh::create_adjacent_entities(*
bulkData_,emptyPartVector);
1003 std::vector<stk::mesh::EntityId> & subcellIds)
const
1006 stk::mesh::Entity cell =
bulkData_->get_entity(elementRank,elementId);
1009 "STK_Interface::getSubcellIndices: could not find element requested (GID = " << elementId <<
")");
1011 const size_t numSubcells =
bulkData_->num_connectivity(cell, static_cast<stk::mesh::EntityRank>(entityRank));
1012 stk::mesh::Entity
const* subcells =
bulkData_->begin(cell, static_cast<stk::mesh::EntityRank>(entityRank));
1014 subcellIds.resize(numSubcells,0);
1017 for(
size_t i = 0; i < numSubcells; ++i) {
1018 stk::mesh::Entity subcell = subcells[i];
1019 subcellIds[i] =
bulkData_->identifier(subcell);
1026 stk::mesh::Selector ownedPart =
metaData_->locally_owned_part();
1030 stk::mesh::get_selected_entities(ownedPart,
bulkData_->buckets(elementRank),elements);
1041 stk::mesh::Selector ownedBlock =
metaData_->locally_owned_part() & (*elementBlock);
1045 stk::mesh::get_selected_entities(ownedBlock,
bulkData_->buckets(elementRank),elements);
1051 stk::mesh::Selector neighborBlock = (!
metaData_->locally_owned_part());
1055 stk::mesh::get_selected_entities(neighborBlock,
bulkData_->buckets(elementRank),elements);
1065 stk::mesh::Selector neighborBlock = (!
metaData_->locally_owned_part()) & (*elementBlock);
1069 stk::mesh::get_selected_entities(neighborBlock,
bulkData_->buckets(elementRank),elements);
1074 stk::mesh::Part * sidePart =
getSideset(sideName);
1076 "Unknown side set \"" << sideName <<
"\"");
1078 stk::mesh::Selector side = *sidePart;
1079 stk::mesh::Selector ownedBlock =
metaData_->locally_owned_part() & side;
1087 stk::mesh::Part * sidePart =
getSideset(sideName);
1090 "Unknown side set \"" << sideName <<
"\"");
1092 "Unknown element block \"" << blockName <<
"\"");
1094 stk::mesh::Selector side = *sidePart;
1095 stk::mesh::Selector block = *elmtPart;
1096 stk::mesh::Selector ownedBlock =
metaData_->locally_owned_part() & block & side;
1104 stk::mesh::Part * sidePart =
getSideset(sideName);
1106 "Unknown side set \"" << sideName <<
"\"");
1108 stk::mesh::Selector side = *sidePart;
1116 stk::mesh::Part * sidePart =
getSideset(sideName);
1119 "Unknown side set \"" << sideName <<
"\"");
1121 "Unknown element block \"" << blockName <<
"\"");
1123 stk::mesh::Selector side = *sidePart;
1124 stk::mesh::Selector block = *elmtPart;
1125 stk::mesh::Selector sideBlock = block & side;
1133 stk::mesh::Part * nodePart =
getNodeset(nodesetName);
1136 "Unknown node set \"" << nodesetName <<
"\"");
1138 "Unknown element block \"" << blockName <<
"\"");
1140 stk::mesh::Selector nodeset = *nodePart;
1141 stk::mesh::Selector block = *elmtPart;
1142 stk::mesh::Selector ownedBlock =
metaData_->locally_owned_part() & block & nodeset;
1155 std::map<std::string, stk::mesh::Part*>::const_iterator blkItr;
1157 names.push_back(blkItr->first);
1167 std::map<std::string, stk::mesh::Part*>::const_iterator sideItr;
1169 names.push_back(sideItr->first);
1177 std::map<std::string, stk::mesh::Part*>::const_iterator nodeItr;
1179 names.push_back(nodeItr->first);
1195 std::unordered_map<stk::mesh::EntityId,std::size_t>::const_iterator itr =
localIDHash_.find(gid);
1204 if(
bulkData_->bucket(elmt).member(*(eb_pair.second)))
1205 return eb_pair.first;
1210 const std::string & blockId)
const
1213 std::map<std::pair<std::string,std::string>,
SolutionFieldType*>::const_iterator
1218 "Solution field name \"" << fieldName <<
"\" in block ID \"" << blockId <<
"\" was not found");
1220 return iter->second;
1224 const std::string & blockId)
const
1227 std::map<std::pair<std::string,std::string>,
SolutionFieldType*>::const_iterator
1232 "Cell field named \"" << fieldName <<
"\" in block ID \"" << blockId <<
"\" was not found");
1234 return iter->second;
1254 stk::mesh::Part * block =
metaData_->get_part(name);
1256 block = &
metaData_->declare_part_with_topology(name, stk::mesh::get_topology(shards::CellTopology(ctData),
dimension_));
1299 std::vector<stk::mesh::Entity> elements;
1302 for(std::size_t index=0;index<elements.size();++index) {
1303 stk::mesh::Entity element = elements[index];
1307 procId[0] = Teuchos::as<ProcIdData>(
procRank_);
1320 for(std::size_t index=0;index<elements.size();++index) {
1321 stk::mesh::Entity element = elements[index];
1325 procId[0] = Teuchos::as<ProcIdData>(
procRank_);
1337 std::vector<std::string> names;
1340 for(std::size_t b=0;b<names.size();b++) {
1342 std::map<std::string,double>::const_iterator bw_itr =
blockWeights_.find(names[b]);
1343 double blockWeight = (bw_itr!=
blockWeights_.end()) ? bw_itr->second : 1.0;
1345 std::vector<stk::mesh::Entity> elements;
1348 for(std::size_t index=0;index<elements.size();++index) {
1350 double * loadBal = stk::mesh::field_data(*
loadBalField_,elements[index]);
1351 loadBal[0] = blockWeight;
1358 const std::string & fieldName,
1361 std::map<std::string,std::vector<std::string> >::const_iterator blkItr =
meshCoordFields_.find(eBlock);
1367 for(axis=0;axis<Teuchos::as<int>(blkItr->second.size());axis++) {
1368 if(blkItr->second[axis]==fieldName)
1372 if(axis>=Teuchos::as<int>(blkItr->second.size()))
1383 const std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > & matchers =
getPeriodicBCVector();
1386 for(std::size_t m=0;m<matchers.size();m++){
1387 vec = matchers[m]->getMatchedPair(*
this,vec);
1389 if(matchers[m]->getType() ==
"coord")
1391 else if(matchers[m]->getType() ==
"edge")
1393 else if(matchers[m]->getType() ==
"face")
1397 type_vec->insert(type_vec->begin(),vec->size()-type_vec->size(),type);
1400 return std::make_pair(vec,type_vec);
1405 std::map<std::string, stk::mesh::Part*>::const_iterator blkItr =
elementBlocks_.find(blockId);
1412 std::vector<std::string> blockNames, sidesetNames, nodesetNames;
1418 os <<
"STK Mesh data:\n";
1421 os <<
" Entity counts (Nodes, Edges, Cells) = ( "
1426 os <<
" Entity counts (Nodes, Edges, Faces, Cells) = ( "
1432 os <<
" Entity counts (Nodes, Cells) = ( "
1436 os <<
" Element blocks = ";
1437 for(std::size_t i=0;i<blockNames.size();i++)
1438 os <<
"\"" << blockNames[i] <<
"\" ";
1440 os <<
" Sidesets = ";
1441 for(std::size_t i=0;i<sidesetNames.size();i++)
1442 os <<
"\"" << sidesetNames[i] <<
"\" ";
1444 os <<
" Nodesets = ";
1445 for(std::size_t i=0;i<nodesetNames.size();i++)
1446 os <<
"\"" << nodesetNames[i] <<
"\" ";
1450 const std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > & bcVector
1452 if(bcVector.size()!=0) {
1453 os <<
" Periodic BCs:\n";
1454 for(std::size_t i=0;i<bcVector.size();i++)
1455 os <<
" " << bcVector[i]->getString() <<
"\n";
1462 std::vector<std::string> blockNames, sidesetNames, nodesetNames;
1468 os <<
"STK Meta data:\n";
1469 os <<
" Element blocks = ";
1470 for(std::size_t i=0;i<blockNames.size();i++)
1471 os <<
"\"" << blockNames[i] <<
"\" ";
1473 os <<
" Sidesets = ";
1474 for(std::size_t i=0;i<sidesetNames.size();i++)
1475 os <<
"\"" << sidesetNames[i] <<
"\" ";
1477 os <<
" Nodesets = ";
1478 for(std::size_t i=0;i<nodesetNames.size();i++)
1479 os <<
"\"" << nodesetNames[i] <<
"\" ";
1483 const std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > & bcVector
1485 if(bcVector.size()!=0) {
1486 os <<
" Periodic BCs:\n";
1487 for(std::size_t i=0;i<bcVector.size();i++)
1488 os <<
" " << bcVector[i]->getString() <<
"\n";
1494 const stk::mesh::FieldVector & fv =
metaData_->get_fields();
1495 for(std::size_t i=0;i<fv.size();i++)
1496 os <<
"\"" << fv[i]->name() <<
"\" ";
1502 std::map<std::string, Teuchos::RCP<shards::CellTopology> >::const_iterator itr;
1506 std::stringstream ss;
1509 "STK_Interface::getCellTopology: No such element block \"" +eBlock +
"\" available.\n\n"
1510 <<
"STK Meta Data follows: \n" << ss.str());
1519 const int err = MPI_Comm_dup (parallelMach, &newComm);
1521 "panzer::STK_Interface: MPI_Comm_dup failed with error \""
1522 << Teuchos::mpiErrorCodeToString (err) <<
"\".");
1534 stk::mesh::Selector selector(
getMetaData()->universal_part());
1535 stk::mesh::Selector owned_selector(
getMetaData()->locally_owned_part());
1543 if(params.begin()!=params.end())
1544 graph.
sublist(stk::rebalance::Zoltan::default_parameters_name()) = params;
1563 #ifdef PANZER_HAVE_PERCEPT
1565 "ERROR: Number of levels for uniform refinement must be greater than 0");
1569 refinedMesh_->setCoordinatesField();
1571 percept::UniformRefiner breaker(*refinedMesh_,*breakPattern_);
1573 for (
int i=0; i < numberOfLevels; ++i)
1576 if (deleteParentElements)
1577 breaker.deleteParentElements();
1581 "ERROR: Uniform refinement requested. This requires the Percept package to be enabled in Trilinos!");
void initializeFromMetaData()
Teuchos::RCP< ElementDescriptor > buildElementDescriptor(stk::mesh::EntityId elmtId, std::vector< stk::mesh::EntityId > &nodes)
Teuchos::RCP< Teuchos::MpiComm< int > > getSafeCommunicator(stk::ParallelMachine parallelMach) const
void getSidesetNames(std::vector< std::string > &name) const
RCP< const T > getConst() const
std::pair< Teuchos::RCP< std::vector< std::pair< std::size_t, std::size_t > > >, Teuchos::RCP< std::vector< unsigned int > > > getPeriodicNodePairing() const
void addNodeset(const std::string &name)
Teuchos::RCP< stk::mesh::BulkData > bulkData_
void print(std::ostream &os) const
Teuchos::RCP< const std::vector< stk::mesh::Entity > > getElementsOrderedByLID() const
std::vector< stk::mesh::Part * > facesPartVec_
std::map< std::pair< std::string, std::string >, SolutionFieldType * > fieldNameToSolution_
void addEntityToNodeset(stk::mesh::Entity entity, stk::mesh::Part *nodeset)
void addGlobalToExodus(const std::string &key, const int &value)
Add an int global variable to the information to be written to the Exodus output file.
void getElementBlockNames(std::vector< std::string > &names) const
void getSubcellIndices(unsigned entityRank, stk::mesh::EntityId elementId, std::vector< stk::mesh::EntityId > &subcellIds) const
void getElementsSharingNodes(const std::vector< stk::mesh::EntityId > nodeId, std::vector< stk::mesh::Entity > &elements) const
get a set of elements sharing multiple nodes
stk::mesh::Field< double > SolutionFieldType
stk::mesh::Part * getElementBlockPart(const std::string &name) const
get the block count
std::vector< stk::mesh::Part * > edgesPartVec_
std::map< std::string, double > blockWeights_
VectorFieldType * coordinatesField_
basic_FancyOStream< char > FancyOStream
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
std::size_t getEntityCounts(unsigned entityRank) const
get the global counts for the entity of specified rank
void printMetaData(std::ostream &os) const
void addEntityToSideset(stk::mesh::Entity entity, stk::mesh::Part *sideset)
stk::mesh::Part * nodesPart_
void addSolutionField(const std::string &fieldName, const std::string &blockId)
std::map< std::string, Teuchos::RCP< shards::CellTopology > > elementBlockCT_
stk::mesh::EntityId getMaxEntityId(unsigned entityRank) const
get max entity ID of type entityRank
std::size_t currentLocalId_
std::map< std::string, stk::mesh::Part * > sidesets_
std::vector< std::size_t > entityCounts_
bool validBlockId(const std::string &blockId) const
stk::mesh::Part * getNodeset(const std::string &name) const
stk::mesh::Field< double > * getSolutionField(const std::string &fieldName, const std::string &blockId) const
SolutionFieldType * loadBalField_
const double * getNodeCoordinates(stk::mesh::EntityId nodeId) const
stk::mesh::Part * getSideset(const std::string &name) const
static const std::string nodesString
void instantiateBulkData(stk::ParallelMachine parallelMach)
void getMySides(const std::string &sideName, std::vector< stk::mesh::Entity > &sides) const
std::size_t elementLocalId(stk::mesh::Entity elmt) const
unsigned getDimension() const
get the dimension
void addElement(const Teuchos::RCP< ElementDescriptor > &ed, stk::mesh::Part *block)
std::map< std::string, std::vector< std::string > > meshDispFields_
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
VectorFieldType * edgesField_
stk::mesh::EntityRank getSideRank() const
void initialize(stk::ParallelMachine parallelMach, bool setupIO=true, const bool buildRefinementSupport=false)
static const std::string coordsString
stk::mesh::Field< double, stk::mesh::Cartesian > VectorFieldType
Teuchos::RCP< stk::mesh::BulkData > getBulkData() const
void writeToExodus(const std::string &filename)
Write this mesh and associated fields to the given output file.
stk::mesh::EntityId elementGlobalId(std::size_t lid) const
std::map< std::string, stk::mesh::Part * > elementBlocks_
std::vector< stk::mesh::Part * > nodesPartVec_
static const std::string edgesString
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
std::string containingBlockId(stk::mesh::Entity elmt) const
stk::mesh::EntityRank getFaceRank() const
void getOwnedElementsSharingNode(stk::mesh::Entity node, std::vector< stk::mesh::Entity > &elements, std::vector< int > &relIds) const
void addNode(stk::mesh::EntityId gid, const std::vector< double > &coord)
void buildSubcells()
force the mesh to build subcells: edges and faces
Teuchos::RCP< Teuchos::MpiComm< int > > mpiComm_
Teuchos::RCP< stk::mesh::MetaData > metaData_
Teuchos::RCP< stk::mesh::MetaData > getMetaData() const
virtual ~ElementDescriptor()
Teuchos::RCP< std::vector< stk::mesh::Entity > > orderedElementVector_
bool isInitialized() const
Has initialize been called on this mesh object?
void getMyNodes(const std::string &sideName, const std::string &blockName, std::vector< stk::mesh::Entity > &nodes) const
bool nonnull(const boost::shared_ptr< T > &p)
void addMeshCoordFields(const std::string &blockId, const std::vector< std::string > &coordField, const std::string &dispPrefix)
void applyElementLoadBalanceWeights()
stk::mesh::Entity findConnectivityById(stk::mesh::Entity src, stk::mesh::EntityRank tgt_rank, unsigned rel_id) const
bool isMeshCoordField(const std::string &eBlock, const std::string &fieldName, int &axis) const
void getAllSides(const std::string &sideName, std::vector< stk::mesh::Entity > &sides) const
void addSideset(const std::string &name, const CellTopologyData *ctData)
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > field
A field to which we'll contribute, or in which we'll store, the result of computing this integral...
void rebalance(const Teuchos::ParameterList ¶ms)
std::map< std::string, std::vector< std::string > > meshCoordFields_
stk::mesh::EntityRank getEdgeRank() const
static const std::string facesString
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
get the comm associated with this mesh
void initializeFieldsInSTK(const std::map< std::pair< std::string, std::string >, SolutionFieldType * > &nameToField, bool setupIO)
const std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > & getPeriodicBCVector() const
void refineMesh(const int numberOfLevels, const bool deleteParentElements)
void buildLocalElementIDs()
bool isModifiable() const
void setupExodusFile(const std::string &filename)
Set up an output Exodus file for writing results.
std::unordered_map< stk::mesh::EntityId, std::size_t > localIDHash_
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
std::vector< stk::mesh::EntityId > maxEntityId_
stk::mesh::Field< ProcIdData > ProcIdFieldType
void getElementsSharingNode(stk::mesh::EntityId nodeId, std::vector< stk::mesh::Entity > &elements) const
get a set of elements sharing a single node
void getMyElements(std::vector< stk::mesh::Entity > &elements) const
#define TEUCHOS_ASSERT(assertion_test)
stk::mesh::EntityRank getNodeRank() const
void addCellField(const std::string &fieldName, const std::string &blockId)
void getNodeIdsForElement(stk::mesh::Entity element, std::vector< stk::mesh::EntityId > &nodeIds) const
get a list of node ids for nodes connected to an element
stk::mesh::Part * edgesPart_
stk::mesh::EntityRank getElementRank() const
stk::mesh::Part * facesPart_
ProcIdFieldType * processorIdField_
void addElementBlock(const std::string &name, const CellTopologyData *ctData)
stk::mesh::Field< double > * getCellField(const std::string &fieldName, const std::string &blockId) const
const VectorFieldType & getCoordinatesField() const
void getNeighborElements(std::vector< stk::mesh::Entity > &elements) const
void getNodesetNames(std::vector< std::string > &name) const
Teuchos::RCP< const shards::CellTopology > getCellTopology(const std::string &eBlock) const
std::map< std::pair< std::string, std::string >, SolutionFieldType * > fieldNameToCellField_
std::map< std::string, stk::mesh::Part * > nodesets_
VectorFieldType * facesField_