Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
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
26namespace rheolef {
170} // namespace rheolef
171
172#include "rheolef/problem.h"
173
174namespace rheolef {
175
176// [verbatim_problem_mixed_basic]
177template <class T, class M = rheo_default_memory_model>
179public:
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
216protected:
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]
236typedef problem_mixed_basic<Float> problem_mixed;
237// [verbatim_problem_mixed]
238
239// -----------------------------------------------------------------------------
240// inlined
241// -----------------------------------------------------------------------------
242template<class T, class M>
243inline
245 : _a(),
246 _b(),
247 _c(),
248 _sopt(),
249 _mp(),
250 _pmp(),
251 _pa(),
252 _s(),
253 _init_s_done(false)
254{
255}
256template<class T, class M>
257inline
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}
273template<class T, class M>
274inline
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}
291template<class T, class M>
292inline
293bool
295{
296 return _s.initialized();
297}
298template<class T, class M>
299inline
300const solver_option&
302{
303 return _s.option();
304}
305template<class T, class M>
306inline
307void
309{
310 _mp = mp;
311}
312template<class T, class M>
313inline
314void
316{
317 _pmp = pmp;
318}
319template<class T, class M>
320inline
321void
323{
324 _pa = pa;
325}
326template<class T, class M>
327inline
328void
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}
348template<class T, class M>
349inline
350void
352 const field_basic<T,M>& lh,
353 const field_basic<T,M>& kh,
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
field lh(Float epsilon, Float t, const test &v)
see the form page for the full documentation
see the problem page for the full documentation
const vec< T, M > & b() const
Definition field.h:283
vec< T, M > & set_u()
Definition field.h:284
const vec< T, M > & u() const
Definition field.h:282
problem_basic< T, M > _pmp
void set_inner_problem(const problem &pa)
solver_abtb_basic< T, M > _s
solver_basic< T, M >::determinant_type determinant_type
problem_basic< T, M > _pa
solver_basic< T, M >::size_type size_type
void set_preconditionner(const problem &pmp)
const solver_option & option() const
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
void set_metric(const form &mp)
rep::determinant_type determinant_type
Definition solver.h:271
rep::size_type size_type
Definition solver.h:270
see the solver_option page for the full documentation
the finite element space
Definition space.h:382
see the vec page for the full documentation
Definition vec.h:79
problem_mixed_basic< Float > problem_mixed
see the problem_mixed page for the full documentation
This file is part of Rheolef.
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:211
Definition cavity_dg.h:29
Definition cavity_dg.h:25
Definition sphere.icc:25