7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for the ETYPE shapefunction"
10 #include <boost/assign/list_of.hpp>
11 #include <boost/test/unit_test.hpp>
46 0.8, 2.1, 1.).finished())
60 const bool closed = std::abs(std::abs(end_angle - start_angle) - 2.0*
Consts::pi()) <
eps();
64 coord_array.
resize(boost::extents[(u_segments + (!closed)) * (v_segments+1)][dim]);
68 conn_array.
resize(boost::extents[2 * u_segments * v_segments][nb_nodes]);
69 const Real v_step = height / v_segments;
73 for(
Uint v = 0;
v <= v_segments; ++
v)
75 const Real z_coord = v_step *
static_cast<Real
>(
v);
76 for(
Uint u = 0; u <= u_segments; ++u)
78 const Real
theta = start_angle + (end_angle - start_angle) * (static_cast<Real>(u) /
static_cast<Real
>(u_segments));
81 coord_row[
XX] = radius * cos(theta);
82 coord_row[
YY] = radius * sin(theta);
83 coord_row[
ZZ] = z_coord;
87 for(
Uint v = 0;
v != v_segments; ++
v)
90 for(
Uint u = 0; u != u_segments; ++u)
92 const Uint node0 =
v*(u_segments+1) + u;
93 const Uint node1 = node0 + 1;
94 const Uint node3 = (
v+1)*(u_segments+1) + u;
95 const Uint node2 = node3 + 1;
112 for(
Uint v = 0;
v <= v_segments; ++
v)
114 const Real z_coord = v_step *
static_cast<Real
>(
v);
115 for(
Uint u = 0; u != u_segments; ++u)
117 const Real
theta = start_angle + (end_angle - start_angle) * (static_cast<Real>(u) /
static_cast<Real
>(u_segments));
120 coord_row[
XX] = radius * cos(theta);
121 coord_row[
YY] = radius * sin(theta);
122 coord_row[
ZZ] = z_coord;
126 for(
Uint v = 0;
v != v_segments; ++
v)
129 for(
Uint u = 0; u != u_segments; ++u)
131 const Uint node0 =
v*u_segments + u;
132 const Uint node1 = node0 + 1;
133 const Uint node3 = (
v+1)*u_segments + u;
134 const Uint node2 = node3 + 1;
147 conn_array[2 * (
v*u_segments + u_segments-1)][1] =
v*u_segments;
148 conn_array[2 * (
v*u_segments + u_segments-1)][2] = (
v+1)*u_segments;
149 conn_array[2 * (
v*u_segments + u_segments-1) + 1][0] = (
v+1)*u_segments;
165 return result.norm();
179 return result.norm();
207 m_radius(radius), m_circulation(circulation), m_u(U) {}
222 ETYPE::SF::ValueT sf_mat;
223 ETYPE::SF::compute_value(mapped_coords, sf_mat);
225 return normal * (sf_mat * nodal_p);
237 return atan2(coords[
YY], coords[
XX]);
243 Real tmp = (2. * m_u * sin(theta) + m_circulation / (2. *
Consts::pi() * m_radius));
244 return 0.5 * m_rho * tmp * tmp;
251 template<
typename ResultT,
typename FunctorT>
254 const Uint nb_elems = connectivity.
array().size();
255 for(
Uint elem_idx = 0; elem_idx != nb_elems; ++ elem_idx)
259 fill(nodes, coordinates, connectivity.
array()[elem_idx]);
264 template<
typename ResultT,
typename FunctorT,
typename NodesT>
267 static const double mu = 0.3333333333333333333333333;
268 static const double w = 0.5;
270 result += w * functor(mapped_coords, nodes);
281 NodesT nodes_triag3D;
286 BOOST_CHECK_EQUAL(
ETYPE::area(nodes_triag3D), std::sqrt(2.)/2.);
291 const ETYPE::SF::ValueT reference_result(0.1, 0.1, 0.8);
292 ETYPE::SF::ValueT result;
293 ETYPE::SF::compute_value(mapped_coords, result);
301 ETYPE::SF::GradientT expected;
308 ETYPE::SF::GradientT result;
309 ETYPE::SF::compute_gradient(mapped_coords, result);
318 expected(
KSI,
XX) = 0.6;
319 expected(
KSI,
YY) = 0.9;
320 expected(
KSI,
ZZ) = 0.5;
322 expected(
ETA,
XX) = 0.3;
323 expected(
ETA,
YY) = 1.8;
324 expected(
ETA,
ZZ) = 1.;
335 ConstFunctor ftor(
nodes);
340 gauss_integrate<1, GeoShape::TRIAG>(ftor, ftor.mapped_coords, result);
342 BOOST_CHECK_CLOSE(result, area, 0.001);
352 const Real radius = 1.;
353 const Uint u_segments = 100;
354 const Uint v_segments = 24;
355 const Real height = 3.;
360 create_cylinder(*coordinates, *connectivity, radius, u_segments, v_segments, height);
365 BOOST_CHECK_CLOSE(area, 2.*
Consts::pi()*radius*height, 0.1);
370 integrate_region(zero_flux, ConstVectorField(field_vector), *coordinates, *connectivity);
371 BOOST_CHECK_SMALL(zero_flux, 1
e-14);
379 create_cylinder(*arc_coordinates, *arc_connectivity, 1., 100, 24, 3., 0.,
Consts::pi());
382 integrate_region(arc_flux, ConstVectorField(y_vector), *arc_coordinates, *arc_connectivity);
383 BOOST_CHECK_CLOSE(arc_flux, 6., 0.01);
390 const Real radius = 1.;
391 const Uint u_segments = 1000;
392 const Uint v_segments = 100;
393 const Real height = 3.;
398 create_cylinder(*coordinates, *connectivity, radius, u_segments, v_segments, height);
402 const Real circulation = 975.;
405 integrate_region(force, RotatingCylinderPressure(radius, circulation, u), *coordinates, *connectivity);
406 BOOST_CHECK_CLOSE(force[
YY], height * 1.225*u*circulation, 0.001);
407 BOOST_CHECK_SMALL(force[
XX], 1
e-8);
408 BOOST_CHECK_SMALL(force[
ZZ], 1
e-8);
413 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(Area)
Real operator()(const RealVector &mapped_coords, const NodesT &nodes)
boost::proto::terminal< SFOp< NormalOp > >::type const normal
void integrate_region(ResultT &result, FunctorT functor, const Table< Real > &coordinates, const Table< Uint > &connectivity)
Basic Classes for Mathematical applications used by COOLFluiD.
static void compute_jacobian(const MappedCoordsT &mapped_coord, const NodesT &nodes, MatrixType &jacobian)
3D Lagrange P1 Triangular Element type This class provides the lagrangian shape function describing t...
ConstVectorField(const RealVector &vector)
ETYPE::CoordsT operator()(const RealVector &mapped_coords, const NodesT &nodes)
~LagrangeP1Triag3DFixture()
common tear-down for each test case
Real max(const Real a, const Real b)
Maximum between two scalars.
Real e()
Definition of the Unit charge [C].
boost::proto::terminal< SFOp< NodesOp > >::type const nodes
ETYPE::MappedCoordsT mapped_coords
void integrate_element(ResultT &result, FunctorT functor, const NodesT &nodes)
Static functions for mathematical constants.
const ETYPE::MappedCoordsT mapped_coords
ConstFunctor(const NodesT &node_list)
Eigen::Matrix< Real, nb_nodes, Hexa3D_traits::dimension > NodesT
Real pi()
Definition of the Pi constant.
Real theta(const ETYPE::CoordsT &coords)
static const Uint dimension
Basic Classes for Mesh applications used by COOLFluiD.
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealVector
Dynamic sized column vector.
namespace holding LagrangeP1 shape functions and elements
static Real area(const NodesT &nodes)
RotatingCylinderPressure(const Real radius, const Real circulation, const Real U)
Top-level namespace for coolfluid.
void create_cylinder(Table< Real > &coordinates, Table< Uint > &connectivity, const Real radius, const Uint u_segments, const Uint v_segments, const Real height, const Real start_angle=0., const Real end_angle=2.*Consts::pi())
Fills the given coordinate and connectivity data to create a cylinder along the Z-axis, consisting of ETYPE elements.
const ETYPE::CoordsT m_vector
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.
Returns the norm of the normal vector to the curve or surface element (equal to tangent in the case o...
Returns the scalar product of a constant vector field and the local element normal.
Eigen::Matrix< Real, Hexa3D_traits::dimension, 1 > CoordsT
Functions to provide integration over elements.
boost::proto::terminal< SFOp< CoordinatesOp > >::type const coordinates
Hexa3D_traits::SF::MappedCoordsT MappedCoordsT
LagrangeP1Triag3DFixture()
common setup for each test case
void set_row_size(const Uint nb_cols)
Real pressure(const Real theta)
unsigned int Uint
typedef for unsigned int
Eigen::Matrix< Real, Hexa3D_traits::SF::dimensionality, Hexa3D_traits::dimension > JacobianT
Real inner_product(const T1 &v1, const T2 &v2)
Real operator()(const RealVector &mapped_coords, const NodesT &nodes)
static const Uint nb_nodes
Most basic kernel library.
boost::shared_ptr< T > allocate_component(const std::string &name)
Stand-alone function to allocate components of a given type.
Eigen::Matrix< Real, 3, 1 > RealVector3
Fixed size 3x1 column vector.
virtual void resize(const Uint nb_rows)