| 1 |
#include "gtest/gtest.h" // for AssertHelper, EXPECT_EQ, etc |
| 2 |
#include <stk_mesh/base/BulkData.hpp> // for BulkData |
| 3 |
#include <stk_mesh/base/DestroyRelations.hpp> |
| 4 |
#include <stk_mesh/base/GetEntities.hpp> // for count_selected_entities |
| 5 |
#include <stk_mesh/base/SkinBoundary.hpp> // for skin_mesh |
| 6 |
#include <stk_unit_test_utils/getOption.h> |
| 7 |
#include <stk_unit_test_utils/MeshFixture.hpp> |
| 8 |
#include <stk_unit_test_utils/PerformanceTester.hpp> |
| 9 |
|
| 10 |
namespace |
| 11 |
{ |
| 12 |
|
| 13 |
size_t get_num_global_faces(const stk::mesh::BulkData &bulk) |
| 14 |
{ |
| 15 |
std::vector<size_t> meshCounts; |
| 16 |
stk::mesh::comm_mesh_counts(bulk, meshCounts); |
| 17 |
return meshCounts[stk::topology::FACE_RANK]; |
| 18 |
} |
| 19 |
|
| 20 |
class ExposedBlockBoundaryPerformance : public stk::unit_test_util::PerformanceTester |
| 21 |
{ |
| 22 |
public: |
| 23 |
ExposedBlockBoundaryPerformance(stk::mesh::BulkData &bulk) |
| 24 |
: stk::unit_test_util::PerformanceTester(bulk.parallel()), |
| 25 |
bulkData(bulk), |
| 26 |
thingToSkin(bulk.mesh_meta_data().universal_part()), |
| 27 |
skinPart(bulk.mesh_meta_data().declare_part("skinPart")) |
| 28 |
{ |
| 29 |
} |
| 30 |
|
| 31 |
void delete_sides() |
| 32 |
{ |
| 33 |
const stk::mesh::MetaData& meta = bulkData.mesh_meta_data(); |
| 34 |
stk::mesh::EntityVector elems; |
| 35 |
stk::mesh::get_selected_entities(meta.locally_owned_part(), |
| 36 |
bulkData.buckets(stk::topology::ELEM_RANK), elems); |
| 37 |
bulkData.modification_begin(); |
| 38 |
|
| 39 |
for(stk::mesh::Entity elem : elems) |
| 40 |
{ |
| 41 |
stk::mesh::destroy_relations(bulkData, elem, meta.side_rank()); |
| 42 |
} |
| 43 |
|
| 44 |
stk::mesh::EntityVector sides; |
| 45 |
stk::mesh::get_selected_entities(meta.locally_owned_part(), |
| 46 |
bulkData.buckets(meta.side_rank()), sides); |
| 47 |
for(stk::mesh::Entity side : sides) |
| 48 |
{ |
| 49 |
bulkData.destroy_entity(side); |
| 50 |
} |
| 51 |
|
| 52 |
bulkData.modification_end(); |
| 53 |
} |
| 54 |
|
| 55 |
protected: |
| 56 |
virtual void run_algorithm_to_time() |
| 57 |
{ |
| 58 |
stk::mesh::create_exposed_block_boundary_sides(bulkData, thingToSkin, stk::mesh::PartVector{&skinPart}); |
| 59 |
} |
| 60 |
virtual size_t get_value_to_output_as_iteration_count() |
| 61 |
{ |
| 62 |
return get_num_global_faces(bulkData); |
| 63 |
} |
| 64 |
|
| 65 |
stk::mesh::BulkData &bulkData; |
| 66 |
stk::mesh::Selector thingToSkin; |
| 67 |
stk::mesh::Part &skinPart; |
| 68 |
}; |
| 69 |
|
| 70 |
class ExposedBlockBoundaryPerformanceTest : public stk::unit_test_util::MeshFixture |
| 71 |
{ |
| 72 |
protected: |
| 73 |
void run_skin_mesh_perf_test() |
| 74 |
{ |
| 75 |
ExposedBlockBoundaryPerformance perfTester(get_bulk()); |
| 76 |
const int numTimes = 20; |
| 77 |
for(int i=0; i<numTimes; ++i) |
| 78 |
{ |
| 79 |
perfTester.delete_sides(); |
| 80 |
perfTester.run_performance_test(); |
| 81 |
} |
| 82 |
} |
| 83 |
std::string get_mesh_spec() |
| 84 |
{ |
| 85 |
return stk::unit_test_util::get_option("-file", "NO_FILE_SPECIFIED"); |
| 86 |
} |
| 87 |
}; |
| 88 |
|
| 89 |
TEST_F(ExposedBlockBoundaryPerformanceTest, read_mesh_with_auto_decomp) |
| 90 |
{ |
| 91 |
allocate_bulk(stk::mesh::BulkData::AUTO_AURA); |
| 92 |
stk::unit_test_util::read_from_serial_file_and_decompose(get_mesh_spec(), get_bulk(), "rcb"); |
| 93 |
|
| 94 |
run_skin_mesh_perf_test(); |
| 95 |
} |
| 96 |
|
| 97 |
TEST_F(ExposedBlockBoundaryPerformanceTest, read_mesh) |
| 98 |
{ |
| 99 |
setup_mesh(get_mesh_spec(), stk::mesh::BulkData::AUTO_AURA); |
| 100 |
|
| 101 |
run_skin_mesh_perf_test(); |
| 102 |
} |
| 103 |
|
| 104 |
} |
| 105 |
|