COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-mesh-tecplot.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::tecplot::Writer"
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 
17 
18 #include "mesh/Mesh.hpp"
19 #include "mesh/Region.hpp"
20 #include "mesh/MeshReader.hpp"
21 #include "mesh/MeshWriter.hpp"
22 #include "mesh/MeshTransformer.hpp"
23 #include "mesh/Field.hpp"
24 #include "common/DynTable.hpp"
25 #include "common/List.hpp"
26 #include "common/Table.hpp"
27 #include "mesh/Dictionary.hpp"
28 
29 using namespace std;
30 using namespace boost;
31 using namespace cf3;
32 using namespace cf3::mesh;
33 using namespace cf3::common;
34 
36 
38 {
41  {
42  m_argc = boost::unit_test::framework::master_test_suite().argc;
43  m_argv = boost::unit_test::framework::master_test_suite().argv;
44  }
45 
48  {
49  }
51 
52 
54  int m_argc;
55  char** m_argv;
56 
57 };
58 
60 
61 BOOST_FIXTURE_TEST_SUITE( TecWriterTests_TestSuite, TecWriterTests_Fixture )
62 
63 
66 
67 BOOST_AUTO_TEST_CASE( read_2d_mesh )
68 {
69 
70  boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>("cf3.mesh.neu.Reader","meshreader");
71 
72  meshreader->options().set("read_groups",true);
73 
74  // the mesh to store in
75  Mesh& mesh = *Core::instance().root().create_component<Mesh>( "mesh" );
76 
77  meshreader->read_mesh_into("../../resources/quadtriag.neu",mesh);
78 
79 
80  Uint nb_ghosts=0;
81 
82 
83  Field& nodal = mesh.geometry_fields().create_field("nodal","nodal[vector]");
84  for (Uint n=0; n<nodal.size(); ++n)
85  {
86  for(Uint j=0; j<nodal.row_size(); ++j)
87  nodal[n][j] = n;
88  }
89 
90 
91  Dictionary& elems = mesh.create_discontinuous_space("elems_P0","cf3.mesh.LagrangeP0");
92 
93  Field& cell_centred = elems.create_field("cell_centred","cell_centred[vector]");
94  for (Uint e=0; e<cell_centred.size(); ++e)
95  {
96  for(Uint j=0; j<cell_centred.row_size(); ++j)
97  cell_centred[e][j] = e;
98  }
99 
100 
101  Dictionary& P2 = mesh.create_continuous_space("nodes_P2","cf3.mesh.LagrangeP2");
102 
103  Field& nodesP2 = P2.create_field("nodesP2","nodesP2[vector]");
104  for (Uint e=0; e<nodesP2.size(); ++e)
105  {
106  for(Uint j=0; j<nodesP2.row_size(); ++j)
107  nodesP2[e][j] = nodesP2.coordinates()[e][j];
108  }
109 
110 
111  std::vector<URI> fields;
112  fields.push_back(nodal.uri());
113  fields.push_back(cell_centred.uri());
114  fields.push_back(nodesP2.uri());
115  boost::shared_ptr< MeshWriter > tec_writer = build_component_abstract_type<MeshWriter>("cf3.mesh.tecplot.Writer","meshwriter");
116  tec_writer->options().set("cell_centred",true);
117  tec_writer->options().set("mesh",mesh.handle<Mesh const>());
118  tec_writer->options().set("fields",fields);
119  tec_writer->options().set("file",URI("quadtriag.plt"));
120  tec_writer->execute();
121 
122  std::vector<URI> regions;
123  regions.push_back(mesh.uri()/"topology/inlet");
124  regions.push_back(mesh.uri()/"topology/outlet");
125  regions.push_back(mesh.uri()/"topology/wall");
126  regions.push_back(mesh.uri()/"topology/liquid");
127  tec_writer->options().set("regions",regions);
128  tec_writer->options().set("file",URI("quadtriag_filtered.plt"));
129  tec_writer->execute();
130 
131  BOOST_CHECK(true);
132 }
133 
135 /*
136 BOOST_AUTO_TEST_CASE( threeD_test )
137 {
138 
139  boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>("cf3.mesh.neu.Reader","meshreader");
140 
141  meshreader->options().set("number_of_processors",(Uint) Comm::instance().size());
142  meshreader->options().set("rank",(Uint) Comm::instance().rank());
143  meshreader->options().set("Repartition",false);
144  meshreader->options().set("OutputRank",(Uint) 2);
145 
146  // the file to read from
147  boost::filesystem::path fp_in ("../../resources/hextet.neu");
148 
149  // the mesh to store in
150  boost::shared_ptr< Mesh > mesh ( allocate_component<Mesh> ( "mesh" ) );
151 
152 
153  CFinfo.setFilterRankZero(false);
154  meshreader->do_read_mesh_into(fp_in,mesh);
155  CFinfo.setFilterRankZero(true);
156 
157  boost::filesystem::path fp_out ("hextet.msh");
158  boost::shared_ptr< MeshWriter > gmsh_writer = build_component_abstract_type<MeshWriter>("cf3.mesh.gmsh.Writer","meshwriter");
159  gmsh_writer->write_from_to(mesh,fp_out);
160 
161  BOOST_CHECK(true);
162 
163 }
164 */
166 /*
167 BOOST_AUTO_TEST_CASE( read_multiple_2D )
168 {
169 
170  boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>("cf3.mesh.neu.Reader","meshreader");
171 
172  meshreader->options().set("Repartition",true);
173  meshreader->options().set("OutputRank",(Uint) 0);
174 
175  // the file to read from
176  boost::filesystem::path fp_in ("quadtriag.neu");
177 
178  // the mesh to store in
179  boost::shared_ptr< Mesh > mesh ( allocate_component<Mesh> ( "mesh" ) );
180 
181 
182  CFinfo.setFilterRankZero(false);
183 
184 
185 
186  for (Uint count=1; count<=2; ++count)
187  {
188  CFinfo << "\n\n\nMesh parallel:" << CFendl;
189  meshreader->do_read_mesh_into(fp_in,mesh);
190  }
191 
192 
193 
194  CFinfo.setFilterRankZero(true);
195  CFinfo << mesh->tree() << CFendl;
196  CFinfo << meshreader->tree() << CFendl;
197  boost::shared_ptr< MeshTransformer > info = build_component_abstract_type<MeshTransformer>("Info","info");
198  info->transform(mesh);
199 
200 
201  boost::filesystem::path fp_out ("quadtriag_mult.msh");
202  boost::shared_ptr< MeshWriter > gmsh_writer = build_component_abstract_type<MeshWriter>("cf3.mesh.gmsh.Writer","meshwriter");
203  gmsh_writer->write_from_to(mesh,fp_out);
204 
205  BOOST_CHECK_EQUAL(1,1);
206 
207 }
208 */
210 
212 
213 BOOST_AUTO_TEST_SUITE_END()
214 
215 
BOOST_AUTO_TEST_CASE(read_2d_mesh)
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
Dictionary & create_discontinuous_space(const std::string &space_name, const std::string &space_lib_name, const std::vector< Handle< Entities > > &entities)
Definition: Mesh.cpp:316
external boost library namespace
int m_argc
possibly common functions used on the tests below
Dictionary & create_continuous_space(const std::string &space_name, const std::string &space_lib_name, const std::vector< Handle< Entities > > &entities)
Definition: Mesh.cpp:269
TecWriterTests_Fixture()
common setup for each test case
URI uri() const
Construct the full path.
Definition: Component.cpp:248
STL namespace.
Real e()
Definition of the Unit charge [C].
Definition: Consts.hpp:30
Uint size() const
Definition: Table.hpp:127
Basic Classes for Mesh applications used by COOLFluiD.
Top-level namespace for coolfluid.
Definition: Action.cpp:18
Uint row_size(Uint i=0) const
Definition: Table.hpp:133
std::vector< URI > fields
unsigned int Uint
typedef for unsigned int
Definition: CF.hpp:90
Handle< Component > handle()
Get a handle to the component.
Definition: Component.hpp:179
Dictionary & geometry_fields() const
Definition: Mesh.cpp:339
Most basic kernel library.
Definition: Action.cpp:19
~TecWriterTests_Fixture()
common tear-down for each test case
Send comments to:
COOLFluiD Web Admin