| 1 |
#ifndef STK_UNIT_TEST_CEO_COMMON_UTILS_H |
| 2 |
#define STK_UNIT_TEST_CEO_COMMON_UTILS_H |
| 3 |
|
| 4 |
#include <stddef.h> // for NULL |
| 5 |
#include <algorithm> // for lower_bound |
| 6 |
#include <stk_mesh/base/BulkData.hpp> // for BulkData |
| 7 |
#include <vector> // for vector |
| 8 |
#include <stk_unit_test_utils/BulkDataTester.hpp> // for BulkDataTester |
| 9 |
#include "stk_mesh/base/Entity.hpp" // for Entity |
| 10 |
#include "stk_mesh/base/EntityCommListInfo.hpp" |
| 11 |
#include "stk_mesh/base/EntityKey.hpp" // for EntityKey, etc |
| 12 |
#include "stk_mesh/base/Types.hpp" // for EntityProc, EntityId, etc |
| 13 |
#include "stk_topology/topology.hpp" // for topology, etc |
| 14 |
namespace stk { namespace mesh { class MetaData; } } |
| 15 |
namespace stk { namespace mesh { class Part; } } |
| 16 |
|
| 17 |
namespace CEOUtils |
| 18 |
{ |
| 19 |
|
| 20 |
using stk::mesh::Part; |
| 21 |
using stk::mesh::MetaData; |
| 22 |
using stk::mesh::BulkData; |
| 23 |
using stk::mesh::PartVector; |
| 24 |
using stk::mesh::Entity; |
| 25 |
using stk::mesh::EntityId; |
| 26 |
using stk::mesh::EntityKey; |
| 27 |
using stk::mesh::EntityRank; |
| 28 |
using stk::mesh::PairIterEntityComm; |
| 29 |
|
| 30 |
const EntityRank NODE_RANK = stk::topology::NODE_RANK; |
| 31 |
const EntityRank EDGE_RANK = stk::topology::EDGE_RANK; |
| 32 |
const EntityRank FACE_RANK = stk::topology::FACE_RANK; |
| 33 |
const EntityRank ELEM_RANK = stk::topology::ELEM_RANK; |
| 34 |
|
| 35 |
|
| 36 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 37 |
|
| 38 |
inline bool isEntityValidOnCommList(stk::unit_test_util::BulkDataTester& stkMeshBulkData, stk::mesh::Entity entity) |
| 39 |
{ |
| 40 |
EntityKey entityKey = stkMeshBulkData.entity_key(entity); |
| 41 |
stk::mesh::EntityCommListInfoVector::const_iterator iter = std::lower_bound(stkMeshBulkData.my_internal_comm_list().begin(), stkMeshBulkData.my_internal_comm_list().end(), entityKey); |
| 42 |
return iter != stkMeshBulkData.my_internal_comm_list().end() && entityKey == iter->key; |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 48 |
|
| 49 |
inline void add_nodes_to_move(stk::mesh::BulkData& bulk, |
| 50 |
stk::mesh::Entity elem, |
| 51 |
int dest_proc, |
| 52 |
std::vector<stk::mesh::EntityProc>& entities_to_move) |
| 53 |
{ |
| 54 |
const stk::mesh::Entity* nodes = bulk.begin_nodes(elem); |
| 55 |
for(unsigned i = 0; i < bulk.num_nodes(elem); ++i) |
| 56 |
{ |
| 57 |
if(bulk.parallel_owner_rank(nodes[i]) == bulk.parallel_rank()) |
| 58 |
{ |
| 59 |
entities_to_move.push_back(stk::mesh::EntityProc(nodes[i], dest_proc)); |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 65 |
|
| 66 |
enum EntityStates { |
| 67 |
STATE_VALID, |
| 68 |
STATE_NOT_VALID, |
| 69 |
STATE_OWNED, |
| 70 |
STATE_SHARED, |
| 71 |
STATE_NOT_SHARED, |
| 72 |
STATE_GHOSTED_FROM, |
| 73 |
STATE_NOT_GHOSTED_FROM, |
| 74 |
STATE_GHOSTED_TO, |
| 75 |
STATE_NOT_GHOSTED_TO, |
| 76 |
STATE_MESH_MODIFIED, // state mesh state checks |
| 77 |
STATE_MESH_UNCHANGED, |
| 78 |
STATE_MESH_CREATED, |
| 79 |
STATE_MESH_DELETED |
| 80 |
}; |
| 81 |
|
| 82 |
bool check_state(const stk::unit_test_util::BulkDataTester & mesh, const EntityKey & entityKey, EntityStates state, |
| 83 |
int p0 = -1, int p1 = -1, int p2 = -1, int p3 = -1, int p4 = -1, int p5 = -1); |
| 84 |
|
| 85 |
bool check_parts(const stk::mesh::BulkData & mesh, const EntityKey & entityKey, |
| 86 |
stk::mesh::Part *p0 = NULL, stk::mesh::Part *p1 = NULL, stk::mesh::Part *p2 = NULL, |
| 87 |
stk::mesh::Part *p3 = NULL, stk::mesh::Part *p4 = NULL, stk::mesh::Part *p5 = NULL, |
| 88 |
stk::mesh::Part *p6 = NULL, stk::mesh::Part *p7 = NULL, stk::mesh::Part *p8 = NULL, |
| 89 |
stk::mesh::Part *p9 = NULL, stk::mesh::Part *p10 = NULL, stk::mesh::Part *p11 = NULL); |
| 90 |
|
| 91 |
bool check_relns(const stk::mesh::BulkData & mesh, const EntityKey & entityKey, stk::mesh::EntityRank to_rank, |
| 92 |
EntityId id0 = EntityKey::MIN_ID, EntityId id1 = EntityKey::MIN_ID, |
| 93 |
EntityId id2 = EntityKey::MIN_ID, EntityId id3 = EntityKey::MIN_ID, |
| 94 |
EntityId id4 = EntityKey::MIN_ID, EntityId id5 = EntityKey::MIN_ID, |
| 95 |
EntityId id6 = EntityKey::MIN_ID, EntityId id7 = EntityKey::MIN_ID, |
| 96 |
EntityId id8 = EntityKey::MIN_ID, EntityId id9 = EntityKey::MIN_ID, |
| 97 |
EntityId id10 = EntityKey::MIN_ID, EntityId id11 = EntityKey::MIN_ID); |
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
#endif |