7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for the Line2D shapefunction"
10 #include <boost/assign/list_of.hpp>
11 #include <boost/test/unit_test.hpp>
51 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
56 mapped_coords((
ETYPE::MappedCoordsT() << .2).finished()),
59 (
ETYPE::NodesT() << 5., 7.,
76 return sqrt(jac[0]*jac[0] + jac[1]*jac[1]);
103 return normal.dot(m_vector);
116 m_radius(radius), m_circulation(circulation), m_u(U) {}
130 ETYPE::SF::ValueT sf_mat;
131 ETYPE::SF::compute_value(mapped_coords, sf_mat);
133 return normal * (sf_mat * nodal_p);
145 return atan2(coords[
YY], coords[
XX]);
151 Real tmp = (2. * m_u * sin(theta) + m_circulation / (2. *
Consts::pi() * m_radius));
152 return 0.5 * m_rho * tmp * tmp;
161 template<
typename ResultT,
typename FunctorT>
164 const Uint nb_elems = connectivity.
array().size();
165 for(
Uint elem_idx = 0; elem_idx != nb_elems; ++ elem_idx)
168 fill(nodes, coordinates, connectivity.
array()[elem_idx]);
174 template<
typename ResultT,
typename FunctorT,
typename NodesT>
177 static const double mu = 0.;
178 static const double w = 2.;
180 result += w * functor(mapped_coords, nodes);
192 nodes_line2D(0,
XX) = 2.0; nodes_line2D(0,
YY) = 2.0;
193 nodes_line2D(1,
XX) = 1.0; nodes_line2D(1,
YY) = 1.0;
194 BOOST_CHECK_EQUAL(Line2D::area(nodes_line2D),std::sqrt(2.));
199 const ETYPE::SF::ValueT reference_result(0.4, 0.6);
200 ETYPE::SF::ValueT result;
201 Line2D::SF::compute_value(mapped_coords, result);
203 vector_test(result, reference_result, accumulator);
209 ETYPE::SF::GradientT result;
210 ETYPE::SF::GradientT expected;
211 expected(0,0) = -0.5;
213 Line2D::SF::compute_gradient(mapped_coords, result);
223 Line2D::compute_jacobian(mapped_coords,
nodes, result);
231 ConstFunctor ftor(
nodes);
232 const Real vol = Line2D::area(
nodes);
241 gauss_integrate<1, GeoShape::LINE>(ftor, ftor.mapped_coords,
result1);
242 gauss_integrate<2, GeoShape::LINE>(ftor, ftor.mapped_coords,
result2);
243 gauss_integrate<4, GeoShape::LINE>(ftor, ftor.mapped_coords, result4);
244 gauss_integrate<8, GeoShape::LINE>(ftor, ftor.mapped_coords, result8);
245 gauss_integrate<16, GeoShape::LINE>(ftor, ftor.mapped_coords, result16);
246 gauss_integrate<32, GeoShape::LINE>(ftor, ftor.mapped_coords, result32);
268 Mesh&
mesh = *Core::instance().root().create_component<
Mesh>(
"surface_integral");
271 Table<Uint>& connectivity = find_component_recursively<Elements>(
mesh).geometry_space().connectivity();
277 BOOST_CHECK_CLOSE(length, 2.*
Consts::pi(), 0.1);
282 integrate_region(zero_flux, ConstVectorField(field_vector), coordinates, connectivity);
283 BOOST_CHECK_SMALL(zero_flux, 1
e-14);
289 Mesh&
mesh = *Core::instance().root().create_component<
Mesh>(
"arc_integral");
292 Table<Uint>& arc_connectivity = find_component_recursively<Elements>(
mesh).geometry_space().connectivity();
295 integrate_region(arc_flux, ConstVectorField(y_vector), arc_coordinates, arc_connectivity);
296 BOOST_CHECK_CLOSE(arc_flux, 2., 0.01);
303 const Real radius = 1.;
307 Mesh&
mesh = *Core::instance().root().create_component<
Mesh>(
"rotating_cylinder");
310 Table<Uint>& connectivity = find_component_recursively<Elements>(
mesh).geometry_space().connectivity();
314 const Real circulation = 975.;
316 integrate_region(force, RotatingCylinderPressure(radius, circulation, u), coordinates, connectivity);
317 BOOST_CHECK_CLOSE(force[
YY], 1.225*u*circulation, 0.001);
318 BOOST_CHECK_SMALL(force[
XX], 1
e-8);
323 BOOST_AUTO_TEST_SUITE_END()
ConstFunctor(const ETYPE::NodesT &node_list)
boost::proto::terminal< SFOp< NormalOp > >::type const normal
Basic Classes for Mathematical applications used by COOLFluiD.
RotatingCylinderPressure(const Real radius, const Real circulation, const Real U)
static void compute_jacobian(const MappedCoordsT &mapped_coord, const NodesT &nodes, MatrixType &jacobian)
const ETYPE::CoordsT & m_vector
Real operator()(const ETYPE::MappedCoordsT &mapped_coords, const ETYPE::NodesT &nodes)
BOOST_AUTO_TEST_CASE(Area)
Real operator()(const ETYPE::MappedCoordsT &mapped_coords, const ETYPE::NodesT &nodes)
void integrate_element(ResultT &result, FunctorT functor, const NodesT &nodes)
Integral for an element.
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
LagrangeP1Line2DFixture()
common setup for each test case
Eigen::Matrix< Real, nb_nodes, Hexa3D_traits::dimension > NodesT
Lagrange P1 Triangular Element type This class provides the lagrangian shape function describing the ...
Real pi()
Definition of the Pi constant.
Basic Classes for Mesh applications used by COOLFluiD.
namespace holding LagrangeP1 shape functions and elements
Returns the scalar product of a constant vector field and the local element normal.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef ETYPE::NodesT NodesT
Returns the norm of the normal vector to the curve or surface element (equal to tangent in the case o...
Top-level namespace for coolfluid.
void integrate_region(ResultT &result, FunctorT functor, const Table< Real > &coordinates, const Table< Uint > &connectivity)
Integral over a region.
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.
ETYPE::MappedCoordsT mapped_coords
Eigen::Matrix< Real, Hexa3D_traits::dimension, 1 > CoordsT
Functions to provide integration over elements.
const ETYPE::NodesT nodes
boost::proto::terminal< SFOp< CoordinatesOp > >::type const coordinates
Real pressure(const Real theta)
Hexa3D_traits::SF::MappedCoordsT MappedCoordsT
ConstVectorField(const ETYPE::CoordsT &vector)
unsigned int Uint
typedef for unsigned int
const ETYPE::NodesT & m_nodes
Real theta(const ETYPE::CoordsT &coords)
Eigen::Matrix< Real, Hexa3D_traits::SF::dimensionality, Hexa3D_traits::dimension > JacobianT
ETYPE::CoordsT operator()(const ETYPE::MappedCoordsT &mapped_coords, const ETYPE::NodesT &nodes)
Most basic kernel library.
2D Lagrange P1 Triangular Element type This class provides the lagrangian shape function describing t...
const ETYPE::MappedCoordsT mapped_coords