11 #include <stk_util/environment/ReportHandler.hpp> 13 #include <stk_mesh/fixtures/HexFixture.hpp> 15 #include <stk_mesh/base/FieldData.hpp> 16 #include <stk_mesh/base/Types.hpp> 17 #include <stk_mesh/base/Entity.hpp> 18 #include <stk_mesh/base/BulkModification.hpp> 20 #include <stk_mesh/fem/Stencils.hpp> 21 #include <stk_mesh/fem/FEMHelpers.hpp> 22 #include <stk_mesh/fem/BoundaryAnalysis.hpp> 29 : m_spatial_dimension(3),
33 m_fem_meta( m_spatial_dimension, fem::entity_rank_names(m_spatial_dimension) ),
34 m_bulk_data(
stk_classic::mesh::fem::FEMMetaData::get_meta_data(m_fem_meta) , pm ),
35 m_hex_part( fem::
declare_part<shards::Hexahedron<8> >(m_fem_meta,
"hex_part") ),
36 m_node_part( m_fem_meta.
declare_part(
"node_part", m_fem_meta.node_rank() ) ),
37 m_coord_field( m_fem_meta.declare_field<
CoordFieldType>(
"Coordinates") ),
40 typedef shards::Hexahedron<8> Hex8 ;
41 const unsigned nodes_per_elem = Hex8::node_count;
46 fem::FEMMetaData::NODE_RANK,
60 fem::element_node_stencil<Hex8, 3>,
66 std::vector<EntityId> element_ids_on_this_processor;
70 const unsigned num_elems = m_nx * m_ny * m_nz ;
72 const EntityId beg_elem = 1 + ( num_elems * p_rank ) / p_size ;
73 const EntityId end_elem = 1 + ( num_elems * ( p_rank + 1 ) ) / p_size ;
75 for ( EntityId i = beg_elem; i != end_elem; ++i) {
76 element_ids_on_this_processor.push_back(i);
112 std::vector<EntityId>::iterator ib = element_ids_on_this_processor.begin();
113 std::vector<EntityId>::iterator ie = element_ids_on_this_processor.end();
116 ib = std::unique( ib, ie);
117 element_ids_on_this_processor.erase(ib, ie);
126 add_parts.push_back(&m_node_part);
128 std::vector<EntityId>::iterator ib = element_ids_on_this_processor.begin();
129 const std::vector<EntityId>::iterator ie = element_ids_on_this_processor.end();
130 for (; ib != ie; ++ib) {
132 unsigned ix = 0, iy = 0, iz = 0;
135 stk_classic::mesh::EntityId elem_node[8] ;
137 elem_node[0] =
node_id( ix , iy , iz );
138 elem_node[1] =
node_id( ix+1 , iy , iz );
139 elem_node[2] =
node_id( ix+1 , iy , iz+1 );
140 elem_node[3] =
node_id( ix , iy , iz+1 );
141 elem_node[4] =
node_id( ix , iy+1 , iz );
142 elem_node[5] =
node_id( ix+1 , iy+1 , iz );
143 elem_node[6] =
node_id( ix+1 , iy+1 , iz+1 );
144 elem_node[7] =
node_id( ix , iy+1 , iz+1 );
148 for (
unsigned i = 0; i<8; ++i) {
152 ThrowRequireMsg(
node != NULL,
153 "This process should know about the nodes that make up its element");
156 unsigned nx = 0, ny = 0, nz = 0;
163 data[2] = -(Scalar)nz ;
FieldTraits< field_type >::data_type * field_data(const field_type &f, const Bucket::iterator i)
Pointer to the field data array.
Entity & declare_element(BulkData &mesh, Part &part, const EntityId elem_id, const EntityId node_id[])
Declare an element member of a Part with a CellTopology and nodes conformal to that topology...
EntityId elem_id(unsigned x, unsigned y, unsigned z) const
field_type & put_field(field_type &field, EntityRank entity_rank, const Part &part, const void *init_value=NULL)
Declare a field to exist for a given entity type and Part.
Entity * get_entity(EntityRank entity_rank, EntityId entity_id) const
Get entity with a given key.
Field with defined data type and multi-dimensions (if any)
void change_entity_parts(Entity &entity, const PartVector &add_parts, const PartVector &remove_parts=PartVector())
Change the parallel-locally-owned entity's part membership by adding and/or removing parts...
bool modification_end()
Parallel synchronization of modifications and transition to the guaranteed parallel consistent state...
unsigned parallel_size() const
Size of the parallel machine.
bool modification_begin()
Begin a modification phase during which the mesh bulk data could become parallel inconsistent. This is a parallel synchronous call. The first time this method is called the mesh meta data is verified to be committed and parallel consistent. An exception is thrown if this verification fails.
void elem_x_y_z(EntityId entity_id, unsigned &x, unsigned &y, unsigned &z) const
EntityId entity_id(const EntityKey &key)
Given an entity key, return the identifier for the entity.
A fundamental unit within the discretization of a problem domain, including but not limited to nodes...
Part & declare_part(FEMMetaData &meta_data, const std::string &name)
Declare a part with a given cell topology. This is just a convenient function that wraps FEMMetaData'...
EntityId node_id(unsigned x, unsigned y, unsigned z) const
void node_x_y_z(EntityId entity_id, unsigned &x, unsigned &y, unsigned &z) const
unsigned parallel_rank() const
Rank of the parallel machine's local processor.
std::vector< Part *> PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
Entity * node(unsigned x, unsigned y, unsigned z) const