Sierra Toolkit  Version of the Day
UnitTestGridFixture.cpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010, 2011 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 #include <Shards_BasicTopologies.hpp>
11 
12 #include <stk_util/parallel/Parallel.hpp>
13 
14 #include <stk_mesh/base/Types.hpp>
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 #include <stk_mesh/base/Selector.hpp>
20 #include <stk_mesh/base/GetBuckets.hpp>
21 #include <stk_mesh/base/BulkModification.hpp>
22 
23 #include <stk_mesh/fem/BoundaryAnalysis.hpp>
24 #include <stk_mesh/fem/SkinMesh.hpp>
25 
26 #include <stk_mesh/fixtures/GridFixture.hpp>
27 
28 #include <stk_util/parallel/ParallelReduce.hpp>
29 
30 #include <iomanip>
31 #include <algorithm>
32 
35 using stk::mesh::Part;
38 using stk::mesh::Entity;
39 using stk::mesh::EntityVector;
40 using stk::mesh::EntityRank;
44 using std::cout;
45 using std::endl;
46 
47 STKUNIT_UNIT_TEST( UnitTestGridFixture, test_gridfixture )
48 {
49  //Coverage of GridFixture, Hexfixture, BoxFixture,QuadFixture
50  //and RingFixture in fixture directory for more than one
51  //processor.
52  stk::mesh::fixtures::GridFixture grid_mesh(MPI_COMM_WORLD);
53 
54  stk::mesh::BulkData& bulk_data = grid_mesh.bulk_data();
55  stk::mesh::fem::FEMMetaData& fem_meta = grid_mesh.fem_meta();
56  const stk::mesh::EntityRank elem_rank = fem_meta.element_rank();
57 
58  int size , rank;
59  rank = stk::parallel_machine_rank( MPI_COMM_WORLD );
60  size = stk::parallel_machine_size( MPI_COMM_WORLD );
61 
62  // Create a part for the shells
63  stk::mesh::fem::CellTopology line_top(shards::getCellTopologyData<shards::ShellLine<2> >());
64  stk::mesh::Part & shell_part = fem_meta.declare_part("shell_part", line_top);
65 
66  fem_meta.commit();
67 
68  // Generate the plain grid
69  bulk_data.modification_begin();
70  grid_mesh.generate_grid();
71  bulk_data.modification_end();
72 
73  // Add the shells
74  bulk_data.modification_begin();
75 
76  const unsigned num_shell_1_faces = 4*size + rank;
77  const unsigned num_shell_2_faces = 2*size + rank;
78  const unsigned num_shell_faces = num_shell_1_faces + num_shell_2_faces;
79 
80  stk::mesh::PartVector shell_parts;
81  shell_parts.push_back(&shell_part);
82 
83  std::vector<stk::mesh::Entity*> shell_faces;
84 
85  unsigned id_base = 0;
86  unsigned id_offset = 500; // a safe offset to avoid id overlap
87  //Start at 1 so as not to have same element on different processors
88  for (id_base = 1; id_base <= num_shell_faces; ++id_base) {
89 
90  int new_id = rank * num_shell_faces + id_base;
91  stk::mesh::Entity& new_shell = bulk_data.declare_entity(elem_rank,
92  id_offset + new_id,
93  shell_parts);
94  shell_faces.push_back(&new_shell);
95  }
96 
97  bulk_data.modification_end();
98 }
99 
100 
std::vector< Part * > PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
Definition: Types.hpp:31
The manager of an integrated collection of parts and fields.
Definition: MetaData.hpp:56
This is a class for selecting buckets based on a set of meshparts and set logic.
Definition: Selector.hpp:112
void commit()
Commit the part and field declarations so that the meta data manager can be used to create mesh bulk ...
MPI_Comm ParallelMachine
Definition: Parallel.hpp:32
unsigned parallel_machine_size(ParallelMachine parallel_machine)
Member function parallel_machine_size ...
Definition: Parallel.cpp:18
A fundamental unit within the discretization of a problem domain, including but not limited to nodes...
Definition: Entity.hpp:120
unsigned parallel_machine_rank(ParallelMachine parallel_machine)
Member function parallel_machine_rank ...
Definition: Parallel.cpp:29
A defined entity-relationship between parts. An internal class that should never need to be directly...
bool modification_end()
Parallel synchronization of modifications and transition to the guaranteed parallel consistent state...
Part & declare_part(const std::string &name, fem::CellTopology cell_topology)
Declare a part with a given cell topology.
An application-defined subset of a problem domain.
Definition: Part.hpp:49
Manager for an integrated collection of entities, entity relations, and buckets of field data...
Definition: BulkData.hpp:49
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.
Definition: BulkData.cpp:215
FEMMetaData is a class that implements a Finite Element Method skin on top of the Sierra Tool Kit Met...
Definition: FEMMetaData.hpp:54
EntityRank element_rank() const
Returns the element rank which is always equal to spatial dimension.
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.
Definition: BulkData.cpp:172