7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for cf3::mesh::gmsh::Reader parallel"
11 #include <boost/test/unit_test.hpp>
37 using namespace boost;
49 m_argc = boost::unit_test::framework::master_test_suite().argc;
50 m_argv = boost::unit_test::framework::master_test_suite().argv;
74 Core::instance().initiate(m_argc,m_argv);
75 PE::Comm::instance().init(m_argc,m_argv);
76 Core::instance().environment().options().set(
"log_level",(
Uint)
INFO);
77 Core::instance().environment().options().set(
"regist_signal_handlers",
true);
89 Handle<Mesh> generated_mesh = Core::instance().root().create_component<
Mesh>(
"mesh");
90 boost::shared_ptr< MeshGenerator > generate_mesh = build_component_abstract_type<MeshGenerator>(
"cf3.mesh.SimpleMeshGenerator",
"meshgenerator");
91 generate_mesh->
options().
set(
"nb_cells",std::vector<Uint>(dim,25));
92 generate_mesh->options().set(
"lengths",std::vector<Real>(dim,2.));
93 generate_mesh->options().set(
"mesh",generated_mesh->
uri());
94 generate_mesh->options().set(
"bdry",
false);
95 generate_mesh->execute();
97 PE::Comm::instance().barrier();
118 boost::shared_ptr< MeshWriter > write_mesh = build_component_abstract_type<MeshWriter>(
"cf3.mesh.gmsh.Writer",
"meshwriter");
119 write_mesh->
options().
set(
"mesh",generated_mesh);
121 write_mesh->options().set(
"fields",std::vector<URI>(1,generated_mesh->
uri()/
"P2/glb_node_idx"));
122 write_mesh->options().set(
"file",
URI(
"out-utest-mesh-gmsh-parallel.msh"));
123 write_mesh->execute();
126 PE::Comm::instance().barrier();
129 boost::shared_ptr< MeshReader > read_mesh = build_component_abstract_type<MeshReader>(
"cf3.mesh.gmsh.Reader",
"meshreader");
130 read_mesh->options().set(
"read_fields",
true);
132 std::vector< Handle<Mesh> > meshes(PE::Comm::instance().size());
133 for (
Uint p=0;
p<PE::Comm::instance().size(); ++
p)
135 meshes[
p] = Core::instance().root().create_component<
Mesh>(
"mesh"+
to_str(
p));
137 read_mesh->options().set(
"file",
URI(
"out-utest-mesh-gmsh-parallel_P"+
to_str(p)+
".msh"));
138 read_mesh->execute();
139 CFinfo <<
"mesh["<<p<<
"]: nb_cells = " << meshes[
p]->properties().value_str(
"global_nb_cells") <<
CFendl;
140 CFinfo <<
"mesh["<<p<<
"]: nb_nodes = " << meshes[
p]->properties().value_str(
"global_nb_nodes") <<
CFendl;
142 PE::Comm::instance().barrier();
144 boost::shared_ptr< MeshWriter > write_mesh = build_component_abstract_type<MeshWriter>(
"cf3.mesh.gmsh.Writer",
"meshwriter");
145 write_mesh->options().set(
"mesh",meshes[p]);
147 std::cout << meshes[
p]->tree() << std::endl;
151 write_mesh->options().set(
"fields",std::vector<URI>(1,meshes[p]->
uri()/
"geometry/glb_node_idx"));
153 write_mesh->options().set(
"fields",std::vector<URI>(1,meshes[p]->
uri()/
"discontinuous_geometry/glb_node_idx"));
155 write_mesh->options().set(
"file",
URI(
"out-P"+
to_str(p)+
"-utest-mesh-gmsh-parallel.msh"));
156 write_mesh->execute();
162 Handle<Mesh> merged_mesh = Core::instance().root().create_component<
Mesh>(
"merged_mesh");
170 PE::Comm::instance().barrier();
183 PE::Comm::instance().barrier();
186 CFinfo <<
"Write file \"out-merged-utest-mesh-gmsh-parallel.msh\" " <<
CFendl;
187 boost::shared_ptr< MeshWriter > write_mesh = build_component_abstract_type<MeshWriter>(
"cf3.mesh.gmsh.Writer",
"meshwriter");
188 write_mesh->options().set(
"mesh",merged_mesh);
192 write_mesh->options().set(
"fields",std::vector<URI>(1,merged_mesh->
uri()/
"geometry/glb_node_idx"));
194 write_mesh->options().set(
"fields",std::vector<URI>(1,merged_mesh->
uri()/
"discontinuous_geometry/glb_node_idx"));
196 write_mesh->options().set(
"file",
URI(
"out-merged-utest-mesh-gmsh-parallel.msh"));
197 write_mesh->execute();
200 PE::Comm::instance().barrier();
202 CFinfo <<
"Loadbalancing mesh with structure\n" << merged_mesh->
tree(
true);
205 boost::shared_ptr<mesh::actions::LoadBalance>
load_balancer = allocate_component<mesh::actions::LoadBalance>(
"load_balance");
206 load_balancer->transform(*merged_mesh);
210 PE::Comm::instance().barrier();
214 CFinfo <<
"Write file \"out-loadbalanced-utest-mesh-gmsh-parallel.msh\" " <<
CFendl;
215 boost::shared_ptr< MeshWriter > write_mesh = build_component_abstract_type<MeshWriter>(
"cf3.mesh.gmsh.Writer",
"meshwriter");
216 write_mesh->options().set(
"mesh",merged_mesh);
218 write_mesh->options().set(
"fields",std::vector<URI>(1,merged_mesh->
uri()/
"geometry/glb_node_idx"));
220 write_mesh->options().set(
"fields",std::vector<URI>(1,merged_mesh->
uri()/
"discontinuous_geometry/glb_node_idx"));
221 write_mesh->options().set(
"file",
URI(
"out-loadbalanced-utest-mesh-gmsh-parallel.msh"));
222 write_mesh->options().set(
"enable_overlap",
false);
223 write_mesh->execute();
231 PE::Comm::instance().finalize();
232 Core::instance().terminate();
237 BOOST_AUTO_TEST_SUITE_END()
#define CFinfo
these are always defined
Field & create_field(const std::string &name, const Uint cols)
Create a new field in this group.
Dictionary & create_discontinuous_space(const std::string &space_name, const std::string &space_lib_name, const std::vector< Handle< Entities > > &entities)
const std::vector< Handle< Entities > > & elements() const
external boost library namespace
Dictionary & create_continuous_space(const std::string &space_name, const std::string &space_lib_name, const std::vector< Handle< Entities > > &entities)
URI uri() const
Construct the full path.
#define boost_foreach
lowercase version of BOOST_FOREACH
common::URI uri(ComponentWrapper &self)
int m_argc
possibly common functions used on the tests below
Common_API std::string to_str(const T &v)
Converts to std::string.
void fix_node_ranks()
Correct ranks of nodes to be unique in all pid's.
PropertyList & properties()
Basic Classes for Mesh applications used by COOLFluiD.
void remove_duplicate_elements_and_nodes()
Add another mesh to this mesh.
std::string value_str(const std::string &pname) const
gmshReaderMPITests_Fixture()
common setup for each test case
Handle< Component > get_child(const std::string &name)
Top-level namespace for coolfluid.
common::List< Uint > & glb_idx()
Return the global index of every field row.
std::string tree(bool basic_mode=false, Uint depth=0, Uint recursion_level=0) const
void finish()
Apply the changes the mesh adaptor for changes and fix inconsistent state.
unsigned int Uint
typedef for unsigned int
~gmshReaderMPITests_Fixture()
common tear-down for each test case
void set(const std::string &pname, const boost::any &val)
Uint size() const
Number of rows of contained fields.
Most basic kernel library.
void combine_mesh(const Mesh &other_mesh)
Add another mesh to this mesh.
BOOST_AUTO_TEST_CASE(init_mpi)