COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-mesh-neu.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2013 von Karman Institute for Fluid Dynamics, Belgium
2 //
3 // This software is distributed under the terms of the
4 // GNU Lesser General Public License version 3 (LGPLv3).
5 // See doc/lgpl.txt and doc/gpl.txt for the license text.
6 
7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for cf3::mesh::neu::Reader"
9 
10 #include <boost/test/unit_test.hpp>
11 
12 #include "common/Log.hpp"
13 #include "common/OptionList.hpp"
14 #include "common/Core.hpp"
15 #include "common/EventHandler.hpp"
16 #include "common/Environment.hpp"
18 
19 #include "mesh/Mesh.hpp"
20 #include "mesh/Region.hpp"
21 #include "mesh/MeshReader.hpp"
22 #include "mesh/MeshWriter.hpp"
23 #include "mesh/MeshTransformer.hpp"
24 
25 #include "common/DynTable.hpp"
26 #include "common/List.hpp"
27 #include "common/Table.hpp"
28 #include "mesh/Dictionary.hpp"
29 
30 using namespace std;
31 using namespace boost;
32 using namespace cf3;
33 using namespace cf3::mesh;
34 using namespace cf3::common;
35 
37 
39 {
42  {
43  m_argc = boost::unit_test::framework::master_test_suite().argc;
44  m_argv = boost::unit_test::framework::master_test_suite().argv;
45  }
46 
49  {
50  }
52 
53 
55  int m_argc;
56  char** m_argv;
57 
58 };
59 
61 
62 BOOST_FIXTURE_TEST_SUITE( neuReaderMPITests_TestSuite, neuReaderMPITests_Fixture )
63 
64 
67 {
68  PE::Comm::instance().init(m_argc,m_argv);
69 }
70 
72 
73 BOOST_AUTO_TEST_CASE( read_2d_mesh )
74 {
75 
76  boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>("cf3.mesh.neu.Reader","meshreader");
77 
78  meshreader->options().set("read_groups",true);
79 
80  // the mesh to store in
81  Mesh& mesh = *Core::instance().root().create_component<Mesh>("quadtriag");
82 
83  meshreader->read_mesh_into("../../resources/quadtriag.neu",mesh);
84 
85 
86  CFinfo << "elements count = " << find_component<Region>(mesh).recursive_elements_count(true) << CFendl;
87  CFinfo << "nodes count = " << find_component<Region>(mesh).recursive_nodes_count() << CFendl;
88 
89  Uint nb_ghosts=0;
90 
91  boost::shared_ptr< MeshWriter > gmsh_writer = build_component_abstract_type<MeshWriter>("cf3.mesh.gmsh.Writer","meshwriter");
92  gmsh_writer->write_from_to(mesh,"quadtriag.msh");
93 
94  BOOST_CHECK(true);
95 
96  CFinfo << mesh.tree() << CFendl;
97 
98  Dictionary& nodes = find_component_recursively<Dictionary>(mesh);
99  for (Uint n=0; n<nodes.size(); ++n)
100  {
101  if (nodes.is_ghost(n))
102  {
103  CFinfo << "node " << n << " is a ghost node" << CFendl;
104  ++nb_ghosts;
105  }
106  }
107  CFinfo << "ghost node count = " << nb_ghosts << CFendl;
108 }
109 
111 
112 #if 0
113 // Disabled because there exists a duplicate node inside this hextet mesh
114 // The GlobalNumbering algorithm hence gets confused as to who gets to own it.
115 // It could be decided that one of them becomes a ghost!
116 BOOST_AUTO_TEST_CASE( threeD_test )
117 {
118  boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>("cf3.mesh.neu.Reader","meshreader");
119 
120  meshreader->options().set("read_groups",true);
121 
122  // the mesh to store in
123  Mesh& mesh = *Core::instance().root().create_component<Mesh>("hextet");
124 
125  meshreader->read_mesh_into("../../resources/hextet.neu",mesh);
126 
127  CFinfo << "elements count = " << find_component<Region>(mesh).recursive_elements_count(true) << CFendl;
128  CFinfo << "nodes count = " << find_component<Region>(mesh).recursive_nodes_count() << CFendl;
129 
130  boost::shared_ptr< MeshWriter > gmsh_writer = build_component_abstract_type<MeshWriter>("cf3.mesh.gmsh.Writer","meshwriter");
131  gmsh_writer->write_from_to(mesh, "hextet.msh");
132 
133  BOOST_CHECK(true);
134 
135  boost::shared_ptr< MeshWriter > neu_writer = build_component_abstract_type<MeshWriter>("cf3.mesh.neu.Writer","meshwriter");
136  neu_writer->write_from_to(mesh, "hextet_write.neu");
137 }
138 #endif
139 /*
141 BOOST_AUTO_TEST_CASE( read_multiple_2D )
142 {
143 
144  boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>("cf3.mesh.neu.Reader","meshreader");
145 
146  meshreader->options().set("Repartition",true);
147  meshreader->options().set("OutputRank",(Uint) 0);
148 
149  // the file to read from
150  boost::filesystem::path fp_in ("quadtriag.neu");
151 
152  // the mesh to store in
153  boost::shared_ptr< Mesh > mesh ( allocate_component<Mesh> ( "mesh" ) );
154 
155 
156  CFinfo.setFilterRankZero(false);
157 
158 
159 
160  for (Uint count=1; count<=2; ++count)
161  {
162  CFinfo << "\n\n\nMesh parallel:" << CFendl;
163  meshreader->do_read_mesh_into(fp_in,mesh);
164  }
165 
166 
167 
168  CFinfo.setFilterRankZero(true);
169  CFinfo << mesh->tree() << CFendl;
170  CFinfo << meshreader->tree() << CFendl;
171  boost::shared_ptr< MeshTransformer > info = build_component_abstract_type<MeshTransformer>("Info","info");
172  info->transform(mesh);
173 
174 
175  boost::filesystem::path fp_out ("quadtriag_mult.msh");
176  boost::shared_ptr< MeshWriter > gmsh_writer = build_component_abstract_type<MeshWriter>("cf3.mesh.gmsh.Writer","meshwriter");
177  gmsh_writer->write_from_to(mesh,fp_out);
178 
179  BOOST_CHECK_EQUAL(1,1);
180 
181 }
182 */
184 
185 
186 BOOST_AUTO_TEST_CASE( finalize_mpi )
187 {
188  PE::Comm::instance().finalize();
189  XML::SignalFrame frame;
190 
191  Core::instance().environment().options().set("log_level",4);
192 
193  Core::instance().terminate();
194 
195  // Check if any component pings back. No component should respond
196  Core::instance().event_handler().raise_event("ping", frame);
197 
198 }
199 
201 
202 BOOST_AUTO_TEST_SUITE_END()
203 
204 
#define CFinfo
these are always defined
Definition: Log.hpp:104
external boost library namespace
~neuReaderMPITests_Fixture()
common tear-down for each test case
STL namespace.
#define CFendl
Definition: Log.hpp:109
boost::proto::terminal< SFOp< NodesOp > >::type const nodes
Manages a set of maps.
Definition: SignalFrame.hpp:31
BOOST_AUTO_TEST_CASE(init_mpi)
Basic Classes for Mesh applications used by COOLFluiD.
Top-level namespace for coolfluid.
Definition: Action.cpp:18
std::string tree(bool basic_mode=false, Uint depth=0, Uint recursion_level=0) const
Definition: Component.cpp:785
SignalOptions & options(const std::string &name=std::string())
unsigned int Uint
typedef for unsigned int
Definition: CF.hpp:90
int m_argc
possibly common functions used on the tests below
bool is_ghost(const Uint idx) const
Check if a field row is owned by this rank.
Definition: Dictionary.cpp:151
void set(const std::string &pname, const boost::any &val)
Definition: OptionList.cpp:132
Uint size() const
Number of rows of contained fields.
Definition: Dictionary.cpp:99
Most basic kernel library.
Definition: Action.cpp:19
neuReaderMPITests_Fixture()
common setup for each test case
Send comments to:
COOLFluiD Web Admin