Sierra Toolkit Version of the Day
Gear.hpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010 Sandia Corporation.                     */
00003 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00004 /*  license for use of this work by or on behalf of the U.S. Government.  */
00005 /*  Export of this program may require a license from the                 */
00006 /*  United States Government.                                             */
00007 /*------------------------------------------------------------------------*/
00008 
00009 #ifndef STK_MESH_FIXTURES_GEAR_HPP
00010 #define STK_MESH_FIXTURES_GEAR_HPP
00011 
00012 #include <vector>
00013 #include <stk_mesh/base/Types.hpp>
00014 #include <stk_mesh/base/MetaData.hpp>
00015 #include <stk_mesh/base/BulkData.hpp>
00016 #include <stk_mesh/base/Field.hpp>
00017 
00018 #include <stk_mesh/fem/FEMMetaData.hpp>
00019 #include <stk_mesh/fem/CoordinateSystems.hpp>
00020 #include <stk_mesh/fem/TopologyDimensions.hpp>
00021 
00022 namespace {
00023 
00024 const double PI     = 3.14159265358979;
00025 const double TWO_PI = 2 * PI;
00026 
00027 } // namespace 
00028 
00029 
00030 namespace stk {
00031 namespace mesh {
00032 namespace fixtures {
00033 
00038 struct GearMovement
00039 {
00040   double rotation;
00041   double x;
00042   double y;
00043   double z;
00044 
00045   GearMovement(
00046       double arg_rotation = 0.0,
00047       double arg_x = 0.0,
00048       double arg_y = 0.0,
00049       double arg_z = 0.0
00050       ) :
00051      rotation(arg_rotation)
00052    , x(arg_x)
00053    , y(arg_y)
00054    , z(arg_z)
00055   {}
00056 };
00057 
00058 class Gear {
00059 
00060   typedef Field< double ,Cartesian>    CartesianField ;
00061   typedef Field< double ,Cylindrical>  CylindricalField ;
00062 
00063   enum { SpatialDimension = 3 };
00064 
00065  public:
00066   Gear(
00067        fem::FEMMetaData & meta,
00068        BulkData & bulk,
00069        Part & gear,
00070        Part & cylindrical_coord,
00071        Part & hex,
00072        Part & wedge,
00073        CartesianField    & arg_cartesian_coord_field,
00074        CartesianField    & arg_displacement_field,
00075        CartesianField    & arg_translation_field,
00076        CylindricalField  & arg_cylindrical_coord_field,
00077        double arg_element_size  =  0.10,
00078        double arg_radius_min    =  0.6,
00079        double arg_radius_max    =  1.0 + 0.05,
00080        double arg_height_min = -0.4,
00081        double arg_height_max =  0.4
00082        );
00083 
00084   const double element_size;
00085   const double rad_min, rad_max;
00086   const double height_min, height_max;
00087 
00088   const size_t angle_num;
00089   const size_t rad_num;
00090   const size_t height_num;
00091 
00092   const double angle_increment;
00093   const double rad_increment;
00094   const double height_increment;
00095 
00096   const size_t num_elements;
00097   const size_t num_nodes;
00098 
00099   fem::FEMMetaData & meta_data;
00100   BulkData         & bulk_data;
00101 
00102   Part & gear_part;
00103 
00104   //must be called between modification_begin / modification_end
00105   void generate_gear();
00106 
00107   void move( const GearMovement & data );
00108 
00109  private:
00110 
00111   Entity & get_node (
00112         size_t iz ,       // Thickness index
00113         size_t ir ,       // Radial index
00114         size_t ia ) const // Angle index
00115   {
00116     return * gear_entities[ node_index(iz,ir,ia)];
00117   }
00118 
00119     Entity & get_element(
00120         size_t iz ,       // Thickness index
00121         size_t ir ,       // Radial index
00122         size_t ia ) const // Angle index
00123   {
00124     return * gear_entities[ elem_index(iz,ir,ia)];
00125   }
00126 
00127     EntityId node_index(
00128         size_t iz ,       // Thickness index
00129         size_t ir ,       // Radial index
00130         size_t ia ) const // Angle index
00131   {
00132     return static_cast<stk::mesh::EntityId>(iz + height_num * ( ir + rad_num * ia ));
00133   }
00134 
00135   EntityId elem_index(
00136         size_t iz ,       // Thickness index
00137         size_t ir ,       // Radial index
00138         size_t ia ) const // Angle index
00139   {
00140     return static_cast<stk::mesh::EntityId>(num_nodes + iz + (height_num-1) * ( ir + (rad_num-1) * ia ));
00141   }
00142 
00143   void populate_fields(stk::mesh::FieldState state);
00144 
00145   Part & cylindrical_coord_part;
00146   Part & hex_part;
00147   Part & wedge_part;
00148 
00149   CartesianField    & cartesian_coord_field ;
00150   CartesianField    & displacement_field ;
00151   CartesianField    & translation_field ;
00152   CylindricalField  & cylindrical_coord_field ;
00153 
00154   EntityVector gear_entities;
00155 
00156   Gear(const Gear &);
00157   void operator = (const Gear &);
00158 };
00159 
00160 } // fixtures
00161 } // mesh
00162 } // stk
00163 
00164 #endif // STK_MESH_FIXTURES_GEAR_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines