Sierra Toolkit  Version of the Day
GearsFixture.hpp
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 #ifndef STK_MESH_FIXTURES_GEARS_FIXTURE_HPP
10 #define STK_MESH_FIXTURES_GEARS_FIXTURE_HPP
11 
12 #include <vector>
13 
14 #include <stk_util/parallel/Parallel.hpp>
15 
16 #include <stk_mesh/base/Types.hpp>
17 #include <stk_mesh/base/MetaData.hpp>
18 #include <stk_mesh/base/BulkData.hpp>
19 #include <stk_mesh/base/Field.hpp>
20 #include <stk_mesh/base/DataTraits.hpp>
21 
22 #include <stk_mesh/fem/FEMMetaData.hpp>
23 #include <stk_mesh/fem/CoordinateSystems.hpp>
24 #include <stk_mesh/fem/TopologyDimensions.hpp>
25 
26 namespace stk_classic {
27 namespace mesh {
28 namespace fixtures {
29 
30 class Gear;
31 
32 struct GearParams {
33  GearParams()
34  : element_size(0.1),
35  radius_min(0.6),
36  radius_max(1.05),
37  height_min(-0.4),
38  height_max(0.4)
39  {}
40 
41  GearParams(double input_element_size,
42  double input_radius_min,
43  double input_radius_max,
44  double input_height_min,
45  double input_height_max)
46  : element_size(input_element_size),
47  radius_min(input_radius_min),
48  radius_max(input_radius_max),
49  height_min(input_height_min),
50  height_max(input_height_max)
51  {}
52 
53  double element_size;
54  double radius_min;
55  double radius_max;
56  double height_min;
57  double height_max;
58 };
59 
60 class GearsFixture{
61  public:
62 
63  typedef Field< double , Cylindrical> CylindricalField ;
64  typedef Field< double , Cartesian> CartesianField ;
65 
66  enum { SpatialDimension = 3 };
67 
68  GearsFixture( stk_classic::ParallelMachine pm, size_t num_gears,
69  GearParams gear_params=GearParams());
70  ~GearsFixture();
71 
72  void generate_mesh();
73 
74  const size_t NUM_GEARS;
75 
76  fem::FEMMetaData meta_data;
77  BulkData bulk_data;
78 
79  const EntityRank element_rank;
80 
81  Part & cylindrical_coord_part;
82  Part & hex_part;
83  Part & wedge_part;
84 
85  CartesianField & cartesian_coord_field ;
86  CartesianField & displacement_field ;
87  CartesianField & translation_field ;
88  CylindricalField & cylindrical_coord_field;
89 
90  Gear & get_gear(size_t i) {
91  return * m_gears[i];
92  }
93 
94  const Gear & get_gear(size_t i) const{
95  return * m_gears[i];
96  }
97 
98  void update_displacement_field();
99 
100  void communicate_model_fields();
101 
102  private:
103 
104  std::vector<Gear *> m_gears;
105 
106  GearsFixture( const GearsFixture & );
107  GearsFixture & operator = ( const GearsFixture & );
108 };
109 
111 void distribute_gear_across_processors(Gear & gear, GearsFixture::CylindricalField & cylindrical_coord_field);
112 unsigned destination_processor(const Gear & gear, double rad, double angle, double height, unsigned p_rank, unsigned p_size);
113 
114 } // fixtures
115 } // mesh
116 } // stk
117 
118 #endif //STK_MESH_FIXTURES_GEARS_FIXTURE_HPP
119 
Sierra Toolkit.
MPI_Comm ParallelMachine
Definition: Parallel.hpp:32