|
Sierra Toolkit Version of the Day
|
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_HEX_MESH_FIXTURE_HPP 00010 #define STK_MESH_FIXTURES_HEX_MESH_FIXTURE_HPP 00011 00012 #include <Shards_BasicTopologies.hpp> 00013 00014 #include <stk_util/parallel/Parallel.hpp> 00015 00016 #include <stk_mesh/base/Types.hpp> 00017 #include <stk_mesh/base/MetaData.hpp> 00018 #include <stk_mesh/base/BulkData.hpp> 00019 #include <stk_mesh/base/Field.hpp> 00020 #include <stk_mesh/base/DataTraits.hpp> 00021 00022 #include <stk_mesh/fem/EntityRanks.hpp> 00023 #include <stk_mesh/fem/CoordinateSystems.hpp> 00024 #include <stk_mesh/fem/TopologyDimensions.hpp> 00025 00026 namespace stk { 00027 namespace mesh { 00028 namespace fixtures { 00029 00030 class HexFixture 00031 { 00032 public: 00033 00034 typedef double Scalar ; 00035 typedef Field<Scalar, Cartesian> CoordFieldType; 00036 typedef Field<Scalar*,ElementNode> CoordGatherFieldType; 00037 00038 HexFixture(stk::ParallelMachine pm, unsigned nx, unsigned ny, unsigned nz); 00039 00040 ~HexFixture(); 00041 00042 const int spatial_dimension; 00043 const unsigned NX; 00044 const unsigned NY; 00045 const unsigned NZ; 00046 00047 MetaData meta_data; 00048 BulkData bulk_data; 00049 TopologicalMetaData top_data; 00050 00051 Part & hex_part; 00052 00053 CoordFieldType & coord_field ; 00054 CoordGatherFieldType & coord_gather_field ; 00055 00056 EntityId node_id( unsigned ix , unsigned iy , unsigned iz ) const { 00057 return 1 + ix + ( NX + 1 ) * ( iy + ( NY + 1 ) * iz ); 00058 } 00059 00060 EntityId elem_id( unsigned ix , unsigned iy , unsigned iz ) const { 00061 return 1 + ix + NX * ( iy + NY * iz ); 00062 } 00063 00064 void node_ix_iy_iz( EntityId entity_id, unsigned &ix , unsigned &iy , unsigned &iz ) const { 00065 entity_id -= 1; 00066 00067 ix = entity_id % (NX+1); 00068 entity_id /= (NX+1); 00069 00070 iy = entity_id % (NY+1); 00071 entity_id /= (NY+1); 00072 00073 iz = entity_id; 00074 } 00075 00076 void elem_ix_iy_iz( EntityId entity_id, unsigned &ix , unsigned &iy , unsigned &iz ) const { 00077 entity_id -= 1; 00078 00079 ix = entity_id % NX; 00080 entity_id /= NX; 00081 00082 iy = entity_id % NY; 00083 entity_id /= NY; 00084 00085 iz = entity_id; 00086 } 00087 00088 Entity * node( unsigned ix , unsigned iy , unsigned iz ) const { 00089 return bulk_data.get_entity( top_data.node_rank , node_id(ix,iy,iz) ); 00090 } 00091 00092 Entity * elem( unsigned ix , unsigned iy , unsigned iz ) const { 00093 return bulk_data.get_entity( top_data.element_rank , elem_id(ix,iy,iz) ); 00094 } 00095 00096 void generate_mesh( std::vector<EntityId> & element_ids_on_this_processor ); 00097 00098 void generate_mesh(); 00099 private: 00100 00101 HexFixture(); 00102 HexFixture( const HexFixture &); 00103 HexFixture & operator = (const HexFixture &); 00104 }; 00105 00106 00107 } // fixtures 00108 } // mesh 00109 } // stk 00110 #endif