9 #include <stk_util/unit_test_support/stk_utest_macros.hpp> 10 #include <stk_mesh/fixtures/HexFixture.hpp> 11 #include <stk_mesh/base/FieldData.hpp> 13 #include <boost/foreach.hpp> 16 STKUNIT_UNIT_TEST( UnitTestChangeEntityId, change_id )
20 const unsigned NX = 50;
21 const unsigned NY = 50;
22 const unsigned NZ = 50;
23 const unsigned num_elems = NX * NY * NZ;
27 Field<int> & simple_nodal_field = hf.m_fem_meta.declare_field<
Field<int> >(
"simple_nodal_field");
30 fem::FEMMetaData::NODE_RANK,
36 hf.m_fem_meta.commit();
44 const BucketVector & nodes = mesh.
buckets(fem::FEMMetaData::NODE_RANK);
46 BOOST_FOREACH(
Bucket * b, nodes) {
48 for (
int i =0; i<nodal_field.size(); ++i) {
54 const BucketVector & elems = mesh.
buckets(hf.m_fem_meta.element_rank());
56 std::vector<EntityId> old_ids;
57 old_ids.reserve(num_elems);
58 BOOST_FOREACH(
Bucket * b, elems) {
59 for (
size_t i =0; i<b->
size(); ++i) {
62 mesh.change_entity_id( e.
identifier()+num_elems, e);
71 std::vector<EntityId> new_ids_minus_num_elems;
72 new_ids_minus_num_elems.reserve(num_elems);
73 BOOST_FOREACH(
Bucket * b, elems) {
74 for (
size_t i =0; i<b->
size(); ++i) {
76 new_ids_minus_num_elems.push_back(e.
identifier()-num_elems);
80 STKUNIT_EXPECT_TRUE(old_ids == new_ids_minus_num_elems);
82 BOOST_FOREACH(
Bucket * b, nodes) {
84 for (
int i =0; i<nodal_field.size(); ++i) {
85 STKUNIT_EXPECT_TRUE( nodal_field[i] == 1);
const std::vector< Bucket * > & buckets(EntityRank rank) const
Query all buckets of a given entity rank.
field_type & put_field(field_type &field, EntityRank entity_rank, const Part &part, const void *init_value=NULL)
Declare a field to exist for a given entity type and Part.
Field with defined data type and multi-dimensions (if any)
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...
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.
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...
EntityId identifier() const
Identifier for this entity which is globally unique for a given entity type.
A container for the field data of a homogeneous collection of entities.
Field data Array for a given array field and bucket