Sierra Toolkit Version of the Day
UnitTestGridFixture.cpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010, 2011 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 #include <stk_util/unit_test_support/stk_utest_macros.hpp>
00010 #include <Shards_BasicTopologies.hpp>
00011 
00012 #include <stk_util/parallel/Parallel.hpp>
00013 
00014 #include <stk_mesh/base/Types.hpp>
00015 #include <stk_mesh/base/MetaData.hpp>
00016 #include <stk_mesh/base/BulkData.hpp>
00017 #include <stk_mesh/base/Entity.hpp>
00018 #include <stk_mesh/base/GetEntities.hpp>
00019 #include <stk_mesh/base/Selector.hpp>
00020 #include <stk_mesh/base/GetBuckets.hpp>
00021 #include <stk_mesh/base/BulkModification.hpp>
00022 
00023 #include <stk_mesh/fem/BoundaryAnalysis.hpp>
00024 #include <stk_mesh/fem/SkinMesh.hpp>
00025 
00026 #include <stk_mesh/fixtures/GridFixture.hpp>
00027 
00028 #include <stk_util/parallel/ParallelReduce.hpp>
00029 
00030 #include <iomanip>
00031 #include <algorithm>
00032 
00033 using stk::mesh::MetaData;
00034 using stk::mesh::fem::FEMMetaData;
00035 using stk::mesh::Part;
00036 using stk::mesh::PartVector;
00037 using stk::mesh::PartRelation;
00038 using stk::mesh::Entity;
00039 using stk::mesh::EntityVector;
00040 using stk::mesh::EntityRank;
00041 using stk::mesh::Selector;
00042 using stk::mesh::BulkData;
00043 using stk::ParallelMachine;
00044 using std::cout;
00045 using std::endl;
00046 
00047 STKUNIT_UNIT_TEST( UnitTestGridFixture, test_gridfixture )
00048 {
00049   //Coverage of GridFixture, Hexfixture, BoxFixture,QuadFixture
00050   //and RingFixture in fixture directory for more than one
00051   //processor.
00052   stk::mesh::fixtures::GridFixture grid_mesh(MPI_COMM_WORLD);
00053 
00054   stk::mesh::BulkData& bulk_data = grid_mesh.bulk_data();
00055   stk::mesh::fem::FEMMetaData& fem_meta = grid_mesh.fem_meta();
00056   const stk::mesh::EntityRank elem_rank = fem_meta.element_rank();
00057   
00058   int  size , rank;
00059   rank = stk::parallel_machine_rank( MPI_COMM_WORLD );
00060   size = stk::parallel_machine_size( MPI_COMM_WORLD );
00061 
00062   // Create a part for the shells
00063   stk::mesh::fem::CellTopology line_top(shards::getCellTopologyData<shards::ShellLine<2> >());
00064   stk::mesh::Part & shell_part = fem_meta.declare_part("shell_part", line_top);
00065 
00066   fem_meta.commit();
00067 
00068   // Generate the plain grid
00069   bulk_data.modification_begin();
00070   grid_mesh.generate_grid();
00071   bulk_data.modification_end();
00072 
00073   // Add the shells
00074   bulk_data.modification_begin();
00075 
00076   const unsigned num_shell_1_faces = 4*size + rank;
00077   const unsigned num_shell_2_faces = 2*size + rank;
00078   const unsigned num_shell_faces = num_shell_1_faces + num_shell_2_faces;
00079 
00080   stk::mesh::PartVector shell_parts;
00081   shell_parts.push_back(&shell_part);
00082 
00083   std::vector<stk::mesh::Entity*> shell_faces;
00084 
00085   unsigned id_base = 0;
00086   unsigned id_offset = 500; // a safe offset to avoid id overlap
00087   //Start at 1 so as not to have same element on different processors
00088   for (id_base = 1; id_base <= num_shell_faces; ++id_base) {
00089 
00090     int new_id = rank * num_shell_faces + id_base;
00091     stk::mesh::Entity& new_shell = bulk_data.declare_entity(elem_rank,
00092                                                             id_offset + new_id,
00093                                                             shell_parts);
00094     shell_faces.push_back(&new_shell);
00095   }
00096 
00097    bulk_data.modification_end();
00098 }
00099 
00100 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends