form.h
Go to the documentation of this file.
# ifndef _RHEOLEF_FORM_H
# define _RHEOLEF_FORM_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: 2 july 1997
namespace rheolef {
} // namespace rheolef
#include "rheolef/csr.h"
#include "rheolef/field.h"
#include "rheolef/quadrature.h"
#include "rheolef/integrate_option.h"
namespace rheolef {
namespace details {
// these classes are used for allocator from the std::initializer_list
template <class T, class M> class form_concat_value;
template <class T, class M> class form_concat_line;
} // namespace details
// forward declaration:
template <class T, class M> class band_basic;
// [verbatim_form_basic]
template<class T, class M>
class form_basic {
public :
// typedefs:
typedef typename csr<T,M>::size_type size_type;
typedef T value_type;
typedef typename scalar_traits<T>::type float_type;
typedef geo_basic<float_type,M> geo_type;
typedef space_basic<float_type,M> space_type;
// allocator/deallocator:
form_basic ();
form_basic (const form_basic<T,M>&);
form_basic<T,M>& operator= (const form_basic<T,M>&);
// allocators from initializer list (c++ 2011):
form_basic (const std::initializer_list<details::form_concat_value<T,M> >& init_list);
form_basic (const std::initializer_list<details::form_concat_line <T,M> >& init_list);
// accessors:
const space_type& get_first_space() const;
const space_type& get_second_space() const;
const geo_type& get_geo() const;
bool is_symmetric() const;
void set_symmetry (bool is_symm) const;
const communicator& comm() const;
// linear algebra:
form_basic<T,M> operator+ (const form_basic<T,M>& b) const;
form_basic<T,M> operator- (const form_basic<T,M>& b) const;
form_basic<T,M> operator* (const form_basic<T,M>& b) const;
form_basic<T,M>& operator*= (const T& lambda);
field_basic<T,M> operator* (const field_basic<T,M>& xh) const;
field_basic<T,M> trans_mult (const field_basic<T,M>& yh) const;
float_type operator () (const field_basic<T,M>& uh, const field_basic<T,M>& vh) const;
// io:
odiststream& put (odiststream& ops, bool show_partition = true) const;
void dump (std::string name) const;
// accessors & modifiers to unknown & blocked parts:
const csr<T,M>& uu() const { return _uu; }
const csr<T,M>& ub() const { return _ub; }
const csr<T,M>& bu() const { return _bu; }
const csr<T,M>& bb() const { return _bb; }
csr<T,M>& set_uu() { return _uu; }
csr<T,M>& set_ub() { return _ub; }
csr<T,M>& set_bu() { return _bu; }
csr<T,M>& set_bb() { return _bb; }
// [verbatim_form_basic]
// internals:
int constraint_process_rank() const { return uu().constraint_process_rank(); }
// data
protected:
space_type _X;
space_type _Y;
csr<T,M> _uu;
csr<T,M> _ub;
csr<T,M> _bu;
csr<T,M> _bb;
// internals:
public:
// with vf expression arg
template <class Expr>
void assembly_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& fopt,
bool is_on_band);
template <class Expr>
void assembly (
const geo_basic<T,M>& domain,
const Expr& expr,
const integrate_option& fopt);
template <class Expr>
void assembly (
const band_basic<T,M>& gh,
const Expr& expr,
const integrate_option& fopt);
// backward compat: named forms
form_basic (const space_type& X, const space_type& Y,
const std::string& name = "",
const quadrature_option& qopt = quadrature_option());
form_basic (const space_type& X, const space_type& Y,
const std::string& name,
const field_basic<T,M>& weight,
const quadrature_option& qopt = quadrature_option());
template<class Function>
form_basic (const space_type& X, const space_type& Y,
const std::string& name,
Function weight,
const quadrature_option& qopt = quadrature_option());
form_basic (const space_type& X, const space_type& Y,
const std::string& name,
const geo_basic<T,M>& gamma,
const quadrature_option& qopt = quadrature_option());
form_basic (const space_type& X, const space_type& Y,
const std::string& name,
const geo_basic<T,M>& gamma,
const field_basic<T,M>& weight,
const quadrature_option& qopt = quadrature_option());
template<class Function>
form_basic (
const space_type& X,
const space_type& Y,
const std::string& name,
const geo_basic<T,M>& gamma,
Function weight,
const quadrature_option& qopt = quadrature_option());
protected:
// backward compat: named forms (cont.)
template<class WeightFunction>
void form_init (
const std::string& name,
bool has_weight,
WeightFunction weight,
const quadrature_option& qopt);
template<class WeightFunction>
void form_init_on_domain (
const std::string& name,
const geo_basic<T,M>& gamma,
bool has_weight,
WeightFunction weight,
const geo_basic<T,M>& w_omega, // the domain where the fct weight is defined
const quadrature_option& qopt);
// [verbatim_form_basic_cont]
};
template<class T, class M> form_basic<T,M> trans (const form_basic<T,M>& a);
template<class T, class M> field_basic<T,M> diag (const form_basic<T,M>& a);
template<class T, class M> form_basic<T,M> diag (const field_basic<T,M>& dh);
// [verbatim_form_basic_cont]
// [verbatim_form]
typedef form_basic<Float,rheo_default_memory_model> form;
// [verbatim_form]
// ------------ inline'd -----------------------------------
template<class T, class M>
inline
form_basic<T,M>::form_basic ()
: _X(), _Y(), _uu(), _ub(), _bu(), _bb()
{
}
template<class T, class M>
inline
form_basic<T,M>::form_basic (const form_basic<T,M>& a)
: _X(a._X), _Y(a._Y), _uu(a._uu), _ub(a._ub), _bu(a._bu), _bb(a._bb)
{
}
template<class T, class M>
inline
form_basic<T,M>&
form_basic<T,M>::operator= (const form_basic<T,M>& a)
{
_X.operator= (a._X);
_Y.operator= (a._Y);
_uu.operator= (a._uu);
_ub.operator= (a._ub);
_bu.operator= (a._bu);
_bb.operator= (a._bb);
return *this;
}
template<class T, class M>
inline
const typename form_basic<T,M>::space_type&
form_basic<T,M>::get_first_space() const
{
return _X;
}
template<class T, class M>
inline
const typename form_basic<T,M>::space_type&
form_basic<T,M>::get_second_space() const
{
return _Y;
}
template<class T, class M>
inline
const typename form_basic<T,M>::geo_type&
form_basic<T,M>::get_geo() const
{
return _X.get_geo();
}
template<class T, class M>
inline
const communicator&
form_basic<T,M>::comm() const
{
return get_geo().comm();
}
// ----------------
// linear albebra
// ----------------
template<class T, class M>
inline
form_basic<T,M>
form_basic<T,M>::operator+ (const form_basic<T,M>& b) const
{
form_basic<T,M> c (get_first_space(), get_second_space());
c._uu = _uu + b._uu;
c._ub = _ub + b._ub;
c._bu = _bu + b._bu;
c._bb = _bb + b._bb;
return c;
}
template<class T, class M>
inline
form_basic<T,M>
form_basic<T,M>::operator- (const form_basic<T,M>& b) const
{
form_basic<T,M> c (get_first_space(), get_second_space());
c._uu = _uu - b._uu;
c._ub = _ub - b._ub;
c._bu = _bu - b._bu;
c._bb = _bb - b._bb;
return c;
}
template<class T, class M>
inline
form_basic<T,M>
form_basic<T,M>::operator* (const form_basic<T,M>& b) const
{
form_basic<T,M> c (b.get_first_space(), get_second_space());
c._uu = _uu*b._uu + _ub*b._bu;
c._ub = _uu*b._ub + _ub*b._bb;
c._bu = _bu*b._uu + _bb*b._bu;
c._bb = _bu*b._ub + _bb*b._bb;
return c;
}
template<class T, class M>
inline
form_basic<T,M>&
form_basic<T,M>::operator*= (const T& lambda)
{
_uu *= lambda;
_ub *= lambda;
_bu *= lambda;
_bb *= lambda;
return *this;
}
template<class T, class M>
inline
form_basic<T,M>
operator* (const T& lambda, const form_basic<T,M>& a)
{
form_basic<T,M> b = a;
b *= lambda;
return b;
}
template<class T, class M>
inline
form_basic<T,M>
operator- (const form_basic<T,M>& a)
{
return T(-1)*a;
}
template<class T, class M>
inline
bool
form_basic<T,M>::is_symmetric() const
{
return _uu.is_symmetric() && _bb.is_symmetric();
}
template<class T, class M>
inline
void
form_basic<T,M>::set_symmetry (bool is_symm) const
{
_uu.set_symmetry(is_symm);
_bb.set_symmetry(is_symm);
}
}// namespace rheolef
# endif /* _RHEOLEF_FORM_H */
rheolef::geo_basic< float_type, M >
rheolef::domain
geo domain
Definition: geo_domain_indirect.h:58
rheolef::form_basic::_ub
csr< T, M > _ub
Definition: form.h:208
rheolef::form_basic::form_init_on_domain
void form_init_on_domain(const std::string &name, const geo_basic< T, M > &gamma, bool has_weight, WeightFunction weight, const geo_basic< T, M > &w_omega, const quadrature_option &qopt)
Definition: form_weighted.h:222
rheolef::form_basic::_bb
csr< T, M > _bb
Definition: form.h:210
rheolef::form_basic::operator*
form_basic< T, M > operator*(const form_basic< T, M > &b) const
Definition: form.h:381
gh
field gh(Float epsilon, Float t, const field &uh, const test &v)
Definition: burgers_diffusion_operators.icc:37
mkgeo_ball.expr
expr
Definition: mkgeo_ball.sh:361
rheolef::form_basic::space_type
space_basic< float_type, M > space_type
Definition: form.h:152
rheolef::form_basic::ub
const csr< T, M > & ub() const
Definition: form.h:193
rheolef::Function
rheolef::std Function
rheolef::diag
csr< T, M > diag(const vec< T, M > &d)
Definition: csr.cc:56
rheolef::form_basic::bb
const csr< T, M > & bb() const
Definition: form.h:195
rheolef::form_basic::bu
const csr< T, M > & bu() const
Definition: form.h:194
rheolef::space_basic< float_type, M >
band
see the band page for the full documentation
rheolef::form_basic::uu
const csr< T, M > & uu() const
Definition: form.h:192
rheolef::form_basic::float_type
scalar_traits< T >::type float_type
Definition: form.h:150
mkgeo_ball.c
c
Definition: mkgeo_ball.sh:153
rheolef::form_basic::set_bb
csr< T, M > & set_bb()
Definition: form.h:199
rk::gamma
Float gamma[][pmax+1]
Definition: runge_kutta_semiimplicit.icc:70
rheolef::details::form_concat_value
Definition: form.h:134
rheolef::form_basic::get_second_space
const space_type & get_second_space() const
Definition: form.h:333
rheolef::form_basic::get_first_space
const space_type & get_first_space() const
Definition: form.h:326
rheolef::form_basic::form_basic
form_basic()
Definition: form.h:300
rheolef::integrate_option
see the integrate_option page for the full documentation
Definition: integrate_option.h:125
rheolef::form_basic::assembly
void assembly(const geo_basic< T, M > &domain, const Expr &expr, const integrate_option &fopt)
Definition: form_vf_assembly.h:241
a
Definition: diffusion_isotropic.h:25
rheolef::details::form_concat_line
Definition: form.h:135
rheolef::form_basic::is_symmetric
bool is_symmetric() const
Definition: form.h:420
rheolef::form_basic::_Y
space_type _Y
Definition: form.h:206
rheolef::field_basic
Definition: field_expr_utilities.h:38
operator*
return a operator*(eh)
rheolef::form_basic::operator()
float_type operator()(const field_basic< T, M > &uh, const field_basic< T, M > &vh) const
Definition: form.cc:143
rheolef::form_basic::operator=
form_basic< T, M > & operator=(const form_basic< T, M > &)
Definition: form.h:313
rheolef::form_basic::form_init
void form_init(const std::string &name, bool has_weight, WeightFunction weight, const quadrature_option &qopt)
Definition: form_weighted.h:165
rheolef::csr
see the csr page for the full documentation
Definition: asr.h:31
rheolef::form_basic::operator+
form_basic< T, M > operator+(const form_basic< T, M > &b) const
Definition: form.h:357
rheolef::form
form_basic< Float, rheo_default_memory_model > form
Definition: form.h:293
rheolef::band_basic
Definition: band.h:95
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::form_basic::operator*=
form_basic< T, M > & operator*=(const T &lambda)
Definition: form.h:393
rheolef::form_basic::set_ub
csr< T, M > & set_ub()
Definition: form.h:197
rheolef::odiststream
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
rheolef::operator-
form_basic< T, M > operator-(const form_basic< T, M > &a)
Definition: form.h:413
rheolef::form_basic::geo_type
geo_basic< float_type, M > geo_type
Definition: form.h:151
rheolef::form_basic::_bu
csr< T, M > _bu
Definition: form.h:209
rheolef::form_basic
Definition: form.h:144
mkgeo_ball.b
b
Definition: mkgeo_ball.sh:152
mkgeo_ball.a
a
Definition: mkgeo_ball.sh:151
rheolef::scalar_traits::type
T type
Definition: point.h:324
rheolef::form_basic::constraint_process_rank
int constraint_process_rank() const
Definition: form.h:202
rheolef::form_basic::operator-
form_basic< T, M > operator-(const form_basic< T, M > &b) const
Definition: form.h:369
rheolef::form_basic::set_uu
csr< T, M > & set_uu()
Definition: form.h:196
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::form_basic::get_geo
const geo_type & get_geo() const
Definition: form.h:340
rheolef::form_basic::value_type
T value_type
Definition: form.h:149
rheolef::form_basic::size_type
csr< T, M >::size_type size_type
Definition: form.h:148
get_geo
void get_geo(istream &in, my_geo &omega)
Definition: field2gmsh_pos.cc:126
rheolef::form_basic::_X
space_type _X
Definition: form.h:205
rheolef::form_basic::set_symmetry
void set_symmetry(bool is_symm) const
Definition: form.h:427
rheolef::form_basic::comm
const communicator & comm() const
Definition: form.h:347
rheolef::trans
csr< T, sequential > trans(const csr< T, sequential > &a)
trans(a): see the form page for the full documentation
Definition: csr.h:455
rheolef::form_basic::put
odiststream & put(odiststream &ops, bool show_partition=true) const
Definition: form.cc:235
rheolef::form_basic::trans_mult
field_basic< T, M > trans_mult(const field_basic< T, M > &yh) const
Definition: form.cc:134
rheolef::quadrature_option
integrate_option quadrature_option
Definition: integrate_option.h:186
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:367
mkgeo_contraction.name
name
Definition: mkgeo_contraction.sh:133
rheolef::form_basic::set_bu
csr< T, M > & set_bu()
Definition: form.h:198
rheolef::form_basic::_uu
csr< T, M > _uu
Definition: form.h:207
rheolef::form_basic::dump
void dump(std::string name) const
Definition: form.cc:262
T
Expr1::float_type T
Definition: field_expr.h:218
lambda
Definition: yield_slip_circle.h:34
rheolef::form_basic::assembly_internal
void assembly_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 &fopt, bool is_on_band)
Definition: form_vf_assembly.h:87