COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-mesh-lagrangep1-line1d.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 the Line1D shapefunction"
9 
10 #include <boost/assign/list_of.hpp>
11 #include <boost/test/unit_test.hpp>
12 
13 #include "common/Log.hpp"
14 
15 #include "mesh/ElementType.hpp"
16 #include "common/Table.hpp"
19 
21 
22 using namespace boost::assign;
23 using namespace cf3;
24 using namespace cf3::common;
25 using namespace cf3::mesh;
26 using namespace cf3::mesh::Integrators;
27 using namespace cf3::mesh::LagrangeP1;
28 using namespace cf3::Tools::Testing;
29 
31 
32 typedef Line1D ETYPE;
33 
35 {
38  mapped_coords((ETYPE::MappedCoordsT() << .2).finished()),
39  nodes((ETYPE::NodesT() << 5., 10.).finished())
40  {
41  }
42 
45  {
46  }
48 
51 
52  struct ConstFunctor
53  {
54  ConstFunctor(const ETYPE::NodesT& node_list) : m_nodes(node_list) {}
55 
56  Real operator()() const
57  {
58  return Line1D::jacobian_determinant(mapped_coords, m_nodes);
59  }
61  private:
63  };
64 };
65 
67 
68 BOOST_FIXTURE_TEST_SUITE( Line1DSuite, LagrangeP1Line1DFixture )
69 
70 
73 {
74  RealMatrix nodes_line1D ( (RealMatrix(2,1) << 2.0, 1.0).finished() );
75  boost::shared_ptr< ElementType > line1d = build_component_abstract_type<ElementType>("cf3.mesh.LagrangeP1.Line1D","line1d");
76  BOOST_CHECK_EQUAL(line1d->volume(nodes_line1D),1.);
77 }
78 
80 {
81  const ETYPE::SF::ValueT reference_result(0.4, 0.6);
82  ETYPE::SF::ValueT result;
83  Line1D::SF::compute_value(mapped_coords, result);
84  Accumulator accumulator;
85  vector_test(result, reference_result, accumulator);
86  BOOST_CHECK_LT(boost::accumulators::max(accumulator.ulps), 10); // Maximal difference can't be greater than 10 times the least representable unit
87 }
88 
89 BOOST_AUTO_TEST_CASE( MappedCoordinates )
90 {
91  ETYPE::CoordsT test_coords;
92  test_coords << 6.;
93  ETYPE::MappedCoordsT result;
94  Line1D::compute_mapped_coordinate(test_coords, nodes, result);
95  Accumulator acc = test(result[0], -0.6);
96  BOOST_CHECK_LT(boost::accumulators::max(acc.ulps), 5);
97 }
98 
99 BOOST_AUTO_TEST_CASE( MappedGradient )
100 {
101  ETYPE::SF::GradientT result;
102  ETYPE::SF::GradientT expected;
103  expected(0,0) = -0.5;
104  expected(0,1) = 0.5;
105  Line1D::SF::compute_gradient(mapped_coords, result);
106  Accumulator accumulator;
107  vector_test(result, expected, accumulator);
108  BOOST_CHECK_LT(boost::accumulators::max(accumulator.ulps), 2);
109 }
110 
111 BOOST_AUTO_TEST_CASE( JacobianDeterminant )
112 {
113  BOOST_CHECK_LT(boost::accumulators::max(test(Line1D::jacobian_determinant(mapped_coords, nodes), 0.5*Line1D::volume(nodes)).ulps), 1);
114 }
115 
117 {
118  ETYPE::JacobianT expected;
119  expected << 2.5;
120  ETYPE::JacobianT result;
121  Line1D::compute_jacobian(mapped_coords, nodes, result);
122  Accumulator accumulator;
123  vector_test(result, expected, accumulator);
124  BOOST_CHECK_LT(boost::accumulators::max(accumulator.ulps), 2);
125 }
126 
127 BOOST_AUTO_TEST_CASE( JacobianAdjoint )
128 {
129  ETYPE::JacobianT expected;
130  expected << 1.;
131  ETYPE::JacobianT result;
132  Line1D::compute_jacobian_adjoint(mapped_coords, nodes, result);
133  Accumulator accumulator;
134  vector_test(result, expected, accumulator);
135  BOOST_CHECK_LT(boost::accumulators::max(accumulator.ulps), 1);
136 }
137 
138 BOOST_AUTO_TEST_CASE( integrateConst )
139 {
140  ConstFunctor ftor(nodes);
141  const Real vol = Line1D::volume(nodes);
142 
143  cf3::Real result1 = 0.0;
144  cf3::Real result2 = 0.0;
145  cf3::Real result4 = 0.0;
146  cf3::Real result8 = 0.0;
147  cf3::Real result16 = 0.0;
148  cf3::Real result32 = 0.0;
149 
150  gauss_integrate<1, GeoShape::LINE>(ftor, ftor.mapped_coords, result1);
151  gauss_integrate<2, GeoShape::LINE>(ftor, ftor.mapped_coords, result2);
152  gauss_integrate<4, GeoShape::LINE>(ftor, ftor.mapped_coords, result4);
153  gauss_integrate<8, GeoShape::LINE>(ftor, ftor.mapped_coords, result8);
154  gauss_integrate<16, GeoShape::LINE>(ftor, ftor.mapped_coords, result16);
155  gauss_integrate<32, GeoShape::LINE>(ftor, ftor.mapped_coords, result32);
156 
157  BOOST_CHECK_LT(boost::accumulators::max(test(result1, vol).ulps), 1);
158  BOOST_CHECK_LT(boost::accumulators::max(test(result2, vol).ulps), 5);
159  BOOST_CHECK_LT(boost::accumulators::max(test(result4, vol).ulps), 5);
160  BOOST_CHECK_LT(boost::accumulators::max(test(result8, vol).ulps), 5);
161  BOOST_CHECK_LT(boost::accumulators::max(test(result16, vol).ulps), 5);
162  BOOST_CHECK_LT(boost::accumulators::max(test(result32, vol).ulps), 5);
163 }
164 
166 
167 BOOST_AUTO_TEST_SUITE_END()
168 
169 
cf3::Real result2[213]
boost::proto::terminal< SFOp< JacobianDeterminantOp > >::type const jacobian_determinant
boost::proto::terminal< SFOp< VolumeOp > >::type const volume
Static terminals that can be used in proto expressions.
cf3::Real result1[201]
Real max(const Real a, const Real b)
Maximum between two scalars.
Definition: Terminals.hpp:228
boost::proto::terminal< SFOp< NodesOp > >::type const nodes
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealMatrix
Dynamic sized matrix of Real scalars.
Definition: MatrixTypes.hpp:22
Eigen::Matrix< Real, nb_nodes, Hexa3D_traits::dimension > NodesT
Lagrange P1 Triangular Element type This class provides the lagrangian shape function describing the ...
Definition: Line1D.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
Basic Classes for Mesh applications used by COOLFluiD.
namespace holding LagrangeP1 shape functions and elements
Top-level namespace for coolfluid.
Definition: Action.cpp:18
~LagrangeP1Line1DFixture()
common tear-down for each test case
Eigen::Matrix< Real, Hexa3D_traits::dimension, 1 > CoordsT
BOOST_AUTO_TEST_CASE(Volume)
LagrangeP1Line1DFixture()
common setup for each test case
Functions to provide integration over elements.
Definition: Gauss.hpp:26
void vector_test(const VectorT &A, const VectorT &B, Accumulator &Result)
Compares vector-like sequences.
Definition: Difference.hpp:139
Eigen::Matrix< Real, Hexa3D_traits::SF::dimensionality, Hexa3D_traits::dimension > JacobianT
Most basic kernel library.
Definition: Action.cpp:19
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
const ETYPE::MappedCoordsT mapped_coords
common values accessed by all tests goes here
Send comments to:
COOLFluiD Web Admin