Go to the documentation of this file.
24 #ifndef ELEMENT_HPP_INCLUDED
25 #define ELEMENT_HPP_INCLUDED
27 #include <boost/math/constants/constants.hpp>
29 #include "../util/crtp_base.hpp"
30 #include "../tmp/bool.hpp"
62 unsigned num = 0,
unsigned ind1 = 0,
unsigned ind2 = 0) :
63 m_num(num), m_ind1(ind1), m_ind2(ind2)
67 std::ostream &print_debug(std::ostream &os)
const
69 return os <<
"Element overlapping info: " << std::endl
70 <<
"Number of coincident nodes: " << m_num << std::endl
71 <<
"Start index on element 1 : " << m_ind1 <<
" and on element 2 " << m_ind2;
78 unsigned m_ind1, m_ind2;
83 template <
class Derived,
unsigned Order>
87 namespace element_traits
90 template <
class Derived>
93 static const std::string value;
97 template <
class Derived>
101 template <
class Derived>
105 template <
class Derived>
109 template <
class Derived>
119 template <
class Derived,
unsigned Order>
121 typename lset<Derived>::type,
126 template <
class Derived>
129 typedef Eigen::Matrix<
137 template <
class Derived,
unsigned Order>
140 typedef Eigen::Matrix<
148 template <
class Derived,
unsigned Order>
150 typename location_complexity<Derived, Order>::type,
151 location_impl<Derived, Order>,
152 typename coords_type<Derived>::type,
153 typename shape_set_traits::domain<
154 typename lset<Derived>::type
159 template <
class Derived,
unsigned Order>
165 >::type::return_type type;
173 template <
class Derived,
unsigned Order>
178 typedef typename element_traits::coords_type<Derived>::type coords_t;
179 typedef typename element_traits::location_value_type<Derived, Order>::type ret_t;
182 static ret_t eval(coords_t
const &coords, xi_t
const &xi)
184 return coords * lset_t::template eval_shape<Order>(xi);
193 template <
class Derived>
210 typedef typename domain_t::xi_t
xi_t;
220 typedef typename element_traits::location_value_type<Derived, 0>::type
x_t;
222 typedef typename element_traits::location_return_type<Derived, 0>::type
x_return_type;
224 typedef typename element_traits::location_value_type<Derived, 1>::type
dx_t;
226 typedef typename element_traits::location_return_type<Derived, 1>::type
dx_return_type;
228 typedef typename element_traits::location_value_type<Derived, 2>::type
ddx_t;
230 typedef typename element_traits::location_return_type<Derived, 2>::type
ddx_return_type;
233 typedef Eigen::Matrix<unsigned, num_nodes, 1>
nodes_t;
235 typedef typename element_traits::coords_type<Derived>::type
coords_t;
281 for (
unsigned e = 0; e < domain_t::num_edges; ++e)
283 auto const &edge = domain_t::get_edge(e);
284 x_t x0 =
get_x(domain_t::get_corner(edge[0]));
285 x_t x1 =
get_x(domain_t::get_corner(edge[1]));
373 template <
class OtherElem>
376 unsigned num_coinc = 0;
377 unsigned start_ind1 = 0, start_ind2 = 0;
379 auto const &otherNodes = other.get_nodes();
382 for (
unsigned j = 0; j < OtherElem::num_nodes; ++j)
384 if (
m_nodes[i] == otherNodes[j])
398 if (j < start_ind2 ||
399 (j==OtherElem::num_nodes-1 &&
428 xi_t const &xi = lset_t::corner_at(i);
430 coords.col(i) = x0 + dx0 * dxi;
434 return Derived(coords);
445 return lhs(0,0) < rhs(0,0);
450 template <
class LSet,
class scalar_t>
454 template <
class LSet,
class scalar_t>
459 namespace element_traits
462 template <
class LSet,
class Scalar>
464 :
space<Scalar, LSet::domain_t::dimension> {};
466 template <
class LSet,
class Scalar>
472 template <
class LSet,
class Scalar>
479 template<
class Derived,
class enable =
void>
483 namespace element_traits
486 template <
class LSet,
class Scalar>
488 :
space<Scalar, LSet::domain_t::dimension + 1> {};
490 template <
class LSet,
class Scalar>
496 template <
class LSet,
class Scalar>
501 template <
class Derived>
503 element_traits::space_type<Derived>::type::dimension == 3
506 typedef typename element_traits::location_value_type<Derived, 0>::type x_t;
507 typedef typename element_traits::location_value_type<Derived, 1>::type dx_t;
509 static x_t eval(dx_t
const &m)
516 template <
class Derived>
518 element_traits::space_type<Derived>::type::dimension == 2
521 typedef typename element_traits::location_value_type<Derived, 0>::type x_t;
522 typedef typename element_traits::location_value_type<Derived, 1>::type dx_t;
524 static x_t eval(dx_t
const &m)
526 using namespace boost::math::double_constants;
527 return Eigen::Rotation2D<typename Derived::scalar_t>(-pi/2.0) * m;
531 namespace element_traits
534 template <
class Derived>
536 typename location_complexity<Derived, 1>::type,
537 normal_impl<Derived>,
538 typename location_value_type<Derived, 1>::type
542 template <
class Derived>
547 >::type::return_type type;
554 template <
class LSet,
class scalar_t>
571 using base_t::get_dx;
591 :
base_t(coords, id, nodes),
592 normal_computer(get_dx(
xi_t()))
596 void flip_inplace(
void)
601 surface_element flip(
void)
const
603 return surface_element(this->get_coords().colwise().reverse(), this->get_id()(0), this->get_nodes().reverse());
613 return normal_computer(get_dx(xi));
622 template <
class LSet,
class scalar_t>
623 class volume_element :
624 public element_base<volume_element<LSet, scalar_t> >
639 using base_t::get_dx;
651 :
base_t(coords, id, nodes)
element_traits::location_value_type< Derived, 0 >::type x_t
type of the element's physical location variable
element_base< volume_element< LSet, scalar_t > > base_t
the base class type
Derived get_linearized_elem(xi_t const &xi0) const
construct linearized elem around an intrinsic coordinate
class describing a volume element that has no normal vector
Eigen::Matrix< unsigned, num_nodes, 1 > nodes_t
vector type that stores the element's corner node indices
The physical coordinate space of the element.
scalar_t m_linear_size_estimate
estimated linear size of an element
Defines the domain where the shape function set is defined.
The return type of the physical location's derivatives.
element_base(coords_t const &coords, unsigned id=0, nodes_t const &nodes=nodes_t())
constructor
const x_t & get_center(void) const
return element center
element_traits::lset< Derived >::type lset_t
the element's L-set
element_traits::normal_return_type< surface_element >::type normal_return_type
the return type of function get_normal
@ num_nodes
the number of nodes
normal_return_type get_normal(xi_t const &xi=domain_t::get_center()) const
return element normal
nodes_t m_nodes
the element's nodal indices in the mesh
element_overlapping get_overlapping(OtherElem const &other) const
check overlapping state with other element
element_traits::normal_factory_functor< surface_element >::type normal_computer
functor computing the normal vector
element_base< surface_element< LSet, scalar_t > > base_t
the base class type
element_traits::coords_type< Derived >::type coords_t
matrix type that stores the element's corner nodes
constexpr unsigned num_derivatives(unsigned order, unsigned dim)
return the number of partial derivatives in dim dimensions In 1D there is one partial derivative and ...
const nodes_t & get_nodes(void) const
return nodes
Class that computes or stores the locations.
space_t::scalar_t scalar_t
the element's scalar variable
coords_t m_coords
the element's corner coordinates
Defines the complexity to determine if the location derivative can be precomputed or not.
domain_t::xi_t xi_t
type of the shape functions' independent variable
class representing a coordinate space with a scalar and a dimension
dx_return_type get_dx(xi_t const &xi) const
return element location gradient
element_traits::coords_type< Derived >::type coords_t
matrix type that stores the element's corner nodes
Indicates if the element is a surface element or not.
#define NIHU_CRTP_HELPERS
define CRTP helper function
The element type's textual id.
element_traits::location_return_type< Derived, 1 >::type dx_return_type
return type of the element physical location derivative
Matrix that stores the physical location's derivatives.
typename base_t::domain_t domain_t
the domain type
Assigns an id to the element type.
element_traits::location_factory_functor< Derived, 0 >::type x_computer
functor computing the locations
elem_id_t id_t
type that stores the element's id
The return type of the normal vector.
domain_t::xi_t xi_t
type of the shape functions' independent variable
class describing the overlapping state of two elements
x_return_type get_x(xi_t const &xi) const
return element location
The geometrical shape set of the element.
compute location derivatives from nodal coordinates
volume_element(coords_t const &coords, unsigned id=0, nodes_t const &nodes=nodes_t())
constructor
Derived type
self-returning metafunction
id_t m_id
the element's identifier
const scalar_t & get_linear_size_estimate(void) const
return linear size estimate
compute surface normal from location derivatives
Class that computes or stores the normals.
element_traits::location_factory_functor< Derived, 1 >::type dx_computer
functor computing the location derivative vector
surface_element(coords_t const &coords, unsigned id=0, nodes_t const &nodes=nodes_t())
constructor
Eigen::Matrix< unsigned, num_nodes, 1 > nodes_t
vector type that stores the element's corner node indices
unsigned get_ind2(void) const
return index of first coincident node in element 2
class describing a surface element that provides a normal vector
element_overlapping(unsigned num=0, unsigned ind1=0, unsigned ind2=0)
constructor
bool operator<(elem_id_t const &lhs, elem_id_t const &rhs)
compare two element id's by value
lset_t::domain_t domain_t
the element's reference domain
ddx_return_type get_ddx(xi_t const &xi) const
return element location second derivative matrix
unsigned get_num(void) const
return number of coincident nodes
element_traits::location_return_type< Derived, 0 >::type x_return_type
return type of the element physical location variable when obtained by get_x
unsigned get_ind1(void) const
return index of first coincident node in element 1
Eigen::Matrix< unsigned, num_nodes, 1 > nodes_t
vector type that stores the element's corner node indices
element_traits::location_value_type< Derived, 1 >::type dx_t
type of the gradient of the element's physical location variable
element_traits::space_type< Derived >::type space_t
the element space type
const coords_t & get_coords(void) const
return coordinates
@ dXI
index of xi in 1st derivative matrix
NIHU_CRTP_HELPERS element_base()
default constructor for std::vector container
typename base_t::domain_t domain_t
the domain type
@ dETA
index of eta in 1st derivative matrix
x_t m_center
the element's center
element_traits::location_value_type< Derived, 2 >::type ddx_t
type of the second derivative of the element's physical location variable
Definition of shape function sets.
const id_t & get_id(void) const
return elem id
element_traits::coords_type< Derived >::type coords_t
matrix type that stores the element's corner nodes
element_traits::location_return_type< Derived, 2 >::type ddx_return_type
return type of the element physical location second derivative
Eigen::Matrix< unsigned, 1, 1 > elem_id_t
type that stores the element's id
The geometrical element representation.
element_traits::location_factory_functor< Derived, 2 >::type ddx_computer
functor computing the location second derivative matrix
Matrix that stores the element's corner coordinates.
Defines the complexity to determine if the shape functions can be precomputed or not.
Assigns an id to the shape set.