COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-proto-lagrangep2.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 proto operators"
9 
10 #include <boost/accumulators/accumulators.hpp>
11 #include <boost/accumulators/statistics/stats.hpp>
12 #include <boost/accumulators/statistics/mean.hpp>
13 #include <boost/accumulators/statistics/max.hpp>
14 
15 #include <boost/foreach.hpp>
16 #include <boost/test/unit_test.hpp>
17 #include <boost/proto/debug.hpp>
18 
19 #include "solver/Model.hpp"
20 #include "solver/Solver.hpp"
21 
27 
28 #include "common/Core.hpp"
29 #include "common/Log.hpp"
30 
31 #include "math/MatrixTypes.hpp"
32 
33 #include "mesh/Domain.hpp"
34 #include "mesh/Mesh.hpp"
35 #include "mesh/Region.hpp"
36 #include "mesh/Elements.hpp"
37 #include "mesh/MeshReader.hpp"
38 #include "mesh/ElementData.hpp"
39 #include "mesh/FieldManager.hpp"
40 #include "mesh/Dictionary.hpp"
43 
45 #include "mesh/ElementTypes.hpp"
46 
47 #include "physics/PhysModel.hpp"
48 
52 
53 using namespace cf3;
54 using namespace cf3::solver;
55 using namespace cf3::solver::actions;
56 using namespace cf3::solver::actions::Proto;
57 using namespace cf3::mesh;
58 using namespace cf3::common;
59 
60 
61 BOOST_AUTO_TEST_SUITE( ProtoLagrangeP2Suite )
62 
63 using boost::proto::lit;
64 
66 
67 
68 BOOST_AUTO_TEST_CASE( LagrangeP2 )
69 {
72 
73  Dictionary& dict = mesh->create_continuous_space("cf3.mesh.LagrangeP2", "cf3.mesh.LagrangeP2");
74  dict.add_tag("solution");
75  dict.create_field( "solution", "u[vector]" ).add_tag("solution");
76 
77  FieldVariable<0, VectorField > u("u", "solution", "cf3.mesh.LagrangeP2");
78 
79  RealVector2 centroid(1./3, 1.3);
80  RealMatrix result;
81 
82  RealMatrix expected(6,6);
83  expected <<
84  1./60., -1./360., -1./360., 0., -1./90., 0.,
85  -1./360., 1./60., -1./360., 0., 0., -1./90.,
86  -1./360., -1./360., 1./60., -1./90., 0., 0.,
87  0., 0., -1./90., 4./45., 2./45., 2./45.,
88  -1./90., 0., 0., 2./45., 4./45., 2./45.,
89  0., -1./90., 0., 2./45., 2./45., 4./45.;
90 
91  for_each_node(mesh->topology(), group(u[0] = 0., u[1] = 1.));
92 
93  for_each_element< boost::mpl::vector2<mesh::LagrangeP1::Triag2D, mesh::LagrangeP2::Triag2D> >
94  (
95  mesh->topology(),
96  group
97  (
98  _A(u) = _0,
99  element_quadrature(_A(u[_i], u[_i]) += transpose(N(u))*N(u)),
100  lit(result) = _A
101  )
102  );
103 
104  BOOST_CHECK(((result.block<6,6>(0,0) - expected).array().abs() < 1e-15).all());
105  BOOST_CHECK(((result.block<6,6>(6,6) - expected).array().abs() < 1e-15).all());
106  BOOST_CHECK((result.block<6,6>(0,6).array() == 0.).all());
107  BOOST_CHECK((result.block<6,6>(6,0).array() == 0.).all());
108 }
109 
110 BOOST_AUTO_TEST_SUITE_END()
111 
112 
boost::proto::terminal< SFOp< ShapeFunctionOp > >::type const N
Field & create_field(const std::string &name, const Uint cols)
Create a new field in this group.
Definition: Dictionary.cpp:178
static boost::proto::terminal< ZeroTag >::type _0
Placeholder for the zero matrix.
Definition: Terminals.hpp:209
external boost library namespace
static boost::proto::terminal< ElementSystemMatrix< boost::mpl::int_< 0 > > >::type const _A
Some predefined element matrices (more can be user-defined, but you have to change the number in the ...
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
Basic Classes for Solver applications used by CF.
Definition: Action.cpp:29
static boost::proto::terminal< ElementQuadratureTag >::type element_quadrature
Use element_quadrature(expr1, expr2, ..., exprN) to evaluate a group of expressions.
void create_rectangle_tris(Mesh &mesh, const Real x_len, const Real y_len, const Uint x_segments, const Uint y_segments)
Create a triangulated version of a 2D rectangular grid.
Real e()
Definition of the Unit charge [C].
Definition: Consts.hpp:30
void for_each_node(mesh::Region &root_region, const ExprT &expr)
Definition: NodeLooper.hpp:239
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealMatrix
Dynamic sized matrix of Real scalars.
Definition: MatrixTypes.hpp:22
boost::proto::terminal< TransposeFunction >::type const transpose
Basic Classes for Mesh applications used by COOLFluiD.
Top-level namespace for coolfluid.
Definition: Action.cpp:18
static boost::proto::terminal< IndexTag< boost::mpl::int_< 0 > > >::type const _i
Index looping over the dimensions of a variable.
void add_tag(const std::string &tag)
common::Component & root() const
Gives the default root component.
Definition: Core.cpp:145
static boost::proto::terminal< ExpressionGroupTag >::type group
Use group(expr1, expr2, ..., exprN) to evaluate a group of expressions.
Eigen::Matrix< Real, 2, 1 > RealVector2
Fixed size 2x1 column vector.
Definition: MatrixTypes.hpp:40
BOOST_AUTO_TEST_CASE(LagrangeP2)
Region & topology() const
Definition: Mesh.hpp:51
static Core & instance()
Definition: Core.cpp:37
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
Send comments to:
COOLFluiD Web Admin