Sierra Toolkit Version of the Day
UnitTestMesh.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 
00010 #include <stk_mesh/base/Types.hpp>
00011 #include <stk_mesh/base/MetaData.hpp>
00012 #include <stk_mesh/base/BulkData.hpp>
00013 #include <stk_mesh/base/GetEntities.hpp>
00014 #include <stk_mesh/base/Field.hpp>
00015 #include <stk_mesh/base/FieldData.hpp>
00016 #include <stk_mesh/base/Comm.hpp>
00017 #include <stk_mesh/fem/EntityRanks.hpp>
00018 #include <stk_mesh/base/GetBuckets.hpp>
00019 
00020 //----------------------------------------------------------------------
00021 //----------------------------------------------------------------------
00022 
00023 namespace stk {
00024 namespace unit_test {
00025 
00026 // Helper function to generate a vector of entity names
00027 std::vector<std::string>  get_entity_rank_names ( int rank );
00028 
00029 class  UnitTestMesh {
00030 protected:
00031     stk::mesh::MetaData   m_meta_data;
00032     stk::mesh::BulkData   m_bulk_data;
00033     stk::mesh::Part     & m_test_part;   // A simple part
00034     stk::mesh::Part     & m_cell_part;   // A part to put cells in
00035 
00036     stk::mesh::Part     & m_part_A_0;
00037     stk::mesh::Part     & m_part_A_1;
00038     stk::mesh::Part     & m_part_A_2;
00039     stk::mesh::Part     & m_part_A_3;
00040 
00041     stk::mesh::Part     & m_part_A_superset;
00042 
00043     stk::mesh::Part     & m_part_B_0;
00044     stk::mesh::Part     & m_part_B_1;
00045     stk::mesh::Part     & m_part_B_2;
00046     stk::mesh::Part     & m_part_B_3;
00047 
00048     stk::mesh::Part     & m_part_B_superset;
00049 
00050     unsigned    m_comm_rank;
00051     unsigned    m_comm_size;
00052 
00053     stk::mesh::BulkData::BulkDataSyncState     m_previous_state;
00054 
00055 
00065      void priv_generate_boxes( stk::mesh::BulkData  & mesh ,
00066                               const bool  generate_aura ,
00067                               const int   root_box[][2] ,
00068                                     int   local_box[][2] );
00069 
00070     void enter_modification ()
00071     {
00072       m_previous_state = m_bulk_data.synchronized_state();
00073       if ( m_previous_state == stk::mesh::BulkData::SYNCHRONIZED )
00074         m_bulk_data.modification_begin();
00075     }
00076 
00077      void exit_modification ()
00078     {
00079       if ( m_previous_state == stk::mesh::BulkData::SYNCHRONIZED )
00080         m_bulk_data.modification_end();
00081     }
00082 
00083 public:
00084     UnitTestMesh( stk::ParallelMachine pm = MPI_COMM_WORLD ,
00085                   unsigned block_size = 1000 );
00086    ~UnitTestMesh () {}
00087 
00088      const stk::mesh::BulkData & bulk_data () const { return m_bulk_data; }
00089      stk::mesh::BulkData       & nonconst_bulk_data () { return m_bulk_data; }
00090 
00091      unsigned  comm_size() const { return m_comm_size; }
00092      unsigned  comm_rank() const { return m_comm_rank; }
00093 
00094      void  generate_boxes ( bool aura = false );
00095 
00096      stk::mesh::Entity  &get_new_entity ( stk::mesh::EntityRank rank , stk::mesh::EntityId parallel_dependent_id )
00097      {
00098        return m_bulk_data.declare_entity ( rank , parallel_dependent_id*m_comm_size + m_comm_rank + 1 , std::vector<stk::mesh::Part *> () );
00099      }
00100 
00101 
00102      enum { MAX_RANK = 3 };
00103      const stk::mesh::MetaData & meta_data () const { return m_meta_data; }
00104 
00105      stk::mesh::Part &     get_test_part () { return m_test_part; }
00106      stk::mesh::Part &     get_cell_part () { return m_cell_part; }
00107 
00108      stk::mesh::Part &     get_part_a_0 () { return m_part_A_0; }
00109      stk::mesh::Part &     get_part_a_1 () { return m_part_A_1; }
00110      stk::mesh::Part &     get_part_a_2 () { return m_part_A_2; }
00111      stk::mesh::Part &     get_part_a_3 () { return m_part_A_3; }
00112 
00113      stk::mesh::Part &     get_part_a_superset () { return m_part_A_superset; }
00114 
00115      stk::mesh::Part &     get_part_b_0 () { return m_part_B_0; }
00116      stk::mesh::Part &     get_part_b_1 () { return m_part_B_1; }
00117      stk::mesh::Part &     get_part_b_2 () { return m_part_B_2; }
00118      stk::mesh::Part &     get_part_b_3 () { return m_part_B_3; }
00119 
00120      stk::mesh::Part &     get_part_b_superset () { return m_part_B_superset; }
00121 
00122 private:
00123   UnitTestMesh();
00124   UnitTestMesh( const UnitTestMesh & );
00125   UnitTestMesh & operator = ( const UnitTestMesh & );
00126 };
00127 
00128 } // namespace unit_test
00129 } // namespace stk
00130 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends