COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-mesh-actions-rotate-translate.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::Rotate"
9 
10 #include <boost/test/unit_test.hpp>
11 #include <boost/assign/list_of.hpp>
12 
13 #include "common/Log.hpp"
14 #include "common/OptionList.hpp"
15 #include "common/Core.hpp"
16 #include "common/PE/debug.hpp"
17 #include "common/PE/Comm.hpp"
18 
19 #include "math/Consts.hpp"
20 
21 #include "mesh/actions/Rotate.hpp"
22 
23 #include "mesh/MeshWriter.hpp"
24 #include "mesh/Mesh.hpp"
26 
27 using namespace cf3;
28 using namespace cf3::common;
29 using namespace cf3::mesh;
30 using namespace cf3::mesh::actions;
31 using namespace cf3::common::PE;
32 using namespace boost::assign;
33 
35 
37 {
40  {
41  m_argc = boost::unit_test::framework::master_test_suite().argc;
42  m_argv = boost::unit_test::framework::master_test_suite().argv;
43  }
44 
47  {
48  }
49 
51 
52  int m_argc;
53  char** m_argv;
54 
57 };
58 
60 
62 
63 BOOST_FIXTURE_TEST_SUITE( TestRotate_TestSuite, TestRotate_Fixture )
64 
65 
68 {
69  Core::instance().initiate(m_argc,m_argv);
70  //PE::Comm::instance().init(m_argc,m_argv);
71 }
72 
74 
75 BOOST_AUTO_TEST_CASE( test_rotate_2d )
76 {
78  mesh_generator->options().set("mesh",Core::instance().root().uri()/"rect");
79 
80  mesh_generator->options().set("lengths",std::vector<Real>(2,10.));
81  std::vector<Uint> nb_cells = list_of(10)(5);
82  mesh_generator->options().set("nb_cells",nb_cells);
83  Mesh& mesh = mesh_generator->generate();
84 
85  boost::shared_ptr<MeshTransformer> rotate = boost::dynamic_pointer_cast<MeshTransformer>(build_component("cf3.mesh.actions.Rotate","rotate"));
86  std::vector<Real> axis_point = list_of(5.)(5.);
87  rotate->options().set("axis_point",axis_point);
88  rotate->options().set("angle",90.);
89  rotate->transform(mesh);
90  mesh.write_mesh("file:rotated_rect.msh");
91 }
92 
94 
95 BOOST_AUTO_TEST_CASE( test_rotate_3d )
96 {
98  mesh_generator->options().set("mesh",Core::instance().root().uri()/"box");
99 
100  mesh_generator->options().set("lengths",std::vector<Real>(3,10.));
101  std::vector<Uint> nb_cells = list_of(10)(5)(2);
102  mesh_generator->options().set("nb_cells",nb_cells);
103  Mesh& mesh = mesh_generator->generate();
104 
105  boost::shared_ptr<MeshTransformer> rotate = boost::dynamic_pointer_cast<MeshTransformer>(build_component("cf3.mesh.actions.Rotate","rotate"));
106  std::vector<Real> axis_direction = list_of(1)(1)(1);
107  std::vector<Real> axis_point = list_of(5.)(5.)(5.);
108  rotate->options().set("axis_direction",axis_direction);
109  rotate->options().set("axis_point",axis_point);
110  rotate->options().set("angle",90.);
111  rotate->transform(mesh);
112  mesh.write_mesh("file:rotated_box.msh");
113 }
114 
116 
117 BOOST_AUTO_TEST_CASE( test_translate_2d )
118 {
119 
120  Mesh& mesh = *Core::instance().root().get_child("rect")->handle<Mesh>();
121 
122  boost::shared_ptr<MeshTransformer> translate = boost::dynamic_pointer_cast<MeshTransformer>(build_component("cf3.mesh.actions.Translate","translate"));
123  std::vector<Real> tvec = list_of(-5)(-5);
124  translate->options().set("vector",tvec);
125  translate->transform(mesh);
126 
127  mesh.write_mesh("file:translated_rect.msh");
128 }
129 
131 
132 BOOST_AUTO_TEST_CASE( test_translate_3d )
133 {
134 
135  Mesh& mesh = *Core::instance().root().get_child("box")->handle<Mesh>();
136 
137  boost::shared_ptr<MeshTransformer> translate = boost::dynamic_pointer_cast<MeshTransformer>(build_component("cf3.mesh.actions.Translate","translate"));
138  std::vector<Real> tvec = list_of(-5)(-5)(-5);
139  translate->options().set("vector",tvec);
140  translate->transform(mesh);
141 
142  mesh.write_mesh("file:translated_box.msh");
143 }
144 
146 
148 {
149  //PE::Comm::instance().finalize();
151 }
152 
154 
155 BOOST_AUTO_TEST_SUITE_END()
156 
157 
void write_mesh(const common::URI &file, const std::vector< common::URI > fields=std::vector< common::URI >())
Definition: Mesh.cpp:391
int m_argc
possibly common functions used on the tests below
~TestRotate_Fixture()
common tear-down for each test case
boost::shared_ptr< Component > build_component(const std::string &builder_name, const std::string &name, const std::string &factory_type_name)
Definition: Component.cpp:1200
common::URI uri(ComponentWrapper &self)
tuple root
Definition: coolfluid.py:24
void terminate()
Definition: Core.cpp:131
Generate a simple carthesian P1 mesh without grading.
Mesh & generate()
generate, wraps execute() and returns the mesh reference
static Handle< Mesh > mesh
common values accessed by all tests goes here
Basic Classes for Mesh applications used by COOLFluiD.
TestRotate_Fixture()
common setup for each test case
Handle< Component > get_child(const std::string &name)
Definition: Component.cpp:441
void initiate(int argc, char **argv)
Definition: Core.cpp:98
Top-level namespace for coolfluid.
Definition: Action.cpp:18
common::Component & root() const
Gives the default root component.
Definition: Core.cpp:145
Action derived classes for mesh manipulations.
Classes offering a MPI interface for COOLFluiD.
Definition: all_gather.hpp:39
static Core & instance()
Definition: Core.cpp:37
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