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);
205 void addNode(stk::mesh::EntityId gid,
const std::vector<double> & coord);
262 std::vector<stk::mesh::EntityId> & subcellIds)
const;
266 void getMyElements(std::vector<stk::mesh::Entity> & elements)
const;
270 void getMyElements(
const std::string & blockID,std::vector<stk::mesh::Entity> & elements)
const;
279 void getNeighborElements(
const std::string & blockID,std::vector<stk::mesh::Entity> & elements)
const;
283 void getMyEdges(std::vector<stk::mesh::Entity> & edges)
const;
292 void getMyEdges(
const std::string & edgeBlockName,std::vector<stk::mesh::Entity> & edges)
const;
302 void getMyEdges(
const std::string & edgeBlockName,
const std::string & blockName,std::vector<stk::mesh::Entity> & edges)
const;
311 void getAllEdges(
const std::string & edgeBlockName,std::vector<stk::mesh::Entity> & edges)
const;
321 void getAllEdges(
const std::string & edgeBlockName,
const std::string & blockName,std::vector<stk::mesh::Entity> & edges)
const;
325 void getMyFaces(std::vector<stk::mesh::Entity> & faces)
const;
334 void getMyFaces(
const std::string & faceBlockName,std::vector<stk::mesh::Entity> & faces)
const;
344 void getMyFaces(
const std::string & faceBlockName,
const std::string & blockName,std::vector<stk::mesh::Entity> & faces)
const;
353 void getAllFaces(
const std::string & faceBlockName,std::vector<stk::mesh::Entity> & faces)
const;
363 void getAllFaces(
const std::string & faceBlockName,
const std::string & blockName,std::vector<stk::mesh::Entity> & faces)
const;
372 void getMySides(
const std::string & sideName,std::vector<stk::mesh::Entity> & sides)
const;
382 void getMySides(
const std::string & sideName,
const std::string & blockName,std::vector<stk::mesh::Entity> & sides)
const;
391 void getAllSides(
const std::string & sideName,std::vector<stk::mesh::Entity> & sides)
const;
401 void getAllSides(
const std::string & sideName,
const std::string & blockName,std::vector<stk::mesh::Entity> & sides)
const;
412 void getMyNodes(
const std::string & sideName,
const std::string & blockName,std::vector<stk::mesh::Entity> & nodes)
const;
422 stk::mesh::Entity
findConnectivityById(stk::mesh::Entity src, stk::mesh::EntityRank tgt_rank,
unsigned rel_id)
const;
437 const bool append =
false);
458 const bool append =
false,
459 const bool append_after_restart_time =
false,
460 const double restart_time = 0.0);
499 const std::string& key,
523 const std::string& key,
524 const double& value);
547 const std::string& key,
548 const std::vector<int>& value);
571 const std::string& key,
572 const std::vector<double>& value);
583 #ifdef PANZER_HAVE_PERCEPT
592 {
if(
bulkData_==Teuchos::null)
return false;
593 return bulkData_->in_modifiable_state(); }
655 std::map<std::string, stk::mesh::Part*>::const_iterator itr =
elementBlocks_.find(name);
663 std::map<std::string, stk::mesh::Part*>::const_iterator itr =
edgeBlocks_.find(name);
671 std::map<std::string, stk::mesh::Part*>::const_iterator itr =
faceBlocks_.find(name);
683 return (itr !=
sidesets_.end()) ? itr->second :
nullptr;
693 return (itr !=
nodesets_.end()) ? itr->second :
nullptr;
709 void getNodeIdsForElement(stk::mesh::Entity element,std::vector<stk::mesh::EntityId> & nodeIds)
const;
714 std::vector<int> & relIds)
const;
719 std::vector<int> & relIds,
unsigned int matchType)
const;
723 void getElementsSharingNodes(
const std::vector<stk::mesh::EntityId> nodeId,std::vector<stk::mesh::Entity> & elements)
const;
756 std::size_t
edgeLocalId(stk::mesh::Entity elmt)
const;
760 std::size_t
edgeLocalId(stk::mesh::EntityId gid)
const;
782 std::size_t
faceLocalId(stk::mesh::Entity elmt)
const;
786 std::size_t
faceLocalId(stk::mesh::EntityId gid)
const;
801 {
return bulkData_->parallel_owner_rank(entity); }
805 inline bool isValid(stk::mesh::Entity entity)
const
817 const std::string & blockId)
const;
823 stk::mesh::Field<double> *
getCellField(
const std::string & fieldName,
824 const std::string & blockId)
const;
830 stk::mesh::Field<double> *
getEdgeField(
const std::string & fieldName,
831 const std::string & blockId)
const;
837 stk::mesh::Field<double> *
getFaceField(
const std::string & fieldName,
838 const std::string & blockId)
const;
864 template <
typename ArrayT>
866 const std::vector<std::size_t> & localElementIds,
const ArrayT & solutionValues,
double scaleValue=1.0);
882 template <
typename ArrayT>
884 const std::vector<std::size_t> & localElementIds,ArrayT & solutionValues)
const;
900 template <
typename ArrayT>
901 void setCellFieldData(
const std::string & fieldName,
const std::string & blockId,
902 const std::vector<std::size_t> & localElementIds,
const ArrayT & solutionValues,
double scaleValue=1.0);
928 template <
typename ArrayT>
929 void setEdgeFieldData(
const std::string & fieldName,
const std::string & blockId,
930 const std::vector<std::size_t> & localEdgeIds,
const ArrayT & edgeValues,
double scaleValue=1.0);
946 template <
typename ArrayT>
947 void setFaceFieldData(
const std::string & fieldName,
const std::string & blockId,
948 const std::vector<std::size_t> & localFaceIds,
const ArrayT & faceValues,
double scaleValue=1.0);
960 template <
typename ArrayT>
961 void getElementVertices(
const std::vector<std::size_t> & localIds, ArrayT & vertices)
const;
971 template <
typename ArrayT>
972 void getElementVertices(
const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices)
const;
983 template <
typename ArrayT>
984 void getElementVertices(
const std::vector<std::size_t> & localIds,
const std::string & eBlock, ArrayT & vertices)
const;
995 template <
typename ArrayT>
996 void getElementVertices(
const std::vector<stk::mesh::Entity> & elements,
const std::string & eBlock, ArrayT & vertices)
const;
1006 template <
typename ArrayT>
1017 template <
typename ArrayT>
1029 template <
typename ArrayT>
1030 void getElementVerticesNoResize(
const std::vector<std::size_t> & localIds,
const std::string & eBlock, ArrayT & vertices)
const;
1041 template <
typename ArrayT>
1042 void getElementVerticesNoResize(
const std::vector<stk::mesh::Entity> & elements,
const std::string & eBlock, ArrayT & vertices)
const;
1055 template <
typename ArrayT>
1056 void getElementNodes(
const std::vector<std::size_t> & localIds, ArrayT & nodes)
const;
1066 template <
typename ArrayT>
1067 void getElementNodes(
const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes)
const;
1078 template <
typename ArrayT>
1079 void getElementNodes(
const std::vector<std::size_t> & localIds,
const std::string & eBlock, ArrayT & nodes)
const;
1090 template <
typename ArrayT>
1091 void getElementNodes(
const std::vector<stk::mesh::Entity> & elements,
const std::string & eBlock, ArrayT & nodes)
const;
1101 template <
typename ArrayT>
1112 template <
typename ArrayT>
1124 template <
typename ArrayT>
1125 void getElementNodesNoResize(
const std::vector<std::size_t> & localIds,
const std::string & eBlock, ArrayT & nodes)
const;
1136 template <
typename ArrayT>
1137 void getElementNodesNoResize(
const std::vector<stk::mesh::Entity> & elements,
const std::string & eBlock, ArrayT & nodes)
const;
1144 stk::mesh::EntityRank
getFaceRank()
const {
return stk::topology::FACE_RANK; }
1145 stk::mesh::EntityRank
getEdgeRank()
const {
return stk::topology::EDGE_RANK; }
1146 stk::mesh::EntityRank
getNodeRank()
const {
return stk::topology::NODE_RANK; }
1166 const std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > &
1172 std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > &
1212 void print(std::ostream & os)
const;
1284 template <
typename ArrayT>
1285 void getElementVertices_FromField(
const std::vector<stk::mesh::Entity> & elements,
const std::string & eBlock, ArrayT & vertices)
const;
1287 template <
typename ArrayT>
1289 const std::string & eBlock, ArrayT & vertices)
const;
1300 template <
typename ArrayT>
1303 template <
typename ArrayT>
1318 template <
typename ArrayT>
1319 void getElementNodes_FromField(
const std::vector<stk::mesh::Entity> & elements,
const std::string & eBlock, ArrayT & nodes)
const;
1321 template <
typename ArrayT>
1323 const std::string & eBlock, ArrayT & nodes)
const;
1334 template <
typename ArrayT>
1337 template <
typename ArrayT>
1345 void refineMesh(
const int numberOfLevels,
const bool deleteParentElements);
1387 bool isMeshCoordField(
const std::string & eBlock,
const std::string & fieldName,
int & axis)
const;
1404 template <
typename ArrayT>
1405 void setDispFieldData(
const std::string & fieldName,
const std::string & blockId,
int axis,
1406 const std::vector<std::size_t> & localElementIds,
const ArrayT & solutionValues);
1413 #ifdef PANZER_HAVE_PERCEPT
1467 #ifdef PANZER_HAVE_IOSS
1476 enum class GlobalVariable
1500 const GlobalVariable& flag);
1549 template <
typename ArrayT>
1551 const std::vector<std::size_t> & localElementIds,
const ArrayT & solutionValues,
double scaleValue)
1554 auto solutionValues_h = Kokkos::create_mirror_view(solutionValues);
1555 Kokkos::deep_copy(solutionValues_h, solutionValues);
1557 int field_axis = -1;
1559 setDispFieldData(fieldName,blockId,field_axis,localElementIds,solutionValues_h);
1565 for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1566 std::size_t localId = localElementIds[cell];
1567 stk::mesh::Entity element = elements[localId];
1570 const size_t num_nodes =
bulkData_->num_nodes(element);
1571 stk::mesh::Entity
const* nodes =
bulkData_->begin_nodes(element);
1572 for(std::size_t i=0; i<num_nodes; ++i) {
1573 stk::mesh::Entity node = nodes[i];
1575 double * solnData = stk::mesh::field_data(*field,node);
1577 solnData[0] = scaleValue*solutionValues_h(cell,i);
1582 template <
typename ArrayT>
1584 const std::vector<std::size_t> & localElementIds,
const ArrayT & dispValues)
1593 for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1594 std::size_t localId = localElementIds[cell];
1595 stk::mesh::Entity element = elements[localId];
1598 const size_t num_nodes =
bulkData_->num_nodes(element);
1599 stk::mesh::Entity
const* nodes =
bulkData_->begin_nodes(element);
1600 for(std::size_t i=0; i<num_nodes; ++i) {
1601 stk::mesh::Entity node = nodes[i];
1603 double * solnData = stk::mesh::field_data(*field,node);
1604 double * coordData = stk::mesh::field_data(coord_field,node);
1606 solnData[0] = dispValues(cell,i)-coordData[axis];
1611 template <
typename ArrayT>
1613 const std::vector<std::size_t> & localElementIds,ArrayT & solutionValues)
const
1619 localElementIds.size(),
1620 bulkData_->num_nodes(elements[localElementIds[0]]));
1624 for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1625 std::size_t localId = localElementIds[cell];
1626 stk::mesh::Entity element = elements[localId];
1629 const size_t num_nodes =
bulkData_->num_nodes(element);
1630 stk::mesh::Entity
const* nodes =
bulkData_->begin_nodes(element);
1631 for(std::size_t i=0; i<num_nodes; ++i) {
1632 stk::mesh::Entity node = nodes[i];
1634 double * solnData = stk::mesh::field_data(*field,node);
1636 solutionValues(cell,i) = solnData[0];
1641 template <
typename ArrayT>
1643 const std::vector<std::size_t> & localElementIds,
const ArrayT & solutionValues,
double scaleValue)
1649 auto solutionValues_h = Kokkos::create_mirror_view(solutionValues);
1650 Kokkos::deep_copy(solutionValues_h, solutionValues);
1652 for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1653 std::size_t localId = localElementIds[cell];
1654 stk::mesh::Entity element = elements[localId];
1656 double * solnData = stk::mesh::field_data(*field,element);
1658 solnData[0] = scaleValue*solutionValues_h.access(cell,0);
1662 template <
typename ArrayT>
1664 const std::vector<std::size_t> & localEdgeIds,
const ArrayT & edgeValues,
double scaleValue)
1670 auto edgeValues_h = Kokkos::create_mirror_view(edgeValues);
1671 Kokkos::deep_copy(edgeValues_h, edgeValues);
1673 for(std::size_t idx=0;idx<localEdgeIds.size();idx++) {
1674 std::size_t localId = localEdgeIds[idx];
1675 stk::mesh::Entity edge = edges[localId];
1677 double * solnData = stk::mesh::field_data(*field,edge);
1679 solnData[0] = scaleValue*edgeValues_h.access(idx,0);
1683 template <
typename ArrayT>
1685 const std::vector<std::size_t> & localFaceIds,
const ArrayT & faceValues,
double scaleValue)
1691 auto faceValues_h = Kokkos::create_mirror_view(faceValues);
1692 Kokkos::deep_copy(faceValues_h, faceValues);
1694 for(std::size_t idx=0;idx<localFaceIds.size();idx++) {
1695 std::size_t localId = localFaceIds[idx];
1696 stk::mesh::Entity face = faces[localId];
1698 double * solnData = stk::mesh::field_data(*field,face);
1700 solnData[0] = scaleValue*faceValues_h.access(idx,0);
1706 template <
typename ArrayT>
1717 std::vector<stk::mesh::Entity> selected_elements;
1718 for(std::size_t cell=0;cell<localElementIds.size();cell++)
1719 selected_elements.push_back(elements[localElementIds[cell]]);
1725 "STK_Interface::getElementVertices: Cannot call this method when field coordinates are used "
1726 "without specifying an element block.");
1730 template <
typename ArrayT>
1738 "STK_Interface::getElementVertices: Cannot call this method when field coordinates are used "
1739 "without specifying an element block.");
1743 template <
typename ArrayT>
1754 template <
typename ArrayT>
1760 std::vector<stk::mesh::Entity> selected_elements;
1761 for(std::size_t cell=0;cell<localElementIds.size();cell++)
1762 selected_elements.push_back(elements[localElementIds[cell]]);
1772 template <
typename ArrayT>
1783 std::vector<stk::mesh::Entity> selected_elements;
1784 for(std::size_t cell=0;cell<localElementIds.size();cell++)
1785 selected_elements.push_back(elements[localElementIds[cell]]);
1791 "STK_Interface::getElementVerticesNoResize: Cannot call this method when field coordinates are used "
1792 "without specifying an element block.");
1796 template <
typename ArrayT>
1804 "STK_Interface::getElementVerticesNoResize: Cannot call this method when field coordinates are used "
1805 "without specifying an element block.");
1809 template <
typename ArrayT>
1820 template <
typename ArrayT>
1826 std::vector<stk::mesh::Entity> selected_elements;
1827 for(std::size_t cell=0;cell<localElementIds.size();cell++)
1828 selected_elements.push_back(elements[localElementIds[cell]]);
1838 template <
typename ArrayT>
1842 if(elements.size() == 0) {
1852 const auto masterVertexCount
1853 = stk::mesh::get_cell_topology(
bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1857 auto vertices_h = Kokkos::create_mirror_view(vertices);
1858 Kokkos::deep_copy(vertices_h, vertices);
1862 for(std::size_t cell = 0; cell < elements.size(); cell++) {
1863 const auto element = elements[cell];
1866 const auto vertexCount
1867 = stk::mesh::get_cell_topology(
bulkData_->bucket(element).topology()).getCellTopologyData()->vertex_count;
1869 "In call to STK_Interface::getElementVertices all elements "
1870 "must have the same vertex count!");
1873 const size_t num_nodes =
bulkData_->num_nodes(element);
1874 auto const* nodes =
bulkData_->begin_nodes(element);
1876 "In call to STK_Interface::getElementVertices cardinality of "
1877 "element node relations must be the vertex count!");
1878 for(std::size_t node = 0; node < num_nodes; ++node) {
1882 for(
unsigned d=0;d<dim;d++)
1883 vertices_h(cell,node,d) = coord[d];
1886 Kokkos::deep_copy(vertices, vertices_h);
1889 template <
typename ArrayT>
1893 if(elements.size()==0) {
1902 unsigned masterVertexCount
1903 = stk::mesh::get_cell_topology(
bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1907 auto vertices_h = Kokkos::create_mirror_view(vertices);
1908 for(std::size_t cell=0;cell<elements.size();cell++) {
1909 stk::mesh::Entity element = elements[cell];
1912 unsigned vertexCount
1913 = stk::mesh::get_cell_topology(
bulkData_->bucket(element).topology()).getCellTopologyData()->vertex_count;
1915 "In call to STK_Interface::getElementVertices all elements "
1916 "must have the same vertex count!");
1919 const size_t num_nodes =
bulkData_->num_nodes(element);
1920 stk::mesh::Entity
const* nodes =
bulkData_->begin_nodes(element);
1922 "In call to STK_Interface::getElementVertices cardinality of "
1923 "element node relations must be the vertex count!");
1924 for(std::size_t node=0; node<num_nodes; ++node) {
1928 for(
unsigned d=0;d<dim;d++)
1929 vertices_h(cell,node,d) = coord[d];
1932 Kokkos::deep_copy(vertices, vertices_h);
1935 template <
typename ArrayT>
1941 if(elements.size()==0) {
1947 unsigned masterVertexCount
1948 = stk::mesh::get_cell_topology(
bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1952 auto vertices_h = Kokkos::create_mirror_view(vertices);
1953 std::map<std::string,std::vector<std::string> >::const_iterator itr =
meshCoordFields_.find(eBlock);
1959 const std::vector<std::string> & coordField = itr->second;
1960 std::vector<SolutionFieldType*> fields(
getDimension());
1961 for(std::size_t d=0;d<fields.size();d++) {
1965 for(std::size_t cell=0;cell<elements.size();cell++) {
1966 stk::mesh::Entity element = elements[cell];
1969 const size_t num_nodes =
bulkData_->num_nodes(element);
1970 stk::mesh::Entity
const* nodes =
bulkData_->begin_nodes(element);
1971 for(std::size_t i=0; i<num_nodes; ++i) {
1972 stk::mesh::Entity node = nodes[i];
1977 double * solnData = stk::mesh::field_data(*fields[d],node);
1981 vertices_h(cell,i,d) = solnData[0]+coord[d];
1985 Kokkos::deep_copy(vertices, vertices_h);
1988 template <
typename ArrayT>
1990 const std::string & eBlock, ArrayT & vertices)
const
1995 if(elements.size()==0) {
1999 std::map<std::string,std::vector<std::string> >::const_iterator itr =
meshCoordFields_.find(eBlock);
2005 const std::vector<std::string> & coordField = itr->second;
2006 std::vector<SolutionFieldType*> fields(
getDimension());
2007 for(std::size_t d=0;d<fields.size();d++) {
2011 for(std::size_t cell=0;cell<elements.size();cell++) {
2012 stk::mesh::Entity element = elements[cell];
2015 const size_t num_nodes =
bulkData_->num_nodes(element);
2016 stk::mesh::Entity
const* nodes =
bulkData_->begin_nodes(element);
2017 for(std::size_t i=0; i<num_nodes; ++i) {
2018 stk::mesh::Entity node = nodes[i];
2023 double * solnData = stk::mesh::field_data(*fields[d],node);
2027 vertices(cell,i,d) = solnData[0]+coord[d];
2035 template <
typename ArrayT>
2046 std::vector<stk::mesh::Entity> selected_elements;
2047 for(std::size_t cell=0;cell<localElementIds.size();cell++)
2048 selected_elements.push_back(elements[localElementIds[cell]]);
2054 "STK_Interface::getElementNodes: Cannot call this method when field coordinates are used "
2055 "without specifying an element block.");
2059 template <
typename ArrayT>
2067 "STK_Interface::getElementNodes: Cannot call this method when field coordinates are used "
2068 "without specifying an element block.");
2072 template <
typename ArrayT>
2083 template <
typename ArrayT>
2089 std::vector<stk::mesh::Entity> selected_elements;
2090 for(std::size_t cell=0;cell<localElementIds.size();cell++)
2091 selected_elements.push_back(elements[localElementIds[cell]]);
2101 template <
typename ArrayT>
2112 std::vector<stk::mesh::Entity> selected_elements;
2113 for(std::size_t cell=0;cell<localElementIds.size();cell++)
2114 selected_elements.push_back(elements[localElementIds[cell]]);
2120 "STK_Interface::getElementNodesNoResize: Cannot call this method when field coordinates are used "
2121 "without specifying an element block.");
2125 template <
typename ArrayT>
2133 "STK_Interface::getElementNodesNoResize: Cannot call this method when field coordinates are used "
2134 "without specifying an element block.");
2138 template <
typename ArrayT>
2149 template <
typename ArrayT>
2155 std::vector<stk::mesh::Entity> selected_elements;
2156 for(std::size_t cell=0;cell<localElementIds.size();cell++)
2157 selected_elements.push_back(elements[localElementIds[cell]]);
2167 template <
typename ArrayT>
2171 if(elements.size() == 0) {
2181 const auto masterNodeCount
2182 = stk::mesh::get_cell_topology(
bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->node_count;
2186 auto nodes_h = Kokkos::create_mirror_view(nodes);
2187 Kokkos::deep_copy(nodes_h, nodes);
2191 for(std::size_t cell = 0; cell < elements.size(); cell++) {
2192 const auto element = elements[cell];
2195 const auto nodeCount
2196 = stk::mesh::get_cell_topology(
bulkData_->bucket(element).topology()).getCellTopologyData()->node_count;
2198 "In call to STK_Interface::getElementNodes all elements "
2199 "must have the same node count!");
2202 const size_t num_nodes =
bulkData_->num_nodes(element);
2203 auto const* elem_nodes =
bulkData_->begin_nodes(element);
2205 "In call to STK_Interface::getElementNodes cardinality of "
2206 "element node relations must be the node count!");
2207 for(std::size_t node = 0; node < num_nodes; ++node) {
2211 for(
unsigned d=0;d<dim;d++)
2212 nodes_h(cell,node,d) = coord[d];
2215 Kokkos::deep_copy(nodes, nodes_h);
2218 template <
typename ArrayT>
2222 if(elements.size()==0) {
2231 unsigned masterNodeCount
2232 = stk::mesh::get_cell_topology(
bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->node_count;
2236 auto nodes_h = Kokkos::create_mirror_view(nodes);
2237 for(std::size_t cell=0;cell<elements.size();cell++) {
2238 stk::mesh::Entity element = elements[cell];
2242 = stk::mesh::get_cell_topology(
bulkData_->bucket(element).topology()).getCellTopologyData()->node_count;
2244 "In call to STK_Interface::getElementNodes all elements "
2245 "must have the same node count!");
2248 const size_t num_nodes =
bulkData_->num_nodes(element);
2249 stk::mesh::Entity
const* elem_nodes =
bulkData_->begin_nodes(element);
2251 "In call to STK_Interface::getElementNodes cardinality of "
2252 "element node relations must be the node count!");
2253 for(std::size_t node=0; node<num_nodes; ++node) {
2257 for(
unsigned d=0;d<dim;d++)
2258 nodes_h(cell,node,d) = coord[d];
2261 Kokkos::deep_copy(nodes, nodes_h);
2264 template <
typename ArrayT>
2270 if(elements.size()==0) {
2276 unsigned masterNodeCount
2277 = stk::mesh::get_cell_topology(
bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->node_count;
2281 auto nodes_h = Kokkos::create_mirror_view(nodes);
2282 std::map<std::string,std::vector<std::string> >::const_iterator itr =
meshCoordFields_.find(eBlock);
2288 const std::vector<std::string> & coordField = itr->second;
2289 std::vector<SolutionFieldType*> fields(
getDimension());
2290 for(std::size_t d=0;d<fields.size();d++) {
2295 for(std::size_t cell=0;cell<elements.size();cell++) {
2296 stk::mesh::Entity element = elements[cell];
2299 const size_t num_nodes =
bulkData_->num_nodes(element);
2300 stk::mesh::Entity
const* elem_nodes =
bulkData_->begin_nodes(element);
2301 for(std::size_t i=0; i<num_nodes; ++i) {
2302 stk::mesh::Entity node = elem_nodes[i];
2307 double * solnData = stk::mesh::field_data(*fields[d],node);
2311 nodes_h(cell,i,d) = solnData[0]+coord[d];
2315 Kokkos::deep_copy(nodes, nodes_h);
2318 template <
typename ArrayT>
2320 const std::string & eBlock, ArrayT & nodes)
const
2325 if(elements.size()==0) {
2329 std::map<std::string,std::vector<std::string> >::const_iterator itr =
meshCoordFields_.find(eBlock);
2335 const std::vector<std::string> & coordField = itr->second;
2336 std::vector<SolutionFieldType*> fields(
getDimension());
2337 for(std::size_t d=0;d<fields.size();d++) {
2342 for(std::size_t cell=0;cell<elements.size();cell++) {
2343 stk::mesh::Entity element = elements[cell];
2346 const size_t num_nodes =
bulkData_->num_nodes(element);
2347 stk::mesh::Entity
const* elem_nodes =
bulkData_->begin_nodes(element);
2348 for(std::size_t i=0; i<num_nodes; ++i) {
2349 stk::mesh::Entity node = elem_nodes[i];
2354 double * solnData = stk::mesh::field_data(*fields[d],node);
2358 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 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_