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>
48 0.8,2.1,0.).finished())
62 const bool closed = std::abs(std::abs(end_angle - start_angle) - 2.0*
Consts::pi()) <
eps();
66 coord_array.
resize(boost::extents[(u_segments + (!closed)) * (v_segments+1)][dim]);
70 conn_array.
resize(boost::extents[u_segments * v_segments][nb_nodes]);
71 const Real v_step = height / v_segments;
75 for(
Uint v = 0;
v <= v_segments; ++
v)
77 const Real z_coord = v_step *
static_cast<Real
>(
v);
78 for(
Uint u = 0; u <= u_segments; ++u)
80 const Real
theta = start_angle + (end_angle - start_angle) * (static_cast<Real>(u) /
static_cast<Real
>(u_segments));
83 coord_row[
XX] = radius * cos(theta);
84 coord_row[
YY] = radius * sin(theta);
85 coord_row[
ZZ] = z_coord;
89 for(
Uint v = 0;
v != v_segments; ++
v)
92 for(
Uint u = 0; u != u_segments; ++u)
95 nodes[0] =
v*(u_segments+1) + u;
96 nodes[1] = nodes[0] + 1;
97 nodes[3] = (
v+1)*(u_segments+1) + u;
98 nodes[2] = nodes[3] + 1;
104 for(
Uint v = 0;
v <= v_segments; ++
v)
106 const Real z_coord = v_step *
static_cast<Real
>(
v);
107 for(
Uint u = 0; u != u_segments; ++u)
109 const Real
theta = start_angle + (end_angle - start_angle) * (static_cast<Real>(u) /
static_cast<Real
>(u_segments));
112 coord_row[
XX] = radius * cos(theta);
113 coord_row[
YY] = radius * sin(theta);
114 coord_row[
ZZ] = z_coord;
118 for(
Uint v = 0;
v != v_segments; ++
v)
121 for(
Uint u = 0; u != u_segments; ++u)
124 nodes[0] =
v*u_segments + u;
125 nodes[1] = nodes[0] + 1;
126 nodes[3] = (
v+1)*u_segments + u;
127 nodes[2] = nodes[3] + 1;
129 conn_array[
v*u_segments + u_segments-1][1] =
v*u_segments;
130 conn_array[
v*u_segments + u_segments-1][2] = (
v+1)*u_segments;
138 template<
typename SF>
145 typename SF::CoordsT result;
147 return result.norm();
161 return result.norm();
188 m_radius(radius), m_circulation(circulation), m_u(U) {}
204 ETYPE::SF::ValueT sf_mat;
205 ETYPE::SF::compute_value(mapped_coords, sf_mat);
207 return normal * (sf_mat * nodal_p);
219 return atan2(coords[
YY], coords[
XX]);
225 Real tmp = (2. * m_u * sin(theta) + m_circulation / (2. *
Consts::pi() * m_radius));
226 return 0.5 * m_rho * tmp * tmp;
235 template<
typename ResultT,
typename FunctorT>
238 const Uint nb_elems = connectivity.
array().size();
239 for(
Uint elem_idx = 0; elem_idx != nb_elems; ++ elem_idx)
242 fill(nodes, coordinates, connectivity.
array()[elem_idx]);
248 template<
typename ResultT,
typename FunctorT,
typename NodesT>
251 static const double mu = 0.;
252 static const double w = 4.;
254 result += w * functor(mapped_coords, nodes);
271 BOOST_CHECK_EQUAL(
ETYPE::area(nodes_quad3D), std::sqrt(2.));
276 const ETYPE::SF::ValueT reference_result(0.045, 0.055, 0.495, 0.405);
277 ETYPE::SF::ValueT result;
278 ETYPE::SF::compute_value(mapped_coords, result);
286 ETYPE::SF::GradientT expected;
287 const cf3::Real ksi = mapped_coords[0];
288 const cf3::Real eta = mapped_coords[1];
289 expected(0,0) = 0.25 * (-1 + eta);
290 expected(1,0) = 0.25 * (-1 + ksi);
291 expected(0,1) = 0.25 * ( 1 - eta);
292 expected(1,1) = 0.25 * (-1 - ksi);
293 expected(0,2) = 0.25 * ( 1 + eta);
294 expected(1,2) = 0.25 * ( 1 + ksi);
295 expected(0,3) = 0.25 * (-1 - eta);
296 expected(1,3) = 0.25 * ( 1 - ksi);
297 ETYPE::SF::GradientT result;
298 ETYPE::SF::compute_gradient(mapped_coords, result);
307 expected(
KSI,
XX) = 0.2775;
308 expected(
KSI,
YY) = -0.045;
309 expected(
KSI,
ZZ) = 0.5;
311 expected(
ETA,
XX) = 0.13625;
312 expected(
ETA,
YY) = 0.5975;
313 expected(
ETA,
ZZ) = 0.5;
324 ConstFunctor<ETYPE> ftor(
nodes);
334 gauss_integrate<1, GeoShape::QUAD>(ftor, ftor.mapped_coords,
result1);
335 gauss_integrate<2, GeoShape::QUAD>(ftor, ftor.mapped_coords,
result2);
336 gauss_integrate<4, GeoShape::QUAD>(ftor, ftor.mapped_coords, result4);
337 gauss_integrate<8, GeoShape::QUAD>(ftor, ftor.mapped_coords, result8);
338 gauss_integrate<16, GeoShape::QUAD>(ftor, ftor.mapped_coords, result16);
339 gauss_integrate<32, GeoShape::QUAD>(ftor, ftor.mapped_coords, result32);
341 BOOST_CHECK_CLOSE(result1, area, 0.001);
357 const Real radius = 1.;
358 const Uint u_segments = 100;
359 const Uint v_segments = 24;
360 const Real height = 3.;
365 create_cylinder(*coordinates, *connectivity, radius, u_segments, v_segments, height);
370 BOOST_CHECK_CLOSE(area, 2.*
Consts::pi()*radius*height, 0.1);
375 integrate_region(zero_flux, ConstVectorField(field_vector), *coordinates, *connectivity);
376 BOOST_CHECK_SMALL(zero_flux, 1
e-14);
384 create_cylinder(*arc_coordinates, *arc_connectivity, 1., 100, 24, 3., 0.,
Consts::pi());
387 integrate_region(arc_flux, ConstVectorField(y_vector), *arc_coordinates, *arc_connectivity);
388 BOOST_CHECK_CLOSE(arc_flux, 6., 0.01);
395 const Real radius = 1.;
396 const Uint u_segments = 1000;
397 const Uint v_segments = 100;
398 const Real height = 3.;
403 create_cylinder(*coordinates, *connectivity, radius, u_segments, v_segments, height);
407 const Real circulation = 975.;
410 integrate_region(force, RotatingCylinderPressure(radius, circulation, u), *coordinates, *connectivity);
411 BOOST_CHECK_CLOSE(force[
YY], height * 1.225*u*circulation, 0.001);
412 BOOST_CHECK_SMALL(force[
XX], 1
e-8);
413 BOOST_CHECK_SMALL(force[
ZZ], 1
e-8);
418 BOOST_AUTO_TEST_SUITE_END()
RotatingCylinderPressure(const Real radius, const Real circulation, const Real U)
ETYPE::CoordsT operator()(const RealVector &mapped_coords, const NodesT &nodes)
boost::proto::terminal< SFOp< NormalOp > >::type const normal
LagrangeP1Quad3DFixture()
common setup for each test case
Returns the scalar product of a constant vector field and the local element normal.
SF::MappedCoordsT mapped_coords
~LagrangeP1Quad3DFixture()
common tear-down for each test case
Basic Classes for Mathematical applications used by COOLFluiD.
static void compute_jacobian(const MappedCoordsT &mapped_coord, const NodesT &nodes, MatrixType &jacobian)
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
Real operator()(const ETYPE::MappedCoordsT &mapped_coords, const NodesT &nodes)
Static functions for mathematical constants.
Returns the norm of the normal vector to the curve or surface element (equal to tangent in the case o...
Eigen::Matrix< Real, nb_nodes, Hexa3D_traits::dimension > NodesT
void integrate_region(ResultT &result, FunctorT functor, const Table< Real > &coordinates, const Table< Uint > &connectivity)
Integrate over a region.
void integrate_element(ResultT &result, FunctorT functor, const NodesT &nodes)
Integration over a single element.
Real pi()
Definition of the Pi constant.
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
Real operator()(const ETYPE::MappedCoordsT &mapped_coords, const NodesT &nodes)
static Real area(const NodesT &nodes)
Real theta(const ETYPE::CoordsT &coords)
BOOST_AUTO_TEST_CASE(Area)
Top-level namespace for coolfluid.
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.
Eigen::Matrix< Real, Hexa3D_traits::dimension, 1 > CoordsT
Functions to provide integration over elements.
boost::proto::terminal< SFOp< CoordinatesOp > >::type const coordinates
const ETYPE::MappedCoordsT mapped_coords
Hexa3D_traits::SF::MappedCoordsT MappedCoordsT
const ETYPE::CoordsT m_vector
void set_row_size(const Uint nb_cols)
unsigned int Uint
typedef for unsigned int
Eigen::Matrix< Real, 4, 1 > RealVector4
Fixed size 4x1 column vector.
ConstFunctor(const NodesT &node_list)
ConstVectorField(const ETYPE::CoordsT &vector)
Eigen::Matrix< Real, Hexa3D_traits::SF::dimensionality, Hexa3D_traits::dimension > JacobianT
Real inner_product(const T1 &v1, const T2 &v2)
static const Uint nb_nodes
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.
Real pressure(const Real theta)
Most basic kernel library.
2D Lagrange P1 Quadrilateral Element type This class provides the lagrangian shape function describin...
boost::shared_ptr< T > allocate_component(const std::string &name)
Stand-alone function to allocate components of a given type.
virtual void resize(const Uint nb_rows)