COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-blockmesh-2d.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::BlockMesh::BlockMeshMPI"
9 
10 #include <boost/assign.hpp>
11 #include <boost/test/unit_test.hpp>
12 
13 #include "common/Core.hpp"
14 #include "common/Environment.hpp"
16 #include "common/Log.hpp"
17 #include "common/List.hpp"
18 #include "common/Table.hpp"
19 #include "common/OptionList.hpp"
20 
22 #include "mesh/Domain.hpp"
23 #include "mesh/Mesh.hpp"
24 #include "mesh/Field.hpp"
25 #include "mesh/MeshWriter.hpp"
26 
27 using namespace cf3;
28 using namespace cf3::common;
29 using namespace cf3::mesh;
30 
31 using namespace boost::assign;
32 
34 
35 BOOST_AUTO_TEST_SUITE( BlockMesh2D )
36 
37 
40 {
41  Core::instance().environment().options().set("log_level", 4u);
42 
44 
45  const Real length = 1.;
46  const Real half_height = 1.;
47  const Real ratio = 0.2;
48  const Uint x_segs = 12;
49  const Uint y_segs = 10;
50 
52 
53  (*blocks.create_points(2, 6)) << 0. << -half_height
54  << length << -half_height
55  << 0. << 0.
56  << length << 0.
57  << 0. << half_height
58  << length << half_height;
59 
60  (*blocks.create_blocks(2)) << 0 << 1 << 3 << 2
61  << 2 << 3 << 5 << 4;
62 
63  (*blocks.create_block_subdivisions()) << x_segs << y_segs
64  << x_segs << y_segs;
65 
66  (*blocks.create_block_gradings()) << 1. << 1. << 1./ratio << 1./ratio
67  << 1. << 1. << ratio << ratio;
68 
69  *blocks.create_patch("left", 2) << 2 << 0 << 4 << 2;
70  *blocks.create_patch("right", 2) << 1 << 3 << 3 << 5;
71  *blocks.create_patch("top", 1) << 5 << 4;
72  *blocks.create_patch("bottom", 1) << 0 << 1;
73 
74  Mesh& mesh = *domain.create_component<Mesh>("mesh");
75 
76  blocks.create_mesh(mesh);
77 
78  BOOST_CHECK_EQUAL(mesh.dimension(), 2);
79 
80  BOOST_CHECK_NO_THROW(mesh.write_mesh("grid-2d.msh"));
81 
82 
83  // Test block partitioning
84  BOOST_CHECK_NO_THROW(blocks.partition_blocks(5, 0));
85 // BOOST_CHECK_NO_THROW(blocks.partition_blocks(3, 1));
86 
87  Handle<Mesh> block_mesh = blocks.create_block_mesh();
88  BOOST_CHECK(true);
89  std::vector<URI> fields;
90  BOOST_FOREACH(const Field& field, find_components_recursively<Field>(*block_mesh))
91  {
92  if(field.name() != "coordinates")
93  fields.push_back(field.uri());
94  }
95 
96  Handle<MeshWriter> mesh_writer = block_mesh->create_component<MeshWriter>("writer","cf3.mesh.gmsh.Writer");
97  mesh_writer->options().set("mesh",block_mesh->handle<Mesh const>());
98  mesh_writer->options().set("fields",fields);
99  mesh_writer->options().set("enable_overlap",true);
100  mesh_writer->options().set("file",URI("grid-2d-parblocks.msh"));
101  mesh_writer->execute();
102 }
103 
105 
106 BOOST_AUTO_TEST_SUITE_END()
107 
108 
void write_mesh(const common::URI &file, const std::vector< common::URI > fields=std::vector< common::URI >())
Definition: Mesh.cpp:391
virtual void execute()
execute the action
Definition: MeshWriter.cpp:151
BOOST_AUTO_TEST_CASE(Grid2D)
URI uri() const
Construct the full path.
Definition: Component.cpp:248
const std::string & name() const
Access the name of the component.
Definition: Component.hpp:146
Handle< common::Table< Uint > > create_block_subdivisions()
Definition: BlockData.cpp:1315
void partition_blocks(const Uint nb_partitions, const Uint direction)
Definition: BlockData.cpp:1495
Handle< common::Table< Uint > > create_blocks(const Uint nb_blocks)
Create the table that holds the blocks.
Definition: BlockData.cpp:1299
Uint dimension() const
Definition: Mesh.hpp:86
Basic Classes for Mesh applications used by COOLFluiD.
Top-level namespace for coolfluid.
Definition: Action.cpp:18
Handle< common::Table< Real > > create_block_gradings()
Definition: BlockData.cpp:1329
Handle< common::Table< Uint > > create_patch(const std::string &name, const Uint nb_faces)
Definition: BlockData.cpp:1343
std::vector< URI > fields
Handle< Mesh > create_block_mesh()
Create the volume block mesh.
Definition: BlockData.cpp:1372
common::Component & root() const
Gives the default root component.
Definition: Core.cpp:145
common::Environment & environment() const
Definition: Core.cpp:168
unsigned int Uint
typedef for unsigned int
Definition: CF.hpp:90
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
Handle< common::Table< Real > > create_points(const Uint dimensions, const Uint nb_points)
Create the table that holds the points for the blocks.
Definition: BlockData.cpp:1287
Send comments to:
COOLFluiD Web Admin