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 
39 using stk_classic::mesh::EntityVector;
40 using stk_classic::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_classic::mesh::fixtures::GridFixture grid_mesh(MPI_COMM_WORLD);
53 
54  stk_classic::mesh::BulkData& bulk_data = grid_mesh.bulk_data();
55  stk_classic::mesh::fem::FEMMetaData& fem_meta = grid_mesh.fem_meta();
56  const stk_classic::mesh::EntityRank elem_rank = fem_meta.element_rank();
57 
58  int size , rank;
59  rank = stk_classic::parallel_machine_rank( MPI_COMM_WORLD );
60  size = stk_classic::parallel_machine_size( MPI_COMM_WORLD );
61 
62  // Create a part for the shells
63  stk_classic::mesh::fem::CellTopology line_top(shards::getCellTopologyData<shards::ShellLine<2> >());
64  stk_classic::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 
81  shell_parts.push_back(&shell_part);
82 
83  std::vector<stk_classic::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_classic::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 
stk_classic::mesh::PartRelation
A defined entity-relationship between parts. An internal class that should never need to be directly...
Definition: PartRelation.hpp:33
stk_classic::parallel_machine_size
unsigned parallel_machine_size(ParallelMachine parallel_machine)
Member function parallel_machine_size ...
Definition: Parallel.cpp:18
stk_classic::mesh::Part
An application-defined subset of a problem domain.
Definition: Part.hpp:49
stk_classic::mesh::BulkData::declare_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.
Definition: BulkData.cpp:215
stk_classic::ParallelMachine
MPI_Comm ParallelMachine
Definition: Parallel.hpp:32
stk_classic::mesh::BulkData::modification_end
bool modification_end()
Parallel synchronization of modifications and transition to the guaranteed parallel consistent state.
Definition: BulkDataEndSync.cpp:729
stk_classic::mesh::fem::FEMMetaData::declare_part
Part & declare_part(const std::string &name, fem::CellTopology cell_topology)
Declare a part with a given cell topology.
Definition: FEMMetaData.hpp:240
stk_classic::mesh::fem::FEMMetaData::commit
void commit()
Commit the part and field declarations so that the meta data manager can be used to create mesh bulk ...
Definition: FEMMetaData.hpp:466
stk_classic::mesh::BulkData::modification_begin
bool modification_begin()
Begin a modification phase during which the mesh bulk data could become parallel inconsistent....
Definition: BulkData.cpp:172
stk_classic::mesh::MetaData
The manager of an integrated collection of parts and fields.
Definition: MetaData.hpp:56
stk_classic::mesh::PartVector
std::vector< Part * > PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
Definition: Types.hpp:31
stk_classic::mesh::Selector
This is a class for selecting buckets based on a set of meshparts and set logic.
Definition: Selector.hpp:112
stk_classic::parallel_machine_rank
unsigned parallel_machine_rank(ParallelMachine parallel_machine)
Member function parallel_machine_rank ...
Definition: Parallel.cpp:29
stk_classic::mesh::fem::FEMMetaData::element_rank
EntityRank element_rank() const
Returns the element rank which is always equal to spatial dimension.
Definition: FEMMetaData.hpp:160
stk_classic::mesh::fem::FEMMetaData
FEMMetaData is a class that implements a Finite Element Method skin on top of the Sierra Tool Kit Met...
Definition: FEMMetaData.hpp:54
stk_classic::mesh::Entity
A fundamental unit within the discretization of a problem domain, including but not limited to nodes,...
Definition: Entity.hpp:120
stk_classic::mesh::BulkData
Manager for an integrated collection of entities, entity relations, and buckets of field data.
Definition: BulkData.hpp:49