problem_mixed.h
Go to the documentation of this file.
#ifndef _RHEOLEF_PROBLEM_MIXED_H
#define _RHEOLEF_PROBLEM_MIXED_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
//
// =========================================================================
// AUTHORS: Pierre.Saramito@imag.fr
// DATE: 21 february 2020
namespace rheolef {
} // namespace rheolef
#include "rheolef/problem.h"
namespace rheolef {
// [verbatim_problem_mixed_basic]
template <class T, class M = rheo_default_memory_model>
class problem_mixed_basic {
public:
// typedefs:
typedef typename solver_basic<T,M>::size_type size_type;
typedef typename solver_basic<T,M>::determinant_type determinant_type;
// allocators:
problem_mixed_basic();
problem_mixed_basic(
const form_basic<T,M>& a,
const form_basic<T,M>& b,
const solver_option& sopt = solver_option());
problem_mixed_basic(
const form_basic<T,M>& a,
const form_basic<T,M>& b,
const form_basic<T,M>& c,
const solver_option& sopt = solver_option());
// accessor:
void solve (const field_basic<T,M>& lh, const field_basic<T,M>& kh,
field_basic<T,M>& uh, field_basic<T,M>& ph) const;
bool initialized() const;
const solver_option& option() const;
// modifiers:
void set_metric (const form& mp);
void set_preconditionner (const problem& pmp);
void set_inner_problem (const problem& pa);
// [verbatim_problem_mixed_basic]
protected:
// internal:
void _init_s() const;
// data:
form_basic<T,M> _a, _b, _c;
solver_option _sopt;
mutable form_basic<T,M> _mp;
problem_basic<T,M> _pmp, _pa;
mutable solver_abtb_basic<T,M> _s;
mutable bool _init_s_done;
// [verbatim_problem_mixed_basic_cont]
};
// [verbatim_problem_mixed_basic_cont]
// [verbatim_problem_mixed]
typedef problem_mixed_basic<Float> problem_mixed;
// [verbatim_problem_mixed]
// -----------------------------------------------------------------------------
// inlined
// -----------------------------------------------------------------------------
template<class T, class M>
inline
problem_mixed_basic<T,M>::problem_mixed_basic()
: _a(),
_b(),
_c(),
_sopt(),
_mp(),
_pmp(),
_pa(),
_s(),
_init_s_done(false)
{
}
template<class T, class M>
inline
problem_mixed_basic<T,M>::problem_mixed_basic (
const form_basic<T,M>& a,
const form_basic<T,M>& b,
const solver_option& sopt)
: _a(a),
_b(b),
_c(),
_sopt(),
_mp(),
_pmp(),
_pa(),
_s(),
_init_s_done(false)
{
}
template<class T, class M>
inline
problem_mixed_basic<T,M>::problem_mixed_basic (
const form_basic<T,M>& a,
const form_basic<T,M>& b,
const form_basic<T,M>& c,
const solver_option& sopt)
: _a(a),
_b(b),
_c(c),
_sopt(),
_mp(),
_pmp(),
_pa(),
_s(),
_init_s_done(false)
{
}
template<class T, class M>
inline
bool
problem_mixed_basic<T,M>::initialized() const
{
return _s.initialized();
}
template<class T, class M>
inline
const solver_option&
problem_mixed_basic<T,M>::option() const
{
return _s.option();
}
template<class T, class M>
inline
void
problem_mixed_basic<T,M>::set_metric (const form& mp)
{
_mp = mp;
}
template<class T, class M>
inline
void
problem_mixed_basic<T,M>::set_preconditionner (const problem& pmp)
{
_pmp = pmp;
}
template<class T, class M>
inline
void
problem_mixed_basic<T,M>::set_inner_problem (const problem& pa)
{
_pa = pa;
}
template<class T, class M>
inline
void
problem_mixed_basic<T,M>::_init_s() const
{
if (_init_s_done) return;
_init_s_done = true;
if (_mp.uu().dis_nnz() == 0) {
// default mp metric is the Qh L2 scalar product:
const space_basic<T,M> Qh = _b.get_second_space();
test_basic<T,M,details::vf_tag_01> p (Qh);
test_basic<T,M,details::vf_tag_10> q (Qh);
_mp = integrate (p*q);
}
if (_c.uu().dis_nnz() == 0) {
_s = solver_abtb_basic<T,M> (_a.uu(), _b.uu(), _mp.uu(), _sopt);
} else {
_s = solver_abtb_basic<T,M> (_a.uu(), _b.uu(), _c.uu(), _mp.uu(), _sopt);
}
if (_pmp.initialized()) { _s.set_preconditioner (_pmp.get_solver()); }
if ( _pa.initialized()) { _s.set_inner_solver ( _pa.get_solver()); }
}
template<class T, class M>
inline
void
problem_mixed_basic<T,M>::solve (
const field_basic<T,M>& lh,
const field_basic<T,M>& kh,
field_basic<T,M>& uh,
field_basic<T,M>& ph) const
{
_init_s();
vec<T,M> f = lh.u() - _a.ub()*uh.b() - _b.bu().trans_mult(ph.b());
vec<T,M> g;
if (_c.uu().dis_nnz() == 0) {
g = kh.u() - _b.ub()*uh.b();
} else {
g = kh.u() - _b.ub()*uh.b() + _c.ub()*ph.b();
}
_s.solve (f, g, uh.set_u(), ph.set_u());
}
} // namespace rheolef
#endif // _RHEOLEF_PROBLEM_MIXED_H
g
u_exact g
Definition: burgers_diffusion_exact.h:33
lh
field lh(Float epsilon, Float t, const test &v)
Definition: burgers_diffusion_operators.icc:25
form
see the form page for the full documentation
problem
see the problem page for the full documentation
rheolef::field_basic< T, M >
rheolef::field_basic::set_u
vec< T, M > & set_u()
Definition: field.h:312
rheolef::field_basic::u
const vec< T, M > & u() const
Definition: field.h:310
rheolef::field_basic::b
const vec< T, M > & b() const
Definition: field.h:311
rheolef::form_basic
Definition: form.h:144
rheolef::problem_basic
Definition: problem.h:120
rheolef::problem_mixed_basic
Definition: problem_mixed.h:178
rheolef::problem_mixed_basic::_init_s
void _init_s() const
Definition: problem_mixed.h:329
rheolef::problem_mixed_basic::_pmp
problem_basic< T, M > _pmp
Definition: problem_mixed.h:226
rheolef::problem_mixed_basic::_mp
form_basic< T, M > _mp
Definition: problem_mixed.h:225
rheolef::problem_mixed_basic::set_inner_problem
void set_inner_problem(const problem &pa)
Definition: problem_mixed.h:322
rheolef::problem_mixed_basic::_s
solver_abtb_basic< T, M > _s
Definition: problem_mixed.h:227
rheolef::problem_mixed_basic::determinant_type
solver_basic< T, M >::determinant_type determinant_type
Definition: problem_mixed.h:184
rheolef::problem_mixed_basic::_init_s_done
bool _init_s_done
Definition: problem_mixed.h:228
rheolef::problem_mixed_basic::_c
form_basic< T, M > _c
Definition: problem_mixed.h:223
rheolef::problem_mixed_basic::_pa
problem_basic< T, M > _pa
Definition: problem_mixed.h:226
rheolef::problem_mixed_basic::size_type
solver_basic< T, M >::size_type size_type
Definition: problem_mixed.h:183
rheolef::problem_mixed_basic::set_preconditionner
void set_preconditionner(const problem &pmp)
Definition: problem_mixed.h:315
rheolef::problem_mixed_basic::option
const solver_option & option() const
Definition: problem_mixed.h:301
rheolef::problem_mixed_basic::problem_mixed_basic
problem_mixed_basic()
Definition: problem_mixed.h:244
rheolef::problem_mixed_basic::_a
form_basic< T, M > _a
Definition: problem_mixed.h:223
rheolef::problem_mixed_basic::_b
form_basic< T, M > _b
Definition: problem_mixed.h:223
rheolef::problem_mixed_basic::solve
void solve(const field_basic< T, M > &lh, const field_basic< T, M > &kh, field_basic< T, M > &uh, field_basic< T, M > &ph) const
Definition: problem_mixed.h:351
rheolef::problem_mixed_basic::_sopt
solver_option _sopt
Definition: problem_mixed.h:224
rheolef::problem_mixed_basic::set_metric
void set_metric(const form &mp)
Definition: problem_mixed.h:308
rheolef::problem_mixed_basic::initialized
bool initialized() const
Definition: problem_mixed.h:294
rheolef::solver_abtb_basic
Definition: solver_abtb.h:115
rheolef::solver_basic
Definition: solver.h:264
rheolef::solver_option
see the solver_option page for the full documentation
Definition: solver_option.h:155
rheolef::space_basic< T, M >
rheolef::test_basic< T, M, details::vf_tag_01 >
rheolef::vec< T, M >
rheolef::problem_mixed
problem_mixed_basic< Float > problem_mixed
see the problem_mixed page for the full documentation
Definition: problem_mixed.h:236
mkgeo_ball.b
int b
Definition: mkgeo_ball.sh:152
mkgeo_ball.c
int c
Definition: mkgeo_ball.sh:153
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::integrate
std::enable_if< details::is_field_expr_v2_nonlinear_arg< Expr >::value &&! is_undeterminated< Result >::value, Result >::type integrate(const geo_basic< T, M > &omega, const Expr &expr, const integrate_option &iopt, Result dummy=Result())
see the integrate page for the full documentation
Definition: integrate.h:202
a
Definition: diffusion_isotropic.h:25
f
Definition: cavity_dg.h:29
g
Definition: cavity_dg.h:25
p
Definition: sphere.icc:25