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"
208 template <
class T,
class M>
class field_concat_value;
209 template <
class FieldWdof>
class field_wdof_sliced;
210 template <
class FieldRdof>
class field_rdof_sliced_const;
218 template <
class T,
class M = rheo_default_memory_model>
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<
364 "field = expr; expr should have homogeneous space. HINT: use field = interpolate(Xh, expr)");
371 template<
class FieldRdof>
372 typename std::enable_if<
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,
458 const integrate_option& qopt,
460 template <
class Expr>
464 const integrate_option& iopt);
465 template <
class Expr>
467 const band_basic<T,M>&
gh,
469 const integrate_option& iopt);
487 template<
class T,
class M>
493 template<
class T,
class M>
503 template <
class T,
class M>
506 template <
class T,
class M>
520 template <
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; }
592 template <
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());
600 template <
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());
611 template <
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; }
681 template <
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());
689 template <
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());
700 template <
class T,
class M>
706 _dis_dof_indexes_requires_update(true),
707 _dis_dof_assembly_requires_update(false)
711 template<
class T,
class M>
712 template<
class Expr,
class Sfinae>
718 _dis_dof_indexes_requires_update(true),
719 _dis_dof_assembly_requires_update(false)
723 template <
class T,
class M>
727 _dis_dof_indexes_requires_update =
true;
729 template <
class T,
class M>
733 _dis_dof_assembly_requires_update =
true;
735 template <
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();
751 template <
class T,
class M>
756 bool blk = _V.is_blocked (idof);
758 return (!blk) ? _u.dis_at(dis_iub) : _b.dis_at(dis_iub);
760 template <
class T,
class M>
761 template <
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;
783 template <
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>());
799 template <
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>());
815 template <
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>());
831 template <
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>());
847 template <
class T,
class M>
854 template <
class T,
class M>
868 template<
class T,
class M>
877 template <
class T,
class M,
class FieldRdof>
879 typename std::enable_if<
880 details::has_field_rdof_interface<FieldRdof>::value
881 && ! details::is_field<FieldRdof>::value
891 template <
class T,
class M>
904 template<
class T,
class M>
905 template <
class Value>
907 typename 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);
917 template<
class T,
class M>
918 template<
class FieldLazy>
919 typename std::enable_if<
920 details::is_field_lazy<FieldLazy>::value
925 const space_basic<T,M>& Xh =
expr.get_space();
926 convert_from_field_lazy (
expr, details::generic_set_plus_op());
929 template<
class T,
class M>
930 template<
class FieldLazy>
931 typename std::enable_if<
932 details::is_field_lazy<FieldLazy>::value
937 const space_basic<T,M>& Xh =
expr.get_space();
938 convert_from_field_lazy (
expr, details::generic_set_minus_op());
946 template<
class FieldLazy>
947 typename 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;
962 template<
class FieldWdof>
965 operator>> (odiststream& ids, details::field_wdof_sliced<FieldWdof>&
u);
973 template<
class T,
class M>
975 details::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);
981 template<
class T,
class M>
983 details::field_wdof_indirect<field_basic<T,M>>
986 dis_dof_indexes_requires_update();
987 return operator[] (get_space().
get_geo().
operator[] (dom_name));
989 template<
class T,
class M>
991 details::field_rdof_indirect_const<field_basic<T,M>>
994 return details::field_rdof_indirect_const<field_basic<T,M>> (*
this, dom);
996 template<
class T,
class M>
998 details::field_rdof_indirect_const<field_basic<T,M>>
1001 return operator[] (get_space().
get_geo().
operator[] (dom_name));
1008 template<
class T,
class M>
1010 details::field_rdof_sliced_const<field_basic<T,M>>
1013 return details::field_rdof_sliced_const<field_basic<T,M>> (*
this, i_comp);
1015 template<
class T,
class M>
1017 details::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);
1026 template<
class T,
class M>
1027 template<
class FieldLazy,
class SetPlusOp>
1029 typename std::enable_if<
1030 details::is_field_lazy<FieldLazy>::value
1033 field_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< Derived > operator()(size_type i_comp, size_type j_comp) const
bool have_homogeneous_space(space_type &Xh) const
field_rdof_indirect_const< Derived > operator[](const std::string &dom_name) const
typename field_traits< Derived >::size_type size_type
field_wdof_sliced< field_basic< T, M > > operator()(size_type i_comp, size_type j_comp)
std::enable_if< details::is_rheolef_arithmetic< Value >::value, field_wdof_base< field_basic< T, M > > & >::type operator=(const Value &)
field_wdof_indirect< field_basic< T, M > > operator[](const std::string &dom_name)
see the disarray page for the full documentation
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 space_type & get_space() const
const T & dis_dof(size_type dis_idof) const
const_iterator begin_dof() const
size_type dis_ndof() const
valued_type valued_tag() const
std::string get_approx() const
const geo_type & get_geo() const
bool _dis_dof_indexes_requires_update
idiststream & get(idiststream &ips)
point_basic< T > dis_vector_evaluate(const point_basic< T > &x) const
details::field_wdof_indirect< field_basic< T, M > > operator[](const geo_type &dom)
odiststream & put(odiststream &ops) const
void dis_dof_assembly_requires_update() const
const std::string & valued() 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)
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
const distributor & ownership() 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 vec< T, M > & u() const
int constraint_process_rank() const
const_iterator end_dof() const
const vec< T, M > & b() const
const communicator & comm() 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())
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
odiststream: see the diststream page for the full documentation
see the vec page for the full documentation
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)
void dis_idof(const basis_basic< T > &b, const geo_size &gs, const geo_element &K, typename std::vector< size_type >::iterator dis_idof_tab)
This file is part of Rheolef.
bool operator==(const heap_allocator< T1 > &lhs, const heap_allocator< T1 > &rhs)
std::istream & operator>>(std::istream &is, const catchmark &m)
idiststream & operator>>(idiststream &ips, field_basic< T, M > &uh)
std::enable_if< details::is_rheolef_arithmetic< U >::value,ad3_basic< T > & >::type operator-=(ad3_basic< T > &a, const U &b)
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
std::enable_if< details::is_rheolef_arithmetic< U >::value,ad3_basic< T >>::type operator+(const U &a, const ad3_basic< T > &b)
csr< T, sequential > operator*(const T &lambda, const csr< T, sequential > &a)
std::enable_if< details::has_field_rdof_interface< FieldRdof >::value &&! details::is_field< FieldRdof >::value,field_basic< T, M >>::type lazy_interpolate(const space_basic< T, M > &Xh, const FieldRdof &uh)
see the interpolate page for the full documentation
std::ostream & operator<<(std::ostream &os, const catchmark &m)
bool operator!=(const heap_allocator< T1 > &lhs, const heap_allocator< T1 > &rhs)
std::enable_if< details::is_rheolef_arithmetic< U >::value,ad3_basic< T > & >::type operator+=(ad3_basic< T > &a, const U &b)
const_iterator begin_dof() const
ostream & operator<<(ostream &os, const tiny_element &K)