41 #ifndef DTK_STKMESHHELPERS_IMPL_HPP 42 #define DTK_STKMESHHELPERS_IMPL_HPP 45 #include <unordered_set> 49 #include <stk_mesh/base/Field.hpp> 50 #include <stk_mesh/base/FieldBase.hpp> 51 #include <stk_mesh/base/MetaData.hpp> 52 #include <stk_topology/topology.hpp> 59 template <
class FieldType>
60 Intrepid::FieldContainer<double> STKMeshHelpers::extractEntityNodeCoordinates(
61 const Teuchos::Array<stk::mesh::Entity> &stk_entities,
62 const stk::mesh::BulkData &bulk_data,
const int space_dim )
65 const stk::mesh::FieldBase *coord_field_base =
66 bulk_data.mesh_meta_data().coordinate_field();
67 const stk::mesh::Field<double, FieldType> *coord_field =
68 dynamic_cast<const stk::mesh::Field<double, FieldType> *
>(
72 int num_cells = stk_entities.size();
74 stk::mesh::EntityRank stk_rank = stk::topology::INVALID_RANK;
77 stk_rank = bulk_data.entity_rank( stk_entities[0] );
78 if ( stk::topology::NODE_RANK == stk_rank )
84 const stk::mesh::Entity *begin =
85 bulk_data.begin_nodes( stk_entities[0] );
86 const stk::mesh::Entity *end =
87 bulk_data.end_nodes( stk_entities[0] );
88 num_nodes = std::distance( begin, end );
91 Intrepid::FieldContainer<double> coords( num_cells, num_nodes, space_dim );
94 double *node_coords = 0;
95 for (
int c = 0; c < num_cells; ++c )
97 if ( stk::topology::NODE_RANK == stk_rank )
100 stk::mesh::field_data( *coord_field, stk_entities[c] );
101 for (
int d = 0; d < space_dim; ++d )
103 coords( c, 0, d ) = node_coords[d];
108 const stk::mesh::Entity *begin =
109 bulk_data.begin_nodes( stk_entities[c] );
110 DTK_REMEMBER(
const stk::mesh::Entity *end =
111 bulk_data.end_nodes( stk_entities[c] ) );
112 DTK_CHECK( std::distance( begin, end ) == num_nodes );
113 for (
int n = 0; n < num_nodes; ++n )
115 node_coords = stk::mesh::field_data( *coord_field, begin[n] );
116 for (
int d = 0; d < space_dim; ++d )
118 coords( c, n, d ) = node_coords[d];
131 #endif // end DTK_STKMESHHELPERS_IMPL_HPP Assertions and Design-by-Contract for error handling.