1# ifndef _RHEOLEF_FIELD_H
2# define _RHEOLEF_FIELD_H
199#include "rheolef/field_rdof.icc"
200#include "rheolef/field_wdof.icc"
201#include "rheolef/integrate_option.h"
208template <
class T,
class M>
class field_concat_value;
209template <
class FieldWdof>
class field_wdof_sliced;
210template <
class FieldRdof>
class field_rdof_sliced_const;
218template <
class T,
class M = rheo_default_memory_model>
229 using geo_type = geo_basic <float_type,memory_type>;
244 const T& init_value = std::numeric_limits<T>::max());
248 const T& init_value = std::numeric_limits<T>::max());
252 template <
class Expr,
class Sfinae =
253 typename std::enable_if<
274 const std::string&
valued()
const {
return _V.valued(); }
276 std::string name()
const {
return _V.name(); }
333 template <
class SetOp = details::
generic_set_op>
337 template <
class Value>
338 typename std::enable_if<
351 template <
class Expr>
352 typename std::enable_if<
354 && ! details::has_field_rdof_interface <Expr>::value
355 && ! details::is_field_expr_v2_constant <Expr>::value
356 && ! details::is_field <Expr>::value
364 "field = expr; expr should have homogeneous space. HINT: use field = interpolate(Xh, expr)");
371 template<
class FieldRdof>
372 typename std::enable_if<
374 && ! details::is_field <FieldRdof>::value
387 template<
class FieldLazy>
388 typename std::enable_if<
406 typename std::enable_if<
414 typename std::enable_if<
420 template<
class FieldLazy,
class SetPlusOp>
421 typename std::enable_if<
425 convert_from_field_lazy (
const FieldLazy& expr,
const SetPlusOp& set_plus_op);
452 template <
class Expr>
456 const band_basic<T,M>&
gh,
460 template <
class Expr>
465 template <
class Expr>
467 const band_basic<T,M>&
gh,
487template<
class T,
class M>
493template<
class T,
class M>
503template <
class T,
class M>
506template <
class T,
class M>
520template <
class T,
class M>
539 : _blk_dis_iub_iter(),
540 _blk_dis_iub_incr(1),
547 : _blk_dis_iub_iter(blk_dis_iub_iter),
548 _blk_dis_iub_incr(1),
555 : _blk_dis_iub_iter(blk_dis_iub_iter),
556 _blk_dis_iub_incr(blk_dis_iub_incr),
568 bool blk = (*_blk_dis_iub_iter).is_blocked();
569 size_type dis_iub = (*_blk_dis_iub_iter).dis_iub();
570 size_type iub = (!blk) ? dis_iub - _first_iu : dis_iub - _first_ib;
571 return (!blk) ?
_u[iub] :
_b[iub];
573 iterator& operator++ () { _blk_dis_iub_iter += _blk_dis_iub_incr;
return *
this; }
592template <
class T,
class M>
597 dis_dof_indexes_requires_update();
598 return iterator (_V.data()._idof2blk_dis_iub.begin(), _u.begin(), _b.begin(), _u.ownership().first_index(), _b.ownership().first_index());
600template <
class T,
class M>
605 dis_dof_indexes_requires_update();
606 return iterator (_V.data()._idof2blk_dis_iub.end(), _u.begin(), _b.begin(), _u.ownership().first_index(), _b.ownership().first_index());
611template <
class T,
class M>
630 : _blk_dis_iub_iter(),
631 _blk_dis_iub_incr(1),
638 : _blk_dis_iub_iter(blk_dis_iub_iter),
639 _blk_dis_iub_incr(1),
645 : _blk_dis_iub_iter(i._blk_dis_iub_iter),
646 _blk_dis_iub_incr(i._blk_dis_iub_incr),
649 _first_iu(i._first_iu),
650 _first_ib(i._first_ib)
658 bool blk = (*_blk_dis_iub_iter).is_blocked();
659 size_type dis_iub = (*_blk_dis_iub_iter).dis_iub();
660 size_type iub = (!blk) ? dis_iub - _first_iu : dis_iub - _first_ib;
661 return (!blk) ?
_u[iub] :
_b[iub];
663 const_iterator& operator++ () { _blk_dis_iub_iter += _blk_dis_iub_incr;
return *
this; }
681template <
class T,
class M>
686 dis_dof_indexes_requires_update();
687 return const_iterator (_V.data()._idof2blk_dis_iub.begin(), _u.begin(), _b.begin(), _u.ownership().first_index(), _b.ownership().first_index());
689template <
class T,
class M>
694 dis_dof_indexes_requires_update();
695 return const_iterator (_V.data()._idof2blk_dis_iub.end(), _u.begin(), _b.begin(), _u.ownership().first_index(), _b.ownership().first_index());
700template <
class T,
class M>
706 _dis_dof_indexes_requires_update(true),
707 _dis_dof_assembly_requires_update(false)
711template<
class T,
class M>
712template<
class Expr,
class Sfinae>
718 _dis_dof_indexes_requires_update(true),
719 _dis_dof_assembly_requires_update(false)
723template <
class T,
class M>
727 _dis_dof_indexes_requires_update =
true;
729template <
class T,
class M>
733 _dis_dof_assembly_requires_update =
true;
735template <
class T,
class M>
740 dis_dof_indexes_requires_update();
741 bool blk = _V.is_blocked (idof);
744 size_type iub = dis_iub - _u.ownership().first_index();
747 size_type iub = dis_iub - _b.ownership().first_index();
751template <
class T,
class M>
756 bool blk = _V.is_blocked (idof);
758 return (!blk) ? _u.dis_at(dis_iub) : _b.dis_at(dis_iub);
760template <
class T,
class M>
761template <
class SetOp>
765#ifdef _RHEOLEF_HAVE_MPI
766 std::size_t nproc = ownership().comm().size();
768 std::size_t do_assembly = mpi::all_reduce (ownership().comm(),
size_t(_dis_dof_assembly_requires_update), std::plus<std::size_t>());
769 std::size_t do_indexes = mpi::all_reduce (ownership().comm(),
size_t(_dis_dof_indexes_requires_update), std::plus<std::size_t>());
771 _u.dis_entry_assembly (set_op);
772 _b.dis_entry_assembly (set_op);
775 _u.set_dis_indexes (_V.ext_iu_set());
776 _b.set_dis_indexes (_V.ext_ib_set());
780 _dis_dof_indexes_requires_update =
false;
781 _dis_dof_assembly_requires_update =
false;
783template <
class T,
class M>
788 T val = std::numeric_limits<T>::max();
790 val = std::min(val, *iter);
792#ifdef _RHEOLEF_HAVE_MPI
794 val = mpi::all_reduce (comm(), val, mpi::minimum<T>());
799template <
class T,
class M>
804 T val = std::numeric_limits<T>::min();
806 val = std::max(val, *iter);
808#ifdef _RHEOLEF_HAVE_MPI
810 val = mpi::all_reduce (comm(), val, mpi::maximum<T>());
815template <
class T,
class M>
820 T val = std::numeric_limits<T>::max();
822 val = std::min(val, abs(*iter));
824#ifdef _RHEOLEF_HAVE_MPI
826 val = mpi::all_reduce (comm(), val, mpi::minimum<T>());
831template <
class T,
class M>
838 val = std::max(val, abs(*iter));
840#ifdef _RHEOLEF_HAVE_MPI
842 val = mpi::all_reduce (comm(), val, mpi::maximum<T>());
847template <
class T,
class M>
854template <
class T,
class M>
868template<
class T,
class M>
877template <
class T,
class M,
class FieldRdof>
879typename std::enable_if<
880 details::has_field_rdof_interface<FieldRdof>::value
881 && ! details::is_field<FieldRdof>::value
891template <
class T,
class M>
904template<
class T,
class M>
905template <
class Value>
907typename std::enable_if<
908 details::is_rheolef_arithmetic<Value>::value
913 check_macro (name() !=
"",
"field=constant : uninitialized field in affectation");
914 std::fill (
begin_dof(), end_dof(), value);
917template<
class T,
class M>
918template<
class FieldLazy>
919typename std::enable_if<
920 details::is_field_lazy<FieldLazy>::value
923field_basic<T,M>::operator+= (
const FieldLazy& expr)
925 const space_basic<T,M>& Xh = expr.get_space();
926 convert_from_field_lazy (expr, details::generic_set_plus_op());
929template<
class T,
class M>
930template<
class FieldLazy>
931typename std::enable_if<
932 details::is_field_lazy<FieldLazy>::value
935field_basic<T,M>::operator-= (
const FieldLazy& expr)
937 const space_basic<T,M>& Xh =
expr.get_space();
938 convert_from_field_lazy (expr, details::generic_set_minus_op());
946template<
class FieldLazy>
947typename std::enable_if<
948 details::has_field_lazy_interface<FieldLazy>::value
949 && ! details::is_field<FieldLazy>::value
955 using T =
typename FieldLazy::scalar_type;
956 using M =
typename FieldLazy::memory_type;
962template<
class FieldWdof>
965operator>> (odiststream& ids, details::field_wdof_sliced<FieldWdof>&
u);
973template<
class T,
class M>
975details::field_wdof_indirect<field_basic<T,M>>
978 dis_dof_indexes_requires_update();
979 return details::field_wdof_indirect<field_basic<T,M>> (*
this, dom);
981template<
class T,
class M>
983details::field_wdof_indirect<field_basic<T,M>>
986 dis_dof_indexes_requires_update();
987 return operator[] (get_space().
get_geo().
operator[] (dom_name));
989template<
class T,
class M>
991details::field_rdof_indirect_const<field_basic<T,M>>
994 return details::field_rdof_indirect_const<field_basic<T,M>> (*
this, dom);
996template<
class T,
class M>
998details::field_rdof_indirect_const<field_basic<T,M>>
1001 return operator[] (get_space().
get_geo().
operator[] (dom_name));
1008template<
class T,
class M>
1010details::field_rdof_sliced_const<field_basic<T,M>>
1013 return details::field_rdof_sliced_const<field_basic<T,M>> (*
this, i_comp);
1015template<
class T,
class M>
1017details::field_wdof_sliced<field_basic<T,M>>
1020 dis_dof_indexes_requires_update();
1021 return details::field_wdof_sliced<field_basic<T,M>> (*
this, i_comp);
1026template<
class T,
class M>
1027template<
class FieldLazy,
class SetPlusOp>
1029typename std::enable_if<
1030 details::is_field_lazy<FieldLazy>::value
1033field_basic<T,M>::convert_from_field_lazy (
const FieldLazy& expr,
const SetPlusOp& set_plus_op)
field::size_type size_type
field gh(Float epsilon, Float t, const field &uh, const test &v)
see the band page for the full documentation
field_rdof_sliced_const< field_basic< T, M > > operator()(size_type i_comp, size_type j_comp) const
field_rdof_indirect_const< field_basic< T, M > > operator[](const std::string &dom_name) const
std::enable_if< details::is_rheolef_arithmetic< Value >::value, field_wdof_base< field_basic< T, M > > & >::type operator=(const Value &)
field_wdof_sliced< field_basic< T, M > > operator()(size_type i_comp, size_type j_comp)
field_wdof_indirect< field_basic< T, M > > operator[](const std::string &dom_name)
rep::base::const_iterator const_iterator
see the distributor page for the full documentation
size_type dis_size() const
global and local sizes
size_type size(size_type iproc) const
const communicator_type & comm() const
size_type _blk_dis_iub_incr
std::forward_iterator_tag iterator_category
const_iterator(iter_t blk_dis_iub_iter, data_t u, data_t b, size_type first_iu, size_type first_ib)
vec< T, M >::size_type size_type
const_iterator operator++(int)
disarray< space_pair_type, M >::const_iterator iter_t
void set_increment(size_type incr)
std::ptrdiff_t difference_type
const_iterator(iterator i)
vec< T, M >::const_iterator data_t
size_type _blk_dis_iub_incr
std::forward_iterator_tag iterator_category
vec< T, M >::size_type size_type
iterator(iter_t blk_dis_iub_iter, data_t u, data_t b, size_type first_iu, size_type first_ib)
disarray< space_pair_type, M >::const_iterator iter_t
void set_increment(size_type incr)
std::ptrdiff_t difference_type
vec< T, M >::iterator data_t
iterator(iter_t blk_dis_iub_iter, size_type blk_dis_iub_incr, data_t u, data_t b, size_type first_iu, size_type first_ib)
void dis_dof_indexes_requires_update() const
const T & dis_dof(size_type dis_idof) const
const_iterator begin_dof() const
size_type dis_ndof() const
details::field_wdof_indirect< field_basic< T, M > > operator[](const geo_type &dom)
valued_type valued_tag() const
std::string get_approx() const
bool _dis_dof_indexes_requires_update
idiststream & get(idiststream &ips)
point_basic< T > dis_vector_evaluate(const point_basic< T > &x) const
odiststream & put(odiststream &ops) const
void dis_dof_assembly_requires_update() const
void dis_dof_update(const SetOp &=SetOp()) const
void do_integrate_internal(const geo_basic< T, M > &dom, const geo_basic< T, M > &band, const band_basic< T, M > &gh, const Expr &expr, const integrate_option &qopt, bool is_on_band)
const vec< T, M > & b() const
field_basic< T, M > & operator=(const field_basic< T, M > &)
dis_reference dis_dof_entry(size_type dis_idof)
bool _dis_dof_assembly_requires_update
odiststream & put_field(odiststream &ops) const
typename vec< scalar_type, memory_type >::dis_reference dis_reference
T operator()(const point_basic< T > &x) const
const T & dof(size_type idof) const
const geo_type & get_geo() const
int constraint_process_rank() const
const_iterator end_dof() const
const space_type & get_space() const
const vec< T, M > & u() const
const std::string & valued() const
void do_integrate(const geo_basic< T, M > &dom, const Expr &expr, const integrate_option &iopt)
T evaluate(const geo_element &K, const point_basic< T > &hat_xq, size_type i_comp=0) const
typename float_traits< T >::type float_type
void resize(const space_type &V, const T &init_value=std::numeric_limits< T >::max())
const distributor & ownership() const
const communicator & comm() const
T dis_evaluate(const point_basic< T > &x, size_type i_comp=0) const
see the geo_element page for the full documentation
idiststream: see the diststream page for the full documentation
see the integrate_option page for the full documentation
odiststream: see the diststream page for the full documentation
see the vec page for the full documentation
base::size_type size_type
base::const_iterator const_iterator
int constraint_process_rank() const
field_basic< Float, sequential > field_sequential
field_basic< Float > field
see the field page for the full documentation
#define trace_macro(message)
void get_geo(istream &in, my_geo &omega)
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
void assign_with_operator(ForwardIterator first, ForwardIterator last, InputIterator iter_rhs, OpAssign op_assign)
std::enable_if< has_field_lazy_interface< FieldLazy >::value &&has_field_wdof_interface< FieldWdof >::value, FieldWdof & >::type convert_lazy2wdof(const FieldLazy &expr0, const SetPlusOp &my_set_plus_op, FieldWdof &uh)
This file is part of Rheolef.
bool operator!=(const heap_allocator< T1 > &lhs, const heap_allocator< T1 > &rhs)
bool operator==(const heap_allocator< T1 > &lhs, const heap_allocator< T1 > &rhs)
std::ostream & operator<<(std::ostream &os, const catchmark &m)
field_basic< T, M > lazy_interpolate(const space_basic< T, M > &X2h, const field_basic< T, M > &u1h)
see the interpolate page for the full documentation
const_iterator begin_dof() const
std::enable_if< details::is_rheolef_arithmetic< U >::value, ad3_basic< T > & >::type operator-=(ad3_basic< T > &a, const U &b)
std::enable_if< details::is_rheolef_arithmetic< U >::value, ad3_basic< T > & >::type operator+=(ad3_basic< T > &a, const U &b)
bool have_homogeneous_space(space_basic< scalar_type, memory_type > &Vh) const
std::enable_if< details::is_rheolef_arithmetic< U >::value, ad3_basic< T > >::type operator+(const U &a, const ad3_basic< T > &b)
std::istream & operator>>(std::istream &is, const catchmark &m)
field_basic< T, M > interpolate(const space_basic< T, M > &V2h, const field_basic< T, M > &u1h)
see the interpolate page for the full documentation
csr< T, sequential > operator*(const T &lambda, const csr< T, sequential > &a)