GRINS-0.8.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-2017 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 <libmesh/ignore_warnings.h>
30 #include <cppunit/extensions/HelperMacros.h>
31 #include <cppunit/TestCase.h>
32 #include <libmesh/restore_warnings.h>
33 
34 #include "test_comm.h"
35 #include "grins_test_paths.h"
36 
37 // GRINS
38 #include "grins/grins_enums.h"
39 #include "grins/mesh_builder.h"
40 
41 // libMesh
42 #include "libmesh/elem.h"
43 
44 // Ignore warnings from auto_ptr in CPPUNIT_TEST_SUITE_END()
45 #include <libmesh/ignore_warnings.h>
46 
47 namespace GRINSTesting
48 {
49  class MeshBuilderTest : public CppUnit::TestCase
50  {
51  public:
53 
57 
59 
60  public:
61 
63  {
64  std::string filename = std::string(GRINS_TEST_UNIT_INPUT_SRCDIR)+"/mesh_build_1d.in";
65  GetPot input(filename);
66  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = this->build_mesh(input);
67  CPPUNIT_ASSERT_EQUAL((libMesh::dof_id_type)22,mesh->n_elem());
68  this->test_elem_type(*mesh,GRINSEnums::EDGE2);
69  }
70 
72  {
73  std::string filename = std::string(GRINS_TEST_UNIT_INPUT_SRCDIR)+"/mesh_build_2d.in";
74  GetPot input(filename);
75  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = this->build_mesh(input);
76  CPPUNIT_ASSERT_EQUAL((libMesh::dof_id_type)100,mesh->n_elem());
77  this->test_elem_type(*mesh,GRINSEnums::QUAD9);
78 
79  }
80 
82  {
83  std::string filename = std::string(GRINS_TEST_UNIT_INPUT_SRCDIR)+"/mesh_build_3d.in";
84  GetPot input(filename);
85  GRINS::SharedPtr<libMesh::UnstructuredMesh> mesh = this->build_mesh(input);
86  CPPUNIT_ASSERT_EQUAL((libMesh::dof_id_type)125,mesh->n_elem());
87  this->test_elem_type(*mesh,GRINSEnums::HEX8);
88  }
89 
90  private:
91 
92  GRINS::SharedPtr<libMesh::UnstructuredMesh> build_mesh( const GetPot& input )
93  {
94  GRINS::MeshBuilder mesh_builder;
95  return mesh_builder.build( input, *TestCommWorld );
96  }
97 
98  void test_elem_type( const libMesh::MeshBase& mesh, GRINSEnums::ElemType elem_type_expected )
99  {
100  for( libMesh::MeshBase::const_element_iterator e = mesh.active_elements_begin();
101  e != mesh.active_elements_end(); ++ e )
102  {
103  const libMesh::Elem* elem = *e;
104  GRINSEnums::ElemType elem_type_computed = elem->type();
105  CPPUNIT_ASSERT_EQUAL( elem_type_expected, elem_type_computed);
106  }
107  }
108  };
109 
110  CPPUNIT_TEST_SUITE_REGISTRATION( MeshBuilderTest );
111 
112 } // end namespace GRINSTesting
113 
114 #endif // GRINS_HAVE_CPPUNIT
CPPUNIT_TEST_SUITE_REGISTRATION(AntiochAirNASA9ThermoTest)
GRINS::SharedPtr< libMesh::UnstructuredMesh > build_mesh(const GetPot &input)
Definition: mesh_builder.C:92
libMesh::Parallel::Communicator * TestCommWorld
Definition: unit_driver.C:70
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:98

Generated on Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1