| 1 |
#include "FaceCreatorFixture.hpp" |
| 2 |
#include <stk_io/IossBridge.hpp> |
| 3 |
#include <stk_mesh/base/Comm.hpp> |
| 4 |
#include <stk_mesh/base/FEMHelpers.hpp> |
| 5 |
#include <stk_mesh/base/GetEntities.hpp> |
| 6 |
#include <stk_mesh/baseImpl/elementGraph/ElemElemGraph.hpp> |
| 7 |
#include <stk_unit_test_utils/BulkDataTester.hpp> |
| 8 |
#include <stk_unit_test_utils/stk_mesh_fixtures/QuadFixture.hpp> |
| 9 |
#include <stk_unit_test_utils/unittestMeshUtils.hpp> |
| 10 |
|
| 11 |
namespace |
| 12 |
{ |
| 13 |
|
| 14 |
void convert_quad_fixture_to_my_bulk_data_flavor(unsigned numX, unsigned numY, stk::mesh::BulkData& bulkData) |
| 15 |
{ |
| 16 |
stk::mesh::fixtures::QuadFixture fixture(bulkData.parallel(), numX, numY, false); |
| 17 |
|
| 18 |
stk::mesh::Field<double> &coordField = fixture.m_meta.declare_field<double>(stk::topology::NODE_RANK, "model_coordinates"); |
| 19 |
stk::mesh::put_field_on_mesh(coordField, fixture.m_meta.universal_part(), fixture.m_meta.spatial_dimension(), nullptr); |
| 20 |
stk::mesh::Part& block_1 = fixture.m_meta.declare_part_with_topology("block_1", stk::topology::QUADRILATERAL_4_2D); |
| 21 |
stk::io::set_field_output_type(coordField, stk::io::FieldOutputType::VECTOR_3D); |
| 22 |
stk::io::put_io_part_attribute(block_1); |
| 23 |
|
| 24 |
fixture.m_meta.commit(); |
| 25 |
fixture.generate_mesh(); |
| 26 |
|
| 27 |
std::vector<double> x; |
| 28 |
std::vector<double> y; |
| 29 |
|
| 30 |
for(unsigned j=0;j<=numY;++j) |
| 31 |
{ |
| 32 |
for(unsigned i=0;i<=numX;i++) |
| 33 |
{ |
| 34 |
x.push_back(i); // 0 1 2, 0 1 2, 0 1 2, ... |
| 35 |
y.push_back(j); // 0 0 0, 1 1 1 |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
stk::mesh::EntityVector nodes; |
| 40 |
stk::mesh::get_selected_entities(fixture.m_meta.universal_part(), fixture.m_bulk_data.buckets(stk::topology::NODE_RANK), nodes); |
| 41 |
for(stk::mesh::Entity node : nodes ) |
| 42 |
{ |
| 43 |
double* coords = stk::mesh::field_data(coordField, node); |
| 44 |
unsigned id = fixture.m_bulk_data.identifier(node); |
| 45 |
coords[0] = x[id-1]; |
| 46 |
coords[1] = y[id-1]; |
| 47 |
} |
| 48 |
|
| 49 |
fixture.m_bulk_data.modification_begin(); |
| 50 |
stk::mesh::EntityVector elems; |
| 51 |
stk::mesh::get_selected_entities(fixture.m_meta.locally_owned_part(), fixture.m_bulk_data.buckets(stk::topology::ELEM_RANK), elems); |
| 52 |
for(stk::mesh::Entity element : elems) |
| 53 |
{ |
| 54 |
fixture.m_bulk_data.change_entity_parts(element, stk::mesh::ConstPartVector{&block_1}); |
| 55 |
} |
| 56 |
fixture.m_bulk_data.modification_end(); |
| 57 |
|
| 58 |
std::ostringstream os; |
| 59 |
const std::string file_temp("testadfasdasdfas.exo"); |
| 60 |
stk::io::write_mesh(file_temp, fixture.m_bulk_data); |
| 61 |
stk::io::fill_mesh(file_temp, bulkData); |
| 62 |
|
| 63 |
STK_ThrowRequireMsg(fixture.m_bulk_data.parallel_size()<10, "Testing assumption violated."); |
| 64 |
os << file_temp << "." << fixture.m_bulk_data.parallel_size() << "." << fixture.m_bulk_data.parallel_rank(); |
| 65 |
unlink(os.str().c_str()); |
| 66 |
} |
| 67 |
|
| 68 |
class FaceCreator2DElemGraphUsingBDElemGraphFaceSharingTester : public FaceCreatorFixture |
| 69 |
{ |
| 70 |
protected: |
| 71 |
|
| 72 |
FaceCreator2DElemGraphUsingBDElemGraphFaceSharingTester() : FaceCreatorFixture(2) {} |
| 73 |
|
| 74 |
void setup_2x1_2d_mesh(stk::mesh::BulkData::AutomaticAuraOption aura_option) |
| 75 |
{ |
| 76 |
setup_empty_mesh(aura_option); |
| 77 |
unsigned numX = 2, numY = 1; |
| 78 |
convert_quad_fixture_to_my_bulk_data_flavor(numX, numY, get_bulk()); |
| 79 |
} |
| 80 |
|
| 81 |
virtual stk::mesh::EntityVector get_nodes_of_face_for_this_proc() |
| 82 |
{ |
| 83 |
std::vector<unsigned> face_node_ids = { 2, 5 }; |
| 84 |
return get_nodes_for_proc(face_node_ids); |
| 85 |
} |
| 86 |
|
| 87 |
virtual unsigned get_permuted_index(unsigned i) |
| 88 |
{ |
| 89 |
std::vector<std::vector<unsigned> > index_for_proc = { |
| 90 |
{0, 1}, |
| 91 |
{1, 0} |
| 92 |
}; |
| 93 |
return index_for_proc[get_bulk().parallel_rank()][i]; |
| 94 |
} |
| 95 |
}; |
| 96 |
|
| 97 |
|
| 98 |
TEST_F(FaceCreator2DElemGraphUsingBDElemGraphFaceSharingTester, twoHexesTwoProcsCreateTwoFacesWithAura) |
| 99 |
{ |
| 100 |
if(stk::parallel_machine_size(get_comm())==2) |
| 101 |
{ |
| 102 |
setup_2x1_2d_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 103 |
test_that_one_face_exists_after_both_procs_create_face_on_proc_boundary(); |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
TEST_F(FaceCreator2DElemGraphUsingBDElemGraphFaceSharingTester, twoHexesTwoProcsCreateTwoFacesWithoutAura) |
| 108 |
{ |
| 109 |
if(stk::parallel_machine_size(get_comm())==2) |
| 110 |
{ |
| 111 |
setup_2x1_2d_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 112 |
test_that_one_face_exists_after_both_procs_create_face_on_proc_boundary(); |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
TEST_F(FaceCreator2DElemGraphUsingBDElemGraphFaceSharingTester, twoHexesTwoProcsCreateOneFaceWithAura) |
| 117 |
{ |
| 118 |
if(stk::parallel_machine_size(get_comm())==2) |
| 119 |
{ |
| 120 |
setup_2x1_2d_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 121 |
test_that_one_face_exists_on_both_procs_after_only_one_proc_makes_face(); |
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
TEST_F(FaceCreator2DElemGraphUsingBDElemGraphFaceSharingTester, twoHexesTwoProcsCreateOneFaceWithoutAura) |
| 126 |
{ |
| 127 |
if(stk::parallel_machine_size(get_comm())==2) |
| 128 |
{ |
| 129 |
setup_2x1_2d_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 130 |
test_that_one_face_exists_on_both_procs_after_only_one_proc_makes_face(); |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
} |