Go to the documentation of this file.
24 #ifndef NIHU_MESH_HPP_INCLUDED
25 #define NIHU_MESH_HPP_INCLUDED
27 #include "../util/crtp_base.hpp"
28 #include "../util/eigen_utils.hpp"
29 #include "../util/type2tag.hpp"
31 #include "../tmp/integer.hpp"
32 #include "../tmp/sequence.hpp"
33 #include "../tmp/algorithm.hpp"
34 #include "../tmp/control.hpp"
35 #include "../tmp/vector.hpp"
45 template <
class ElemType>
57 template <
class xType>
62 static unsigned const nDim = x_t::SizeAtCompileTime;
88 template <
class ElemTypeVector>
97 template <
class Derived>
109 template <
class ElemTypeVector>
112 ,
public field_points<typename first_elements_x_type<ElemTypeVector>::type>
142 template <
class ElemType>
147 template <
class elem_t>
156 if (input[0] == elem_t::id)
161 for (
unsigned i = 0; i < elem_t::num_nodes; ++i)
163 nodes[i] = input[i+1];
164 coords.col(i) = m.
points[nodes[i]];
185 template <
class node_t,
class elem_t>
188 unsigned const N_MAX_ELEM = 1+9;
190 for (
unsigned i = 0; i < unsigned(nodes.rows()); ++i)
193 for (
unsigned j = 0; j <
nDim; ++j)
197 for (
unsigned i = 0; i < unsigned(elements.rows()); ++i)
199 unsigned e[N_MAX_ELEM] = {0};
200 for (
unsigned j = 0; j < unsigned(elements.cols()); ++j)
201 e[j] =
unsigned(elements(i,j));
209 template <
class ElemType>
212 return m_elements.eigen_std_vector<ElemType>::type::begin();
218 template <
class ElemType>
221 return m_elements.eigen_std_vector<ElemType>::type::end();
227 template <
class ElemType>
230 return m_elements.eigen_std_vector<ElemType>::type::operator[](i);
241 return tmp::call_until<
256 for (
unsigned i = 0; i <
nDim; ++i)
266 template <
class elem_t>
269 m_elements.eigen_std_vector<elem_t>::type::push_back(e.derived());
270 return *(
m_elements.eigen_std_vector<elem_t>::type::rbegin());
296 template <
class nodes_t,
class elements_t,
class...Args>
298 create_mesh(nodes_t
const &nodes, elements_t
const &elements, Args...)
304 template <
class Mesh,
class Elem>
306 :
public mesh_base<homogeneous_submesh<Mesh, Elem>>
317 typename mesh_t::template elem_iterator_t<elem_t>::type
begin()
const
319 return m_parent.template begin<elem_t>();
323 typename mesh_t::template elem_iterator_t<elem_t>::type
end()
const
325 return m_parent.template end<elem_t>();
328 Elem
const &get_elem(
int i)
const
330 return m_parent.template get_elem<elem_t>(i);
342 template <
class Mesh,
class Tag>
343 homogeneous_submesh<Mesh, typename tag2type<Tag>::type>
field_points< typename first_elements_x_type< ElemTypeVector >::type > base_t
type of base class
combine a sequence of classes so that the result is inherited from each element
Convert T to an std::vector<T> with Eigen allocator.
homogeneous_submesh< Mesh, typename tag2type< Tag >::type > create_homogeneous_submesh(Mesh const &mesh, Tag)
factory function to create a homogeneous submesh from a mesh
static const unsigned nDim
number of dimensions of the mesh
class describing a volume element that has no normal vector
base_t::x_t x_t
type of a nodal vector
metafunction to dereference an iterator
x_t::Scalar scalar_t
type of a nodal coordinate
bool add_elem(unsigned const input[])
add a new element to the mesh
mesh< tmp::vector< typename tag2type< Args >::type... > > create_mesh(nodes_t const &nodes, elements_t const &elements, Args...)
factory function to create a mesh from nodes and elements matrices
eigen_std_vector< ElemType >::type::const_iterator type
the iterator that traverses a submesh's element container
unsigned m_num_elements
total number of elements in the mesh
element_traits::coords_type< Derived >::type coords_t
matrix type that stores the element's corner nodes
return begin iterator of a sequence
unsigned get_num_elements() const
return number of elements
elem_iterator_t< ElemType >::type begin() const
return begin iterator of the elements
eigen_std_vector< x_t >::type points
nodal coordinates
#define NIHU_CRTP_HELPERS
define CRTP helper function
size_t get_num_points() const
return number of points
const elem_t & push_element(element_base< elem_t > const &e)
add a new element to the mesh
bool operator()(unsigned const input[], mesh &m)
add an element of given type to the mesh
static const unsigned nDim
number of dimensions
metafunction computing the first element's x_t in a vector of elements
mesh_t::template elem_iterator_t< elem_t >::type end() const
return end iterator of the elements
Eigen::Matrix< unsigned, num_nodes, 1 > nodes_t
vector type that stores the element's corner node indices
mesh_t::template elem_iterator_t< elem_t >::type begin() const
return begin iterator of the elements
void add_point(x_t const &p)
add a point to the field point mesh
void add_node(scalar_t input[])
add a new node to the mesh
Declaration of element classes.
tmp::inherit< typename tmp::transform< elem_type_vector_t, tmp::inserter< typename tmp::empty< elem_type_vector_t >::type, tmp::push_back< tmp::_1, tmp::_2 > >, eigen_std_vector< tmp::_1 > >::type >::type elem_container_t
combine elem_vector into a BIG heterogeneous std::vector container
eigen_std_vector< x_t >::type::const_iterator iterator_t
node iterator type
elem_container_t m_elements
element geometries (BIG heterogeneous container)
push an element to the back
ElemTypeVector elem_type_vector_t
define template parameter as nested type
const ElemType & get_elem(size_t i) const
return element with a given index
container class for a mesh
container class for field points
mesh(node_t const &nodes, elem_t const &elements)
build the mesh from mesh description matrices
transform elements in a sequence using a user-specified metafunctor and an inserter
The geometrical element representation.
elem_iterator_t< ElemType >::type end() const
return end iterator of the elements
xType x_t
template parameter as nested type
metafunction returning the iterator that traverses the homogeneous element vector of specified elemen...