11 #ifndef __Panzer_STK_Interface_hpp__
12 #define __Panzer_STK_Interface_hpp__
17 #include <stk_mesh/base/Types.hpp>
18 #include <stk_mesh/base/MetaData.hpp>
19 #include <stk_mesh/base/BulkData.hpp>
20 #include <stk_mesh/base/Field.hpp>
21 #include <stk_mesh/base/FieldBase.hpp>
23 #include "Kokkos_Core.hpp"
25 #include <Shards_CellTopology.hpp>
26 #include <Shards_CellTopologyData.h>
28 #include <PanzerAdaptersSTK_config.hpp>
29 #include <Kokkos_ViewFactory.hpp>
31 #include <unordered_map>
33 #ifdef PANZER_HAVE_IOSS
34 #include <stk_io/StkMeshIoBroker.hpp>
37 #ifdef PANZER_HAVE_PERCEPT
40 class URP_Heterogeneous_3D;
44 namespace panzer_stk {
46 class PeriodicBC_MatcherBase;
53 ElementDescriptor(stk::mesh::EntityId gid,
const std::vector<stk::mesh::EntityId> & nodes);
60 std::vector<stk::mesh::EntityId>
nodes_;
103 void addElementBlock(
const std::string & name,
const CellTopologyData * ctData);
109 const std::string & edgeBlockName,
110 const stk::topology & topology);
112 const std::string & edgeBlockName,
113 const CellTopologyData * ctData);
118 const std::string & faceBlockName,
119 const stk::topology & topology);
121 const std::string & faceBlockName,
122 const CellTopologyData * ctData);
126 void addSideset(
const std::string & name,
const CellTopologyData * ctData);
134 void addSolutionField(
const std::string & fieldName,
const std::string & blockId);
138 void addCellField(
const std::string & fieldName,
const std::string & blockId);
142 void addEdgeField(
const std::string & fieldName,
const std::string & blockId);
146 void addFaceField(
const std::string & fieldName,
const std::string & blockId);
157 const std::vector<std::string> & coordField,
158 const std::string & dispPrefix);
179 void initialize(stk::ParallelMachine parallelMach,
bool setupIO=
true,
180 const bool buildRefinementSupport =
false);
208 void endModification(
const bool find_and_set_shared_nodes_in_stk=
true);
215 void addNode(stk::mesh::EntityId gid,
const std::vector<double> & coord);
272 std::vector<stk::mesh::EntityId> & subcellIds)
const;
276 void getMyElements(std::vector<stk::mesh::Entity> & elements)
const;
280 void getMyElements(
const std::string & blockID,std::vector<stk::mesh::Entity> & elements)
const;
289 void getNeighborElements(
const std::string & blockID,std::vector<stk::mesh::Entity> & elements)
const;
293 void getMyEdges(std::vector<stk::mesh::Entity> & edges)
const;
302 void getMyEdges(
const std::string & edgeBlockName,std::vector<stk::mesh::Entity> & edges)
const;
312 void getMyEdges(
const std::string & edgeBlockName,
const std::string & blockName,std::vector<stk::mesh::Entity> & edges)
const;
321 void getAllEdges(
const std::string & edgeBlockName,std::vector<stk::mesh::Entity> & edges)
const;
331 void getAllEdges(
const std::string & edgeBlockName,
const std::string & blockName,std::vector<stk::mesh::Entity> & edges)
const;
335 void getMyFaces(std::vector<stk::mesh::Entity> & faces)
const;
344 void getMyFaces(
const std::string & faceBlockName,std::vector<stk::mesh::Entity> & faces)
const;
354 void getMyFaces(
const std::string & faceBlockName,
const std::string & blockName,std::vector<stk::mesh::Entity> & faces)
const;
363 void getAllFaces(
const std::string & faceBlockName,std::vector<stk::mesh::Entity> & faces)
const;
373 void getAllFaces(
const std::string & faceBlockName,
const std::string & blockName,std::vector<stk::mesh::Entity> & faces)
const;
382 void getMySides(
const std::string & sideName,std::vector<stk::mesh::Entity> & sides)
const;
392 void getMySides(
const std::string & sideName,
const std::string & blockName,std::vector<stk::mesh::Entity> & sides)
const;
401 void getAllSides(
const std::string & sideName,std::vector<stk::mesh::Entity> & sides)
const;
411 void getAllSides(
const std::string & sideName,
const std::string & blockName,std::vector<stk::mesh::Entity> & sides)
const;
422 void getMyNodes(
const std::string & sideName,
const std::string & blockName,std::vector<stk::mesh::Entity> & nodes)
const;
432 stk::mesh::Entity
findConnectivityById(stk::mesh::Entity src, stk::mesh::EntityRank tgt_rank,
unsigned rel_id)
const;
447 const bool append =
false);
468 const bool append =
false,
469 const bool append_after_restart_time =
false,
470 const double restart_time = 0.0);
474 const std::vector<Ioss::Property>& ioss_properties,
475 const bool append =
false,
476 const bool append_after_restart_time =
false,
477 const double restart_time = 0.0);
516 const std::string& key,
540 const std::string& key,
541 const double& value);
564 const std::string& key,
565 const std::vector<int>& value);
588 const std::string& key,
589 const std::vector<double>& value);
600 #ifdef PANZER_HAVE_PERCEPT
609 {
if(
bulkData_==Teuchos::null)
return false;
610 return bulkData_->in_modifiable_state(); }
672 std::map<std::string, stk::mesh::Part*>::const_iterator itr =
elementBlocks_.find(name);
680 std::map<std::string, stk::mesh::Part*>::const_iterator itr =
edgeBlocks_.find(name);
688 std::map<std::string, stk::mesh::Part*>::const_iterator itr =
faceBlocks_.find(name);
700 return (itr !=
sidesets_.end()) ? itr->second :
nullptr;
710 return (itr !=
nodesets_.end()) ? itr->second :
nullptr;
726 void getNodeIdsForElement(stk::mesh::Entity element,std::vector<stk::mesh::EntityId> & nodeIds)
const;
731 std::vector<int> & relIds)
const;
736 std::vector<int> & relIds,
unsigned int matchType)
const;
740 void getElementsSharingNodes(
const std::vector<stk::mesh::EntityId> nodeId,std::vector<stk::mesh::Entity> & elements)
const;
773 std::size_t
edgeLocalId(stk::mesh::Entity elmt)
const;
777 std::size_t
edgeLocalId(stk::mesh::EntityId gid)
const;
799 std::size_t
faceLocalId(stk::mesh::Entity elmt)
const;
803 std::size_t
faceLocalId(stk::mesh::EntityId gid)
const;
818 {
return bulkData_->parallel_owner_rank(entity); }
822 inline bool isValid(stk::mesh::Entity entity)
const
834 const std::string & blockId)
const;
840 stk::mesh::Field<double> *
getCellField(
const std::string & fieldName,
841 const std::string & blockId)
const;
847 stk::mesh::Field<double> *
getEdgeField(
const std::string & fieldName,
848 const std::string & blockId)
const;
854 stk::mesh::Field<double> *
getFaceField(
const std::string & fieldName,
855 const std::string & blockId)
const;
881 template <
typename ArrayT>
883 const std::vector<std::size_t> & localElementIds,
const ArrayT & solutionValues,
double scaleValue=1.0);
899 template <
typename ArrayT>
901 const std::vector<std::size_t> & localElementIds,ArrayT & solutionValues)
const;
917 template <
typename ArrayT>
918 void setCellFieldData(
const std::string & fieldName,
const std::string & blockId,
919 const std::vector<std::size_t> & localElementIds,
const ArrayT & solutionValues,
double scaleValue=1.0);
945 template <
typename ArrayT>
946 void setEdgeFieldData(
const std::string & fieldName,
const std::string & blockId,
947 const std::vector<std::size_t> & localEdgeIds,
const ArrayT & edgeValues,
double scaleValue=1.0);
963 template <
typename ArrayT>
964 void setFaceFieldData(
const std::string & fieldName,
const std::string & blockId,
965 const std::vector<std::size_t> & localFaceIds,
const ArrayT & faceValues,
double scaleValue=1.0);
977 template <
typename ArrayT>
978 void getElementVertices(
const std::vector<std::size_t> & localIds, ArrayT & vertices)
const;
988 template <
typename ArrayT>
989 void getElementVertices(
const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices)
const;
1000 template <
typename ArrayT>
1001 void getElementVertices(
const std::vector<std::size_t> & localIds,
const std::string & eBlock, ArrayT & vertices)
const;
1012 template <
typename ArrayT>
1013 void getElementVertices(
const std::vector<stk::mesh::Entity> & elements,
const std::string & eBlock, ArrayT & vertices)
const;
1023 template <
typename ArrayT>
1034 template <
typename ArrayT>
1046 template <
typename ArrayT>
1047 void getElementVerticesNoResize(
const std::vector<std::size_t> & localIds,
const std::string & eBlock, ArrayT & vertices)
const;
1058 template <
typename ArrayT>
1059 void getElementVerticesNoResize(
const std::vector<stk::mesh::Entity> & elements,
const std::string & eBlock, ArrayT & vertices)
const;
1072 template <
typename ArrayT>
1073 void getElementNodes(
const std::vector<std::size_t> & localIds, ArrayT & nodes)
const;
1083 template <
typename ArrayT>
1084 void getElementNodes(
const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes)
const;
1095 template <
typename ArrayT>
1096 void getElementNodes(
const std::vector<std::size_t> & localIds,
const std::string & eBlock, ArrayT & nodes)
const;
1107 template <
typename ArrayT>
1108 void getElementNodes(
const std::vector<stk::mesh::Entity> & elements,
const std::string & eBlock, ArrayT & nodes)
const;
1118 template <
typename ArrayT>
1129 template <
typename ArrayT>
1141 template <
typename ArrayT>
1142 void getElementNodesNoResize(
const std::vector<std::size_t> & localIds,
const std::string & eBlock, ArrayT & nodes)
const;
1153 template <
typename ArrayT>
1154 void getElementNodesNoResize(
const std::vector<stk::mesh::Entity> & elements,
const std::string & eBlock, ArrayT & nodes)
const;
1161 stk::mesh::EntityRank
getFaceRank()
const {
return stk::topology::FACE_RANK; }
1162 stk::mesh::EntityRank
getEdgeRank()
const {
return stk::topology::EDGE_RANK; }
1163 stk::mesh::EntityRank
getNodeRank()
const {
return stk::topology::NODE_RANK; }
1183 const std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > &
1189 std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > &
1229 void print(std::ostream & os)
const;
1301 template <
typename ArrayT>
1302 void getElementVertices_FromField(
const std::vector<stk::mesh::Entity> & elements,
const std::string & eBlock, ArrayT & vertices)
const;
1304 template <
typename ArrayT>
1306 const std::string & eBlock, ArrayT & vertices)
const;
1317 template <
typename ArrayT>
1320 template <
typename ArrayT>
1335 template <
typename ArrayT>
1336 void getElementNodes_FromField(
const std::vector<stk::mesh::Entity> & elements,
const std::string & eBlock, ArrayT & nodes)
const;
1338 template <
typename ArrayT>
1340 const std::string & eBlock, ArrayT & nodes)
const;
1351 template <
typename ArrayT>
1354 template <
typename ArrayT>
1362 void refineMesh(
const int numberOfLevels,
const bool deleteParentElements);
1404 bool isMeshCoordField(
const std::string & eBlock,
const std::string & fieldName,
int & axis)
const;
1421 template <
typename ArrayT>
1422 void setDispFieldData(
const std::string & fieldName,
const std::string & blockId,
int axis,
1423 const std::vector<std::size_t> & localElementIds,
const ArrayT & solutionValues);
1430 #ifdef PANZER_HAVE_PERCEPT
1484 #ifdef PANZER_HAVE_IOSS
1493 enum class GlobalVariable
1517 const GlobalVariable& flag);
1566 template <
typename ArrayT>
1568 const std::vector<std::size_t> & localElementIds,
const ArrayT & solutionValues,
double scaleValue)
1571 auto solutionValues_h = Kokkos::create_mirror_view(solutionValues);
1572 Kokkos::deep_copy(solutionValues_h, solutionValues);
1574 int field_axis = -1;
1576 setDispFieldData(fieldName,blockId,field_axis,localElementIds,solutionValues_h);
1582 for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1583 std::size_t localId = localElementIds[cell];
1584 stk::mesh::Entity element = elements[localId];
1587 const size_t num_nodes =
bulkData_->num_nodes(element);
1588 stk::mesh::Entity
const* nodes =
bulkData_->begin_nodes(element);
1589 for(std::size_t i=0; i<num_nodes; ++i) {
1590 stk::mesh::Entity node = nodes[i];
1592 double * solnData = stk::mesh::field_data(*field,node);
1594 solnData[0] = scaleValue*solutionValues_h(cell,i);
1599 template <
typename ArrayT>
1601 const std::vector<std::size_t> & localElementIds,
const ArrayT & dispValues)
1610 for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1611 std::size_t localId = localElementIds[cell];
1612 stk::mesh::Entity element = elements[localId];
1615 const size_t num_nodes =
bulkData_->num_nodes(element);
1616 stk::mesh::Entity
const* nodes =
bulkData_->begin_nodes(element);
1617 for(std::size_t i=0; i<num_nodes; ++i) {
1618 stk::mesh::Entity node = nodes[i];
1620 double * solnData = stk::mesh::field_data(*field,node);
1621 double * coordData = stk::mesh::field_data(coord_field,node);
1623 solnData[0] = dispValues(cell,i)-coordData[axis];
1628 template <
typename ArrayT>
1630 const std::vector<std::size_t> & localElementIds,ArrayT & solutionValues)
const
1636 localElementIds.size(),
1637 bulkData_->num_nodes(elements[localElementIds[0]]));
1641 for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1642 std::size_t localId = localElementIds[cell];
1643 stk::mesh::Entity element = elements[localId];
1646 const size_t num_nodes =
bulkData_->num_nodes(element);
1647 stk::mesh::Entity
const* nodes =
bulkData_->begin_nodes(element);
1648 for(std::size_t i=0; i<num_nodes; ++i) {
1649 stk::mesh::Entity node = nodes[i];
1651 double * solnData = stk::mesh::field_data(*field,node);
1653 solutionValues(cell,i) = solnData[0];
1658 template <
typename ArrayT>
1660 const std::vector<std::size_t> & localElementIds,
const ArrayT & solutionValues,
double scaleValue)
1666 auto solutionValues_h = Kokkos::create_mirror_view(solutionValues);
1667 Kokkos::deep_copy(solutionValues_h, solutionValues);
1669 for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1670 std::size_t localId = localElementIds[cell];
1671 stk::mesh::Entity element = elements[localId];
1673 double * solnData = stk::mesh::field_data(*field,element);
1675 solnData[0] = scaleValue*solutionValues_h.access(cell,0);
1679 template <
typename ArrayT>
1681 const std::vector<std::size_t> & localEdgeIds,
const ArrayT & edgeValues,
double scaleValue)
1687 auto edgeValues_h = Kokkos::create_mirror_view(edgeValues);
1688 Kokkos::deep_copy(edgeValues_h, edgeValues);
1690 for(std::size_t idx=0;idx<localEdgeIds.size();idx++) {
1691 std::size_t localId = localEdgeIds[idx];
1692 stk::mesh::Entity edge = edges[localId];
1694 double * solnData = stk::mesh::field_data(*field,edge);
1696 solnData[0] = scaleValue*edgeValues_h.access(idx,0);
1700 template <
typename ArrayT>
1702 const std::vector<std::size_t> & localFaceIds,
const ArrayT & faceValues,
double scaleValue)
1708 auto faceValues_h = Kokkos::create_mirror_view(faceValues);
1709 Kokkos::deep_copy(faceValues_h, faceValues);
1711 for(std::size_t idx=0;idx<localFaceIds.size();idx++) {
1712 std::size_t localId = localFaceIds[idx];
1713 stk::mesh::Entity face = faces[localId];
1715 double * solnData = stk::mesh::field_data(*field,face);
1717 solnData[0] = scaleValue*faceValues_h.access(idx,0);
1723 template <
typename ArrayT>
1734 std::vector<stk::mesh::Entity> selected_elements;
1735 for(std::size_t cell=0;cell<localElementIds.size();cell++)
1736 selected_elements.push_back(elements[localElementIds[cell]]);
1742 "STK_Interface::getElementVertices: Cannot call this method when field coordinates are used "
1743 "without specifying an element block.");
1747 template <
typename ArrayT>
1755 "STK_Interface::getElementVertices: Cannot call this method when field coordinates are used "
1756 "without specifying an element block.");
1760 template <
typename ArrayT>
1771 template <
typename ArrayT>
1777 std::vector<stk::mesh::Entity> selected_elements;
1778 for(std::size_t cell=0;cell<localElementIds.size();cell++)
1779 selected_elements.push_back(elements[localElementIds[cell]]);
1789 template <
typename ArrayT>
1800 std::vector<stk::mesh::Entity> selected_elements;
1801 for(std::size_t cell=0;cell<localElementIds.size();cell++)
1802 selected_elements.push_back(elements[localElementIds[cell]]);
1808 "STK_Interface::getElementVerticesNoResize: Cannot call this method when field coordinates are used "
1809 "without specifying an element block.");
1813 template <
typename ArrayT>
1821 "STK_Interface::getElementVerticesNoResize: Cannot call this method when field coordinates are used "
1822 "without specifying an element block.");
1826 template <
typename ArrayT>
1837 template <
typename ArrayT>
1843 std::vector<stk::mesh::Entity> selected_elements;
1844 for(std::size_t cell=0;cell<localElementIds.size();cell++)
1845 selected_elements.push_back(elements[localElementIds[cell]]);
1855 template <
typename ArrayT>
1859 if(elements.size() == 0) {
1869 const auto masterVertexCount
1870 = stk::mesh::get_cell_topology(
bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1874 auto vertices_h = Kokkos::create_mirror_view(vertices);
1875 Kokkos::deep_copy(vertices_h, vertices);
1879 for(std::size_t cell = 0; cell < elements.size(); cell++) {
1880 const auto element = elements[cell];
1883 const auto vertexCount
1884 = stk::mesh::get_cell_topology(
bulkData_->bucket(element).topology()).getCellTopologyData()->vertex_count;
1886 "In call to STK_Interface::getElementVertices all elements "
1887 "must have the same vertex count!");
1890 const size_t num_nodes =
bulkData_->num_nodes(element);
1891 auto const* nodes =
bulkData_->begin_nodes(element);
1893 "In call to STK_Interface::getElementVertices cardinality of "
1894 "element node relations must be the vertex count!");
1895 for(std::size_t node = 0; node < num_nodes; ++node) {
1899 for(
unsigned d=0;d<dim;d++)
1900 vertices_h(cell,node,d) = coord[d];
1903 Kokkos::deep_copy(vertices, vertices_h);
1906 template <
typename ArrayT>
1910 if(elements.size()==0) {
1919 unsigned masterVertexCount
1920 = stk::mesh::get_cell_topology(
bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1924 auto vertices_h = Kokkos::create_mirror_view(vertices);
1925 for(std::size_t cell=0;cell<elements.size();cell++) {
1926 stk::mesh::Entity element = elements[cell];
1929 unsigned vertexCount
1930 = stk::mesh::get_cell_topology(
bulkData_->bucket(element).topology()).getCellTopologyData()->vertex_count;
1932 "In call to STK_Interface::getElementVertices all elements "
1933 "must have the same vertex count!");
1936 const size_t num_nodes =
bulkData_->num_nodes(element);
1937 stk::mesh::Entity
const* nodes =
bulkData_->begin_nodes(element);
1939 "In call to STK_Interface::getElementVertices cardinality of "
1940 "element node relations must be the vertex count!");
1941 for(std::size_t node=0; node<num_nodes; ++node) {
1945 for(
unsigned d=0;d<dim;d++)
1946 vertices_h(cell,node,d) = coord[d];
1949 Kokkos::deep_copy(vertices, vertices_h);
1952 template <
typename ArrayT>
1958 if(elements.size()==0) {
1964 unsigned masterVertexCount
1965 = stk::mesh::get_cell_topology(
bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1969 auto vertices_h = Kokkos::create_mirror_view(vertices);
1970 std::map<std::string,std::vector<std::string> >::const_iterator itr =
meshCoordFields_.find(eBlock);
1976 const std::vector<std::string> & coordField = itr->second;
1977 std::vector<SolutionFieldType*> fields(
getDimension());
1978 for(std::size_t d=0;d<fields.size();d++) {
1982 for(std::size_t cell=0;cell<elements.size();cell++) {
1983 stk::mesh::Entity element = elements[cell];
1986 const size_t num_nodes =
bulkData_->num_nodes(element);
1987 stk::mesh::Entity
const* nodes =
bulkData_->begin_nodes(element);
1988 for(std::size_t i=0; i<num_nodes; ++i) {
1989 stk::mesh::Entity node = nodes[i];
1994 double * solnData = stk::mesh::field_data(*fields[d],node);
1998 vertices_h(cell,i,d) = solnData[0]+coord[d];
2002 Kokkos::deep_copy(vertices, vertices_h);
2005 template <
typename ArrayT>
2007 const std::string & eBlock, ArrayT & vertices)
const
2012 if(elements.size()==0) {
2016 std::map<std::string,std::vector<std::string> >::const_iterator itr =
meshCoordFields_.find(eBlock);
2022 const std::vector<std::string> & coordField = itr->second;
2023 std::vector<SolutionFieldType*> fields(
getDimension());
2024 for(std::size_t d=0;d<fields.size();d++) {
2028 for(std::size_t cell=0;cell<elements.size();cell++) {
2029 stk::mesh::Entity element = elements[cell];
2032 const size_t num_nodes =
bulkData_->num_nodes(element);
2033 stk::mesh::Entity
const* nodes =
bulkData_->begin_nodes(element);
2034 for(std::size_t i=0; i<num_nodes; ++i) {
2035 stk::mesh::Entity node = nodes[i];
2040 double * solnData = stk::mesh::field_data(*fields[d],node);
2044 vertices(cell,i,d) = solnData[0]+coord[d];
2052 template <
typename ArrayT>
2063 std::vector<stk::mesh::Entity> selected_elements;
2064 for(std::size_t cell=0;cell<localElementIds.size();cell++)
2065 selected_elements.push_back(elements[localElementIds[cell]]);
2071 "STK_Interface::getElementNodes: Cannot call this method when field coordinates are used "
2072 "without specifying an element block.");
2076 template <
typename ArrayT>
2084 "STK_Interface::getElementNodes: Cannot call this method when field coordinates are used "
2085 "without specifying an element block.");
2089 template <
typename ArrayT>
2100 template <
typename ArrayT>
2106 std::vector<stk::mesh::Entity> selected_elements;
2107 for(std::size_t cell=0;cell<localElementIds.size();cell++)
2108 selected_elements.push_back(elements[localElementIds[cell]]);
2118 template <
typename ArrayT>
2129 std::vector<stk::mesh::Entity> selected_elements;
2130 for(std::size_t cell=0;cell<localElementIds.size();cell++)
2131 selected_elements.push_back(elements[localElementIds[cell]]);
2137 "STK_Interface::getElementNodesNoResize: Cannot call this method when field coordinates are used "
2138 "without specifying an element block.");
2142 template <
typename ArrayT>
2150 "STK_Interface::getElementNodesNoResize: Cannot call this method when field coordinates are used "
2151 "without specifying an element block.");
2155 template <
typename ArrayT>
2166 template <
typename ArrayT>
2172 std::vector<stk::mesh::Entity> selected_elements;
2173 for(std::size_t cell=0;cell<localElementIds.size();cell++)
2174 selected_elements.push_back(elements[localElementIds[cell]]);
2184 template <
typename ArrayT>
2188 if(elements.size() == 0) {
2198 const auto masterNodeCount
2199 = stk::mesh::get_cell_topology(
bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->node_count;
2203 auto nodes_h = Kokkos::create_mirror_view(nodes);
2204 Kokkos::deep_copy(nodes_h, nodes);
2208 for(std::size_t cell = 0; cell < elements.size(); cell++) {
2209 const auto element = elements[cell];
2212 const auto nodeCount
2213 = stk::mesh::get_cell_topology(
bulkData_->bucket(element).topology()).getCellTopologyData()->node_count;
2215 "In call to STK_Interface::getElementNodes all elements "
2216 "must have the same node count!");
2219 const size_t num_nodes =
bulkData_->num_nodes(element);
2220 auto const* elem_nodes =
bulkData_->begin_nodes(element);
2222 "In call to STK_Interface::getElementNodes cardinality of "
2223 "element node relations must be the node count!");
2224 for(std::size_t node = 0; node < num_nodes; ++node) {
2228 for(
unsigned d=0;d<dim;d++)
2229 nodes_h(cell,node,d) = coord[d];
2232 Kokkos::deep_copy(nodes, nodes_h);
2235 template <
typename ArrayT>
2239 if(elements.size()==0) {
2248 unsigned masterNodeCount
2249 = stk::mesh::get_cell_topology(
bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->node_count;
2253 auto nodes_h = Kokkos::create_mirror_view(nodes);
2254 for(std::size_t cell=0;cell<elements.size();cell++) {
2255 stk::mesh::Entity element = elements[cell];
2259 = stk::mesh::get_cell_topology(
bulkData_->bucket(element).topology()).getCellTopologyData()->node_count;
2261 "In call to STK_Interface::getElementNodes all elements "
2262 "must have the same node count!");
2265 const size_t num_nodes =
bulkData_->num_nodes(element);
2266 stk::mesh::Entity
const* elem_nodes =
bulkData_->begin_nodes(element);
2268 "In call to STK_Interface::getElementNodes cardinality of "
2269 "element node relations must be the node count!");
2270 for(std::size_t node=0; node<num_nodes; ++node) {
2274 for(
unsigned d=0;d<dim;d++)
2275 nodes_h(cell,node,d) = coord[d];
2278 Kokkos::deep_copy(nodes, nodes_h);
2281 template <
typename ArrayT>
2287 if(elements.size()==0) {
2293 unsigned masterNodeCount
2294 = stk::mesh::get_cell_topology(
bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->node_count;
2298 auto nodes_h = Kokkos::create_mirror_view(nodes);
2299 std::map<std::string,std::vector<std::string> >::const_iterator itr =
meshCoordFields_.find(eBlock);
2305 const std::vector<std::string> & coordField = itr->second;
2306 std::vector<SolutionFieldType*> fields(
getDimension());
2307 for(std::size_t d=0;d<fields.size();d++) {
2312 for(std::size_t cell=0;cell<elements.size();cell++) {
2313 stk::mesh::Entity element = elements[cell];
2316 const size_t num_nodes =
bulkData_->num_nodes(element);
2317 stk::mesh::Entity
const* elem_nodes =
bulkData_->begin_nodes(element);
2318 for(std::size_t i=0; i<num_nodes; ++i) {
2319 stk::mesh::Entity node = elem_nodes[i];
2324 double * solnData = stk::mesh::field_data(*fields[d],node);
2328 nodes_h(cell,i,d) = solnData[0]+coord[d];
2332 Kokkos::deep_copy(nodes, nodes_h);
2335 template <
typename ArrayT>
2337 const std::string & eBlock, ArrayT & nodes)
const
2342 if(elements.size()==0) {
2346 std::map<std::string,std::vector<std::string> >::const_iterator itr =
meshCoordFields_.find(eBlock);
2352 const std::vector<std::string> & coordField = itr->second;
2353 std::vector<SolutionFieldType*> fields(
getDimension());
2354 for(std::size_t d=0;d<fields.size();d++) {
2359 for(std::size_t cell=0;cell<elements.size();cell++) {
2360 stk::mesh::Entity element = elements[cell];
2363 const size_t num_nodes =
bulkData_->num_nodes(element);
2364 stk::mesh::Entity
const* elem_nodes =
bulkData_->begin_nodes(element);
2365 for(std::size_t i=0; i<num_nodes; ++i) {
2366 stk::mesh::Entity node = elem_nodes[i];
2371 double * solnData = stk::mesh::field_data(*fields[d],node);
2375 nodes(cell,i,d) = solnData[0]+coord[d];
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
std::pair< Teuchos::RCP< std::vector< std::pair< std::size_t, std::size_t > > >, Teuchos::RCP< std::vector< unsigned int > > > getPeriodicNodePairing() const
const bool & useBoundingBoxSearch() const
Teuchos::RCP< std::vector< stk::mesh::Entity > > orderedEdgeVector_
Kokkos::DynRankView< typename InputArray::value_type, PHX::Device > createDynRankView(const InputArray &a, const std::string &name, const DimensionPack...dims)
Wrapper to simplify Panzer use of Sacado ViewFactory.
ElementBlockException(const std::string &what)
void addNodeset(const std::string &name)
EdgeBlockException(const std::string &what)
Teuchos::RCP< stk::mesh::BulkData > bulkData_
void getFaceBlockNames(std::vector< std::string > &names) const
void print(std::ostream &os) const
void getElementNodesNoResize(const std::vector< std::size_t > &localIds, ArrayT &nodes) const
unsigned entityOwnerRank(stk::mesh::Entity entity) const
void getMyEdges(std::vector< stk::mesh::Entity > &edges) const
void setEdgeFieldData(const std::string &fieldName, const std::string &blockId, const std::vector< std::size_t > &localEdgeIds, const ArrayT &edgeValues, double scaleValue=1.0)
stk::mesh::Field< double > VectorFieldType
Teuchos::RCP< const std::vector< stk::mesh::Entity > > getElementsOrderedByLID() const
void setSolutionFieldData(const std::string &fieldName, const std::string &blockId, const std::vector< std::size_t > &localElementIds, const ArrayT &solutionValues, double scaleValue=1.0)
std::vector< stk::mesh::Part * > facesPartVec_
std::vector< stk::mesh::EntityId > nodes_
std::map< std::pair< std::string, std::string >, SolutionFieldType * > fieldNameToSolution_
void getElementVerticesNoResize(const std::vector< std::size_t > &localIds, ArrayT &vertices) const
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 setDispFieldData(const std::string &fieldName, const std::string &blockId, int axis, const std::vector< std::size_t > &localElementIds, const ArrayT &solutionValues)
void getElementNodes_FromCoordsNoResize(const std::vector< stk::mesh::Entity > &elements, ArrayT &nodes) const
void getElementBlockNames(std::vector< std::string > &names) const
void addPeriodicBC(const Teuchos::RCP< const PeriodicBC_MatcherBase > &bc)
void getSubcellIndices(unsigned entityRank, stk::mesh::EntityId elementId, std::vector< stk::mesh::EntityId > &subcellIds) const
std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > & getPeriodicBCVector()
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 part
std::vector< stk::mesh::Part * > edgesPartVec_
bool nonnull(const std::shared_ptr< T > &p)
bool isFaceLocal(stk::mesh::Entity face) const
std::map< std::string, double > blockWeights_
Teuchos::RCP< const std::vector< stk::mesh::Entity > > getEdgesOrderedByLID() const
VectorFieldType * coordinatesField_
#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 getElementNodes_FromFieldNoResize(const std::vector< stk::mesh::Entity > &elements, const std::string &eBlock, ArrayT &nodes) const
void getElementVertices(const std::vector< std::size_t > &localIds, ArrayT &vertices) const
void addEntityToSideset(stk::mesh::Entity entity, stk::mesh::Part *sideset)
std::map< std::string, stk::mesh::Part * > faceBlocks_
stk::mesh::Part * nodesPart_
stk::mesh::EntityId edgeGlobalId(std::size_t lid) const
void getElementVertices_FromCoords(const std::vector< stk::mesh::Entity > &elements, ArrayT &vertices) const
void getElementNodes(const std::vector< std::size_t > &localIds, ArrayT &nodes) const
void addSolutionField(const std::string &fieldName, const std::string &blockId)
std::map< std::string, Teuchos::RCP< shards::CellTopology > > elementBlockCT_
void addEntityToFaceBlock(stk::mesh::Entity entity, stk::mesh::Part *faceblock)
stk::mesh::EntityId getMaxEntityId(unsigned entityRank) const
get max entity ID of type entityRank
std::size_t currentLocalId_
std::map< std::pair< std::string, std::string >, SolutionFieldType * > fieldNameToFaceField_
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 getEdgeBlockNames(std::vector< std::string > &names) const
stk::mesh::Part * getFaceBlock(const std::string &name) const
get the block part
void addInformationRecords(const std::vector< std::string > &info_records)
stk::mesh::EntityId faceGlobalId(std::size_t lid) const
void endModification(const bool find_and_set_shared_nodes_in_stk=true)
void getAllFaces(const std::string &faceBlockName, std::vector< stk::mesh::Entity > &faces) const
stk::mesh::Field< double > * getSolutionField(const std::string &fieldName, const std::string &blockId) const
SolutionFieldType * loadBalField_
void addEdgeBlock(const std::string &elemBlockName, const std::string &edgeBlockName, const stk::topology &topology)
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 getElementVertices_FromFieldNoResize(const std::vector< stk::mesh::Entity > &elements, const std::string &eBlock, ArrayT &vertices) const
std::set< std::string > informationRecords_
void getMySides(const std::string &sideName, std::vector< stk::mesh::Entity > &sides) const
std::size_t getNumSidesets() const
get the side set count
stk::mesh::EntityId elementGlobalId(stk::mesh::Entity elmt) const
stk::mesh::Field< double > * getEdgeField(const std::string &fieldName, const std::string &blockId) const
std::size_t elementLocalId(stk::mesh::Entity elmt) const
bool useFieldCoordinates_
stk::mesh::EntityId faceGlobalId(stk::mesh::Entity face) const
void getElementVertices_FromCoordsNoResize(const std::vector< stk::mesh::Entity > &elements, ArrayT &vertices) 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_
void setupExodusFile(const std::string &filename, const bool append=false, const bool append_after_restart_time=false, const double restart_time=0.0)
Set up an output Exodus file for writing results.
VectorFieldType * edgesField_
void setUseFieldCoordinates(bool useFieldCoordinates)
stk::mesh::EntityRank getSideRank() const
void getAllEdges(const std::string &edgeBlockName, std::vector< stk::mesh::Entity > &edges) const
void initialize(stk::ParallelMachine parallelMach, bool setupIO=true, const bool buildRefinementSupport=false)
FaceBlockException(const std::string &what)
static const std::string coordsString
void setFaceFieldData(const std::string &fieldName, const std::string &blockId, const std::vector< std::size_t > &localFaceIds, const ArrayT &faceValues, double scaleValue=1.0)
std::size_t getNumElementBlocks() const
get the block count
void getElementNodes_FromField(const std::vector< stk::mesh::Entity > &elements, const std::string &eBlock, ArrayT &nodes) const
Teuchos::RCP< stk::mesh::BulkData > getBulkData() const
std::map< std::string, stk::mesh::Part * > edgeBlocks_
void getElementVertices_FromField(const std::vector< stk::mesh::Entity > &elements, const std::string &eBlock, ArrayT &vertices) const
bool getUseFieldCoordinates() const
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 edgeBlockString
static const std::string edgesString
SidesetException(const std::string &what)
std::string containingBlockId(stk::mesh::Entity elmt) const
stk::mesh::EntityRank getFaceRank() const
std::size_t edgeLocalId(stk::mesh::Entity elmt) const
const STK_Interface * mesh_
std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > periodicBCs_
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 addEntitiesToEdgeBlock(std::vector< stk::mesh::Entity > entities, stk::mesh::Part *edgeblock)
void setBlockWeight(const std::string &blockId, double weight)
void buildSubcells()
force the mesh to build subcells: edges and faces
Teuchos::RCP< Teuchos::MpiComm< int > > mpiComm_
LocalIdCompare(const STK_Interface *mesh)
void setInitialStateTime(double value)
Teuchos::RCP< stk::mesh::MetaData > metaData_
Teuchos::RCP< stk::mesh::MetaData > getMetaData() const
virtual ~ElementDescriptor()
Teuchos::RCP< std::vector< stk::mesh::Entity > > orderedElementVector_
std::size_t getNumNodesets() const
get the side set count
double getInitialStateTime() const
bool isInitialized() const
Has initialize been called on this mesh object?
void writeToExodus(const std::string &filename, const bool append=false)
Write this mesh and associated fields to the given output file.
void getMyNodes(const std::string &sideName, const std::string &blockName, std::vector< stk::mesh::Entity > &nodes) const
void getSolutionFieldData(const std::string &fieldName, const std::string &blockId, const std::vector< std::size_t > &localElementIds, ArrayT &solutionValues) const
void addEdgeField(const std::string &fieldName, const std::string &blockId)
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
void setUseLowerCaseForIO(bool useLowerCase)
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)
static const std::string faceBlockString
std::unordered_map< stk::mesh::EntityId, std::size_t > localFaceIDHash_
void addEntityToEdgeBlock(stk::mesh::Entity entity, stk::mesh::Part *edgeblock)
std::map< std::pair< std::string, std::string >, SolutionFieldType * > fieldNameToEdgeField_
stk::mesh::Part * getEdgeBlock(const std::string &name) const
get the block part
void setCellFieldData(const std::string &fieldName, const std::string &blockId, const std::vector< std::size_t > &localElementIds, const ArrayT &solutionValues, double scaleValue=1.0)
const VectorFieldType & getEdgesField() const
std::unordered_map< stk::mesh::EntityId, std::size_t > localEdgeIDHash_
ProcIdFieldType * getProcessorIdField()
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
void addEntitiesToFaceBlock(std::vector< stk::mesh::Entity > entities, stk::mesh::Part *faceblock)
void initializeFieldsInSTK(const std::map< std::pair< std::string, std::string >, SolutionFieldType * > &nameToField, bool setupIO)
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
get the comm associated with this mesh
const std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > & getPeriodicBCVector() const
const VectorFieldType & getFacesField() const
void refineMesh(const int numberOfLevels, const bool deleteParentElements)
stk::mesh::Field< double > * getFaceField(const std::string &fieldName, const std::string &blockId) const
void buildLocalElementIDs()
std::size_t faceLocalId(stk::mesh::Entity elmt) const
bool isModifiable() const
void addFaceBlock(const std::string &elemBlockName, const std::string &faceBlockName, const stk::topology &topology)
Teuchos::RCP< std::vector< stk::mesh::Entity > > orderedFaceVector_
std::unordered_map< stk::mesh::EntityId, std::size_t > localIDHash_
bool isValid(stk::mesh::Entity entity) const
std::vector< stk::mesh::EntityId > maxEntityId_
stk::mesh::Field< ProcIdData > ProcIdFieldType
void addPeriodicBCs(const std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > &bc_vec)
void getElementsSharingNode(stk::mesh::EntityId nodeId, std::vector< stk::mesh::Entity > &elements) const
get a set of elements sharing a single node
void addFaceField(const std::string &fieldName, const std::string &blockId)
#define TEUCHOS_ASSERT(assertion_test)
void getMyElements(std::vector< stk::mesh::Entity > &elements) const
stk::mesh::EntityRank getNodeRank() const
void getMyFaces(std::vector< stk::mesh::Entity > &faces) 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
Teuchos::RCP< const std::vector< stk::mesh::Entity > > getFacesOrderedByLID() const
stk::mesh::Part * edgesPart_
bool operator()(stk::mesh::Entity a, stk::mesh::Entity b)
stk::mesh::EntityRank getElementRank() const
void getElementNodes_FromCoords(const std::vector< stk::mesh::Entity > &elements, ArrayT &nodes) const
stk::mesh::EntityId edgeGlobalId(stk::mesh::Entity edge) const
stk::mesh::Part * facesPart_
ProcIdFieldType * processorIdField_
void addElementBlock(const std::string &name, const CellTopologyData *ctData)
const std::vector< stk::mesh::EntityId > & getNodes() const
stk::mesh::Field< double > * getCellField(const std::string &fieldName, const std::string &blockId) const
const VectorFieldType & getCoordinatesField() const
stk::mesh::Part * getOwnedPart() const
Get a pointer to the locally owned part.
stk::mesh::EntityId getGID() const
void setBoundingBoxSearchFlag(const bool &searchFlag)
bool getUseLowerCaseForIO() const
bool isEdgeLocal(stk::mesh::Entity edge) const
double getCurrentStateTime() 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_