13 #include <stk_util/unit_test_support/stk_utest_macros.hpp> 15 #include <stk_util/parallel/Parallel.hpp> 17 #include <stk_mesh/base/BulkData.hpp> 18 #include <stk_mesh/base/GetEntities.hpp> 19 #include <stk_mesh/base/EntityComm.hpp> 20 #include <stk_mesh/base/Comm.hpp> 22 #include <stk_mesh/fixtures/BoxFixture.hpp> 23 #include <stk_mesh/fixtures/RingFixture.hpp> 25 #include <unit_tests/UnitTestModificationEndWrapper.hpp> 26 #include <unit_tests/UnitTestRingFixture.hpp> 37 using stk_classic::mesh::BaseEntityRank;
41 using stk_classic::mesh::EntityId;
43 using stk_classic::mesh::EntityVector;
44 using stk_classic::mesh::EntityRank;
49 const EntityRank NODE_RANK = FEMMetaData::NODE_RANK;
52 void printEntity(std::ostringstream& msg,
Entity *entity)
54 msg <<
" :: " << print_entity_key(entity) <<
":o[" << entity->
owner_rank() <<
"]:l[" << entity->
log_query()
57 msg <<
"(" << ec->ghost_id <<
"," << ec->proc <<
")";
62 void printNode(std::ostringstream& msg,
Entity *node)
64 printEntity(msg, node);
65 PairIterRelation rels = node->
relations();
66 for (
unsigned i = 0; i < rels.size(); i++)
68 Entity *entity = rels[i].entity();
70 printEntity(msg, entity);
74 void printBuckets(std::ostringstream& msg,
BulkData& mesh)
76 const std::vector<Bucket*> & buckets = mesh.
buckets(0);
77 for (
unsigned i=0; i < buckets.size(); i++)
79 const Bucket& bucket = *buckets[i];
80 msg <<
" bucket[" << i <<
"] = ";
81 size_t bucket_size = bucket.
size();
82 for (
unsigned ie=0; ie < bucket_size; ie++)
84 msg << bucket[ie].identifier() <<
", ";
89 static void checkBuckets(
BulkData& mesh)
91 const std::vector<Bucket*> & buckets = mesh.
buckets(0);
92 for (
unsigned i=0; i < buckets.size(); i++)
94 Bucket* bucket = buckets[i];
99 STKUNIT_UNIT_TEST(UnitTestingOfBulkData, test_other_ghosting_2)
117 EntityId elems_0[][4] = { {100, 21, 50, 0}, {201, 21, 32, 1}, {302, 32, 50, 2},
118 {500, 41, 70, 0}, {301, 41, 42, 1}, {402, 42, 70, 2} };
120 EntityId nodes_0[][2] = { {21,1}, {50,0}, {32, 2}, {41, 1}, {42, 1}, {70, 0} };
122 unsigned nelems =
sizeof(elems_0)/4/
sizeof(EntityId);
123 unsigned nnodes =
sizeof(nodes_0)/2/
sizeof(EntityId);
128 const unsigned spatial_dim = 2;
130 std::vector<std::string> entity_rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dim);
131 entity_rank_names.push_back(
"FAMILY_TREE");
133 FEMMetaData meta_data(spatial_dim, entity_rank_names);
137 unsigned max_bucket_size = 1;
138 BulkData mesh(FEMMetaData::get_meta_data(meta_data), pm, max_bucket_size);
143 if (p_size != 3)
return;
153 const EntityRank elem_rank = meta_data.element_rank();
158 for (
unsigned ielem=0; ielem < nelems; ielem++)
160 if (elems_0[ielem][3] == p_rank)
162 elem = &mesh.
declare_entity(elem_rank, elems_0[ielem][0], empty_parts);
166 nodes.push_back( &mesh.
declare_entity(NODE_RANK, elems_0[ielem][2], empty_parts) );
167 nodes.push_back( &mesh.
declare_entity(NODE_RANK, elems_0[ielem][1], empty_parts) );
183 std::vector<EntityProc> change;
185 for (
unsigned inode=0; inode < nnodes; inode++)
187 node1 = mesh.
get_entity(0, nodes_0[inode][0]);
190 unsigned dest = nodes_0[inode][1];
192 change.push_back(eproc);
202 MPI_Barrier(MPI_COMM_WORLD);
216 STKUNIT_ASSERT(did_it_elem);
218 STKUNIT_ASSERT(did_it);
PairIterEntityComm comm() const
Complete communicaiton list for this entity.
void declare_relation(Entity &e_from, Entity &e_to, const RelationIdentifier local_id)
Declare a relation and its converse between entities in the same mesh.
bool assert_correct() const
A method to assist in unit testing - accesses private data as necessary.
This is a class for selecting buckets based on a set of meshparts and set logic.
const std::vector< Bucket * > & buckets(EntityRank rank) const
Query all buckets of a given entity rank.
Entity * get_entity(EntityRank entity_rank, EntityId entity_id) const
Get entity with a given key.
Integer type for the entity keys, which is an encoding of the entity type and entity identifier...
std::pair< Entity *, unsigned > EntityProc
Pairing of an entity with a processor rank.
EntityModificationLog log_query() const
Query the current state of the entity log.
An application-defined subset of a problem domain.
size_t size() const
Number of entities associated with this bucket.
bool modification_end()
Parallel synchronization of modifications and transition to the guaranteed parallel consistent state...
unsigned parallel_size() const
Size of the parallel machine.
bool modification_begin()
Begin a modification phase during which the mesh bulk data could become parallel inconsistent. This is a parallel synchronous call. The first time this method is called the mesh meta data is verified to be committed and parallel consistent. An exception is thrown if this verification fails.
PairIterRelation relations() const
All Entity relations for which this entity is a member. The relations are ordered from lowest entity-...
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 change_entity_owner(const std::vector< EntityProc > &arg_change)
Give away ownership of entities to other parallel processes.
unsigned parallel_rank() const
Rank of the parallel machine's local processor.
EntityRank entity_rank() const
The rank of this entity.
Entity & declare_entity(EntityRank ent_rank, EntityId ent_id, const PartVector &parts)
Create or retrieve a locally owned entity of a given rank and id.
std::vector< Part *> PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
PairIter< std::vector< EntityCommInfo >::const_iterator > PairIterEntityComm
Span of ( communication-subset-ordinal , process-rank ) pairs for the communication of an entity...
A container for the field data of a homogeneous collection of entities.
bool destroy_entity(Entity *&entity)
Request the destruction an entity on the local process.
unsigned owner_rank() const
Parallel processor rank of the processor which owns this entity.