COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-mesh-lagrangep1-prism3d.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2011 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 the Prism3D shape function"
9 
10 #include <boost/assign/list_of.hpp>
11 #include <boost/test/unit_test.hpp>
12 
14 #include <Eigen/StdVector>
15 
16 #include "common/Log.hpp"
17 
18 #include "common/Table.hpp"
21 
23 
24 using namespace boost::assign;
25 using namespace cf3;
26 using namespace cf3::mesh;
27 using namespace cf3::mesh::Integrators;
28 using namespace cf3::mesh::LagrangeP1;
29 using namespace cf3::Tools::Testing;
30 
32 
33 typedef Prism3D ETYPE;
34 
36 {
39  mapped_coords(0.5, 0.4, 0.1),
40  unit_nodes
41  (
42  (ETYPE::NodesT() <<
43  0., 0., 0.,
44  1., 0., 0.,
45  0., 1., 0.,
46  0., 0., 1.,
47  1., 0., 1.,
48  0., 1., 1.).finished()
49  ),
50  skewed_nodes
51  (
52  (ETYPE::NodesT() <<
53  0.2, 0.3, 0.,
54  1.2, 0.3, 0.,
55  0.2, 1.3, 0.,
56  0.2, 0.3, 1.,
57  1.2, 0.3, 1.,
58  0.2, 1.3, 1.).finished()
59  )
60  {
61  }
62 
65  {
66  }
71 
72  struct ConstFunctor
73  {
74  ConstFunctor(const ETYPE::NodesT& node_list) : m_nodes(node_list) {}
75 
76  Real operator()() const
77  {
78  return Prism3D::jacobian_determinant(mapped_coords, m_nodes);
79  }
81  private:
83  };
84 };
85 
87 
88 BOOST_FIXTURE_TEST_SUITE( Prism3DSuite, Prism3DFixture )
89 
90 
93 {
94  BOOST_CHECK_CLOSE(ETYPE::volume(unit_nodes), 0.5, 0.0001);
95  BOOST_CHECK_CLOSE(ETYPE::volume(skewed_nodes), 0.5, 0.0001);
96 
97  ETYPE::NodesT nodes_Prism3D;
98  nodes_Prism3D <<
99  0.0, 0.0, 0.0,
100  1.0, 0.0, 0.0,
101  0.0, 1.0, 0.0,
102  0.0, 0.0, 1.0,
103  1.0, 0.0, 1.0,
104  0.0, 1.0, 1.0;
105  BOOST_CHECK_EQUAL(ETYPE::volume(nodes_Prism3D), 0.5);
106 }
107 
109 {
110  ETYPE::SF::ValueT reference_result;
111  reference_result << 0.045, 0.225, 0.18, 0.055, 0.275, 0.22;
112 
113  ETYPE::SF::ValueT result;
114  ETYPE::SF::compute_value(mapped_coords, result);
115 
116  Accumulator accumulator;
117  vector_test(result, reference_result, accumulator);
118  BOOST_CHECK_LT(boost::accumulators::max(accumulator.ulps), 10); // Maximal difference can't be greater than 10 times the least representable unit
119 }
120 
121 BOOST_AUTO_TEST_CASE( IntegrateConst )
122 {
123  ConstFunctor ftor(skewed_nodes);
124  Real result = 0.0;
125 
126  gauss_integrate<1, GeoShape::PRISM>(ftor, ftor.mapped_coords, result);
127  BOOST_CHECK_CLOSE(result, 0.5, 0.000001);
128 
129  gauss_integrate<2, GeoShape::PRISM>(ftor, ftor.mapped_coords, result);
130  BOOST_CHECK_CLOSE(result, 0.5, 0.000001);
131 }
132 
133 BOOST_AUTO_TEST_CASE( MappedGradient )
134 {
135  ETYPE::SF::GradientT expected;
136  expected << -0.45, 0.45, 0, -0.55, 0.55, 0,
137  -0.45, 0, 0.45, -0.55, 0, 0.55,
138  -0.05, -0.25, -0.2, 0.05, 0.25, 0.2;
139 
140  ETYPE::SF::GradientT result;
141  ETYPE::SF::compute_gradient(mapped_coords, result);
142 
143  Accumulator accumulator;
144  vector_test(result, expected, accumulator);
145  BOOST_CHECK_LT(boost::accumulators::max(accumulator.ulps), 3);
146 }
147 
148 BOOST_AUTO_TEST_CASE( JacobianDeterminant )
149 {
150  BOOST_CHECK_CLOSE(ETYPE::jacobian_determinant(mapped_coords, unit_nodes), 0.5, 0.00001);
151  BOOST_CHECK_CLOSE(ETYPE::jacobian_determinant(mapped_coords, skewed_nodes), 0.5, 0.00001);
152 }
153 
155 {
156  ETYPE::JacobianT expected;
157  expected << 1, 0, 0, 0, 1, 0, 0, 0, 0.5;
158 
159  ETYPE::JacobianT result;
160  ETYPE::compute_jacobian(mapped_coords, skewed_nodes, result);
161 
162  Accumulator accumulator;
163  vector_test(result, expected, accumulator);
164  BOOST_CHECK_LT(boost::accumulators::max(accumulator.ulps), 2);
165 }
166 
167 BOOST_AUTO_TEST_CASE( JacobianAdjoint )
168 {
169  ETYPE::JacobianT expected;
170  expected << 0.5, 0, 0, 0, 0.5, 0, 0, 0, 1.;
171 
172  ETYPE::JacobianT result;
173  ETYPE::compute_jacobian_adjoint(mapped_coords, skewed_nodes, result);
174 
175  Accumulator accumulator;
176  vector_test(result, expected, accumulator);
177  BOOST_CHECK_LT(boost::accumulators::max(accumulator.ulps), 2);
178 }
179 
181 
182 BOOST_AUTO_TEST_SUITE_END()
183 
184 
static void compute_jacobian_adjoint(const MappedCoordsT &mapped_coord, const NodesT &nodes, JacobianT &result)
Definition: Hexa3D.cpp:308
boost::proto::terminal< SFOp< JacobianDeterminantOp > >::type const jacobian_determinant
ConstFunctor(const ETYPE::NodesT &node_list)
static void compute_jacobian(const MappedCoordsT &mapped_coord, const NodesT &nodes, MatrixType &jacobian)
static Real jacobian_determinant(const MappedCoordsT &mapped_coord, const NodesT &nodes)
Definition: Hexa3D.cpp:169
Real max(const Real a, const Real b)
Maximum between two scalars.
Definition: Terminals.hpp:228
BOOST_AUTO_TEST_CASE(Volume)
Prism3DFixture()
common setup for each test case
Eigen::Matrix< Real, nb_nodes, Hexa3D_traits::dimension > NodesT
3D Lagrange P1 Triangular Prism Element type This class provides the lagrangian shape function descri...
Definition: Prism3D.hpp:36
boost::accumulators::accumulator_set< Real, boost::accumulators::stats< boost::accumulators::tag::min, boost::accumulators::tag::mean, boost::accumulators::tag::max, boost::accumulators::tag::median, boost::accumulators::tag::lazy_variance > > ulps
Stores statistics for comparisons of inexact (floating-point) types using Units in the Last Place (UL...
Definition: Difference.hpp:55
~Prism3DFixture()
common tear-down for each test case
Basic Classes for Mesh applications used by COOLFluiD.
namespace holding LagrangeP1 shape functions and elements
Top-level namespace for coolfluid.
Definition: Action.cpp:18
Functions to provide integration over elements.
Definition: Gauss.hpp:26
const ETYPE::NodesT skewed_nodes
static Real volume(const NodesT &nodes)
Definition: Hexa3D.cpp:324
void vector_test(const VectorT &A, const VectorT &B, Accumulator &Result)
Compares vector-like sequences.
Definition: Difference.hpp:139
const ETYPE::MappedCoordsT mapped_coords
common values accessed by all tests goes here
Eigen::Matrix< Real, Hexa3D_traits::SF::dimensionality, Hexa3D_traits::dimension > JacobianT
const ETYPE::NodesT unit_nodes
2D Lagrange P1 Triangular Element type This class provides the lagrangian shape function describing t...
Definition: Hexa3D.hpp:36
Stores the results of the difference::test() function.
Definition: Difference.hpp:49
Send comments to:
COOLFluiD Web Admin