COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-mesh-actions-facebuilder-mpi.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 "Tests mesh::actions::BuildFaces"
9 
10 #include <boost/test/unit_test.hpp>
11 #include <boost/assign/list_of.hpp>
12 
13 #include "common/List.hpp"
14 #include "common/Log.hpp"
15 #include "common/Core.hpp"
16 #include "common/Environment.hpp"
17 #include "common/OptionList.hpp"
18 
20 #include "common/PE/Comm.hpp"
21 #include "common/PE/debug.hpp"
22 
25 #include "mesh/MeshTransformer.hpp"
26 #include "mesh/MeshWriter.hpp"
27 #include "mesh/Mesh.hpp"
28 #include "mesh/Region.hpp"
29 #include "mesh/Faces.hpp"
30 #include "mesh/MeshReader.hpp"
31 #include "mesh/Field.hpp"
33 #include "mesh/Cells.hpp"
35 
36 using namespace cf3;
37 using namespace boost::assign;
38 using namespace cf3::common;
39 using namespace cf3::mesh;
40 using namespace cf3::mesh::actions;
41 
43 
45 {
48  {
49  m_argc = boost::unit_test::framework::master_test_suite().argc;
50  m_argv = boost::unit_test::framework::master_test_suite().argv;
51  }
52 
55  {
56  }
57 
59  int m_argc;
60  char** m_argv;
61 
62 
65 };
66 
67 Handle<Mesh> TestBuildFaces_Fixture::mesh = Core::instance().root().create_component<Mesh>("mesh");
68 
70 
71 BOOST_FIXTURE_TEST_SUITE( TestBuildFaces_TestSuite, TestBuildFaces_Fixture )
72 
73 
76 {
77  Core::instance().initiate(m_argc,m_argv);
78  PE::Comm::instance().init(m_argc,m_argv);
79  Core::instance().environment().options().set("log_level",(Uint)DEBUG);
80  Core::instance().environment().options().set("only_cpu0_writes",false);
81 }
82 
84 
86 {
87  boost::shared_ptr<MeshReader> meshreader = build_component_abstract_type<MeshReader>("cf3.mesh.neu.Reader","meshreader");
88  meshreader->read_mesh_into("../../../resources/quadtriag.neu",*mesh);
89 
90 // PEProcessSortedExecute(-1,
91 // std::cout << PERank << mesh->tree() << std::endl<<std::endl;
92 // )
93 
94 
95 }
96 
98 
99 BOOST_AUTO_TEST_CASE( build_faces )
100 {
101  boost::shared_ptr<BuildFaces> facebuilder = allocate_component<BuildFaces>("facebuilder");
102 
103  facebuilder->set_mesh(mesh);
104  facebuilder->execute();
105 
107  std::cout << "checking rank " << PERank << std::endl;
108  BOOST_CHECK( is_not_null(Core::instance().root().access_component("mesh/topology/inlet")) );
109  BOOST_CHECK( is_not_null(Core::instance().root().access_component("mesh/topology/outlet")) );
110  BOOST_CHECK( is_not_null(Core::instance().root().access_component("mesh/topology/wall")) );
111  BOOST_CHECK( is_not_null(Core::instance().root().access_component("mesh/topology/liquid")) );
112  BOOST_CHECK( is_not_null(Core::instance().root().access_component("mesh/topology/liquid/cells")) );
113  BOOST_CHECK( is_not_null(Core::instance().root().access_component("mesh/topology/liquid/inner_faces")) );
114 // BOOST_CHECK( is_not_null(Core::instance().root().access_component("mesh/topology/liquid/outer_faces")) );
115  BOOST_CHECK( is_not_null(Core::instance().root().access_component("mesh/topology/gas")) );
116  BOOST_CHECK( is_not_null(Core::instance().root().access_component("mesh/topology/gas/cells")) );
117  BOOST_CHECK( is_not_null(Core::instance().root().access_component("mesh/topology/gas/inner_faces")) );
118 // BOOST_CHECK( is_not_null(Core::instance().root().access_component("mesh/topology/gas/outer_faces")) );
119 
120  std::cout << "glb_idx = " << *mesh->topology().access_component("gas/inner_faces/Line/global_indices")->handle< List<Uint> >() << std::endl;
121  std::cout << "rank = " << *mesh->topology().access_component("gas/inner_faces/Line/rank")->handle< List<Uint> >() << std::endl;
122  );
123 
124 }
125 
127 
128 BOOST_AUTO_TEST_CASE( write_mesh )
129 {
130 
131 // PEProcessSortedExecute(-1,
132 // std::cout << PERank << mesh->tree() << std::endl<<std::endl;
133 // )
134 
135  boost::shared_ptr<MeshWriter> tecwriter = build_component_abstract_type<MeshWriter>("cf3.mesh.tecplot.Writer","meshwriter");
136  tecwriter->write_from_to(*mesh,URI("file:quadtriag-faces.plt"));
137 
138  boost::shared_ptr<MeshWriter> gmshwriter = build_component_abstract_type<MeshWriter>("cf3.mesh.gmsh.Writer","meshwriter");
139  gmshwriter->write_from_to(*mesh,URI("file:quadtriag-faces.msh"));
140 
141 }
142 
144 
145 BOOST_AUTO_TEST_CASE( finalize_mpi )
146 {
147  Core::instance().terminate();
148  PE::Comm::instance().finalize();
149 }
150 
152 BOOST_AUTO_TEST_SUITE_END()
153 
154 
int m_argc
possibly common functions used on the tests below
tuple root
Definition: coolfluid.py:24
static Handle< Mesh > mesh
common values accessed by all tests goes here
Basic Classes for Mesh applications used by COOLFluiD.
Top-level namespace for coolfluid.
Definition: Action.cpp:18
unsigned int Uint
typedef for unsigned int
Definition: CF.hpp:90
Action derived classes for mesh manipulations.
BOOST_AUTO_TEST_CASE(init_mpi)
~TestBuildFaces_Fixture()
common tear-down for each test case
TestBuildFaces_Fixture()
common setup for each test case
#define PERank
Definition: debug.hpp:36
Most basic kernel library.
Definition: Action.cpp:19
bool is_not_null(T ptr)
predicate for comparison to nullptr
Definition: CF.hpp:147
#define PEProcessSortedExecute(irank, expression)
Definition: debug.hpp:43
Send comments to:
COOLFluiD Web Admin