7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Tests mesh::actions::BuildFaces"
10 #include <boost/test/unit_test.hpp>
11 #include <boost/assign/list_of.hpp>
47 m_argc = boost::unit_test::framework::master_test_suite().argc;
48 m_argv = boost::unit_test::framework::master_test_suite().argv;
75 boost::shared_ptr<BuildFaces> facebuilder = allocate_component<BuildFaces>(
"facebuilder");
76 BOOST_CHECK_EQUAL(facebuilder->name(),
"facebuilder");
77 Core::instance().environment().options().set(
"log_level",(
Uint)
INFO);
82 boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>(
"cf3.mesh.neu.Reader",
"meshreader");
83 meshreader->read_mesh_into(
"../../../resources/quadtriag.neu",*
mesh);
88 BOOST_CHECK_EQUAL( f2c.
size() , 31u);
91 Handle<Elements> liquid_triag (
mesh->access_component(
"topology/liquid/elements_cf3.mesh.LagrangeP1.Triag2D"));
92 Handle<Elements> gas_triag (
mesh->access_component(
"topology/gas/elements_cf3.mesh.LagrangeP1.Triag2D"));
93 Handle<Elements> gas_quad (
mesh->access_component(
"topology/gas/elements_cf3.mesh.LagrangeP1.Quad2D"));
100 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
101 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,0) );
102 BOOST_CHECK( face.cells()[1] ==
Entity(*liquid_triag,9) );
105 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
106 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,0) );
107 BOOST_CHECK( face.cells()[1] ==
Entity(*gas_triag,2) );
110 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
111 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,0) );
112 BOOST_CHECK( face.cells()[1] ==
Entity(*liquid_triag,1) );
115 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
116 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,1) );
117 BOOST_CHECK( face.cells()[1] ==
Entity(*liquid_triag,2) );
120 BOOST_CHECK_EQUAL( face.is_bdry() ,
true);
121 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,1) );
124 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
125 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,2) );
126 BOOST_CHECK( face.cells()[1] ==
Entity(*liquid_triag,3) );
129 BOOST_CHECK_EQUAL( face.is_bdry() ,
true);
130 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,2) );
133 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
134 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,3) );
135 BOOST_CHECK( face.cells()[1] ==
Entity(*liquid_triag,8) );
138 BOOST_CHECK_EQUAL( face.is_bdry() ,
true);
139 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,3) );
142 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
143 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,4) );
144 BOOST_CHECK( face.cells()[1] ==
Entity(*liquid_triag,5) );
147 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
148 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,4) );
149 BOOST_CHECK( face.cells()[1] ==
Entity(*gas_triag,0) );
152 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
153 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,4) );
154 BOOST_CHECK( face.cells()[1] ==
Entity(*liquid_triag,9) );
157 BOOST_CHECK_EQUAL( face.is_bdry() ,
true);
158 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,5) );
161 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
162 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,5) );
163 BOOST_CHECK( face.cells()[1] ==
Entity(*liquid_triag,6) );
166 BOOST_CHECK_EQUAL( face.is_bdry() ,
true);
167 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,6) );
170 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
171 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,6) );
172 BOOST_CHECK( face.cells()[1] ==
Entity(*liquid_triag,7) );
175 BOOST_CHECK_EQUAL( face.is_bdry() ,
true);
176 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,7) );
179 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
180 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,7) );
181 BOOST_CHECK( face.cells()[1] ==
Entity(*liquid_triag,8) );
184 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
185 BOOST_CHECK( face.cells()[0] ==
Entity(*liquid_triag,8) );
186 BOOST_CHECK( face.cells()[1] ==
Entity(*liquid_triag,9) );
189 BOOST_CHECK_EQUAL( face.is_bdry() ,
true);
190 BOOST_CHECK( face.cells()[0] ==
Entity(*gas_quad,0) );
193 BOOST_CHECK_EQUAL( face.is_bdry() ,
true);
194 BOOST_CHECK( face.cells()[0] ==
Entity(*gas_quad,0) );
197 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
198 BOOST_CHECK( face.cells()[0] ==
Entity(*gas_quad,0) );
199 BOOST_CHECK( face.cells()[1] ==
Entity(*gas_quad,1) );
202 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
203 BOOST_CHECK( face.cells()[0] ==
Entity(*gas_quad,0) );
204 BOOST_CHECK( face.cells()[1] ==
Entity(*gas_triag,1) );
207 BOOST_CHECK_EQUAL( face.is_bdry() ,
true);
208 BOOST_CHECK( face.cells()[0] ==
Entity(*gas_quad,1) );
211 BOOST_CHECK_EQUAL( face.is_bdry() ,
true);
212 BOOST_CHECK( face.cells()[0] ==
Entity(*gas_quad,1) );
215 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
216 BOOST_CHECK( face.cells()[0] ==
Entity(*gas_quad,1) );
217 BOOST_CHECK( face.cells()[1] ==
Entity(*gas_triag,3) );
220 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
221 BOOST_CHECK( face.cells()[0] ==
Entity(*gas_triag,0) );
222 BOOST_CHECK( face.cells()[1] ==
Entity(*gas_triag,3) );
225 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
226 BOOST_CHECK( face.cells()[0] ==
Entity(*gas_triag,0) );
227 BOOST_CHECK( face.cells()[1] ==
Entity(*gas_triag,1) );
230 BOOST_CHECK_EQUAL( face.is_bdry() ,
true);
231 BOOST_CHECK( face.cells()[0] ==
Entity(*gas_triag,1) );
234 BOOST_CHECK_EQUAL( face.is_bdry() ,
true);
235 BOOST_CHECK( face.cells()[0] ==
Entity(*gas_triag,2) );
238 BOOST_CHECK_EQUAL( face.is_bdry() ,
false);
239 BOOST_CHECK( face.cells()[0] ==
Entity(*gas_triag,2) );
240 BOOST_CHECK( face.cells()[1] ==
Entity(*gas_triag,3) );
259 boost::shared_ptr<BuildFaces> facebuilder = allocate_component<BuildFaces>(
"facebuilder");
261 facebuilder->set_mesh(
mesh);
262 facebuilder->execute();
266 boost::shared_ptr< MeshTransformer > info = build_component_abstract_type<MeshTransformer>(
"cf3.mesh.actions.Info",
"info");
269 Region& wall_region = find_component_recursively_with_name<Region>(
mesh->topology(),
"wall");
270 Faces& wall_faces = find_component<Faces>(wall_region);
276 BOOST_CHECK_EQUAL(f2c.size(),6u);
277 for (
Face2Cell face(f2c); face.
idx<f2c.size(); ++face.idx)
279 CFinfo << wall_faces.parent()->name()<<
"/"<<wall_faces.name() <<
"["<<face.idx<<
"] <--> ";
281 Entity cell = face.cells()[0];
284 RealVector face_coordinates = wall_faces.geometry_space().get_coordinates(face.idx).row(0);
285 bool match_found =
false;
286 for (
Uint i=0; i<cell_coordinates.rows(); ++i)
288 if (cell_coordinates.row(i) == face_coordinates.transpose())
294 BOOST_CHECK(match_found);
304 boost::shared_ptr<BuildFaceNormals> face_normal_builder = allocate_component<BuildFaceNormals>(
"facenormalsbuilder");
306 face_normal_builder->set_mesh(
mesh);
307 face_normal_builder->execute();
311 boost::shared_ptr< MeshTransformer > info = build_component_abstract_type<MeshTransformer>(
"cf3.mesh.actions.Info",
"info");
314 boost::shared_ptr< MeshWriter > mesh_writer = build_component_abstract_type<MeshWriter>(
"cf3.mesh.gmsh.Writer",
"writer");
317 mesh_writer->options().set(
"fields",fields);
318 mesh_writer->options().set(
"mesh",
mesh);
319 mesh_writer->options().set(
"file",
URI(
"facenormals.msh"));
320 mesh_writer->execute();
331 boost::shared_ptr<SimpleMeshGenerator> mesh_gen = allocate_component<SimpleMeshGenerator>(
"mesh_gen");
332 std::vector<Real> lengths = list_of(10.)(10.);
333 std::vector<Uint> nb_cells = list_of(5u)(5u);
334 mesh_gen->options().set(
"mesh",
URI(
"//rectangle_mesh"));
335 mesh_gen->options().set(
"lengths",lengths);
336 mesh_gen->options().set(
"nb_cells",nb_cells);
337 Mesh& rmesh = mesh_gen->generate();
339 boost::shared_ptr<BuildFaces> facebuilder = allocate_component<BuildFaces>(
"facebuilder");
342 facebuilder->set_mesh(rmesh);
345 facebuilder->execute();
348 Region& inner_faces_region = find_component_recursively_with_name<Region>(rmesh.
topology(),mesh::Tags::inner_faces());
349 CellFaces& inner_faces = find_component<CellFaces>(inner_faces_region);
355 CFinfo <<
"\n\nCHECKING inner faces connectivity"<<
CFendl;
356 for (
Face2Cell face(f2c); face.
idx<f2c.size(); ++face.idx)
358 CFinfo << inner_faces.parent()->name()<<
"/"<<inner_faces.name() <<
"["<<face.idx<<
"] <--> ";
360 Entity cell = face.cells()[0];
363 RealVector face_coordinates = inner_faces.geometry_space().get_coordinates(face.idx).row(0);
364 bool match_found =
false;
365 for (
Uint i=0; i<cell_coordinates.rows(); ++i)
367 if (cell_coordinates.row(i) == face_coordinates.transpose())
373 BOOST_CHECK(match_found);
376 cell = face.cells()[0];
379 face_coordinates = inner_faces.geometry_space().get_coordinates(face.idx).row(0);
380 for (
Uint i=0; i<cell_coordinates.rows(); ++i)
382 if (cell_coordinates.row(i) == face_coordinates.transpose())
388 BOOST_CHECK(match_found);
395 BOOST_AUTO_TEST_SUITE_END()
#define CFinfo
these are always defined
boost::proto::terminal< SFOp< NormalOp > >::type const normal
RealMatrix get_coordinates() const
common::URI uri(ComponentWrapper &self)
void setup(Region ®ion)
const std::string & name() const
Access the name of the component.
static Handle< Mesh > mesh
common values accessed by all tests goes here
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealMatrix
Dynamic sized matrix of Real scalars.
Handle< Component > parent() const
Basic Classes for Mesh applications used by COOLFluiD.
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealVector
Dynamic sized column vector.
Top-level namespace for coolfluid.
Low storage struct to uniquely identify one element.
std::vector< URI > fields
unsigned int Uint
typedef for unsigned int
Action derived classes for mesh manipulations.
~TestBuildFaces_Fixture()
common tear-down for each test case
Region & topology() const
BOOST_AUTO_TEST_CASE(Constructors)
TestBuildFaces_Fixture()
common setup for each test case
Most basic kernel library.
bool is_not_null(T ptr)
predicate for comparison to nullptr