Sierra Toolkit  Version of the Day
UnitTestGenerateNewEntities.cpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 #include <stk_util/unit_test_support/stk_utest_macros.hpp>
10 
11 #include <stk_util/parallel/Parallel.hpp>
12 
13 #include <Shards_BasicTopologies.hpp>
14 
15 #include <stk_mesh/base/MetaData.hpp>
16 #include <stk_mesh/base/BulkData.hpp>
17 #include <stk_mesh/base/Entity.hpp>
18 #include <stk_mesh/base/GetEntities.hpp>
19 
20 #include <stk_mesh/fem/FEMMetaData.hpp>
21 
22 namespace {
23 
24 const stk_classic::mesh::EntityRank NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK;
25 
26 STKUNIT_UNIT_TEST( UnitTestStkMeshGenerateNewEntities , testUnit )
27 {
28  // Test BulkData's generate_new_entities method.
29 
30  stk_classic::ParallelMachine pm(MPI_COMM_WORLD);
31 
32  const int spatial_dimension = 3;
33  stk_classic::mesh::fem::FEMMetaData meta_data( spatial_dimension );
35 
36  meta_data.commit();
37 
38  const stk_classic::mesh::PartVector no_parts;
39 
40  bulk_data.modification_begin();
41 
42  bulk_data.declare_entity(NODE_RANK, bulk_data.parallel_rank() + 1, no_parts);
43 
44  bulk_data.modification_end();
45 
46  // Create a request vector for 2 new nodes on each processor
47  size_t num_nodes_requested = 2;
48  std::vector<size_t> requests(meta_data.entity_rank_count(), 0);
49  requests[0] = num_nodes_requested;
50 
51  bulk_data.modification_begin();
52 
53  // generate_new_entities creates new blank entities of the requested ranks
54  stk_classic::mesh::EntityVector new_nodes;
55  bulk_data.generate_new_entities(requests, new_nodes);
56  STKUNIT_ASSERT_EQ(new_nodes.size(), num_nodes_requested);
57 
58  // confirm that the nodes we created earlier are not in the new entities
59  for (stk_classic::mesh::EntityVector::const_iterator itr = new_nodes.begin();
60  itr != new_nodes.end(); ++itr) {
61  STKUNIT_ASSERT_GT((*itr)->identifier(), bulk_data.parallel_size());
62  }
63 
64  bulk_data.modification_end();
65 }
66 
67 }
FEMMetaData is a class that implements a Finite Element Method skin on top of the Sierra Tool Kit Met...
Definition: FEMMetaData.hpp:54
Manager for an integrated collection of entities, entity relations, and buckets of field data...
Definition: BulkData.hpp:49
static MetaData & get_meta_data(FEMMetaData &fem_meta)
Getter for MetaData off of a FEMMetaData object.
MPI_Comm ParallelMachine
Definition: Parallel.hpp:32
std::vector< Part *> PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
Definition: Types.hpp:31