COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-nodes.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::LagrangeSF"
9 
10 #include <boost/assign/list_of.hpp>
11 #include <boost/test/unit_test.hpp>
12 
13 #include "common/Log.hpp"
14 #include "common/Core.hpp"
16 #include "common/DynTable.hpp"
17 #include "common/List.hpp"
18 
20 
21 #include "mesh/Connectivity.hpp"
22 #include "mesh/Mesh.hpp"
23 #include "mesh/Region.hpp"
24 #include "mesh/Elements.hpp"
25 #include "mesh/MeshReader.hpp"
26 #include "mesh/MeshWriter.hpp"
27 #include "mesh/ElementData.hpp"
29 #include "mesh/Field.hpp"
30 #include "mesh/Space.hpp"
31 
33 
35 
36 using namespace cf3;
37 using namespace cf3::mesh;
38 using namespace cf3::mesh::Integrators;
39 using namespace cf3::common;
40 
42 
44 {
47  {
48  mesh2d = Core::instance().root().create_component<Mesh> ( "mesh2d" );
49  // uncomment if you want to use arguments to the test executable
50  //int* argc = &boost::unit_test::framework::master_test_suite().argc;
51  //char*** argv = &boost::unit_test::framework::master_test_suite().argv;
52 
53  // Read the a .neu mesh as 2D mixed mesh
54  boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>("cf3.mesh.neu.Reader","meshreader");
55 
56  // Read the mesh
57  meshreader->read_mesh_into("../../resources/quadtriag.neu",*mesh2d);
58  }
59 
62  {
63  }
66 
68  {
69  BOOST_FOREACH(Elements& region, find_components_recursively<Elements>(*mesh2d))
70  {
71  return (region);
72  }
73  throw ShouldNotBeHere(FromHere(), "");
74  }
75 
76 };
77 
79 
80 BOOST_FIXTURE_TEST_SUITE( Nodes, Nodes_Fixture )
81 
82 
84 BOOST_AUTO_TEST_CASE( FillVector )
85 {
86  const Elements& firstRegion = get_first_region();
87  const Table<Real>& coords = firstRegion.geometry_fields().coordinates();
88  const Table<Uint>& conn = firstRegion.geometry_space().connectivity();
89  const Uint element_count = conn.size();
90  std::vector<RealVector> node_vector(conn.row_size(), RealVector(coords.row_size()));
91  for(Uint element = 0; element != element_count; ++element)
92  {
93  fill(node_vector, coords, conn[element]);
94  for(Uint node_idx = 0; node_idx != conn.row_size(); ++node_idx)
95  {
96  for(Uint xyz = 0; xyz != coords.row_size(); ++xyz)
97  {
98  BOOST_CHECK_EQUAL(node_vector[node_idx][xyz], coords[conn[element][node_idx]][xyz]);
99  }
100  }
101  }
102 }
103 
104 BOOST_AUTO_TEST_CASE( FillMatrix )
105 {
106  const Elements& firstRegion = get_first_region();
107  const Table<Real>& coords = firstRegion.geometry_fields().coordinates();
108  const Table<Uint>& conn = firstRegion.geometry_space().connectivity();
109  const Uint element_count = conn.size();
110  RealMatrix node_matrix(conn.row_size(), coords.row_size());
111  for(Uint element = 0; element != element_count; ++element)
112  {
113  fill(node_matrix, coords, conn[element]);
114  for(Uint node_idx = 0; node_idx != conn.row_size(); ++node_idx)
115  {
116  for(Uint xyz = 0; xyz != coords.row_size(); ++xyz)
117  {
118  BOOST_CHECK_EQUAL(node_matrix(node_idx, xyz), coords[conn[element][node_idx]][xyz]);
119  }
120  }
121  }
122 }
123 
125 
126 BOOST_AUTO_TEST_CASE( Construct_Geometry )
127 {
128  boost::shared_ptr<Dictionary> geometry = allocate_component<ContinuousDictionary>("geometry_fieds");
129  BOOST_CHECK( is_not_null(geometry) );
130 
131  Handle<Field> coords = geometry->create_component<Field>("coordinates");
132  coords->set_row_size(2u);
133  coords->create_descriptor("coords[vec]",2u);
134 
135  // Tagging this component will cache it to geometry->coordinates()
136  coords->add_tag(mesh::Tags::coordinates());
137 
138 
139  geometry->resize(10);
140  BOOST_CHECK_EQUAL(geometry->coordinates().size() , 10u);
141  BOOST_CHECK_EQUAL(geometry->coordinates().row_size() , 2u);
142  BOOST_CHECK_EQUAL(geometry->rank().size() , 10u);
143  BOOST_CHECK_EQUAL(geometry->glb_idx().size() , 10u);
144 
145  // created on demand
146  BOOST_CHECK_EQUAL(geometry->glb_elem_connectivity().size() , 10u);
147 }
148 
150 
151 BOOST_AUTO_TEST_SUITE_END()
152 
153 
Space & geometry_space() const
Definition: Entities.hpp:94
Elements & get_first_region()
Definition: utest-nodes.cpp:67
Nodes_Fixture()
common setup for each test case
Definition: utest-nodes.cpp:46
~Nodes_Fixture()
common tear-down for each test case
Definition: utest-nodes.cpp:61
const Field & coordinates() const
Definition: Dictionary.cpp:481
Dictionary & geometry_fields() const
Const access to the coordinates.
Definition: Entities.hpp:63
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealMatrix
Dynamic sized matrix of Real scalars.
Definition: MatrixTypes.hpp:22
Uint size() const
Definition: Table.hpp:127
Basic Classes for Mesh applications used by COOLFluiD.
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealVector
Dynamic sized column vector.
Definition: MatrixTypes.hpp:25
Top-level namespace for coolfluid.
Definition: Action.cpp:18
void fill(NodeValuesT &to_fill, const common::Table< Real > &data_array, const RowT &element_row, const Uint start=0)
Fill STL-vector like per-node data storage.
Definition: ElementData.hpp:28
void add_tag(const std::string &tag)
Functions to provide integration over elements.
Definition: Gauss.hpp:26
Uint row_size(Uint i=0) const
Definition: Table.hpp:133
boost::proto::terminal< SFOp< CoordinatesOp > >::type const coordinates
void set_row_size(const Uint nb_cols)
Definition: Table.hpp:78
common::Component & root() const
Gives the default root component.
Definition: Core.cpp:145
unsigned int Uint
typedef for unsigned int
Definition: CF.hpp:90
static Core & instance()
Definition: Core.cpp:37
void create_descriptor(const std::string &description, const Uint dimension=0)
Definition: Field.cpp:190
BOOST_AUTO_TEST_CASE(FillVector)
Definition: utest-nodes.cpp:84
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
Connectivity & connectivity()
connectivity table to dictionary entries
Definition: Space.hpp:110
bool is_not_null(T ptr)
predicate for comparison to nullptr
Definition: CF.hpp:147
Handle< Mesh > mesh2d
common values accessed by all tests goes here
Definition: utest-nodes.cpp:65
#define FromHere()
Send comments to:
COOLFluiD Web Admin