| 1 |
#include <gtest/gtest.h> // for TEST |
| 2 |
#include "mpi.h" // for MPI_COMM_WORLD, etc |
| 3 |
#include <stk_io/StkMeshIoBroker.hpp> // for StkMeshIoBroker |
| 4 |
#include <stk_mesh/base/ModificationSummary.hpp> |
| 5 |
#include <string> // for string |
| 6 |
#include <utility> // for make_pair |
| 7 |
#include <vector> // for vector |
| 8 |
#include "stk_io/DatabasePurpose.hpp" // for DatabasePurpose::READ_MESH |
| 9 |
#include "stk_mesh/base/Bucket.hpp" // for Bucket |
| 10 |
#include "stk_mesh/base/BulkData.hpp" // for BulkData |
| 11 |
#include "stk_mesh/base/Entity.hpp" // for Entity |
| 12 |
#include "stk_mesh/base/EntityKey.hpp" // for EntityKey |
| 13 |
#include "stk_mesh/base/Types.hpp" // for EntityProc, PartVector, etc |
| 14 |
#include "stk_topology/topology.hpp" // for topology, etc |
| 15 |
namespace stk { namespace mesh { class Ghosting; } } |
| 16 |
|
| 17 |
TEST(ModificationSummary, testString) |
| 18 |
{ |
| 19 |
int numprocs; |
| 20 |
MPI_Comm_size(MPI_COMM_WORLD, &numprocs); |
| 21 |
if (numprocs == 1 ) |
| 22 |
{ |
| 23 |
stk::io::StkMeshIoBroker stkMeshIoBroker(MPI_COMM_WORLD); |
| 24 |
const std::string generatedMeshSpecification = "generated:1x1x3"; |
| 25 |
stkMeshIoBroker.add_mesh_database(generatedMeshSpecification, stk::io::READ_MESH); |
| 26 |
stkMeshIoBroker.create_input_mesh(); |
| 27 |
stkMeshIoBroker.populate_bulk_data(); |
| 28 |
stk::mesh::BulkData &stkMeshBulkData = stkMeshIoBroker.bulk_data(); |
| 29 |
|
| 30 |
//////////////////////// |
| 31 |
|
| 32 |
stk::ModificationSummary writer(stkMeshBulkData); |
| 33 |
|
| 34 |
int mod_count = 0; |
| 35 |
|
| 36 |
stk::mesh::Entity node1 = stkMeshBulkData.get_entity(stk::topology::NODE_RANK, 1); |
| 37 |
stk::mesh::Entity node2 = stkMeshBulkData.get_entity(stk::topology::NODE_RANK, 2); |
| 38 |
|
| 39 |
writer.track_destroy_entity(node1); |
| 40 |
|
| 41 |
const stk::mesh::PartVector &addParts = stkMeshBulkData.bucket(node1).supersets(); |
| 42 |
stk::mesh::OrdinalVector addPartsOrdinals, rmPartsOrdinals; |
| 43 |
stkMeshBulkData.bucket(node1).supersets(addPartsOrdinals); |
| 44 |
stkMeshBulkData.bucket(node2).supersets(rmPartsOrdinals); |
| 45 |
|
| 46 |
writer.track_change_entity_parts(node2, addPartsOrdinals, rmPartsOrdinals); |
| 47 |
writer.track_change_entity_parts(node1, addPartsOrdinals, rmPartsOrdinals); |
| 48 |
|
| 49 |
std::vector<stk::mesh::EntityProc> changes; |
| 50 |
changes.push_back(std::make_pair(node1, 2)); |
| 51 |
changes.push_back(std::make_pair(node2, 4)); |
| 52 |
|
| 53 |
writer.track_change_entity_owner(changes); |
| 54 |
|
| 55 |
stk::mesh::EntityId newId = 12; |
| 56 |
writer.track_change_entity_id(newId, node1); |
| 57 |
|
| 58 |
writer.track_declare_entity(stk::topology::NODE_RANK, newId, addParts); |
| 59 |
|
| 60 |
stk::mesh::Entity element1 = stkMeshBulkData.get_entity(stk::topology::ELEM_RANK, 1); |
| 61 |
stk::mesh::Permutation permut = stk::mesh::Permutation::INVALID_PERMUTATION; |
| 62 |
stk::mesh::RelationIdentifier rel = 0; |
| 63 |
|
| 64 |
writer.track_declare_relation(element1, node1, rel, permut); |
| 65 |
writer.track_declare_relation(element1, node2, rel, permut); |
| 66 |
|
| 67 |
writer.track_destroy_relation(element1, node1, rel); |
| 68 |
|
| 69 |
const stk::mesh::Ghosting &aura = *stkMeshBulkData.ghostings()[1]; |
| 70 |
|
| 71 |
std::vector<stk::mesh::Entity> remove_receive; |
| 72 |
remove_receive.push_back(stkMeshBulkData.get_entity(stk::topology::NODE_RANK, 1)); |
| 73 |
remove_receive.push_back(stkMeshBulkData.get_entity(stk::topology::ELEM_RANK, 1)); |
| 74 |
|
| 75 |
writer.track_change_ghosting(aura, changes , remove_receive); |
| 76 |
|
| 77 |
writer.write_summary(mod_count); |
| 78 |
unlink("modification_cycle_P000_B000_C000000.txt"); |
| 79 |
} |
| 80 |
} |
| 81 |
|