COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-mesh-actions-interpolate.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::GlobalConnectivity"
9 
10 #include <boost/test/unit_test.hpp>
11 
12 #include "common/Log.hpp"
13 #include "common/OptionList.hpp"
14 #include "common/Core.hpp"
15 #include "common/PE/debug.hpp"
16 #include "common/PE/Comm.hpp"
17 
19 
20 #include "mesh/MeshWriter.hpp"
21 #include "mesh/Mesh.hpp"
22 #include "mesh/Region.hpp"
23 #include "mesh/Dictionary.hpp"
25 
26 using namespace cf3;
27 using namespace cf3::common;
28 using namespace cf3::mesh;
29 using namespace cf3::mesh::actions;
30 using namespace cf3::common::PE;
31 
33 
35 {
38  {
39  m_argc = boost::unit_test::framework::master_test_suite().argc;
40  m_argv = boost::unit_test::framework::master_test_suite().argv;
41  }
42 
45  {
46  }
47 
49 
50  int m_argc;
51  char** m_argv;
52 
54  static Handle< Mesh > mesh;
55 };
56 
58 
60 
61 BOOST_FIXTURE_TEST_SUITE( TestGlobalConnectivity_TestSuite, TestGlobalConnectivity_Fixture )
62 
63 
66 {
67  Core::instance().initiate(m_argc,m_argv);
68  PE::Comm::instance().init(m_argc,m_argv);
69 }
70 
72 
74 {
75  Core::instance().initiate(m_argc,m_argv);
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<Real> offsets(2);
82  offsets[XX] = 0.;
83  offsets[YY] = -0.5;
84  mesh_generator->options().set("offsets",offsets);
85  std::vector<Uint> nb_cells(2);
86  nb_cells[XX] = 10u;
87  nb_cells[YY] = 1u;
88  mesh_generator->options().set("nb_cells",nb_cells);
89  Mesh& rect = mesh_generator->generate();
90 
91  mesh_generator->options().set("mesh",Core::instance().root().uri()/"line");
92  mesh_generator->options().set("nb_cells",std::vector<Uint>(1,20));
93  mesh_generator->options().set("lengths",std::vector<Real>(1,20.));
94 // mesh_generator->options().set("offsets",std::vector<Real>(1,-5));
95 
96  Mesh& line = mesh_generator->generate();
97 
98  Field& source = rect.geometry_fields().create_field("solution");
99  Field& target = line.geometry_fields().create_field("solution");
100 
101 
102  for(Uint i=0; i<source.size();++i)
103  {
104  source[i][0] = source.coordinates()[i][XX];
105  }
106 
108  interpolator.options().set("source",source.handle<Field const>());
109  interpolator.options().set("target",target.handle<Field>());
110  interpolator.execute();
111 
112 
113  Handle<MeshWriter> gmsh_writer(Core::instance().root().create_component("gmsh_writer","cf3.mesh.gmsh.Writer"));
114  gmsh_writer->options().set("fields",std::vector<URI>(1,target.uri()) );
115  gmsh_writer->write_from_to(line,"line-interpolated.msh");
116 }
117 
119 
121 {
124 }
125 
127 
128 BOOST_AUTO_TEST_SUITE_END()
129 
130 
Field & create_field(const std::string &name, const Uint cols)
Create a new field in this group.
Definition: Dictionary.cpp:178
Field & coordinates() const
Definition: Field.cpp:262
static Handle< Mesh > mesh
common values accessed by all tests goes here
URI uri() const
Construct the full path.
Definition: Component.cpp:248
boost::python::object create_component(ComponentWrapper &self, const std::string &name, const std::string &builder_name)
common::URI uri(ComponentWrapper &self)
tuple root
Definition: coolfluid.py:24
TestGlobalConnectivity_Fixture()
common setup for each test case
void terminate()
Definition: Core.cpp:131
virtual void execute()
execute the action
Definition: Interpolate.cpp:75
Definition: Defs.hpp:17
Uint size() const
Definition: Table.hpp:127
Generate a simple carthesian P1 mesh without grading.
Mesh & generate()
generate, wraps execute() and returns the mesh reference
Basic Classes for Mesh applications used by COOLFluiD.
void initiate(int argc, char **argv)
Definition: Core.cpp:98
void init(int argc=0, char **args=0)
Definition: Comm.cpp:80
Top-level namespace for coolfluid.
Definition: Action.cpp:18
BOOST_AUTO_TEST_CASE(Init)
common::Component & root() const
Gives the default root component.
Definition: Core.cpp:145
unsigned int Uint
typedef for unsigned int
Definition: CF.hpp:90
Action derived classes for mesh manipulations.
virtual void write_from_to(const Mesh &mesh, const common::URI &file_path)
Definition: MeshWriter.cpp:176
Classes offering a MPI interface for COOLFluiD.
Definition: all_gather.hpp:39
static Core & instance()
Definition: Core.cpp:37
Handle< Component > handle()
Get a handle to the component.
Definition: Component.hpp:179
Definition: Defs.hpp:17
OptionList & options()
Definition: Component.cpp:856
Dictionary & geometry_fields() const
Definition: Mesh.cpp:339
static Comm & instance()
Return a reference to the current PE.
Definition: Comm.cpp:44
Interpolate Fields with matching support.
Definition: Interpolate.hpp:35
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
~TestGlobalConnectivity_Fixture()
common tear-down for each test case
Send comments to:
COOLFluiD Web Admin