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>
77 namespace panzer_stk {
81 : gid_(gid), nodes_(nodes) {}
98 : dimension_(0), initialized_(false), currentLocalId_(0), initialStateTime_(0.0), currentStateTime_(0.0), useFieldCoordinates_(false)
104 : dimension_(0), initialized_(false), currentLocalId_(0), initialStateTime_(0.0), currentStateTime_(0.0), useFieldCoordinates_(false)
110 : dimension_(dim), initialized_(false), currentLocalId_(0), useFieldCoordinates_(false)
112 std::vector<std::string> entity_rank_names = stk::mesh::entity_rank_names();
113 entity_rank_names.push_back(
"FAMILY_TREE");
125 stk::mesh::Part * sideset =
metaData_->get_part(name);
127 sideset = &
metaData_->declare_part_with_topology(name,
128 stk::mesh::get_topology(shards::CellTopology(ctData),
dimension_));
129 sidesets_.insert(std::make_pair(name,sideset));
137 stk::mesh::Part * nodeset =
metaData_->get_part(name);
138 if(nodeset==
nullptr) {
139 const CellTopologyData * ctData = shards::getCellTopologyData<shards::Node>();
140 nodeset = &
metaData_->declare_part_with_topology(name,
141 stk::mesh::get_topology(shards::CellTopology(ctData),
dimension_));
143 nodesets_.insert(std::make_pair(name,nodeset));
150 "Unknown element block \"" << blockId <<
"\"");
151 std::pair<std::string,std::string> key = std::make_pair(fieldName,blockId);
166 "Unknown element block \"" << blockId <<
"\"");
167 std::pair<std::string,std::string> key = std::make_pair(fieldName,blockId);
179 const std::vector<std::string> & coordNames,
180 const std::string & dispPrefix)
186 "Unknown element block \"" << blockId <<
"\"");
190 "STK_Interface::addMeshCoordFields: Can't set more than one set of coordinate "
191 "fields for element block \""+blockId+
"\".");
204 std::pair<std::string,std::string> key = std::make_pair(coordNames[i],blockId);
205 std::string dispName = dispPrefix+coordNames[i];
207 dispFields[i] = dispName;
233 stk::mesh::FieldTraits<VectorFieldType>::data_type* init_vf =
nullptr;
234 stk::mesh::FieldTraits<ProcIdFieldType>::data_type* init_pid =
nullptr;
235 stk::mesh::FieldTraits<SolutionFieldType>::data_type* init_sol =
nullptr;
246 #ifdef PANZER_HAVE_IOSS
253 std::map<std::string, stk::mesh::Part*>::iterator itr;
255 if(!stk::io::is_part_io_part(*itr->second))
256 stk::io::put_io_part_attribute(*itr->second);
261 std::map<std::string, stk::mesh::Part*>::iterator itr;
263 if(!stk::io::is_part_io_part(*itr->second))
264 stk::io::put_io_part_attribute(*itr->second);
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);
280 stk::io::set_field_role(*
edgesField_, Ioss::Field::MESH);
282 stk::io::set_field_role(*
facesField_, Ioss::Field::MESH);
298 std::set<SolutionFieldType*> uniqueFields;
299 std::map<std::pair<std::string,std::string>,
SolutionFieldType*>::const_iterator fieldIter;
300 for(fieldIter=nameToField.begin();fieldIter!=nameToField.end();++fieldIter)
301 uniqueFields.insert(fieldIter->second);
304 std::set<SolutionFieldType*>::const_iterator uniqueFieldIter;
305 stk::mesh::FieldTraits<SolutionFieldType>::data_type* init_sol =
nullptr;
306 for(uniqueFieldIter=uniqueFields.begin();uniqueFieldIter!=uniqueFields.end();++uniqueFieldIter)
307 stk::mesh::put_field_on_mesh(*(*uniqueFieldIter),
metaData_->universal_part(),init_sol);
310 #ifdef PANZER_HAVE_IOSS
313 std::set<SolutionFieldType*>::const_iterator uniqueFieldIter;
314 for(uniqueFieldIter=uniqueFields.begin();uniqueFieldIter!=uniqueFields.end();++uniqueFieldIter)
315 stk::io::set_field_role(*(*uniqueFieldIter), Ioss::Field::TRANSIENT);
332 "STK_Interface: Must call \"initialized\" or \"instantiateBulkData\" before \"beginModification\"");
340 "STK_Interface: Must call \"initialized\" or \"instantiateBulkData\" before \"endModification\"");
347 stk::CommSparse comm(
bulkData_->parallel());
349 for (
int phase=0;phase<2;++phase) {
350 for (
int i=0;i<
bulkData_->parallel_size();++i) {
352 const stk::mesh::BucketVector& buckets =
bulkData_->buckets(stk::topology::NODE_RANK);
353 for (
size_t j=0;j<buckets.size();++j) {
354 const stk::mesh::Bucket& bucket = *buckets[j];
355 if ( bucket.owned() ) {
356 for (
size_t k=0;k<bucket.size();++k) {
357 stk::mesh::EntityKey key =
bulkData_->entity_key(bucket[k]);
358 comm.send_buffer(i).pack<stk::mesh::EntityKey>(key);
366 comm.allocate_buffers();
373 for (
int i=0;i<
bulkData_->parallel_size();++i) {
375 while(comm.recv_buffer(i).remaining()) {
376 stk::mesh::EntityKey key;
377 comm.recv_buffer(i).unpack<stk::mesh::EntityKey>(key);
378 stk::mesh::Entity node =
bulkData_->get_entity(key);
396 "STK_Interface::addNode: STK_Interface must be modifiable to add a node");
398 "STK_Interface::addNode: number of coordinates in vector must mation dimension");
400 "STK_Interface::addNode: STK has STUPID restriction of no zero GIDs, pick something else");
407 for(std::size_t i=0;i<coord.size();++i)
408 fieldCoords[i] = coord[i];
413 std::vector<stk::mesh::Part*> sidesetV;
414 sidesetV.push_back(sideset);
416 bulkData_->change_entity_parts(entity,sidesetV);
421 std::vector<stk::mesh::Part*> nodesetV;
422 nodesetV.push_back(nodeset);
424 bulkData_->change_entity_parts(entity,nodesetV);
429 std::vector<stk::mesh::Part*> blockVec;
430 blockVec.push_back(block);
434 stk::mesh::Entity element =
bulkData_->declare_entity(elementRank,ed->getGID(),blockVec);
437 const std::vector<stk::mesh::EntityId> & nodes = ed->getNodes();
438 for(std::size_t i=0;i<nodes.size();++i) {
440 stk::mesh::Entity node =
bulkData_->get_entity(nodeRank,nodes[i]);
442 bulkData_->declare_relation(element,node,i);
446 procId[0] = Teuchos::as<ProcIdData>(
procRank_);
454 std::vector<stk::mesh::Entity> localElmts;
456 std::vector<stk::mesh::Entity>::const_iterator itr;
457 for(itr=localElmts.begin();itr!=localElmts.end();++itr) {
458 stk::mesh::Entity element = (*itr);
459 stk::mesh::EntityId gid =
bulkData_->identifier(element);
460 std::vector<stk::mesh::EntityId> subcellIds;
463 for(std::size_t i=0;i<subcellIds.size();++i) {
464 stk::mesh::Entity edge =
bulkData_->get_entity(edgeRank,subcellIds[i]);
465 stk::mesh::Entity
const* relations =
bulkData_->begin_nodes(edge);
471 double * edgeCoords = stk::mesh::field_data(*
edgesField_,edge);
473 edgeCoords[j] = (node_coord_1[j]+node_coord_2[j])/2.0;
482 std::vector<stk::mesh::Entity> localElmts;
484 std::vector<stk::mesh::Entity>::const_iterator itr;
485 for(itr=localElmts.begin();itr!=localElmts.end();++itr) {
486 stk::mesh::Entity element = (*itr);
488 std::vector<stk::mesh::EntityId> subcellIds;
491 for(std::size_t i=0;i<subcellIds.size();++i) {
492 stk::mesh::Entity face =
bulkData_->get_entity(faceRank,subcellIds[i]);
493 stk::mesh::Entity
const* relations =
bulkData_->begin_nodes(face);
494 const size_t num_relations =
bulkData_->num_nodes(face);
497 double * faceCoords = stk::mesh::field_data(*
facesField_,face);
500 for(std::size_t k=0;k<num_relations;++k)
502 faceCoords[j] /= double(num_relations);
510 const size_t num_rels =
bulkData_->num_connectivity(src, tgt_rank);
511 stk::mesh::Entity
const* relations =
bulkData_->begin(src, tgt_rank);
512 stk::mesh::ConnectivityOrdinal
const* ordinals =
bulkData_->begin_ordinals(src, tgt_rank);
513 for (
size_t i = 0; i < num_rels; ++i) {
514 if (ordinals[i] == static_cast<stk::mesh::ConnectivityOrdinal>(rel_id)) {
519 return stk::mesh::Entity();
530 const std::string& filename)
544 const std::string& filename)
546 using std::runtime_error;
547 using stk::io::StkMeshIoBroker;
548 using stk::mesh::FieldVector;
549 using stk::ParallelMachine;
551 PANZER_FUNC_TIME_MONITOR(
"STK_Interface::setupExodusFile(filename)");
552 #ifdef PANZER_HAVE_IOSS
554 ParallelMachine comm = *
mpiComm_->getRawMpiComm();
555 meshData_ =
rcp(
new StkMeshIoBroker(comm));
557 meshIndex_ = meshData_->create_output_mesh(filename, stk::io::WRITE_RESULTS);
558 const FieldVector& fields =
metaData_->get_fields();
559 for (
size_t i(0); i < fields.size(); ++i) {
565 auto role = stk::io::get_field_role(*fields[i]);
566 if (role !=
nullptr) {
567 if (*role != Ioss::Field::MESH)
568 meshData_->add_field(meshIndex_, *fields[i]);
570 meshData_->add_field(meshIndex_, *fields[i]);
591 using Teuchos::rcpFromRef;
592 PANZER_FUNC_TIME_MONITOR(
"STK_Interface::writeToExodus(timestep)");
593 #ifdef PANZER_HAVE_IOSS
594 if (not meshData_.is_null())
597 globalToExodus(GlobalVariable::ADD);
599 meshData_->write_defined_output_fields(meshIndex_);
600 globalToExodus(GlobalVariable::WRITE);
601 meshData_->end_output_step(meshIndex_);
606 out.setOutputToRootOnly(0);
607 out <<
"WARNING: Exodus I/O has been disabled or not setup properly; "
608 <<
"not writing to Exodus." << endl;
623 const GlobalVariable& flag)
625 using std::invalid_argument;
632 for (
auto i = globalData_.begin(); i != globalData_.end(); ++i)
634 const string& name = globalData_.name(i);
637 if (globalData_.isType<
int>(name))
639 const auto& value = globalData_.get<
int>(name);
640 if (flag == GlobalVariable::ADD)
644 meshData_->add_global(meshIndex_, name, value,
645 stk::util::ParameterType::INTEGER);
653 meshData_->write_global(meshIndex_, name, value,
654 stk::util::ParameterType::INTEGER);
658 else if (globalData_.isType<
double>(name))
660 const auto& value = globalData_.get<
double>(name);
661 if (flag == GlobalVariable::ADD)
665 meshData_->add_global(meshIndex_, name, value,
666 stk::util::ParameterType::DOUBLE);
674 meshData_->write_global(meshIndex_, name, value,
675 stk::util::ParameterType::DOUBLE);
679 else if (globalData_.isType<Array<int>>(name))
681 const auto& value = globalData_.get<Array<int>>(name).toVector();
682 if (flag == GlobalVariable::ADD)
686 meshData_->add_global(meshIndex_, name, value,
687 stk::util::ParameterType::INTEGERVECTOR);
695 meshData_->write_global(meshIndex_, name, value,
696 stk::util::ParameterType::INTEGERVECTOR);
700 else if (globalData_.isType<Array<double>>(name))
702 const auto& value = globalData_.get<Array<double>>(name).toVector();
703 if (flag == GlobalVariable::ADD)
707 meshData_->add_global(meshIndex_, name, value,
708 stk::util::ParameterType::DOUBLEVECTOR);
716 meshData_->write_global(meshIndex_, name, value,
717 stk::util::ParameterType::DOUBLEVECTOR);
723 "STK_Interface::globalToExodus(): The global variable to be added " \
724 "to the Exodus output file is of an invalid type. Valid types are " \
725 "int and double, along with std::vectors of those types.")
737 const std::string& key,
740 globalData_.set(key, value);
751 const std::string& key,
754 globalData_.set(key, value);
765 const std::string& key,
766 const std::vector<int>& value)
769 globalData_.set(key, Array<int>(value));
780 const std::string& key,
781 const std::vector<double>& value)
784 globalData_.set(key, Array<double>(value));
789 #ifdef PANZER_HAVE_IOSS
801 stk::mesh::Entity node =
bulkData_->get_entity(nodeRank,nodeId);
802 const size_t numElements =
bulkData_->num_elements(node);
803 stk::mesh::Entity
const* relations =
bulkData_->begin_elements(node);
806 elements.insert(elements.end(), relations, relations + numElements);
810 std::vector<int> & relIds)
const
813 const size_t numElements =
bulkData_->num_elements(node);
814 stk::mesh::Entity
const* relations =
bulkData_->begin_elements(node);
815 stk::mesh::ConnectivityOrdinal
const* rel_ids =
bulkData_->begin_element_ordinals(node);
818 for (
size_t i = 0; i < numElements; ++i) {
819 stk::mesh::Entity element = relations[i];
823 elements.push_back(element);
824 relIds.push_back(rel_ids[i]);
830 std::vector<int> & relIds,
unsigned int matchType)
const
832 stk::mesh::EntityRank rank;
835 else if(matchType == 1)
837 else if(matchType == 2)
842 stk::mesh::Entity node =
bulkData_->get_entity(rank,nodeId);
849 std::vector<stk::mesh::Entity> current;
852 std::sort(current.begin(),current.end());
855 for(std::size_t n=1;n<nodeIds.size();++n) {
857 std::vector<stk::mesh::Entity> nextNode;
859 std::sort(nextNode.begin(),nextNode.end());
862 std::vector<stk::mesh::Entity> intersection(std::min(nextNode.size(),current.size()));
863 std::vector<stk::mesh::Entity>::const_iterator endItr
864 = std::set_intersection(current.begin(),current.end(),
865 nextNode.begin(),nextNode.end(),
866 intersection.begin());
867 std::size_t newLength = endItr-intersection.begin();
868 intersection.resize(newLength);
872 current = intersection;
881 stk::mesh::Entity
const* nodeRel =
getBulkData()->begin_nodes(element);
882 const size_t numNodes =
getBulkData()->num_nodes(element);
884 nodeIds.reserve(numNodes);
885 for(
size_t i = 0; i < numNodes; ++i) {
900 const auto entityRankCount =
metaData_->entity_rank_count();
901 const size_t commCount = 10;
906 stk::ParallelMachine mach = *
mpiComm_->getRawMpiComm();
908 std::vector<stk::mesh::EntityId> local(commCount,0);
911 stk::mesh::Selector ownedPart =
metaData_->locally_owned_part();
912 for(stk::mesh::EntityRank i=stk::topology::NODE_RANK;
913 i < static_cast<stk::mesh::EntityRank>(entityRankCount); ++i) {
914 std::vector<stk::mesh::Entity> entities;
916 stk::mesh::get_selected_entities(ownedPart,
bulkData_->buckets(i),entities);
919 std::vector<stk::mesh::Entity>::const_iterator itr;
920 for(itr=entities.begin();itr!=entities.end();++itr) {
921 stk::mesh::EntityId
id =
bulkData_->identifier(*itr);
928 stk::all_reduce(mach,stk::ReduceMax<10>(&local[0]));
929 maxEntityId_.assign(local.begin(),local.begin()+entityRankCount+1);
935 "STK_Interface::getEntityCounts: Entity counts do not include rank: " << entityRank);
943 "STK_Interface::getMaxEntityId: Max entity ids do not include rank: " << entityRank);
950 stk::mesh::PartVector emptyPartVector;
951 stk::mesh::create_adjacent_entities(*
bulkData_,emptyPartVector);
973 std::vector<stk::mesh::EntityId> & subcellIds)
const
976 stk::mesh::Entity cell =
bulkData_->get_entity(elementRank,elementId);
979 "STK_Interface::getSubcellIndices: could not find element requested (GID = " << elementId <<
")");
981 const size_t numSubcells =
bulkData_->num_connectivity(cell, static_cast<stk::mesh::EntityRank>(entityRank));
982 stk::mesh::Entity
const* subcells =
bulkData_->begin(cell, static_cast<stk::mesh::EntityRank>(entityRank));
984 subcellIds.resize(numSubcells,0);
987 for(
size_t i = 0; i < numSubcells; ++i) {
988 stk::mesh::Entity subcell = subcells[i];
989 subcellIds[i] =
bulkData_->identifier(subcell);
996 stk::mesh::Selector ownedPart =
metaData_->locally_owned_part();
1000 stk::mesh::get_selected_entities(ownedPart,
bulkData_->buckets(elementRank),elements);
1011 stk::mesh::Selector ownedBlock =
metaData_->locally_owned_part() & (*elementBlock);
1015 stk::mesh::get_selected_entities(ownedBlock,
bulkData_->buckets(elementRank),elements);
1021 stk::mesh::Selector neighborBlock = (!
metaData_->locally_owned_part());
1025 stk::mesh::get_selected_entities(neighborBlock,
bulkData_->buckets(elementRank),elements);
1035 stk::mesh::Selector neighborBlock = (!
metaData_->locally_owned_part()) & (*elementBlock);
1039 stk::mesh::get_selected_entities(neighborBlock,
bulkData_->buckets(elementRank),elements);
1044 stk::mesh::Part * sidePart =
getSideset(sideName);
1046 "Unknown side set \"" << sideName <<
"\"");
1048 stk::mesh::Selector side = *sidePart;
1049 stk::mesh::Selector ownedBlock =
metaData_->locally_owned_part() & side;
1057 stk::mesh::Part * sidePart =
getSideset(sideName);
1060 "Unknown side set \"" << sideName <<
"\"");
1062 "Unknown element block \"" << blockName <<
"\"");
1064 stk::mesh::Selector side = *sidePart;
1065 stk::mesh::Selector block = *elmtPart;
1066 stk::mesh::Selector ownedBlock =
metaData_->locally_owned_part() & block & side;
1074 stk::mesh::Part * sidePart =
getSideset(sideName);
1076 "Unknown side set \"" << sideName <<
"\"");
1078 stk::mesh::Selector side = *sidePart;
1086 stk::mesh::Part * sidePart =
getSideset(sideName);
1089 "Unknown side set \"" << sideName <<
"\"");
1091 "Unknown element block \"" << blockName <<
"\"");
1093 stk::mesh::Selector side = *sidePart;
1094 stk::mesh::Selector block = *elmtPart;
1095 stk::mesh::Selector sideBlock = block & side;
1103 stk::mesh::Part * nodePart =
getNodeset(nodesetName);
1106 "Unknown node set \"" << nodesetName <<
"\"");
1108 "Unknown element block \"" << blockName <<
"\"");
1110 stk::mesh::Selector nodeset = *nodePart;
1111 stk::mesh::Selector block = *elmtPart;
1112 stk::mesh::Selector ownedBlock =
metaData_->locally_owned_part() & block & nodeset;
1125 std::map<std::string, stk::mesh::Part*>::const_iterator blkItr;
1127 names.push_back(blkItr->first);
1137 std::map<std::string, stk::mesh::Part*>::const_iterator sideItr;
1139 names.push_back(sideItr->first);
1147 std::map<std::string, stk::mesh::Part*>::const_iterator nodeItr;
1149 names.push_back(nodeItr->first);
1165 std::unordered_map<stk::mesh::EntityId,std::size_t>::const_iterator itr =
localIDHash_.find(gid);
1174 if(
bulkData_->bucket(elmt).member(*(eb_pair.second)))
1175 return eb_pair.first;
1180 const std::string & blockId)
const
1183 std::map<std::pair<std::string,std::string>,
SolutionFieldType*>::const_iterator
1188 "Solution field name \"" << fieldName <<
"\" in block ID \"" << blockId <<
"\" was not found");
1190 return iter->second;
1194 const std::string & blockId)
const
1197 std::map<std::pair<std::string,std::string>,
SolutionFieldType*>::const_iterator
1202 "Cell field named \"" << fieldName <<
"\" in block ID \"" << blockId <<
"\" was not found");
1204 return iter->second;
1224 stk::mesh::Part * block =
metaData_->get_part(name);
1226 block = &
metaData_->declare_part_with_topology(name, stk::mesh::get_topology(shards::CellTopology(ctData),
dimension_));
1269 std::vector<stk::mesh::Entity> elements;
1272 for(std::size_t index=0;index<elements.size();++index) {
1273 stk::mesh::Entity element = elements[index];
1277 procId[0] = Teuchos::as<ProcIdData>(
procRank_);
1290 for(std::size_t index=0;index<elements.size();++index) {
1291 stk::mesh::Entity element = elements[index];
1295 procId[0] = Teuchos::as<ProcIdData>(
procRank_);
1307 std::vector<std::string> names;
1310 for(std::size_t b=0;b<names.size();b++) {
1312 std::map<std::string,double>::const_iterator bw_itr =
blockWeights_.find(names[b]);
1313 double blockWeight = (bw_itr!=
blockWeights_.end()) ? bw_itr->second : 1.0;
1315 std::vector<stk::mesh::Entity> elements;
1318 for(std::size_t index=0;index<elements.size();++index) {
1320 double * loadBal = stk::mesh::field_data(*
loadBalField_,elements[index]);
1321 loadBal[0] = blockWeight;
1328 const std::string & fieldName,
1331 std::map<std::string,std::vector<std::string> >::const_iterator blkItr =
meshCoordFields_.find(eBlock);
1337 for(axis=0;axis<Teuchos::as<int>(blkItr->second.size());axis++) {
1338 if(blkItr->second[axis]==fieldName)
1342 if(axis>=Teuchos::as<int>(blkItr->second.size()))
1353 const std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > & matchers =
getPeriodicBCVector();
1356 for(std::size_t m=0;m<matchers.size();m++){
1357 vec = matchers[m]->getMatchedPair(*
this,vec);
1359 if(matchers[m]->getType() ==
"coord")
1361 else if(matchers[m]->getType() ==
"edge")
1363 else if(matchers[m]->getType() ==
"face")
1367 type_vec->insert(type_vec->begin(),vec->size()-type_vec->size(),type);
1370 return std::make_pair(vec,type_vec);
1375 std::map<std::string, stk::mesh::Part*>::const_iterator blkItr =
elementBlocks_.find(blockId);
1382 std::vector<std::string> blockNames, sidesetNames, nodesetNames;
1388 os <<
"STK Mesh data:\n";
1391 os <<
" Entity counts (Nodes, Edges, Cells) = ( "
1396 os <<
" Entity counts (Nodes, Edges, Faces, Cells) = ( "
1402 os <<
" Entity counts (Nodes, Cells) = ( "
1406 os <<
" Element blocks = ";
1407 for(std::size_t i=0;i<blockNames.size();i++)
1408 os <<
"\"" << blockNames[i] <<
"\" ";
1410 os <<
" Sidesets = ";
1411 for(std::size_t i=0;i<sidesetNames.size();i++)
1412 os <<
"\"" << sidesetNames[i] <<
"\" ";
1414 os <<
" Nodesets = ";
1415 for(std::size_t i=0;i<nodesetNames.size();i++)
1416 os <<
"\"" << nodesetNames[i] <<
"\" ";
1420 const std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > & bcVector
1422 if(bcVector.size()!=0) {
1423 os <<
" Periodic BCs:\n";
1424 for(std::size_t i=0;i<bcVector.size();i++)
1425 os <<
" " << bcVector[i]->getString() <<
"\n";
1432 std::vector<std::string> blockNames, sidesetNames, nodesetNames;
1438 os <<
"STK Meta data:\n";
1439 os <<
" Element blocks = ";
1440 for(std::size_t i=0;i<blockNames.size();i++)
1441 os <<
"\"" << blockNames[i] <<
"\" ";
1443 os <<
" Sidesets = ";
1444 for(std::size_t i=0;i<sidesetNames.size();i++)
1445 os <<
"\"" << sidesetNames[i] <<
"\" ";
1447 os <<
" Nodesets = ";
1448 for(std::size_t i=0;i<nodesetNames.size();i++)
1449 os <<
"\"" << nodesetNames[i] <<
"\" ";
1453 const std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > & bcVector
1455 if(bcVector.size()!=0) {
1456 os <<
" Periodic BCs:\n";
1457 for(std::size_t i=0;i<bcVector.size();i++)
1458 os <<
" " << bcVector[i]->getString() <<
"\n";
1464 const stk::mesh::FieldVector & fv =
metaData_->get_fields();
1465 for(std::size_t i=0;i<fv.size();i++)
1466 os <<
"\"" << fv[i]->name() <<
"\" ";
1472 std::map<std::string, Teuchos::RCP<shards::CellTopology> >::const_iterator itr;
1476 std::stringstream ss;
1479 "STK_Interface::getCellTopology: No such element block \"" +eBlock +
"\" available.\n\n"
1480 <<
"STK Meta Data follows: \n" << ss.str());
1489 const int err = MPI_Comm_dup (parallelMach, &newComm);
1491 "panzer::STK_Interface: MPI_Comm_dup failed with error \""
1492 << Teuchos::mpiErrorCodeToString (err) <<
"\".");
1504 stk::mesh::Selector selector(
getMetaData()->universal_part());
1505 stk::mesh::Selector owned_selector(
getMetaData()->locally_owned_part());
1513 if(params.begin()!=params.end())
1514 graph.
sublist(stk::rebalance::Zoltan::default_parameters_name()) = params;
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
void initialize(stk::ParallelMachine parallelMach, bool setupIO=true)
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
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
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 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_