Loading...
Searching...
No Matches
field.h
Go to the documentation of this file.
# ifndef _RHEOLEF_FIELD_H
# define _RHEOLEF_FIELD_H
//
// This file is part of Rheolef.
//
// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
//
// Rheolef is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Rheolef is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Rheolef; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// =========================================================================
// AUTHOR: Pierre.Saramito@imag.fr
// DATE: 23 february 2011
namespace rheolef {
} // namespace rheolef
#include "rheolef/field_rdof.icc"
#include "rheolef/field_wdof.icc"
#include "rheolef/integrate_option.h" // TO_CLEAN with old interface
namespace rheolef {
namespace details {
// forward declarations:
template <class T, class M> class field_concat_value;
template <class FieldWdof> class field_wdof_sliced;
template <class FieldRdof> class field_rdof_sliced_const;
} // namespace details
// ----------------------------------------------------------------------------
// main class
// ----------------------------------------------------------------------------
// [verbatim_field_basic]
template <class T, class M = rheo_default_memory_model>
class field_basic: public details::field_wdof_base<field_basic<T,M>> {
public :
// typedefs:
using wdof_base = details::field_wdof_base<field_basic<T,M>>;
using rdof_base = details::field_rdof_base<field_basic<T,M>>;
using size_type = std::size_t;
using scalar_type = T;
using memory_type = M;
using float_type = typename float_traits<T>::type;
using geo_type = geo_basic <float_type,memory_type>;
using space_type = space_basic<float_type,memory_type>;
using dis_reference = typename vec<scalar_type,memory_type>::dis_reference;
using valued_type = space_constant::valued_type;
using value_type = T; // TODO: run-time dependent, set it to undeterminated<T>
using result_type = T; // TODO: run-time dependent, set it to undeterminated<T>
class iterator;
class const_iterator;
// allocator/deallocator:
field_basic();
explicit field_basic (
const space_type& V,
const T& init_value = std::numeric_limits<T>::max());
void resize (
const space_type& V,
const T& init_value = std::numeric_limits<T>::max());
// expressions: field_expr or field_lazy are accepted here
// TODO: merge with FieldLazy piecewise_poly
template <class Expr, class Sfinae =
typename std::enable_if<
( details::is_field_expr_affine_homogeneous<Expr>::value
&& ! details::is_field<Expr>::value
)
|| details::is_field_lazy<Expr>::value
>::type>
field_basic (const Expr& expr);
field_basic (const std::initializer_list<details::field_concat_value<T,M> >& init_list);
// assignments:
field_basic<T,M>& operator= (const field_basic<T,M>&);
field_basic<T,M>& operator= (const std::initializer_list<details::field_concat_value<T,M> >& init_list);
// accessors:
const space_type& get_space() const { return _V; }
const geo_type& get_geo() const { return _V.get_geo(); }
std::string get_approx() const { return _V.get_approx(); }
valued_type valued_tag() const { return _V.valued_tag(); }
const std::string& valued() const { return _V.valued(); }
#ifdef TO_CLEAN
std::string name() const { return _V.name(); }
bool have_homogeneous_space (space_basic<T,M>& Xh) const { Xh = get_space(); return true; }
#endif // TO_CLEAN
// accessors & modifiers to unknown & blocked parts:
const vec<T,M>& u() const { return _u; }
const vec<T,M>& b() const { return _b; }
vec<T,M>& set_u() { dis_dof_indexes_requires_update(); return _u; }
vec<T,M>& set_b() { dis_dof_indexes_requires_update(); return _b; }
// accessors to extremas:
T min() const;
T max() const;
T max_abs() const;
T min_abs() const;
// accessors by degrees-of-freedom (dof):
const distributor& ownership() const { return get_space().ownership(); }
const communicator& comm() const { return ownership().comm(); }
size_type ndof() const { return ownership().size(); }
size_type dis_ndof() const { return ownership().dis_size(); }
T& dof (size_type idof);
const T& dof (size_type idof) const;
const T& dis_dof (size_type dis_idof) const;
// write access to non-local dis_idof changes to others procs
dis_reference dis_dof_entry (size_type dis_idof);
iterator begin_dof();
iterator end_dof();
const_iterator begin_dof() const;
const_iterator end_dof() const;
// input/output:
idiststream& get (idiststream& ips);
odiststream& put (odiststream& ops) const;
odiststream& put_field (odiststream& ops) const;
// evaluate uh(x) where x is given locally as hat_x in K:
T dis_evaluate (const point_basic<T>& x, size_type i_comp = 0) const;
T operator() (const point_basic<T>& x) const { return dis_evaluate (x,0); }
point_basic<T> dis_vector_evaluate (const point_basic<T>& x) const;
// [verbatim_field_basic]
// internals:
int constraint_process_rank() const { return u().constraint_process_rank(); }
public:
// evaluate uh(x) where x is given locally as hat_x in K:
// requiers to call field::dis_dof_upgrade() before.
T evaluate (const geo_element& K, const point_basic<T>& hat_xq, size_type i_comp = 0) const;
// propagate changed values shared at partition boundaries to others procs
template <class SetOp = details::generic_set_op>
void dis_dof_update (const SetOp& = SetOp()) const;
// assignments from expressions
template <class Value>
typename std::enable_if<
details::is_rheolef_arithmetic<Value>::value
,field_basic<T,M>&
>::type
operator= (const Value& value)
{
trace_macro("op=(value)...");
check_macro (get_space().name() != "", "field=constant : uninitialized field in affectation");
wdof_base::operator= (value);
trace_macro("op=(value) done");
return *this;
}
// TODO: merge with FieldRdof/Lazy && piecewise_polynomial
template <class Expr>
typename std::enable_if<
details::is_field_expr_affine_homogeneous<Expr>::value
&& ! details::has_field_rdof_interface <Expr>::value
&& ! details::is_field_expr_v2_constant <Expr>::value
&& ! details::is_field <Expr>::value
,field_basic<T, M>&
>::type
operator= (const Expr& expr)
{
trace_macro("op=(expr)...");
space_type Xh;
check_macro (expr.have_homogeneous_space (Xh),
"field = expr; expr should have homogeneous space. HINT: use field = interpolate(Xh, expr)");
if (get_space().name() != Xh.name()) resize (Xh, 0);
details::assign_with_operator (begin_dof(), end_dof(), expr.begin_dof(), details::assign_op());
trace_macro("op=(expr) done");
return *this;
}
// TODO: FieldRdof && piecewise_polynomial only: filter
template<class FieldRdof>
typename std::enable_if<
details::has_field_rdof_interface<FieldRdof>::value
&& ! details::is_field <FieldRdof>::value
,field_basic<T, M>&
>::type
operator= (const FieldRdof& rdof)
{
trace_macro("op=(rdof)...");
const space_type& Xh = rdof.get_space();
if (get_space().name() != Xh.name()) resize (Xh, 0);
wdof_base::operator= (rdof);
trace_macro("op=(rdof) done");
return *this;
}
// TODO: FieldLazy && piecewise_polynomial only: filter
template<class FieldLazy>
typename std::enable_if<
details::has_field_lazy_interface<FieldLazy>::value
&& ! details::has_field_rdof_interface<FieldLazy>::value
,field_basic<T, M>&
>::type
operator= (const FieldLazy& lazy)
{
trace_macro("op=(lazy)...");
const space_type& Xh = lazy.get_space();
if (get_space().name() != Xh.name()) resize (Xh, 0);
wdof_base::operator= (lazy);
trace_macro("op=(lazy) done");
return *this;
}
#ifdef TO_CLEAN
// TODO: move in field_wdof
template<class Expr>
typename std::enable_if<
details::is_field_lazy<Expr>::value
,field_basic<T, M>&
>::type
operator+= (const Expr&);
// TODO: move in field_wdof
template<class Expr>
typename std::enable_if<
details::is_field_lazy<Expr>::value
,field_basic<T, M>&
>::type
operator-= (const Expr&);
template<class FieldLazy, class SetPlusOp>
typename std::enable_if<
details::is_field_lazy<FieldLazy>::value
,void
>::type
convert_from_field_lazy (const FieldLazy& expr, const SetPlusOp& set_plus_op);
#endif // TO_CLEAN
// accessors by domains and indexes:
// TODO: why is it necessary to explicit them while its done implicitely in field_wdof_indirect ?
details::field_wdof_indirect<field_basic<T,M>> operator[] (const geo_type& dom)
{ return wdof_base::operator[] (dom); }
details::field_wdof_indirect<field_basic<T,M>> operator[] (std::string dom_name)
{ return wdof_base::operator[] (dom_name); }
details::field_rdof_indirect_const<field_basic<T,M>> operator[] (const geo_type& dom) const
{ return rdof_base::operator[] (dom); }
details::field_rdof_indirect_const<field_basic<T,M>> operator[] (std::string dom_name) const
{ return rdof_base::operator[] (dom_name); }
size_type size() const { return _V.size(); }
details::field_wdof_sliced<field_basic<T,M>> operator[] (size_type i_comp)
{ return wdof_base::operator[] (i_comp); }
details::field_wdof_sliced<field_basic<T,M>> operator() (size_type i_comp, size_type j_comp)
{ return wdof_base::operator() (i_comp, j_comp); }
details::field_rdof_sliced_const<field_basic<T,M>> operator[] (size_type i_comp) const
{ return rdof_base::operator[] (i_comp); }
details::field_rdof_sliced_const<field_basic<T,M>> operator() (size_type i_comp, size_type j_comp) const
{ return rdof_base::operator() (i_comp, j_comp); }
// old interface
template <class Expr>
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);
template <class Expr>
void do_integrate (
const geo_basic<T,M>& dom,
const Expr& expr,
const integrate_option& iopt);
template <class Expr>
void do_integrate (
const band_basic<T,M>& gh,
const Expr& expr,
const integrate_option& iopt);
protected:
void dis_dof_indexes_requires_update() const;
void dis_dof_assembly_requires_update() const;
// data:
space_type _V;
mutable vec<T,M> _u;
mutable vec<T,M> _b;
mutable bool _dis_dof_indexes_requires_update;
mutable bool _dis_dof_assembly_requires_update;
// [verbatim_field_basic_cont]
};
namespace details {
// concepts:
template<class T, class M>
struct is_field<field_basic<T,M>> : std::true_type {};
// field class is not an ordinary function/functor : for compose(field,args...) filtering
template <typename T, typename M> struct function_traits <field_basic<T,M> > {};
template<class T, class M>
struct field_traits<field_basic<T,M>> {
using size_type = std::size_t;
using scalar_type = T;
using memory_type = M;
};
} // namespace details
// [verbatim_field_basic_cont]
template <class T, class M>
idiststream& operator >> (odiststream& ips, field_basic<T,M>& u);
template <class T, class M>
odiststream& operator << (odiststream& ops, const field_basic<T,M>& uh);
// [verbatim_field]
typedef field_basic<Float> field;
// [verbatim_field]
typedef field_basic<Float,sequential> field_sequential;
// =================================================================================
// field::iterator
// =================================================================================
// TODO: use field_wdof_sliced iterators
template <class T, class M>
class field_basic<T,M>::iterator {
protected:
typedef typename vec<T,M>::iterator data_t; // random acess
typedef typename disarray<space_pair_type,M>::const_iterator iter_t; // forward access
public:
// typedefs:
typedef std::forward_iterator_tag iterator_category; // TODO: not fully random yet
typedef typename vec<T,M>::size_type size_type;
typedef T value_type;
typedef T& reference;
typedef T* pointer;
typedef std::ptrdiff_t difference_type;
// allocators:
iterator ()
: _blk_dis_iub_iter(),
_blk_dis_iub_incr(1),
_u(),
_b(),
_first_iu(0),
_first_ib(0)
{}
iterator (iter_t blk_dis_iub_iter, data_t u, data_t b, size_type first_iu, size_type first_ib)
: _blk_dis_iub_iter(blk_dis_iub_iter),
_blk_dis_iub_incr(1),
_u(u),
_b(b),
_first_iu(first_iu),
_first_ib(first_ib)
{}
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)
: _blk_dis_iub_iter(blk_dis_iub_iter),
_blk_dis_iub_incr(blk_dis_iub_incr),
_u(u),
_b(b),
_first_iu(first_iu),
_first_ib(first_ib)
{}
void set_increment (size_type incr) { _blk_dis_iub_incr = incr; }
// accessors & modifiers:
reference operator* () const {
bool blk = (*_blk_dis_iub_iter).is_blocked();
size_type dis_iub = (*_blk_dis_iub_iter).dis_iub();
size_type iub = (!blk) ? dis_iub - _first_iu : dis_iub - _first_ib;
return (!blk) ? _u[iub] : _b[iub];
}
iterator& operator++ () { _blk_dis_iub_iter += _blk_dis_iub_incr; return *this; }
iterator operator++ (int) { iterator tmp = *this; operator++(); return tmp; }
iterator& operator+= (difference_type n) { _blk_dis_iub_iter += n*_blk_dis_iub_incr; return *this; }
iterator operator+ (difference_type n) const { iterator tmp = *this; return tmp += n; }
reference operator[] (size_type n) const { return *(*this + n); }
// comparators:
bool operator== (const iterator& j) const { return _blk_dis_iub_iter == j._blk_dis_iub_iter; }
bool operator!= (const iterator& j) const { return ! operator== (j); }
//protected:
friend class const_iterator;
// data:
iter_t _blk_dis_iub_iter;
size_type _blk_dis_iub_incr;
data_t _u;
data_t _b;
size_type _first_iu, _first_ib;
};
template <class T, class M>
inline
typename field_basic<T,M>::iterator
field_basic<T,M>::begin_dof ()
{
dis_dof_indexes_requires_update();
return iterator (_V.data()._idof2blk_dis_iub.begin(), _u.begin(), _b.begin(), _u.ownership().first_index(), _b.ownership().first_index());
}
template <class T, class M>
inline
typename field_basic<T,M>::iterator
field_basic<T,M>::end_dof ()
{
dis_dof_indexes_requires_update();
return iterator (_V.data()._idof2blk_dis_iub.end(), _u.begin(), _b.begin(), _u.ownership().first_index(), _b.ownership().first_index());
}
// =================================================================================
// field::const_iterator
// =================================================================================
template <class T, class M>
class field_basic<T,M>::const_iterator {
protected:
typedef typename vec<T,M>::const_iterator data_t;
typedef typename disarray<space_pair_type,M>::const_iterator iter_t;
public:
// typedefs:
typedef std::forward_iterator_tag iterator_category;
typedef typename vec<T,M>::size_type size_type;
typedef T value_type;
typedef const T& reference;
typedef const T* pointer;
typedef std::ptrdiff_t difference_type;
// allocators:
const_iterator ()
: _blk_dis_iub_iter(),
_blk_dis_iub_incr(1),
_u(),
_b(),
_first_iu(0),
_first_ib(0)
{}
const_iterator (iter_t blk_dis_iub_iter, data_t u, data_t b, size_type first_iu, size_type first_ib)
: _blk_dis_iub_iter(blk_dis_iub_iter),
_blk_dis_iub_incr(1),
_u(u), _b(b),
_first_iu(first_iu),
_first_ib(first_ib)
{}
const_iterator (iterator i)
: _blk_dis_iub_iter(i._blk_dis_iub_iter),
_blk_dis_iub_incr(i._blk_dis_iub_incr),
_u(i._u),
_b(i._b),
_first_iu(i._first_iu),
_first_ib(i._first_ib)
{}
void set_increment (size_type incr) { _blk_dis_iub_incr = incr; }
// accessors & modifiers:
reference operator* () const {
bool blk = (*_blk_dis_iub_iter).is_blocked();
size_type dis_iub = (*_blk_dis_iub_iter).dis_iub();
size_type iub = (!blk) ? dis_iub - _first_iu : dis_iub - _first_ib;
return (!blk) ? _u[iub] : _b[iub];
}
const_iterator& operator++ () { _blk_dis_iub_iter += _blk_dis_iub_incr; return *this; }
const_iterator operator++ (int) { const_iterator tmp = *this; operator++(); return tmp; }
const_iterator& operator+= (difference_type n) { _blk_dis_iub_iter += n*_blk_dis_iub_incr; return *this; }
const_iterator operator+ (difference_type n) const { const_iterator tmp = *this; return tmp += n; }
reference operator[] (size_type n) const { return *(*this + n); }
// comparators:
bool operator== (const const_iterator& j) const { return _blk_dis_iub_iter == j._blk_dis_iub_iter; }
bool operator!= (const const_iterator& j) const { return ! operator== (j); }
//protected:
// data:
iter_t _blk_dis_iub_iter;
size_type _blk_dis_iub_incr;
data_t _u;
data_t _b;
size_type _first_iu, _first_ib;
};
template <class T, class M>
inline
typename field_basic<T,M>::const_iterator
field_basic<T,M>::begin_dof () const
{
dis_dof_indexes_requires_update();
return const_iterator (_V.data()._idof2blk_dis_iub.begin(), _u.begin(), _b.begin(), _u.ownership().first_index(), _b.ownership().first_index());
}
template <class T, class M>
inline
typename field_basic<T,M>::const_iterator
field_basic<T,M>::end_dof () const
{
dis_dof_indexes_requires_update();
return const_iterator (_V.data()._idof2blk_dis_iub.end(), _u.begin(), _b.begin(), _u.ownership().first_index(), _b.ownership().first_index());
}
// =================================================================================
// field: inlined
// =================================================================================
template <class T, class M>
inline
field_basic<T,M>::field_basic ()
: _V(),
_u(),
_b(),
_dis_dof_indexes_requires_update(true),
_dis_dof_assembly_requires_update(false)
{
}
// TODO: merge Expr with Fieldlazy
template<class T, class M>
template<class Expr, class Sfinae>
inline
field_basic<T,M>::field_basic (const Expr& expr)
: _V (),
_u (),
_b (),
_dis_dof_indexes_requires_update(true),
_dis_dof_assembly_requires_update(false)
{
operator= (expr);
}
template <class T, class M>
void
field_basic<T,M>::dis_dof_indexes_requires_update() const
{
_dis_dof_indexes_requires_update = true;
}
template <class T, class M>
void
field_basic<T,M>::dis_dof_assembly_requires_update() const
{
_dis_dof_assembly_requires_update = true;
}
template <class T, class M>
inline
T&
field_basic<T,M>::dof (size_type idof)
{
dis_dof_indexes_requires_update();
bool blk = _V.is_blocked (idof);
size_type dis_iub = _V.dis_iub (idof);
if (!blk) {
size_type iub = dis_iub - _u.ownership().first_index();
return _u [iub];
} else {
size_type iub = dis_iub - _b.ownership().first_index();
return _b [iub];
}
}
template <class T, class M>
inline
const T&
field_basic<T,M>::dof (size_type idof) const
{
bool blk = _V.is_blocked (idof);
size_type dis_iub = _V.dis_iub (idof);
return (!blk) ? _u.dis_at(dis_iub) : _b.dis_at(dis_iub);
}
template <class T, class M>
template <class SetOp>
void
field_basic<T,M>::dis_dof_update (const SetOp& set_op) const
{
#ifdef _RHEOLEF_HAVE_MPI
std::size_t nproc = ownership().comm().size();
if (is_distributed<M>::value && nproc > 1) {
std::size_t do_assembly = mpi::all_reduce (ownership().comm(), size_t(_dis_dof_assembly_requires_update), std::plus<std::size_t>());
std::size_t do_indexes = mpi::all_reduce (ownership().comm(), size_t(_dis_dof_indexes_requires_update), std::plus<std::size_t>());
if (do_assembly) {
_u.dis_entry_assembly (set_op);
_b.dis_entry_assembly (set_op);
}
if (do_indexes) {
_u.set_dis_indexes (_V.ext_iu_set());
_b.set_dis_indexes (_V.ext_ib_set());
}
}
#endif // _RHEOLEF_HAVE_MPI
_dis_dof_indexes_requires_update = false;
_dis_dof_assembly_requires_update = false;
}
template <class T, class M>
inline
T
field_basic<T,M>::min () const
{
T val = std::numeric_limits<T>::max();
for (const_iterator iter = begin_dof(), last = end_dof(); iter != last; iter++) {
val = std::min(val, *iter);
}
#ifdef _RHEOLEF_HAVE_MPI
if (is_distributed<M>::value) {
val = mpi::all_reduce (comm(), val, mpi::minimum<T>());
}
#endif // _RHEOLEF_HAVE_MPI
return val;
}
template <class T, class M>
inline
T
field_basic<T,M>::max () const
{
T val = std::numeric_limits<T>::min();
for (const_iterator iter = begin_dof(), last = end_dof(); iter != last; iter++) {
val = std::max(val, *iter);
}
#ifdef _RHEOLEF_HAVE_MPI
if (is_distributed<M>::value) {
val = mpi::all_reduce (comm(), val, mpi::maximum<T>());
}
#endif // _RHEOLEF_HAVE_MPI
return val;
}
template <class T, class M>
inline
T
field_basic<T,M>::min_abs () const
{
T val = std::numeric_limits<T>::max();
for (const_iterator iter = begin_dof(), last = end_dof(); iter != last; iter++) {
val = std::min(val, abs(*iter));
}
#ifdef _RHEOLEF_HAVE_MPI
if (is_distributed<M>::value) {
val = mpi::all_reduce (comm(), val, mpi::minimum<T>());
}
#endif // _RHEOLEF_HAVE_MPI
return val;
}
template <class T, class M>
inline
T
field_basic<T,M>::max_abs () const
{
T val = 0;
for (const_iterator iter = begin_dof(), last = end_dof(); iter != last; iter++) {
val = std::max(val, abs(*iter));
}
#ifdef _RHEOLEF_HAVE_MPI
if (is_distributed<M>::value) {
val = mpi::all_reduce (comm(), val, mpi::maximum<T>());
}
#endif // _RHEOLEF_HAVE_MPI
return val;
}
template <class T, class M>
inline
idiststream&
operator >> (idiststream& ips, field_basic<T,M>& uh)
{
return uh.get (ips);
}
template <class T, class M>
inline
odiststream&
operator << (odiststream& ops, const field_basic<T,M>& uh)
{
return uh.put (ops);
}
// ----------------------------------
// special interpolate with field arg
// ----------------------------------
// re-interpolation of fields and linear field expressions
// for change of mesh, of approx, ect
// not truly lazy, but here for the completeness of the interpolate interface
template<class T, class M>
inline
field_basic<T,M>
lazy_interpolate (const space_basic<T,M>& X2h, const field_basic<T,M>& u1h)
{
return interpolate (X2h, u1h);
}
// interpolate e.g. uh[0] or uh["boundary"], i.e. a FieldRdof
template <class T, class M, class FieldRdof>
inline
typename 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)
{
return interpolate (Xh, field_basic<T,M>(uh));
}
// --------------------------
// operator=
// --------------------------
template <class T, class M>
inline
field_basic<T,M>&
field_basic<T,M>::operator= (const field_basic<T,M>& x)
{
_V.operator= (x._V);
_u.operator= (x._u);
_b.operator= (x._b);
_dis_dof_indexes_requires_update = x._dis_dof_indexes_requires_update;
_dis_dof_assembly_requires_update = x._dis_dof_assembly_requires_update;
return *this;
}
#ifdef TO_CLEAN
template<class T, class M>
template <class Value>
inline
typename std::enable_if<
details::is_rheolef_arithmetic<Value>::value
,field_basic<T,M>&
>::type
field_basic<T,M>::operator= (const Value& value)
{
check_macro (name() != "", "field=constant : uninitialized field in affectation");
std::fill (begin_dof(), end_dof(), value);
return *this;
}
template<class T, class M>
template<class FieldLazy>
typename std::enable_if<
details::is_field_lazy<FieldLazy>::value
,field_basic<T, M>&
>::type
field_basic<T,M>::operator+= (const FieldLazy& expr)
{
const space_basic<T,M>& Xh = expr.get_space();
convert_from_field_lazy (expr, details::generic_set_plus_op());
return *this;
}
template<class T, class M>
template<class FieldLazy>
typename std::enable_if<
details::is_field_lazy<FieldLazy>::value
,field_basic<T, M>&
>::type
field_basic<T,M>::operator-= (const FieldLazy& expr)
{
const space_basic<T,M>& Xh = expr.get_space();
convert_from_field_lazy (expr, details::generic_set_minus_op());
return *this;
}
#endif // TO_CLEAN
// --------------------------------------
// io
// --------------------------------------
// TODO: one output for all rdof or lazy & one input for all wdof
template<class FieldLazy>
typename std::enable_if<
details::has_field_lazy_interface<FieldLazy>::value
&& ! details::is_field<FieldLazy>::value
// details::is_field_lazy<FieldLazy>::value
,odiststream&
>::type
operator<< (odiststream& out, const FieldLazy& expr)
{
using T = typename FieldLazy::scalar_type;
using M = typename FieldLazy::memory_type;
field_basic<T,M> uh = expr;
return out << uh;
}
#ifdef TODO
// TODO: as: field vh; din >> vh ; uh[i_comp] = vh;
template<class FieldWdof>
inline
idiststream&
operator>> (odiststream& ids, details::field_wdof_sliced<FieldWdof>& u);
#endif // TODO
// --------------------------------------
// interaction with field_indirect
// --------------------------------------
// TODO: use a template FieldRdof and a dof-based convert function
// => interaction=convert from field_rdof
#ifdef TO_CLEAN
template<class T, class M>
inline
details::field_wdof_indirect<field_basic<T,M>>
field_basic<T,M>::operator[] (const geo_type& dom)
{
dis_dof_indexes_requires_update();
return details::field_wdof_indirect<field_basic<T,M>> (*this, dom);
}
template<class T, class M>
inline
details::field_wdof_indirect<field_basic<T,M>>
field_basic<T,M>::operator[] (std::string dom_name)
{
dis_dof_indexes_requires_update();
return operator[] (get_space().get_geo().operator[] (dom_name));
}
template<class T, class M>
inline
details::field_rdof_indirect_const<field_basic<T,M>>
field_basic<T,M>::operator[] (const geo_type& dom) const
{
return details::field_rdof_indirect_const<field_basic<T,M>> (*this, dom);
}
template<class T, class M>
inline
details::field_rdof_indirect_const<field_basic<T,M>>
field_basic<T,M>::operator[] (std::string dom_name) const
{
return operator[] (get_space().get_geo().operator[] (dom_name));
}
#endif // TO_CLEAN
// --------------------------------------
// interaction with field_wdof_sliced
// --------------------------------------
#ifdef TO_CLEAN
template<class T, class M>
inline
details::field_rdof_sliced_const<field_basic<T,M>>
field_basic<T,M>::operator[] (size_type i_comp) const
{
return details::field_rdof_sliced_const<field_basic<T,M>> (*this, i_comp);
}
template<class T, class M>
inline
details::field_wdof_sliced<field_basic<T,M>>
field_basic<T,M>::operator[] (size_type i_comp)
{
dis_dof_indexes_requires_update();
return details::field_wdof_sliced<field_basic<T,M>> (*this, i_comp);
}
// --------------------------------------
// convert from field_lazy
// --------------------------------------
template<class T, class M>
template<class FieldLazy, class SetPlusOp>
inline
typename std::enable_if<
details::is_field_lazy<FieldLazy>::value
,void
>::type
field_basic<T,M>::convert_from_field_lazy (const FieldLazy& expr, const SetPlusOp& set_plus_op)
{
details::convert_lazy2wdof (expr, set_plus_op, *this);
}
#endif // TO_CLEAN
}// namespace rheolef
# endif /* _RHEOLEF_FIELD_H */
size_type
field::size_type size_type
Definition branch.cc:430
gh
field gh(Float epsilon, Float t, const field &uh, const test &v)
Definition burgers_diffusion_operators.icc:37
band
see the band page for the full documentation
rheolef::details::field_concat_value
Definition field_concat.h:33
rheolef::details::field_rdof_base< field_basic< T, M > >
rheolef::details::field_rdof_base< field_basic< T, M > >::operator()
field_rdof_sliced_const< field_basic< T, M > > operator()(size_type i_comp, size_type j_comp) const
Definition field_rdof.icc:50
rheolef::details::field_rdof_base< field_basic< T, M > >::operator[]
field_rdof_indirect_const< field_basic< T, M > > operator[](const std::string &dom_name) const
Definition field_rdof.icc:32
rheolef::details::field_rdof_indirect_const
Definition field_wdof_indirect.h:212
rheolef::details::field_rdof_sliced_const
Definition field_wdof_sliced.h:204
rheolef::details::field_wdof_base
Definition field_wdof.h:36
rheolef::details::field_wdof_base< field_basic< T, M > >::operator=
std::enable_if< details::is_rheolef_arithmetic< Value >::value, field_wdof_base< field_basic< T, M > > & >::type operator=(const Value &)
Definition field_wdof.icc:45
rheolef::details::field_wdof_base< field_basic< T, M > >::operator()
field_wdof_sliced< field_basic< T, M > > operator()(size_type i_comp, size_type j_comp)
Definition field_wdof.icc:176
rheolef::details::field_wdof_base< field_basic< T, M > >::operator[]
field_wdof_indirect< field_basic< T, M > > operator[](const std::string &dom_name)
Definition field_wdof.icc:158
rheolef::details::field_wdof_indirect
Definition field_wdof_indirect.h:317
rheolef::details::field_wdof_sliced
Definition field_wdof_sliced.h:268
rheolef::disarray::const_iterator
rep::base::const_iterator const_iterator
Definition disarray.h:503
rheolef::distributor
see the distributor page for the full documentation
Definition distributor.h:69
rheolef::distributor::dis_size
size_type dis_size() const
global and local sizes
Definition distributor.h:214
rheolef::distributor::size
size_type size(size_type iproc) const
Definition distributor.h:170
rheolef::distributor::comm
const communicator_type & comm() const
Definition distributor.h:152
rheolef::field_basic::const_iterator
Definition field.h:612
rheolef::field_basic::const_iterator::_blk_dis_iub_incr
size_type _blk_dis_iub_incr
Definition field.h:676
rheolef::field_basic::const_iterator::_first_ib
size_type _first_ib
Definition field.h:679
rheolef::field_basic::const_iterator::value_type
T value_type
Definition field.h:622
rheolef::field_basic::const_iterator::pointer
const T * pointer
Definition field.h:624
rheolef::field_basic::const_iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition field.h:620
rheolef::field_basic::const_iterator::_b
data_t _b
Definition field.h:678
rheolef::field_basic::const_iterator::const_iterator
const_iterator(iter_t blk_dis_iub_iter, data_t u, data_t b, size_type first_iu, size_type first_ib)
Definition field.h:637
rheolef::field_basic::const_iterator::reference
const T & reference
Definition field.h:623
rheolef::field_basic::const_iterator::size_type
vec< T, M >::size_type size_type
Definition field.h:621
rheolef::field_basic::const_iterator::_blk_dis_iub_iter
iter_t _blk_dis_iub_iter
Definition field.h:675
rheolef::field_basic::const_iterator::operator++
const_iterator operator++(int)
Definition field.h:664
rheolef::field_basic::const_iterator::iter_t
disarray< space_pair_type, M >::const_iterator iter_t
Definition field.h:615
rheolef::field_basic::const_iterator::_u
data_t _u
Definition field.h:677
rheolef::field_basic::const_iterator::set_increment
void set_increment(size_type incr)
Definition field.h:653
rheolef::field_basic::const_iterator::const_iterator
const_iterator()
Definition field.h:629
rheolef::field_basic::const_iterator::difference_type
std::ptrdiff_t difference_type
Definition field.h:625
rheolef::field_basic::const_iterator::const_iterator
const_iterator(iterator i)
Definition field.h:644
rheolef::field_basic::const_iterator::data_t
vec< T, M >::const_iterator data_t
Definition field.h:614
rheolef::field_basic::iterator
Definition field.h:521
rheolef::field_basic::iterator::_blk_dis_iub_incr
size_type _blk_dis_iub_incr
Definition field.h:587
rheolef::field_basic::iterator::_first_ib
size_type _first_ib
Definition field.h:590
rheolef::field_basic::iterator::value_type
T value_type
Definition field.h:531
rheolef::field_basic::iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition field.h:529
rheolef::field_basic::iterator::_b
data_t _b
Definition field.h:589
rheolef::field_basic::iterator::size_type
vec< T, M >::size_type size_type
Definition field.h:530
rheolef::field_basic::iterator::operator++
iterator operator++(int)
Definition field.h:574
rheolef::field_basic::iterator::_blk_dis_iub_iter
iter_t _blk_dis_iub_iter
Definition field.h:586
rheolef::field_basic::iterator::iterator
iterator()
Definition field.h:538
rheolef::field_basic::iterator::pointer
T * pointer
Definition field.h:533
rheolef::field_basic::iterator::iterator
iterator(iter_t blk_dis_iub_iter, data_t u, data_t b, size_type first_iu, size_type first_ib)
Definition field.h:546
rheolef::field_basic::iterator::iter_t
disarray< space_pair_type, M >::const_iterator iter_t
Definition field.h:524
rheolef::field_basic::iterator::reference
T & reference
Definition field.h:532
rheolef::field_basic::iterator::_u
data_t _u
Definition field.h:588
rheolef::field_basic::iterator::set_increment
void set_increment(size_type incr)
Definition field.h:563
rheolef::field_basic::iterator::difference_type
std::ptrdiff_t difference_type
Definition field.h:534
rheolef::field_basic::iterator::data_t
vec< T, M >::iterator data_t
Definition field.h:523
rheolef::field_basic::iterator::iterator
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)
Definition field.h:554
rheolef::field_basic
Definition field.h:219
rheolef::field_basic::dis_dof_indexes_requires_update
void dis_dof_indexes_requires_update() const
Definition field.h:725
rheolef::field_basic::max_abs
T max_abs() const
Definition field.h:834
rheolef::field_basic::dis_dof
const T & dis_dof(size_type dis_idof) const
Definition field.cc:377
rheolef::field_basic::_u
vec< T, M > _u
Definition field.h:477
rheolef::field_basic::_b
vec< T, M > _b
Definition field.h:478
rheolef::field_basic::begin_dof
const_iterator begin_dof() const
Definition field.h:684
rheolef::field_basic::dis_ndof
size_type dis_ndof() const
Definition field.h:299
rheolef::field_basic::operator[]
details::field_wdof_indirect< field_basic< T, M > > operator[](const geo_type &dom)
Definition field.h:431
rheolef::field_basic::_V
space_type _V
Definition field.h:476
rheolef::field_basic::valued_tag
valued_type valued_tag() const
Definition field.h:273
rheolef::field_basic::get_approx
std::string get_approx() const
Definition field.h:272
rheolef::field_basic::_dis_dof_indexes_requires_update
bool _dis_dof_indexes_requires_update
Definition field.h:479
rheolef::field_basic::get
idiststream & get(idiststream &ips)
Definition field.cc:122
rheolef::field_basic::dis_vector_evaluate
point_basic< T > dis_vector_evaluate(const point_basic< T > &x) const
Definition field.cc:469
rheolef::field_basic::size
size_type size() const
Definition field.h:441
rheolef::field_basic::dof
T & dof(size_type idof)
Definition field.h:738
rheolef::field_basic::field_basic
field_basic()
Definition field.h:702
rheolef::field_basic::put
odiststream & put(odiststream &ops) const
Definition field.cc:367
rheolef::field_basic::result_type
T result_type
Definition field.h:234
rheolef::field_basic::dis_dof_assembly_requires_update
void dis_dof_assembly_requires_update() const
Definition field.h:731
rheolef::field_basic::set_b
vec< T, M > & set_b()
Definition field.h:285
rheolef::field_basic::dis_dof_update
void dis_dof_update(const SetOp &=SetOp()) const
Definition field.h:763
rheolef::field_basic::do_integrate_internal
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)
Definition field_vf_assembly.h:95
rheolef::field_basic::b
const vec< T, M > & b() const
Definition field.h:283
rheolef::field_basic::operator=
field_basic< T, M > & operator=(const field_basic< T, M > &)
Definition field.h:894
rheolef::field_basic::dis_dof_entry
dis_reference dis_dof_entry(size_type dis_idof)
Definition field.cc:398
rheolef::field_basic::_dis_dof_assembly_requires_update
bool _dis_dof_assembly_requires_update
Definition field.h:480
rheolef::field_basic::set_u
vec< T, M > & set_u()
Definition field.h:284
rheolef::field_basic::put_field
odiststream & put_field(odiststream &ops) const
Definition field.cc:303
rheolef::field_basic::dis_reference
typename vec< scalar_type, memory_type >::dis_reference dis_reference
Definition field.h:231
rheolef::field_basic::operator()
T operator()(const point_basic< T > &x) const
Definition field.h:320
rheolef::field_basic::dof
const T & dof(size_type idof) const
Definition field.h:754
rheolef::field_basic::begin_dof
iterator begin_dof()
Definition field.h:595
rheolef::field_basic::min
T min() const
Definition field.h:786
rheolef::field_basic::max
T max() const
Definition field.h:802
rheolef::field_basic::memory_type
M memory_type
Definition field.h:227
rheolef::field_basic::min_abs
T min_abs() const
Definition field.h:818
rheolef::field_basic::get_geo
const geo_type & get_geo() const
Definition field.h:271
rheolef::field_basic::constraint_process_rank
int constraint_process_rank() const
Definition field.h:325
rheolef::field_basic::end_dof
const_iterator end_dof() const
Definition field.h:692
rheolef::field_basic::get_space
const space_type & get_space() const
Definition field.h:270
rheolef::field_basic::end_dof
iterator end_dof()
Definition field.h:603
rheolef::field_basic::u
const vec< T, M > & u() const
Definition field.h:282
rheolef::field_basic::ndof
size_type ndof() const
Definition field.h:298
rheolef::field_basic::valued
const std::string & valued() const
Definition field.h:274
rheolef::field_basic::do_integrate
void do_integrate(const geo_basic< T, M > &dom, const Expr &expr, const integrate_option &iopt)
Definition field_vf_assembly.h:171
rheolef::field_basic::evaluate
T evaluate(const geo_element &K, const point_basic< T > &hat_xq, size_type i_comp=0) const
Definition field.cc:414
rheolef::field_basic::float_type
typename float_traits< T >::type float_type
Definition field.h:228
rheolef::field_basic::scalar_type
T scalar_type
Definition field.h:226
rheolef::field_basic::resize
void resize(const space_type &V, const T &init_value=std::numeric_limits< T >::max())
Definition field.cc:49
rheolef::field_basic::ownership
const distributor & ownership() const
Definition field.h:296
rheolef::field_basic::size_type
std::size_t size_type
Definition field.h:225
rheolef::field_basic::comm
const communicator & comm() const
Definition field.h:297
rheolef::field_basic::value_type
T value_type
Definition field.h:233
rheolef::field_basic::dis_evaluate
T dis_evaluate(const point_basic< T > &x, size_type i_comp=0) const
Definition field.cc:439
rheolef::geo_basic< float_type, memory_type >
rheolef::geo_element
see the geo_element page for the full documentation
Definition geo_element.h:102
rheolef::idiststream
idiststream: see the diststream page for the full documentation
Definition diststream.h:336
rheolef::integrate_option
see the integrate_option page for the full documentation
Definition integrate_option.h:125
rheolef::odiststream
odiststream: see the diststream page for the full documentation
Definition diststream.h:137
rheolef::point_basic
Definition point.h:86
rheolef::space_basic< float_type, memory_type >
rheolef::vec
see the vec page for the full documentation
Definition vec.h:79
rheolef::vec::iterator
base::iterator iterator
Definition vec.h:91
rheolef::vec::size_type
base::size_type size_type
Definition vec.h:86
rheolef::vec::const_iterator
base::const_iterator const_iterator
Definition vec.h:92
rheolef::vec::constraint_process_rank
int constraint_process_rank() const
Definition vec_concat.h:91
rheolef::field_sequential
field_basic< Float, sequential > field_sequential
Definition field.h:514
rheolef::field
field_basic< Float > field
see the field page for the full documentation
Definition field.h:511
trace_macro
#define trace_macro(message)
Definition dis_macros.h:111
get_geo
void get_geo(istream &in, my_geo &omega)
Definition field2gmsh_pos.cc:126
T
Expr1::float_type T
Definition field_expr.h:230
check_macro
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
mkgeo_ball.expr
str expr
Definition mkgeo_ball.sh:361
rheolef::details::assign_with_operator
void assign_with_operator(ForwardIterator first, ForwardIterator last, InputIterator iter_rhs, OpAssign op_assign)
Definition expr_utilities.h:137
rheolef::details::convert_lazy2wdof
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)
Definition field_wdof_convert.h:59
rheolef::space_constant::valued_type
valued_type
Definition space_constant.h:133
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
rheolef::operator!=
bool operator!=(const heap_allocator< T1 > &lhs, const heap_allocator< T1 > &rhs)
Definition heap_allocator.h:176
rheolef::operator==
bool operator==(const heap_allocator< T1 > &lhs, const heap_allocator< T1 > &rhs)
Definition heap_allocator.h:171
rheolef::operator<<
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition catchmark.h:99
rheolef::lazy_interpolate
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
Definition field.h:871
rheolef::begin_dof
const_iterator begin_dof() const
Definition field_expr_recursive.h:611
rheolef::operator-=
std::enable_if< details::is_rheolef_arithmetic< U >::value, ad3_basic< T > & >::type operator-=(ad3_basic< T > &a, const U &b)
Definition ad3.h:306
rheolef::operator+=
std::enable_if< details::is_rheolef_arithmetic< U >::value, ad3_basic< T > & >::type operator+=(ad3_basic< T > &a, const U &b)
Definition ad3.h:286
rheolef::have_homogeneous_space
bool have_homogeneous_space(space_basic< scalar_type, memory_type > &Vh) const
Definition field_expr_recursive.h:586
rheolef::operator+
std::enable_if< details::is_rheolef_arithmetic< U >::value, ad3_basic< T > >::type operator+(const U &a, const ad3_basic< T > &b)
Definition ad3.h:222
rheolef::operator>>
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition catchmark.h:88
rheolef::interpolate
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
Definition interpolate.cc:233
rheolef::operator*
csr< T, sequential > operator*(const T &lambda, const csr< T, sequential > &a)
Definition csr.h:437
rheolef::const_iterator
Definition field_expr_recursive.h:594
rheolef::details::assign_op
Definition expr_utilities.h:115
rheolef::details::field_traits< field_basic< T, M > >::memory_type
M memory_type
Definition field.h:497
rheolef::details::field_traits< field_basic< T, M > >::scalar_type
T scalar_type
Definition field.h:496
rheolef::details::field_traits< field_basic< T, M > >::size_type
std::size_t size_type
Definition field.h:495
rheolef::details::field_traits
Definition field_lazy.h:265
rheolef::details::function_traits
Definition field_expr_utilities.h:184
rheolef::details::has_field_lazy_interface
Definition field_concept.h:74
rheolef::details::has_field_rdof_interface
Definition field_concept.h:58
rheolef::details::is_field_expr_affine_homogeneous
Definition field_concept.h:100
rheolef::details::is_field_lazy
Definition field_concept.h:70
rheolef::details::is_field
Definition field_concept.h:34
rheolef::details::is_rheolef_arithmetic
Definition Float.h:150
rheolef::float_traits::type
T type
Definition Float.h:94
rheolef::is_distributed
Definition communicator.h:70
u
Definition leveque.h:25
M
Expr1::memory_type M
Definition vec_expr_v2.h:416