7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for cf3::mesh::gmsh::Reader"
10 #include <boost/test/unit_test.hpp>
35 using namespace boost;
47 m_argc = boost::unit_test::framework::master_test_suite().argc;
48 m_argv = boost::unit_test::framework::master_test_suite().argv;
72 Core::instance().initiate(m_argc,m_argv);
73 Core::instance().environment().options().set(
"log_level",4u);
81 boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>(
"cf3.mesh.gmsh.Reader",
"meshreader");
82 BOOST_CHECK_EQUAL( meshreader->name() ,
"meshreader" );
83 BOOST_CHECK_EQUAL( meshreader->get_format() ,
"Gmsh" );
84 std::vector<std::string> extensions = meshreader->get_extensions();
85 BOOST_CHECK_EQUAL( extensions[0] ,
".msh" );
93 Mesh&
mesh = *Core::instance().root().create_component<
Mesh>(
"mesh_2d_triag_p1");
96 meshreader->read_mesh_into(
"../../resources/rectangle-tg-p1.msh",mesh);
101 boost::shared_ptr< MeshWriter > mesh_writer =
102 build_component_abstract_type<MeshWriter> (
"cf3.mesh.gmsh.Writer",
"GmshWriter" );
104 mesh_writer->options().set(
"file",
URI(
"rectangle-tg-p1-out.msh"));
105 mesh_writer->execute();
107 CFinfo <<
"elements count = " << find_component<Region>(
mesh).recursive_elements_count(
true) <<
CFendl;
108 CFinfo <<
"nodes count = " << find_component<Region>(
mesh).recursive_nodes_count() <<
CFendl;
117 boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>(
"cf3.mesh.gmsh.Reader",
"meshreader");
120 Mesh&
mesh = *Core::instance().root().create_component<
Mesh>(
"mesh_2d_triag_p2");
123 meshreader->read_mesh_into(
"../../resources/rectangle-tg-p2.msh",mesh);
128 boost::shared_ptr< MeshWriter > mesh_writer =
129 build_component_abstract_type<MeshWriter> (
"cf3.mesh.gmsh.Writer",
"GmshWriter" );
131 mesh_writer->options().set(
"file",
URI(
"rectangle-tg-p2-out.msh"));
132 mesh_writer->execute();
134 CFinfo <<
"elements count = " << find_component<Region>(
mesh).recursive_elements_count(
true) <<
CFendl;
135 CFinfo <<
"nodes count = " << find_component<Region>(
mesh).recursive_nodes_count() <<
CFendl;
144 boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>(
"cf3.mesh.gmsh.Reader",
"meshreader");
147 Mesh&
mesh = *Core::instance().root().create_component<
Mesh>(
"mesh_2d_quad_p1");
150 meshreader->read_mesh_into(
"../../resources/rectangle-qd-p2.msh",mesh);
155 boost::shared_ptr< MeshWriter > mesh_writer =
156 build_component_abstract_type<MeshWriter> (
"cf3.mesh.gmsh.Writer",
"GmshWriter" );
158 mesh_writer->options().set(
"file",
URI(
"rectangle-qd-p1-out.msh"));
159 mesh_writer->execute();
161 CFinfo <<
"elements count = " << find_component<Region>(
mesh).recursive_elements_count(
true) <<
CFendl;
162 CFinfo <<
"nodes count = " << find_component<Region>(
mesh).recursive_nodes_count() <<
CFendl;
170 boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>(
"cf3.mesh.gmsh.Reader",
"meshreader");
173 Mesh&
mesh = *Core::instance().root().create_component<
Mesh>(
"mesh_2d_quad_p2");
176 meshreader->read_mesh_into(
"../../resources/rectangle-qd-p2.msh",mesh);
181 boost::shared_ptr< MeshWriter > mesh_writer =
182 build_component_abstract_type<MeshWriter> (
"cf3.mesh.gmsh.Writer",
"GmshWriter" );
184 mesh_writer->options().set(
"file",
URI(
"rectangle-qd-p2-out.msh"));
185 mesh_writer->execute();
187 CFinfo <<
"elements count = " << find_component<Region>(
mesh).recursive_elements_count(
true) <<
CFendl;
188 CFinfo <<
"nodes count = " << find_component<Region>(
mesh).recursive_nodes_count() <<
CFendl;
197 boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>(
"cf3.mesh.gmsh.Reader",
"meshreader");
200 Mesh&
mesh = *Core::instance().root().create_component<
Mesh>(
"mesh_2d_mix_p1");
203 meshreader->read_mesh_into(
"../../resources/rectangle-mix-p1.msh",mesh);
208 boost::shared_ptr< MeshWriter > mesh_writer =
209 build_component_abstract_type<MeshWriter> (
"cf3.mesh.gmsh.Writer",
"GmshWriter" );
211 mesh_writer->options().set(
"file",
URI(
"rectangle-mix-p1-out.msh"));
212 mesh_writer->execute();
214 CFinfo <<
"elements count = " << find_component<Region>(
mesh).recursive_elements_count(
true) <<
CFendl;
215 CFinfo <<
"nodes count = " << find_component<Region>(
mesh).recursive_nodes_count() <<
CFendl;
224 boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>(
"cf3.mesh.gmsh.Reader",
"meshreader");
227 Mesh&
mesh = *Core::instance().root().create_component<
Mesh>(
"mesh_2d_mix_p2");
230 meshreader->read_mesh_into(
"../../resources/rectangle-mix-p2.msh",mesh);
235 boost::shared_ptr< MeshWriter > mesh_writer =
236 build_component_abstract_type<MeshWriter> (
"cf3.mesh.gmsh.Writer",
"GmshWriter" );
238 mesh_writer->options().set(
"file",
URI(
"rectangle-mix-p2-out.msh"));
239 mesh_writer->execute();
241 CFinfo <<
"elements count = " << find_component<Region>(
mesh).recursive_elements_count(
true) <<
CFendl;
242 CFinfo <<
"nodes count = " << find_component<Region>(
mesh).recursive_nodes_count() <<
CFendl;
251 boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>(
"cf3.mesh.gmsh.Reader",
"meshreader");
254 Mesh&
mesh = *Core::instance().root().create_component<
Mesh>(
"mesh_2d_mix_p1_out");
257 meshreader->read_mesh_into(
"rectangle-mix-p1-out_P0.msh",mesh);
263 Field& nodal = mesh.geometry_fields().create_field(
"nodal" ,
"nodal[vector]");
271 mesh.create_discontinuous_space(
"elems_P0",
"cf3.mesh.LagrangeP0");
273 Field& cell_centred = mesh.geometry_fields().create_field(
"cell_centred",
"cell_centred[vector]");
277 cell_centred[
e][j] =
e;
281 fields.push_back(cell_centred.
uri());
282 fields.push_back(nodal.
uri());
284 std::vector<URI> regions;
285 regions.push_back(mesh.uri()/
"topology/inlet");
286 regions.push_back(mesh.uri()/
"topology/outlet");
287 regions.push_back(mesh.uri()/
"topology/wall");
288 regions.push_back(mesh.uri()/
"topology/left");
292 boost::shared_ptr< MeshWriter > mesh_writer =
293 build_component_abstract_type<MeshWriter> (
"cf3.mesh.gmsh.Writer",
"GmshWriter" );
299 mesh_writer->options().set(
"mesh",mesh_arg);
300 mesh_writer->options().set(
"fields",fields);
301 mesh_writer->options().set(
"file",
URI(
"rectangle-mix-p1-out-out.msh"));
302 mesh_writer->options().set(
"regions",regions);
303 mesh_writer->execute();
307 CFinfo <<
"elements count = " << find_component<Region>(
mesh).recursive_elements_count(
true) <<
CFendl;
308 CFinfo <<
"nodes count = " << find_component<Region>(
mesh).recursive_nodes_count() <<
CFendl;
316 Core::instance().terminate();
321 BOOST_AUTO_TEST_SUITE_END()
#define CFinfo
these are always defined
external boost library namespace
URI uri() const
Construct the full path.
Real e()
Definition of the Unit charge [C].
Basic Classes for Mesh applications used by COOLFluiD.
BOOST_AUTO_TEST_CASE(init_mpi)
gmshReaderMPITests_Fixture()
common setup for each test case
Top-level namespace for coolfluid.
Uint row_size(Uint i=0) const
std::vector< URI > fields
unsigned int Uint
typedef for unsigned int
~gmshReaderMPITests_Fixture()
common tear-down for each test case
Handle< Component > handle()
Get a handle to the component.
math::VariablesDescriptor & descriptor() const
void set(const std::string &pname, const boost::any &val)
Most basic kernel library.