12 #include <stk_util/unit_test_support/stk_utest_macros.hpp> 14 #include <Shards_BasicTopologies.hpp> 16 #include <stk_util/parallel/Parallel.hpp> 18 #include <stk_mesh/base/Types.hpp> 19 #include <stk_mesh/base/MetaData.hpp> 20 #include <stk_mesh/base/BulkData.hpp> 21 #include <stk_mesh/base/Entity.hpp> 22 #include <stk_mesh/base/GetEntities.hpp> 23 #include <stk_mesh/base/GetBuckets.hpp> 24 #include <stk_mesh/base/Selector.hpp> 25 #include <stk_mesh/base/Field.hpp> 26 #include <stk_mesh/base/DataTraits.hpp> 28 #include <stk_mesh/fem/FEMMetaData.hpp> 29 #include <stk_mesh/fem/FEMHelpers.hpp> 30 #include <stk_mesh/fem/TopologyDimensions.hpp> 31 #include <stk_mesh/fem/SkinMesh.hpp> 33 #include <stk_util/parallel/ParallelReduce.hpp> 37 using stk_classic::mesh::EntityId;
38 using stk_classic::mesh::EntityRank;
42 STKUNIT_UNIT_TEST( UnitTestSkin, SkinPocket)
44 enum { SpatialDim = 3 };
51 fem_meta.
FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim));
54 stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
57 const EntityRank side_rank = fem_meta.
side_rank();
74 bulk_data.modification_begin();
79 EntityId element_id = 1;
80 EntityId node_ids[8] = { 1, 2, 3, 4, 5, 6, 7, 8};
87 if (p_rank == p_size -1)
89 EntityId element_id = 2;
90 EntityId node_ids[8] = { 2, 9, 10, 3, 13, 11, 12, 7};
95 bulk_data.modification_end();
98 stk_classic::mesh::skin_mesh(bulk_data, element_rank);
101 for (EntityId element_id = 1; element_id < 3; ++element_id) {
103 if ( element != NULL) {
105 STKUNIT_EXPECT_TRUE( element_side_relations.size() == 6);
110 STKUNIT_UNIT_TEST( UnitTestSkin, SkinTwoStackedShells)
112 enum { SpatialDim = 3 };
119 fem_meta.
FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim));
122 stk_classic::mesh::fem::CellTopology shell_top(shards::getCellTopologyData<shards::ShellQuadrilateral<4> >());
124 const EntityRank element_rank = fem_meta.
element_rank();
125 const EntityRank side_rank = fem_meta.
side_rank();
144 EntityId node_ids[4] = { 1, 2, 3, 4};
146 bulk_data.modification_begin();
149 bool create_shell_on_proc =
static_cast<int>(p_rank) == 0;
150 if (create_shell_on_proc) {
151 EntityId element_id =
static_cast<EntityId
>(1);
157 bool create_shell_on_proc =
static_cast<int>(p_rank) == (std::max(0,static_cast<int>(p_size)-1));
158 if (create_shell_on_proc) {
159 EntityId element_id =
static_cast<EntityId
>(2);
164 bulk_data.modification_end();
167 stk_classic::mesh::skin_mesh(bulk_data, element_rank);
172 const std::vector<stk_classic::mesh::Bucket*>& side_buckets = bulk_data.buckets(side_rank);
180 STKUNIT_ASSERT_EQUAL( num_sides, 2 );
185 STKUNIT_UNIT_TEST( UnitTestSkin, SkinStackedShells)
187 enum { SpatialDim = 3 };
194 fem_meta.
FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim));
197 stk_classic::mesh::fem::CellTopology shell_top(shards::getCellTopologyData<shards::ShellQuadrilateral<4> >());
199 const EntityRank element_rank = fem_meta.
element_rank();
200 const EntityRank side_rank = fem_meta.
side_rank();
225 EntityId node_ids[8] = { 1, 2, 3, 4, 1, 2, 3, 4};
226 EntityId reverse_node_ids[8] = { 4, 3, 2, 1, 4, 3, 2, 1};
228 bulk_data.modification_begin();
231 for (
int i = 0; i<4; i++ ) {
233 bool create_shell_on_proc =
static_cast<int>(p_rank) == (std::max(0,static_cast<int>(p_size)-1-i));
234 if (create_shell_on_proc) {
235 EntityId element_id =
static_cast<EntityId
>(i+1);
239 bool create_reverse_shell_on_proc =
static_cast<int>(p_rank) == (std::max(0,static_cast<int>(p_size)-1-4-i));
240 if (create_reverse_shell_on_proc) {
241 EntityId reverse_element_id =
static_cast<EntityId
>(i+1+4);
246 bulk_data.modification_end();
249 stk_classic::mesh::skin_mesh(bulk_data, element_rank);
254 const std::vector<stk_classic::mesh::Bucket*>& side_buckets = bulk_data.buckets( side_rank);
262 STKUNIT_ASSERT_EQUAL( num_sides, 2 );
267 EntityId face_1_id = 0;
268 EntityId face_2_id = 0;
269 for (EntityId shell_id = 1; shell_id < 5; ++shell_id) {
271 if ( shell != NULL) {
274 STKUNIT_ASSERT_TRUE( shell_side_relations.size() == 2);
278 if (face_1_id == 0) {
279 face_1_id = shell_side_relations->entity()->identifier();
282 STKUNIT_EXPECT_TRUE( face_1_id == shell_side_relations->entity()->identifier());
286 STKUNIT_EXPECT_TRUE( shell_side_relations->identifier() == 0);
288 ++shell_side_relations;
290 if (face_2_id == 0) {
291 face_2_id = shell_side_relations->entity()->identifier();
294 STKUNIT_EXPECT_TRUE( face_2_id == shell_side_relations->entity()->identifier());
298 STKUNIT_EXPECT_TRUE( shell_side_relations->identifier() == 1);
303 for (EntityId shell_id = 5; shell_id < 9; ++shell_id) {
305 if ( shell != NULL) {
308 STKUNIT_ASSERT_TRUE( shell_side_relations.size() == 2);
312 if (face_2_id == 0) {
313 face_2_id = shell_side_relations->entity()->identifier();
316 STKUNIT_EXPECT_TRUE( face_2_id == shell_side_relations->entity()->identifier());
320 STKUNIT_EXPECT_TRUE( shell_side_relations->identifier() == 0);
322 ++shell_side_relations;
324 if (face_1_id == 0) {
325 face_1_id = shell_side_relations->entity()->identifier();
328 STKUNIT_EXPECT_TRUE( face_1_id == shell_side_relations->entity()->identifier());
332 STKUNIT_EXPECT_TRUE( shell_side_relations->identifier() == 1);
341 STKUNIT_UNIT_TEST( UnitTestSkin, SkinShellOnHex)
343 enum { SpatialDim = 3 };
350 fem_meta.
FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim));
353 stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
355 stk_classic::mesh::fem::CellTopology shell_top(shards::getCellTopologyData<shards::ShellQuadrilateral<4> >());
357 const EntityRank element_rank = fem_meta.
element_rank();
358 const EntityRank side_rank = fem_meta.
side_rank();
377 bulk_data.modification_begin();
382 EntityId element_id = 1;
383 EntityId node_ids[8] = { 1, 2, 3, 4, 5, 6, 7, 8};
390 if (p_rank == p_size -1)
392 EntityId element_id = 2;
393 EntityId node_ids[8] = { 1, 2, 6, 5};
398 bulk_data.modification_end();
401 stk_classic::mesh::skin_mesh(bulk_data, element_rank);
407 if ( element != NULL) {
409 STKUNIT_EXPECT_TRUE( element_side_relations.size() == 5);
410 for (; !element_side_relations.empty(); ++element_side_relations) {
411 unsigned local_side_id = element_side_relations->identifier();
412 bool correct_side_skinned = local_side_id > 0 && local_side_id < 6;
413 STKUNIT_EXPECT_TRUE (correct_side_skinned);
414 std::cout <<
"Hex local side id: " << local_side_id << std::endl;
421 EntityId shell_id = 2;
423 if ( element != NULL) {
425 STKUNIT_EXPECT_TRUE( element_side_relations.size() == 1);
426 for (; !element_side_relations.empty(); ++element_side_relations) {
427 unsigned local_side_id = element_side_relations->identifier();
428 bool correct_side_skinned = local_side_id == 0;
429 STKUNIT_EXPECT_TRUE (correct_side_skinned);
430 std::cout <<
"Shell local side id: " << local_side_id << std::endl;
438 STKUNIT_UNIT_TEST( UnitTestSkin, SkinInvertedShellOnHex)
440 enum { SpatialDim = 3 };
447 fem_meta.
FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim));
450 stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
452 stk_classic::mesh::fem::CellTopology shell_top(shards::getCellTopologyData<shards::ShellQuadrilateral<4> >());
454 const EntityRank element_rank = fem_meta.
element_rank();
455 const EntityRank side_rank = fem_meta.
side_rank();
475 bulk_data.modification_begin();
480 EntityId element_id = 1;
481 EntityId node_ids[8] = { 1, 2, 3, 4, 5, 6, 7, 8};
488 if (p_rank == p_size -1)
490 EntityId element_id = 2;
491 EntityId node_ids[8] = { 1, 2, 5, 6};
496 bulk_data.modification_end();
499 stk_classic::mesh::skin_mesh(bulk_data, element_rank);
505 if ( element != NULL) {
507 STKUNIT_EXPECT_TRUE( element_side_relations.size() == 6);
508 for (; !element_side_relations.empty(); ++element_side_relations) {
509 unsigned local_side_id = element_side_relations->identifier();
510 bool correct_side_skinned = local_side_id < 6;
511 STKUNIT_EXPECT_TRUE (correct_side_skinned);
512 std::cout <<
"Hex local side id: " << local_side_id << std::endl;
519 EntityId shell_id = 2;
521 if ( element != NULL) {
523 STKUNIT_EXPECT_TRUE( element_side_relations.size() == 2);
524 for (; !element_side_relations.empty(); ++element_side_relations) {
525 unsigned local_side_id = element_side_relations->identifier();
526 bool correct_side_skinned = local_side_id < 2;
527 STKUNIT_EXPECT_TRUE (correct_side_skinned);
528 std::cout <<
"Shell local side id: " << element_side_relations->identifier() << std::endl;
536 STKUNIT_UNIT_TEST( UnitTestSkin, SkinStackedShellOnHex)
538 enum { SpatialDim = 3 };
545 fem_meta.
FEM_initialize(SpatialDim, stk_classic::mesh::fem::entity_rank_names(SpatialDim));
548 stk_classic::mesh::fem::CellTopology hex_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
550 stk_classic::mesh::fem::CellTopology shell_top(shards::getCellTopologyData<shards::ShellQuadrilateral<4> >());
552 const EntityRank element_rank = fem_meta.
element_rank();
553 const EntityRank side_rank = fem_meta.
side_rank();
573 bulk_data.modification_begin();
575 bool create_hex_this_proc = (p_rank == 0);
576 bool create_shell_1_this_proc =
static_cast<int>(p_rank) == (std::max(0,static_cast<int>(p_size)-3));
577 bool create_shell_2_this_proc =
static_cast<int>(p_rank) == (std::max(0,static_cast<int>(p_size)-2));
578 bool create_shell_3_this_proc = (p_rank == p_size -1);
580 if (create_hex_this_proc)
582 EntityId element_id = 1;
583 EntityId node_ids[8] = { 1, 2, 3, 4, 5, 6, 7, 8};
589 if (create_shell_1_this_proc)
591 EntityId element_id = 2;
592 EntityId node_ids[8] = { 1, 2, 6, 5};
597 if (create_shell_2_this_proc)
599 EntityId element_id = 3;
600 EntityId node_ids[8] = { 6, 5, 1, 2};
605 if (create_shell_3_this_proc)
607 EntityId element_id = 4;
608 EntityId node_ids[8] = { 1, 5, 6, 2};
613 bulk_data.modification_end();
616 stk_classic::mesh::skin_mesh(bulk_data, element_rank);
622 if ( element != NULL) {
624 STKUNIT_EXPECT_TRUE( element_side_relations.size() == 5);
625 for (; !element_side_relations.empty(); ++element_side_relations) {
626 unsigned local_side_id = element_side_relations->identifier();
627 bool correct_side_skinned = local_side_id > 0 && local_side_id < 6;
628 STKUNIT_EXPECT_TRUE (correct_side_skinned);
629 std::cout <<
"Hex local side id: " << local_side_id << std::endl;
636 EntityId face_id = 0;
637 for (EntityId shell_id = 2; shell_id < 5; ++shell_id) {
639 if ( shell != NULL) {
642 STKUNIT_EXPECT_TRUE( shell_side_relations.size() == 1);
647 face_id = shell_side_relations->entity()->identifier();
650 STKUNIT_EXPECT_TRUE( face_id == shell_side_relations->entity()->identifier());
651 std::cout <<
"Shell: " << shell_id
652 <<
"\tFace_id: " << face_id
653 <<
"\tFace_id: " << shell_side_relations->entity()->identifier()
662 STKUNIT_EXPECT_TRUE( shell_side_relations->identifier() == 0);
665 STKUNIT_EXPECT_TRUE( shell_side_relations->identifier() == 1);
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.
An application-defined subset of a problem domain.
unsigned parallel_machine_rank(ParallelMachine parallel_machine)
Member function parallel_machine_rank ...
PairIterRelation relations() const
All Entity relations for which this entity is a member. The relations are ordered from lowest entity-...
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 all_reduce(ParallelMachine, const ReduceOp &)