COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-mesh-boundingbox.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::BoundingBox"
9 
10 #include <boost/test/unit_test.hpp>
11 
12 #include "common/Log.hpp"
13 #include "common/OptionList.hpp"
14 #include "common/PropertyList.hpp"
15 
16 #include "common/Core.hpp"
17 #include "common/Environment.hpp"
18 
19 #include "mesh/BoundingBox.hpp"
20 #include "mesh/Mesh.hpp"
21 #include "mesh/Region.hpp"
22 #include "mesh/MeshGenerator.hpp"
23 #include "mesh/Field.hpp"
24 
25 using namespace std;
26 using namespace boost;
27 using namespace cf3;
28 using namespace cf3::mesh;
29 using namespace cf3::common;
30 
32 
34 {
37  {
38  m_argc = boost::unit_test::framework::master_test_suite().argc;
39  m_argv = boost::unit_test::framework::master_test_suite().argv;
40  }
41 
44  {
45  }
47 
48 
50  int m_argc;
51  char** m_argv;
52 
53 };
54 
56 
57 BOOST_FIXTURE_TEST_SUITE( boundingboxMPITests_TestSuite, boundingboxMPITests_Fixture )
58 
59 
62 {
63  Core::instance().initiate(m_argc,m_argv);
64  PE::Comm::instance().init(m_argc,m_argv);
65  Core::instance().environment().options().set("log_level",3u);
66 }
67 
69 
71 {
72  Uint dim=2;
73 
74  // Generate a mesh
75  Handle<Mesh> mesh = Core::instance().root().create_component<Mesh>("mesh");
76  boost::shared_ptr< MeshGenerator > generate_mesh = build_component_abstract_type<MeshGenerator>("cf3.mesh.SimpleMeshGenerator","meshgenerator");
77  generate_mesh->options().set("nb_cells",std::vector<Uint>(dim,10));
78  generate_mesh->options().set("lengths",std::vector<Real>(dim,10.));
79  generate_mesh->options().set("mesh",mesh->uri());
80  generate_mesh->execute();
81 
82  // Build a bounding box
83  Handle<BoundingBox> bounding_box = mesh->create_component<BoundingBox>("bounding_box");
84  BOOST_CHECK_NO_THROW(bounding_box->build(*mesh));
85 
86  // Check if bounding box is correct for each rank
87  switch (PE::Comm::instance().rank())
88  {
89  case 0:
90  BOOST_CHECK_EQUAL(bounding_box->min()[XX] , 0.);
91  BOOST_CHECK_EQUAL(bounding_box->min()[YY] , 0.);
92  BOOST_CHECK_EQUAL(bounding_box->max()[XX] , 10.);
93  BOOST_CHECK_EQUAL(bounding_box->max()[YY] , 5.);
94  break;
95 
96  case 1:
97  BOOST_CHECK_EQUAL(bounding_box->min()[XX] , 0.);
98  BOOST_CHECK_EQUAL(bounding_box->min()[YY] , 5.);
99  BOOST_CHECK_EQUAL(bounding_box->max()[XX] , 10.);
100  BOOST_CHECK_EQUAL(bounding_box->max()[YY] , 10.);
101  break;
102  }
103 
104  // Make global bounding box --> all ranks have same bounding_box
105  bounding_box->make_global();
106  BOOST_CHECK_EQUAL(bounding_box->min()[XX] , 0.);
107  BOOST_CHECK_EQUAL(bounding_box->min()[YY] , 0.);
108  BOOST_CHECK_EQUAL(bounding_box->max()[XX] , 10.);
109  BOOST_CHECK_EQUAL(bounding_box->max()[YY] , 10.);
110 }
111 
113 
114 BOOST_AUTO_TEST_CASE( finalize_mpi )
115 {
116  PE::Comm::instance().finalize();
117  Core::instance().terminate();
118 }
119 
121 
122 BOOST_AUTO_TEST_SUITE_END()
123 
124 
const RealVector & min() const
minimum coordinates, defining one corner of the bounding box
Definition: BoundingBox.hpp:61
external boost library namespace
BOOST_AUTO_TEST_CASE(init_mpi)
int m_argc
possibly common functions used on the tests below
const RealVector & max() const
maximum coordinates, defining one corner of the bounding box
Definition: BoundingBox.hpp:64
URI uri() const
Construct the full path.
Definition: Component.cpp:248
STL namespace.
void make_global()
Expand bounding box to encompass all processors.
Definition: BoundingBox.cpp:94
~boundingboxMPITests_Fixture()
common tear-down for each test case
Definition: Defs.hpp:17
Basic Classes for Mesh applications used by COOLFluiD.
Top-level namespace for coolfluid.
Definition: Action.cpp:18
boundingboxMPITests_Fixture()
common setup for each test case
unsigned int Uint
typedef for unsigned int
Definition: CF.hpp:90
Bounding box defined by minimum and maximum coordinates.
Definition: BoundingBox.hpp:24
Definition: Defs.hpp:17
OptionList & options()
Definition: Component.cpp:856
void set(const std::string &pname, const boost::any &val)
Definition: OptionList.cpp:132
Handle< Component > create_component(const std::string &name, const std::string &builder)
Build a (sub)component of this component using the extended type_name of the component.
Definition: Component.cpp:568
Most basic kernel library.
Definition: Action.cpp:19
Send comments to:
COOLFluiD Web Admin