Go to the documentation of this file.
24 #ifndef FUNCTION_SPACE_HPP_INCLUDED
25 #define FUNCTION_SPACE_HPP_INCLUDED
27 #include "../util/casted_iterator.hpp"
28 #include "../util/crtp_base.hpp"
29 #include "../util/type2tag.hpp"
31 #include "field_dimension.hpp"
38 template <
class Derived>
43 template <
class Derived>
53 typedef typename traits_t::mesh_t
mesh_t;
66 quantity_dimension = traits_t::quantity_dimension
73 return derived().get_mesh();
80 template <
class FieldType>
81 typename traits_t::template iterator<FieldType>::type
84 return derived().template field_begin<FieldType>();
91 template <
class FieldType>
92 typename traits_t::template iterator<FieldType>::type
95 return derived().template field_end<FieldType>();
104 return derived().get_num_dofs();
110 template <
class Derived>
115 template<
class Mesh,
class FieldOption,
class Dimension>
120 template <
class Mesh,
class FieldOption,
class Dimension>
127 quantity_dimension = Dimension::value
144 template <
class field_t>
146 typename mesh_elem_iterator_t<typename field_t::elem_t>::type,
152 namespace function_space_impl_internal
154 template <
class Mesh,
class FieldOption,
class Dimension>
157 template <
class Mesh,
class Dimension>
161 static size_t eval(Mesh
const&
mesh)
167 template <
class Mesh,
class Dimension>
171 static size_t eval(Mesh
const&
mesh)
184 template<
class Mesh,
class FieldOption,
class Dimension>
197 return Mesh::get_num_elements() * traits_t::quantity_dimension;
203 return Mesh::get_num_points() * traits_t::quantity_dimension;
211 return static_cast<Mesh
const &
> (*this);
218 template <
class FieldType>
219 typename traits_t::template iterator<FieldType>::type
222 return Mesh::template begin<typename FieldType::elem_t>();
229 template <
class FieldType>
230 typename traits_t::template iterator<FieldType>::type
233 return Mesh::template end<typename FieldType::elem_t>();
253 template<
class Mesh,
class FieldOption,
class Dimension = field_dimension::_1d>
254 class function_space_view :
255 public function_space_base<function_space_view<Mesh, FieldOption, Dimension> >,
256 public function_space_impl<function_space_view<Mesh, FieldOption, Dimension> >
276 template <
class Mesh,
class Option,
class Dimension = field_dimension::_1d>
289 template <
class Mesh,
class Dimension = field_dimension::_1d>
290 function_space_view<Mesh, field_option::isoparametric, Dimension>
const &
302 template <
class Mesh,
class Dimension = field_dimension::_1d>
303 function_space_view<Mesh, field_option::constant, Dimension>
const &
311 template <
class FuncSpace>
315 template <
class FuncSpace>
322 typedef typename base_traits::mesh_t
mesh_t;
325 quantity_dimension = base_traits::quantity_dimension
330 typename base_traits::field_type_vector_t,
333 typename base_traits::field_type_vector_t
341 template <
class dirac_field_t>
343 typename base_traits::template iterator<
344 typename dirac_field_t::field_t
347 field_impl<typename dirac_field_t::field_t>
355 template <
class FuncSpace>
372 using impl_t::get_mesh;
373 using impl_t::get_num_dofs;
376 template <
class dirac_field_t>
377 typename traits_t::template iterator<dirac_field_t>::type
380 return impl_t::template field_begin<typename dirac_field_t::field_t>();
384 template <
class dirac_field_t>
385 typename traits_t::template iterator<dirac_field_t>::type
388 return impl_t::template field_end<typename dirac_field_t::field_t>();
398 template <
class FuncSpace>
399 dirac_space<FuncSpace>
const &
409 template <
class FieldTypeVector>
413 template <
class FieldTypeVector>
417 template <
class field_t>
438 template <
class FieldTypeVector>
452 template <
class field_t>
463 template <
class FieldTypeVector>
491 template <
class field_t>
492 struct field_adder {
struct type {
497 if (input[0] == field_t::id)
502 for (
unsigned i = 0; i < elem_t::num_nodes; ++i)
504 nodes[i] = input[i+1];
505 coords.col(i) = fsp.points[nodes[i]];
507 elem_t const &elemref = fsp.push_element(
elem_t(coords, fsp.m_num_elements++, nodes));
510 typename field_t::dofs_t dofs;
511 for (
unsigned i = 0; i < field_t::num_dofs; ++i)
512 dofs[i] = input[i+elem_t::num_nodes+1];
513 fsp.push_field(
field_t(elemref, dofs));
515 fsp.m_num_dofs = std::max(fsp.m_num_dofs, dofs.maxCoeff()+1);
529 template <
class node_matrix_t,
class field_matrix_t>
533 unsigned const N_MAX_FIELD = 1000;
536 for (
int i = 0; i < nodes.rows(); ++i)
542 unsigned e[N_MAX_FIELD];
543 for (
int i = 0; i < fields.rows(); ++i)
545 for (
int j = 0; j < fields.cols(); ++j)
546 e[j] = (
unsigned)fields(i,j);
556 return static_cast<mesh_t const &
>(*this);
560 template <
class FieldType>
561 typename traits_t::template iterator<FieldType>::type
564 return m_fields.eigen_std_vector<FieldType>::type::begin();
568 template <
class FieldType>
569 typename traits_t::template iterator<FieldType>::type
572 return m_fields.eigen_std_vector<FieldType>::type::end();
578 return tmp::call_until<
580 field_adder<tmp::_1>,
587 template <
class field_t>
590 m_fields.eigen_std_vector<field_t>::type::push_back(f.derived());
591 return *(m_fields.eigen_std_vector<field_t>::type::rbegin());
600 return this->get_num_elements();
620 template <
class FieldTypeVector>
647 template <
class node_matrix_t,
class field_matrix_t>
662 template <
class nodes_t,
class elements_t,
class...fields_t>
663 function_space<tmp::vector<typename tag2type<fields_t>::type...> >
671 template <
class DerivedField,
class OriginalIterator>
677 template <
class Field,
class OriginalIterator>
679 :
public OriginalIterator
694 template <
class Direction>
697 , m_direction(direction.derived())
708 return value_t(this->original_iterator_t::operator*(), m_direction);
713 x_t
const &m_direction;
720 template <
class FunctionSpace>
724 template <
class FunctionSpace>
727 typedef FunctionSpace original_function_space_t;
733 typedef typename original_function_space_t::mesh_t
mesh_t;
737 typename base_traits::field_type_vector_t,
740 typename base_traits::field_type_vector_t
748 quantity_dimension = original_function_space_t::quantity_dimension
751 template <
class field_t>
754 template <
class original_field_t>
767 template <
class FunctionSpace>
777 template <
class Direction>
780 , m_derivative_direction(direction)
784 mesh_t const &get_mesh()
const
786 return m_fs.get_mesh();
789 template <
class FieldType>
790 typename traits_t::template iterator<FieldType>::type
793 typedef typename traits_t::template iterator<FieldType>::type return_t;
794 typedef typename return_t::original_field_t original_field_t;
796 return return_t(m_fs.template field_begin<original_field_t>(), m_derivative_direction);
799 template <
class FieldType>
800 typename traits_t::template iterator<FieldType>::type
803 typedef typename traits_t::template iterator<FieldType>::type return_t;
804 typedef typename return_t::original_field_t original_field_t;
806 return return_t(m_fs.template field_end<original_field_t>(), m_derivative_direction);
810 FunctionSpace
const &m_fs;
811 x_t
const m_derivative_direction;
814 template <
class FunctionSpace,
class Direction>
815 directional_derivative_function_space<FunctionSpace>
816 directional_derivative(function_space_base<FunctionSpace>
const &fs, Eigen::MatrixBase<Direction>
const &direction)
818 return directional_derivative_function_space<FunctionSpace>(fs.derived(), direction);
825 template <
class FuncSpace>
827 function_space_base<typename std::decay<FuncSpace>::type>,
828 typename std::decay<FuncSpace>::type
833 #endif // FUNCTION_SPACE_HPP_INCLUDED
combine a sequence of classes so that the result is inherited from each element
field_container_t m_fields
fields (BIG heterogeneous container)
Convert T to an std::vector<T> with Eigen allocator.
static const unsigned nDim
number of dimensions of the mesh
class describing a volume element that has no normal vector
Mesh mesh_t
the underlying mesh type
FieldTypeVector field_type_vector_t
the field type vector
tag to describe a constant field
traits_t::template iterator< FieldType >::type field_end() const
return end iterator of a subspace
A mesh extended with a Field generating option.
metafunction to dereference an iterator
traits_t::template iterator< FieldType >::type field_begin() const
first field of given element type
const function_space_view< Mesh, Option, Dimension > & create_function_space_view(mesh_base< Mesh > const &msh, Option, Dimension dim=Dimension())
factory function to transform a mesh into a function space
function_space_traits< original_function_space_t > base_traits
the parent traits
OriginalIterator original_iterator_t
Original iterator type.
unsigned m_num_dofs
number of degrees of freedoms
helper metafunction to extract the element type of a field
function_space_traits< dirac_space< FuncSpace > > traits_t
the traits class
mesh< typename field_2_elem_type_vector< FieldTypeVector >::type > mesh_t
the underlying mesh type
unsigned get_num_dofs() const
return number of dofs
element_traits::coords_type< Derived >::type coords_t
matrix type that stores the element's corner nodes
const field_view< Elem, field_option::constant, Dimension > & constant_view(element_base< Elem > const &e, Dimension dim=Dimension())
constant field view factory
const mesh_t & get_mesh() const
return underlying mesh reference
metafunction determining if argument is function space expression
implementation class of function spaces
tmp::deref< typename tmp::begin< typename mesh_t::elem_type_vector_t >::type >::type::x_t x_t
the location type in the function space
function_space()
constructor
field class that computes the directional derivative of a field
return begin iterator of a sequence
class representing a coordinate space with a scalar and a dimension
unsigned get_num_elements() const
return number of elements
traits_t::mesh_t mesh_t
the underlying mesh type
iterator class provides access to its value_t after static cast
impl_t::field_type_vector_t field_type_vector_t
field type vector type redefined to avoid ambigous lookup
#define NIHU_CRTP_HELPERS
define CRTP helper function
tag to describe an isoparametric field
traits_t::template iterator< FieldType >::type field_begin() const
return begin iterator of a subspace
tmp::inherit< typename tmp::transform< field_type_vector_t, tmp::inserter< typename tmp::empty< field_type_vector_t >::type, tmp::push_back< tmp::_1, tmp::_2 > >, eigen_std_vector< tmp::_1 > >::type >::type field_container_t
combine field_type_vector into a BIG heterogeneous std::vector container
size_t get_num_dofs() const
return number of degrees of freedom
CRTP base class of function spaces.
directional_derivative_field< Field > directional_derivative(field_base< Field > const &field, Eigen::MatrixBase< Direction > const &direction)
factory function to create a directional derivative field
const Mesh & get_mesh() const
return mesh reference
tmp::transform< typename base_traits::field_type_vector_t, tmp::inserter< typename tmp::empty< typename base_traits::field_type_vector_t >::type, tmp::push_back< tmp::_1, tmp::_2 > >, dirac_field< tmp::_1 > >::type field_type_vector_t
the field type vector
implementation of fields and field views
const field_view< Elem, field_option::isoparametric, Dimension > & isoparametric_view(element_base< Elem > const &e, Dimension dim=Dimension())
isoparametric field view factory
directional derivative of a function space
size_t get_num_points() const
return number of points
tmp::transform< typename base_traits::field_type_vector_t, tmp::inserter< typename tmp::empty< typename base_traits::field_type_vector_t >::type, tmp::push_back< tmp::_1, tmp::_2 > >, directional_derivative_field< tmp::_1 > >::type field_type_vector_t
the field type vector
original_function_space_t::mesh_t mesh_t
the mesh type
tmp::transform< etv_t, tmp::inserter< typename tmp::empty< etv_t >::type, tmp::push_back< tmp::_1, tmp::_2 > >, field_view< tmp::_1, FieldOption, Dimension > >::type field_type_vector_t
the field type vector
traits_t::template iterator< FieldType >::type field_begin() const
begin iterator of given field type
iterator class for iterating over a directional derivative function space
function_space(node_matrix_t const &nodes, field_matrix_t const &fields)
constructor from node and field definition matrices
function_space_traits< function_space_view< Mesh, FieldOption, Dimension > > traits_t
the traits class
class describing a function space
return a vector containing each element of Seq exactly once
traits_t::field_type_vector_t field_type_vector_t
the field type vector
Dirac-like extension of a function space.
scaled_integral_operator< Scalar, typename std::enable_if< is_integral_operator< IntOp >::value, IntOp >::type > operator*(Scalar &&scalar, IntOp &&intop)
factory operator to create a scaled integral operator
function_space_impl< function_space< FieldTypeVector > > impl_t
the implementation type
function_space< tmp::vector< typename tag2type< fields_t >::type... > > create_function_space(nodes_t const &nodes, elements_t const &elements, fields_t const &...fields)
factory function to create a function space from fields
traits_t::template iterator< FieldType >::type field_end() const
end iterator of given field type
function_space_impl< function_space_view< Mesh, FieldOption, Dimension > > impl_t
the implementation class
unsigned get_num_fields() const
return number of fields
Eigen::Matrix< unsigned, num_nodes, 1 > nodes_t
vector type that stores the element's corner node indices
CRTP base class of all fields.
function_space_impl< FuncSpace > impl_t
the implementation class
NIHU_CRTP_HELPERS typedef function_space_traits< Derived > traits_t
the traits class
traits_t::mesh_t mesh_t
the underlying mesh type
base_traits::mesh_t mesh_t
the mesh type
Field original_field_t
The original field type.
crtp_base_t::x_t x_t
the physical location type
size_t get_num_dofs() const
return number of degrees of freedom
traits_t::template iterator< dirac_field_t >::type field_end() const
return end iterator of a subvector of dirac fields
traits_t::field_type_vector_t field_type_vector_t
the field type vector
metafunction to return the element type vector of a field type vector
crtp_base_t::elem_t elem_t
the element type shorthand
push an element to the back
ElemTypeVector elem_type_vector_t
define template parameter as nested type
tmp::unique< typename tmp::transform< FieldTypeVector, tmp::inserter< typename tmp::empty< FieldTypeVector >::type, tmp::push_back< tmp::_1, tmp::_2 > >, elemize< tmp::_1 > >::type >::type type
the element type vector
const mesh_t & get_mesh() const
return reference to the underlying mesh
Field automatically generated from an element using a field generation option.
traits_t::template iterator< FieldType >::type field_end() const
last field of given element type
function_space_traits< FuncSpace > base_traits
the parent traits
container class for a mesh
mesh_t::elem_type_vector_t etv_t
the mesh element type vector type
class describing a function space
impl_t::mesh_t mesh_t
mesh type redefined to avoid ambigous lookup
const field_t & push_field(field_base< field_t > const &f)
push a field to the vector of fields
transform elements in a sequence using a user-specified metafunctor and an inserter
traits_t::template iterator< dirac_field_t >::type field_begin() const
return begin iterator of a subvector of dirac fields
bool add_field(unsigned const input[])
add a field to the function space
function_space_impl()
constructor
function_space_impl(node_matrix_t const &nodes, field_matrix_t const &fields)
constructor from node and field definition matrices
const dirac_field< Field > & dirac(field_base< Field > const &f)
dirac field view factory
traits class of function spaces
function_space_traits< function_space< FieldTypeVector > > traits_t
the traits class
Declaration of class Mesh.