9 #include <stk_util/unit_test_support/stk_utest_macros.hpp> 11 #include <stk_util/parallel/Parallel.hpp> 13 #include <stk_mesh/base/MetaData.hpp> 14 #include <stk_mesh/base/BulkData.hpp> 15 #include <stk_mesh/base/Entity.hpp> 16 #include <stk_mesh/base/GetEntities.hpp> 17 #include <stk_mesh/base/Selector.hpp> 18 #include <stk_mesh/base/GetBuckets.hpp> 19 #include <stk_mesh/base/Comm.hpp> 21 #include <stk_mesh/fem/BoundaryAnalysis.hpp> 22 #include <stk_mesh/fem/SkinMesh.hpp> 23 #include <stk_mesh/fem/FEMHelpers.hpp> 25 #include <stk_mesh/fixtures/GridFixture.hpp> 27 #include <stk_util/parallel/ParallelReduce.hpp> 29 #include <Shards_BasicTopologies.hpp> 34 static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK;
36 class UnitTestStkMeshSkinning {
53 STKUNIT_UNIT_TEST( UnitTestStkMeshSkinning , testUnit )
55 UnitTestStkMeshSkinning unit(MPI_COMM_WORLD);
59 STKUNIT_UNIT_TEST( UnitTestStkMeshSkinning , testSingleShell )
61 const int spatial_dimension = 3;
63 fem_meta.
FEM_initialize(spatial_dimension, stk_classic::mesh::fem::entity_rank_names(spatial_dimension));
66 const stk_classic::mesh::EntityRank element_rank = fem_meta.
element_rank();
68 const unsigned p_rank = bulk_data.parallel_rank();
72 stk_classic::mesh::fem::CellTopology shell_top(shards::getCellTopologyData<shards::ShellQuadrilateral<4> >());
77 bulk_data.modification_begin();
81 stk_classic::mesh::EntityId elem_node[4] ;
89 stk_classic::mesh::EntityId elem_id = 1;
94 bulk_data.modification_end();
97 stk_classic::mesh::skin_mesh( bulk_data, element_rank, &skin_part);
100 const unsigned mesh_rank = element_rank;
103 const std::vector<stk_classic::mesh::Bucket*>& buckets = bulk_data.buckets( mesh_rank -1);
111 STKUNIT_ASSERT_EQUAL( num_skin_entities, 2 );
117 void UnitTestStkMeshSkinning::test_skinning()
120 if (m_num_procs > 1) {
124 stk_classic::mesh::fixtures::GridFixture grid_mesh(MPI_COMM_WORLD);
128 const stk_classic::mesh::EntityRank element_rank = fem_meta.
element_rank();
132 stk_classic::mesh::fem::CellTopology line_top(shards::getCellTopologyData<shards::ShellLine<2> >());
137 grid_mesh.bulk_data().modification_begin();
140 grid_mesh.generate_grid();
143 std::vector<unsigned>
count;
146 const unsigned num_shell_1_faces = 4;
147 const unsigned num_shell_2_faces = 2;
148 const unsigned num_shell_faces = num_shell_1_faces + num_shell_2_faces;
149 const unsigned num_entities =
count[NODE_RANK] +
153 shell_parts.push_back(&shell_part);
155 std::vector<stk_classic::mesh::Entity*> shell_faces;
156 for (
unsigned i = 1; i <= num_shell_faces; ++i) {
160 shell_faces.push_back(&new_shell);
166 unsigned node_list_1[5] = {21, 26, 31, 36, 41};
167 for (
unsigned i = 0; i < num_shell_1_faces; ++i) {
176 unsigned node_list_2[3] = {31, 36, 41};
177 for (
unsigned i = 0; i < num_shell_2_faces; ++i) {
185 grid_mesh.bulk_data().modification_end();
188 stk_classic::mesh::skin_mesh(bulk_data, element_rank, &skin_part);
192 const std::vector<stk_classic::mesh::Bucket*>& edge_buckets = bulk_data.
buckets(fem_meta.
edge_rank());
193 std::vector<stk_classic::mesh::Entity*> skin_entities;
196 unsigned num_expected_skin_entites = 16;
197 STKUNIT_EXPECT_EQUAL(num_expected_skin_entites, skin_entities.size());
201 std::map<unsigned, unsigned> results;
202 std::map<unsigned, unsigned> expected_results;
204 expected_results[1] = 2;
205 expected_results[2] = 1;
206 expected_results[3] = 1;
207 expected_results[4] = 1;
208 expected_results[5] = 1;
209 expected_results[9] = 1;
210 expected_results[13] = 2;
211 expected_results[14] = 1;
212 expected_results[15] = 1;
213 expected_results[16] = 1;
214 expected_results[42] = 1;
215 expected_results[43] = 1;
216 expected_results[44] = 1;
217 expected_results[45] = 1;
218 expected_results[46] = 1;
219 expected_results[47] = 1;
223 std::set<std::set<unsigned> > sharing;
224 std::set<std::set<unsigned> > expected_sharing;
226 std::set<unsigned> temp;
229 expected_sharing.insert(temp);
234 expected_sharing.insert(temp);
238 for (std::vector<stk_classic::mesh::Entity*>::const_iterator
239 itr = skin_entities.begin(); itr != skin_entities.end(); ++itr) {
241 (*itr)->relations(element_rank);
242 bool has_multiple = upward_relation_itr.size() > 1;
243 std::set<unsigned> sharing_elements;
244 for ( ; !upward_relation_itr.empty() ; ++upward_relation_itr ) {
245 unsigned elem_id = upward_relation_itr->entity()->identifier();
246 if (results.find(elem_id) != results.end()) {
250 results[elem_id] = 1;
254 sharing_elements.insert(elem_id);
258 sharing.insert(sharing_elements);
262 STKUNIT_EXPECT_TRUE(results == expected_results);
263 STKUNIT_EXPECT_TRUE(sharing == expected_sharing);
void declare_relation(Entity &e_from, Entity &e_to, const RelationIdentifier local_id)
Declare a relation and its converse between entities in the same mesh.
unsigned count_selected_entities(const Selector &selector, const std::vector< Bucket * > &input_buckets)
Count entities in selected buckets (selected by the given selector instance), and sorted by ID...
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...
This is a class for selecting buckets based on a set of meshparts and set logic.
const std::vector< Bucket * > & buckets(EntityRank rank) const
Query all buckets of a given entity rank.
Entity * get_entity(EntityRank entity_rank, EntityId entity_id) const
Get entity with a given key.
An application-defined subset of a problem domain.
void get_selected_entities(const Selector &selector, const std::vector< Bucket * > &input_buckets, std::vector< Entity * > &entities)
Get entities in selected buckets (selected by the given selector instance), and sorted by ID...
unsigned parallel_machine_rank(ParallelMachine parallel_machine)
Member function parallel_machine_rank ...
unsigned parallel_machine_size(ParallelMachine parallel_machine)
Member function parallel_machine_size ...
Manager for an integrated collection of entities, entity relations, and buckets of field data...
A fundamental unit within the discretization of a problem domain, including but not limited to nodes...
void count_entities(const Selector &selector, const BulkData &mesh, std::vector< EntityRank > &count)
Local count selected entities of each type.
Entity & declare_entity(EntityRank ent_rank, EntityId ent_id, const PartVector &parts)
Create or retrieve a locally owned entity of a given rank and id.
std::vector< Part *> PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
void all_reduce(ParallelMachine, const ReduceOp &)
eastl::iterator_traits< InputIterator >::difference_type count(InputIterator first, InputIterator last, const T &value)