Rheolef  7.1
an efficient C++ finite element environment
problem_mixed.h
Go to the documentation of this file.
1 #ifndef _RHEOLEF_PROBLEM_MIXED_H
2 #define _RHEOLEF_PROBLEM_MIXED_H
3 //
4 // This file is part of Rheolef.
5 //
6 // Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7 //
8 // Rheolef is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // Rheolef is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with Rheolef; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 //
22 // =========================================================================
23 // AUTHORS: Pierre.Saramito@imag.fr
24 // DATE: 21 february 2020
25 
26 namespace rheolef {
170 } // namespace rheolef
171 
172 #include "rheolef/problem.h"
173 
174 namespace rheolef {
175 
176 // [verbatim_problem_mixed_basic]
177 template <class T, class M = rheo_default_memory_model>
179 public:
180 
181 // typedefs:
182 
185 
186 // allocators:
187 
189 
191  const form_basic<T,M>& a,
192  const form_basic<T,M>& b,
193  const solver_option& sopt = solver_option());
194 
196  const form_basic<T,M>& a,
197  const form_basic<T,M>& b,
198  const form_basic<T,M>& c,
199  const solver_option& sopt = solver_option());
200 
201 // accessor:
202 
203  void solve (const field_basic<T,M>& lh, const field_basic<T,M>& kh,
204  field_basic<T,M>& uh, field_basic<T,M>& ph) const;
205 
206  bool initialized() const;
207  const solver_option& option() const;
208 
209 // modifiers:
210 
211  void set_metric (const form& mp);
212  void set_preconditionner (const problem& pmp);
213  void set_inner_problem (const problem& pa);
214 // [verbatim_problem_mixed_basic]
215 
216 protected:
217 // internal:
218 
219  void _init_s() const;
220 
221 // data:
222 
228  mutable bool _init_s_done;
229 
230 // [verbatim_problem_mixed_basic_cont]
231 };
232 // [verbatim_problem_mixed_basic_cont]
233 
235 // [verbatim_problem_mixed]
236 typedef problem_mixed_basic<Float> problem_mixed;
237 // [verbatim_problem_mixed]
238 
239 // -----------------------------------------------------------------------------
240 // inlined
241 // -----------------------------------------------------------------------------
242 template<class T, class M>
243 inline
245  : _a(),
246  _b(),
247  _c(),
248  _sopt(),
249  _mp(),
250  _pmp(),
251  _pa(),
252  _s(),
253  _init_s_done(false)
254 {
255 }
256 template<class T, class M>
257 inline
259  const form_basic<T,M>& a,
260  const form_basic<T,M>& b,
261  const solver_option& sopt)
262  : _a(a),
263  _b(b),
264  _c(),
265  _sopt(),
266  _mp(),
267  _pmp(),
268  _pa(),
269  _s(),
270  _init_s_done(false)
271 {
272 }
273 template<class T, class M>
274 inline
276  const form_basic<T,M>& a,
277  const form_basic<T,M>& b,
278  const form_basic<T,M>& c,
279  const solver_option& sopt)
280  : _a(a),
281  _b(b),
282  _c(c),
283  _sopt(),
284  _mp(),
285  _pmp(),
286  _pa(),
287  _s(),
288  _init_s_done(false)
289 {
290 }
291 template<class T, class M>
292 inline
293 bool
295 {
296  return _s.initialized();
297 }
298 template<class T, class M>
299 inline
300 const solver_option&
302 {
303  return _s.option();
304 }
305 template<class T, class M>
306 inline
307 void
309 {
310  _mp = mp;
311 }
312 template<class T, class M>
313 inline
314 void
316 {
317  _pmp = pmp;
318 }
319 template<class T, class M>
320 inline
321 void
323 {
324  _pa = pa;
325 }
326 template<class T, class M>
327 inline
328 void
330 {
331  if (_init_s_done) return;
332  _init_s_done = true;
333  if (_mp.uu().dis_nnz() == 0) {
334  // default mp metric is the Qh L2 scalar product:
335  const space_basic<T,M> Qh = _b.get_second_space();
338  _mp = integrate (p*q);
339  }
340  if (_c.uu().dis_nnz() == 0) {
341  _s = solver_abtb_basic<T,M> (_a.uu(), _b.uu(), _mp.uu(), _sopt);
342  } else {
343  _s = solver_abtb_basic<T,M> (_a.uu(), _b.uu(), _c.uu(), _mp.uu(), _sopt);
344  }
345  if (_pmp.initialized()) { _s.set_preconditioner (_pmp.get_solver()); }
346  if ( _pa.initialized()) { _s.set_inner_solver ( _pa.get_solver()); }
347 }
348 template<class T, class M>
349 inline
350 void
352  const field_basic<T,M>& lh,
353  const field_basic<T,M>& kh,
354  field_basic<T,M>& uh,
355  field_basic<T,M>& ph) const
356 {
357  _init_s();
358  vec<T,M> f = lh.u() - _a.ub()*uh.b() - _b.bu().trans_mult(ph.b());
359  vec<T,M> g;
360  if (_c.uu().dis_nnz() == 0) {
361  g = kh.u() - _b.ub()*uh.b();
362  } else {
363  g = kh.u() - _b.ub()*uh.b() + _c.ub()*ph.b();
364  }
365  _s.solve (f, g, uh.set_u(), ph.set_u());
366 }
367 
368 } // namespace rheolef
369 #endif // _RHEOLEF_PROBLEM_MIXED_H
g
u_exact g
Definition: burgers_diffusion_exact.h:33
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
form
see the form page for the full documentation
rheolef::problem_basic
Definition: problem.h:120
rheolef::problem_mixed
problem_mixed_basic< Float > problem_mixed
see the problem_mixed page for the full documentation
Definition: problem_mixed.h:236
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
rheolef::problem_mixed_basic::set_inner_problem
void set_inner_problem(const problem &pa)
Definition: problem_mixed.h:322
rheolef::solver_basic::size_type
rep::size_type size_type
Definition: solver.h:270
rheolef::space_basic
the finite element space
Definition: space.h:352
rheolef::problem_mixed_basic::set_preconditionner
void set_preconditionner(const problem &pmp)
Definition: problem_mixed.h:315
rheolef::problem_mixed_basic::_s
solver_abtb_basic< T, M > _s
Definition: problem_mixed.h:227
mkgeo_ball.c
c
Definition: mkgeo_ball.sh:153
rheolef::problem_mixed_basic::_pa
problem_basic< T, M > _pa
Definition: problem_mixed.h:226
rheolef::solver_abtb_basic
Definition: solver_abtb.h:115
rheolef::problem_mixed_basic::determinant_type
solver_basic< T, M >::determinant_type determinant_type
Definition: problem_mixed.h:184
rheolef::problem_mixed_basic::_pmp
problem_basic< T, M > _pmp
Definition: problem_mixed.h:226
rheolef::vec
see the vec page for the full documentation
Definition: vec.h:79
rheolef::solver_abstract_rep::determinant_type
Definition: solver.h:215
rheolef::field_basic::u
const vec< T, M > & u() const
Definition: field.h:310
rheolef::problem_mixed_basic::problem_mixed_basic
problem_mixed_basic()
Definition: problem_mixed.h:244
rheolef::problem_mixed_basic::_mp
form_basic< T, M > _mp
Definition: problem_mixed.h:225
rheolef::problem_mixed_basic::option
const solver_option & option() const
Definition: problem_mixed.h:301
p
Definition: sphere.icc:25
rheolef::problem_mixed_basic::set_metric
void set_metric(const form &mp)
Definition: problem_mixed.h:308
rheolef::field_basic::set_u
vec< T, M > & set_u()
Definition: field.h:312
rheolef::test_basic< T, M, details::vf_tag_01 >
rheolef::problem_mixed_basic::size_type
solver_basic< T, M >::size_type size_type
Definition: problem_mixed.h:183
a
Definition: diffusion_isotropic.h:25
rheolef::problem_mixed_basic::_init_s_done
bool _init_s_done
Definition: problem_mixed.h:228
rheolef::problem_mixed_basic::_b
form_basic< T, M > _b
Definition: problem_mixed.h:223
rheolef::field_basic
Definition: field_expr_utilities.h:38
lh
field lh(Float epsilon, Float t, const test &v)
Definition: burgers_diffusion_operators.icc:25
rheolef::problem_mixed_basic::_init_s
void _init_s() const
Definition: problem_mixed.h:329
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
problem
see the problem page for the full documentation
rheolef::problem_mixed_basic::_c
form_basic< T, M > _c
Definition: problem_mixed.h:223
rheolef::problem_mixed_basic::initialized
bool initialized() const
Definition: problem_mixed.h:294
rheolef::problem_mixed_basic::_a
form_basic< T, M > _a
Definition: problem_mixed.h:223
rheolef::form_basic
Definition: form.h:144
mkgeo_ball.b
b
Definition: mkgeo_ball.sh:152
rheolef::problem_mixed_basic::_sopt
solver_option _sopt
Definition: problem_mixed.h:224
rheolef::problem_mixed_basic
Definition: problem_mixed.h:178
rheolef::field_basic::b
const vec< T, M > & b() const
Definition: field.h:311
g
Definition: cavity_dg.h:25
f
Definition: cavity_dg.h:29
rheolef::solver_option
see the solver_option page for the full documentation
Definition: solver_option.h:155