GRINS-0.7.0
mesh_builder.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2016 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #include "grins_config.h"
26 
27 #ifdef GRINS_HAVE_CPPUNIT
28 
29 #include <cppunit/extensions/HelperMacros.h>
30 #include <cppunit/TestCase.h>
31 
32 #include "test_comm.h"
33 #include "grins_test_paths.h"
34 
35 // GRINS
36 #include "grins/grins_enums.h"
37 #include "grins/mesh_builder.h"
38 
39 // libMesh
40 #include "libmesh/elem.h"
41 
42 namespace GRINSTesting
43 {
44  class MeshBuilderTest : public CppUnit::TestCase
45  {
46  public:
48 
52 
54 
55  public:
56 
58  {
59  std::string filename = std::string(GRINS_TEST_UNIT_INPUT_SRCDIR)+"/mesh_build_1d.in";
60  GetPot input(filename);
61  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = this->build_mesh(input);
62  CPPUNIT_ASSERT_EQUAL((libMesh::dof_id_type)22,mesh->n_elem());
63  this->test_elem_type(*mesh,GRINSEnums::EDGE2);
64  }
65 
67  {
68  std::string filename = std::string(GRINS_TEST_UNIT_INPUT_SRCDIR)+"/mesh_build_2d.in";
69  GetPot input(filename);
70  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = this->build_mesh(input);
71  CPPUNIT_ASSERT_EQUAL((libMesh::dof_id_type)100,mesh->n_elem());
72  this->test_elem_type(*mesh,GRINSEnums::QUAD9);
73 
74  }
75 
77  {
78  std::string filename = std::string(GRINS_TEST_UNIT_INPUT_SRCDIR)+"/mesh_build_3d.in";
79  GetPot input(filename);
80  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = this->build_mesh(input);
81  CPPUNIT_ASSERT_EQUAL((libMesh::dof_id_type)125,mesh->n_elem());
82  this->test_elem_type(*mesh,GRINSEnums::HEX8);
83  }
84 
85  private:
86 
87  GRINS::SharedPtr<libMesh::UnstructuredMesh> build_mesh( const GetPot& input )
88  {
89  GRINS::MeshBuilder mesh_builder;
90  return mesh_builder.build( input, *TestCommWorld );
91  }
92 
93  void test_elem_type( const libMesh::MeshBase& mesh, GRINSEnums::ElemType elem_type_expected )
94  {
95  for( libMesh::MeshBase::const_element_iterator e = mesh.active_elements_begin();
96  e != mesh.active_elements_end(); ++ e )
97  {
98  const libMesh::Elem* elem = *e;
99  GRINSEnums::ElemType elem_type_computed = elem->type();
100  CPPUNIT_ASSERT_EQUAL( elem_type_expected, elem_type_computed);
101  }
102  }
103  };
104 
105  CPPUNIT_TEST_SUITE_REGISTRATION( MeshBuilderTest );
106 
107 } // end namespace GRINSTesting
108 
109 #endif // GRINS_HAVE_CPPUNIT
CPPUNIT_TEST_SUITE_REGISTRATION(AntiochAirNASA9ThermoTest)
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_mesh(const GetPot &input)
Definition: mesh_builder.C:87
libMesh::Parallel::Communicator * TestCommWorld
Definition: unit_driver.C:65
CPPUNIT_TEST_SUITE(MeshBuilderTest)
CPPUNIT_TEST(test_build_1d_mesh)
SharedPtr< libMesh::UnstructuredMesh > build(const GetPot &input, const libMesh::Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD)
Builds the libMesh::Mesh according to input options.
Definition: mesh_builder.C:46
void test_elem_type(const libMesh::MeshBase &mesh, GRINSEnums::ElemType elem_type_expected)
Definition: mesh_builder.C:93

Generated on Thu Jun 2 2016 21:52:28 for GRINS-0.7.0 by  doxygen 1.8.10