segregated_fsi_solver.h
Go to the documentation of this file.
1 // LIC// ====================================================================
2 // LIC// This file forms part of oomph-lib, the object-oriented,
3 // LIC// multi-physics finite-element library, available
4 // LIC// at http://www.oomph-lib.org.
5 // LIC//
6 // LIC// Copyright (C) 2006-2022 Matthias Heil and Andrew Hazel
7 // LIC//
8 // LIC// This library is free software; you can redistribute it and/or
9 // LIC// modify it under the terms of the GNU Lesser General Public
10 // LIC// License as published by the Free Software Foundation; either
11 // LIC// version 2.1 of the License, or (at your option) any later version.
12 // LIC//
13 // LIC// This library is distributed in the hope that it will be useful,
14 // LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // LIC// Lesser General Public License for more details.
17 // LIC//
18 // LIC// You should have received a copy of the GNU Lesser General Public
19 // LIC// License along with this library; if not, write to the Free Software
20 // LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 // LIC// 02110-1301 USA.
22 // LIC//
23 // LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24 // LIC//
25 // LIC//====================================================================
26 #ifndef OOMPH_SEGREGATED_FSI_SOLVER
27 #define OOMPH_SEGREGATED_FSI_SOLVER
28 
29 
30 #include "../generic/problem.h"
31 #include "../generic/geom_objects.h"
32 #include "../generic/mesh.h"
33 
34 namespace oomph
35 {
36  //===============================================================
38  //===============================================================
40  {
41  public:
44  : Niter(0),
45  CPU_total(0.0),
48  Tol_achieved(0.0),
49  Has_converged(false)
50  {
51  }
52 
55 
57  unsigned& niter()
58  {
59  return Niter;
60  }
61 
63  double& cpu_total()
64  {
65  return CPU_total;
66  }
67 
72  {
73  return Essential_cpu_total;
74  }
75 
81  {
83  }
84 
86  double& tol_achieved()
87  {
88  return Tol_achieved;
89  }
90 
92  bool has_converged() const
93  {
94  return Has_converged;
95  }
96 
99  {
100  Has_converged = true;
101  }
102 
105  {
106  Has_converged = false;
107  }
108 
109  private:
111  unsigned Niter;
112 
114  double CPU_total;
115 
120 
126 
128  double Tol_achieved;
129 
132  };
133 
134 
138 
139 
140  //=======================================================================
142  //=======================================================================
144  {
145  public:
147  SegregatedSolverError(const bool& ran_out_of_iterations = false)
148  {
149  Ran_out_of_iterations = ran_out_of_iterations;
150  }
151 
155  };
156 
157 
161 
162 
163  //===============================================================
166  //===============================================================
167  class SegregatableFSIProblem : public virtual Problem
168  {
169  protected:
173 
177 
181 
182  public:
192  {
193  // Use pointwise Aitken extrapolation?
194  Use_pointwise_aitken = false;
195 
196  // Default: No under-relaxation
197  Omega_relax = 1.0;
198 
199  // Don't use of Irons and Tuck's extrapolation for solid values
201 
202  // Start using pointwise Aitken immediately
204 
205  // By default we don't recheck convergence
207 
208  // Default solve type is full solve
210 
211  // Convergence criterion
213 
214  // Convergence tolerance (as in global Newton solver)
216 
217  // Doc max. global residual during iteration?
218  Doc_max_global_residual = false;
219 
220  // Max. number of Picard iterations
221  Max_picard = 50;
222 
223  // Pointer to Mesh containing only fluid elements -- the elements in this
224  // Mesh will be excluded from the assembly process when
225  // the solid problem is solved
226  Fluid_mesh_pt = 0;
227 
228  // Pointer to Mesh containing only solid elements -- the elements in this
229  // mesh will be excluded from the assembly process when
230  // the fluid problem is solved
231  Solid_mesh_pt = 0;
232 
233  // Initialise timer that allows doc of iteration/cpu time
234  T_ref = clock();
236 
238  Timer_has_been_halted = false;
239  }
240 
243 
257  virtual void identify_fluid_and_solid_dofs(Vector<Data*>& fluid_data_pt,
258  Vector<Data*>& solid_data_pt,
259  Mesh*& fluid_mesh_pt,
260  Mesh*& solid_mesh_pt) = 0;
261 
274  const bool& full_setup_of_fluid_and_solid_dofs = true);
275 
281 
287 
288 
295 
296 
305  const bool& shift_values);
306 
307 
311  {
313  Convergence_tolerance = tol;
314  }
315 
321  {
324  }
325 
329  {
331  Convergence_tolerance = tol;
332  }
333 
339  {
342  }
343 
347  {
349  Convergence_tolerance = tol;
350  }
351 
357  {
360  }
361 
362 
366  void enable_pointwise_aitken(const unsigned& pointwise_aitken_start)
367  {
368  Pointwise_aitken_start = pointwise_aitken_start;
369  Use_pointwise_aitken = true;
370  }
371 
376  {
377  Use_pointwise_aitken = true;
378  }
379 
382  {
383  Use_pointwise_aitken = false;
384  }
385 
391  void enable_under_relaxation(const double& omega = 1.0)
392  {
393  Omega_relax = omega;
394  }
395 
398  {
400  }
401 
404  {
406  }
407 
410  {
414  };
415 
416 
419  {
423  };
424 
429  void get_solid_change(double& rms_change,
430  double& max_change,
431  double& rms_norm);
432 
436  void store_solid_dofs();
437 
439  void reset_timer()
440  {
442  T_ref = clock();
443  Timer_has_been_halted = false;
444  }
445 
446 
451  {
452  T_ref = clock();
453  Timer_has_been_halted = false;
454  }
455 
456 
460  void halt_timer()
461  {
463  {
464  T_spent_on_actual_solve += double(clock() - T_ref) / CLOCKS_PER_SEC;
465  Timer_has_been_halted = true;
466  }
467  }
468 
469 
472  {
473  halt_timer();
474  double time = T_spent_on_actual_solve;
475  restart_timer();
476  return time;
477  }
478 
479 
480  protected:
483 
488 
491 
495 
498 
501 
503  unsigned Max_picard;
504 
507 
509  void restore_fluid_dofs();
510 
512  void pin_solid_dofs();
513 
515  void restore_solid_dofs();
516 
517 
520 
525 
529 
534 
538 
542 
547 
552 
555 
558 
561 
565 
568 
569  private:
571  void extrapolate_solid_data();
572 
575  void under_relax_solid();
576 
587 
598 
600  void pin_fluid_dofs();
601 
604  double Omega_relax;
605 
609 
612 
616  clock_t T_ref;
617 
622 
625  };
626 
627 } // namespace oomph
628 
629 
630 #endif
Definition: mesh.h:67
Object that collates convergence data of Picard iteration.
Definition: segregated_fsi_solver.h:40
void set_solver_converged()
Set the flag to indicate that the solver has converged.
Definition: segregated_fsi_solver.h:98
void set_solver_not_converged()
Set the flag to indicate that the solver has not converged.
Definition: segregated_fsi_solver.h:104
unsigned & niter()
Number of iterations performed.
Definition: segregated_fsi_solver.h:57
double & cpu_for_global_residual()
Definition: segregated_fsi_solver.h:80
double & tol_achieved()
Final tolerance achieved by the iteration.
Definition: segregated_fsi_solver.h:86
PicardConvergenceData()
Constructor initialises all data.
Definition: segregated_fsi_solver.h:43
~PicardConvergenceData()
Empty destructor.
Definition: segregated_fsi_solver.h:54
bool Has_converged
Flag to indicate if the solver has converged.
Definition: segregated_fsi_solver.h:131
bool has_converged() const
Flag to indicate if the solver has converged.
Definition: segregated_fsi_solver.h:92
double Essential_cpu_total
Definition: segregated_fsi_solver.h:119
double & essential_cpu_total()
Definition: segregated_fsi_solver.h:71
unsigned Niter
Number of iterations performed.
Definition: segregated_fsi_solver.h:111
double CPU_total
Total CPU time for segregated solve.
Definition: segregated_fsi_solver.h:114
double CPU_for_global_residual
Definition: segregated_fsi_solver.h:125
double & cpu_total()
Total CPU time for segregated solve.
Definition: segregated_fsi_solver.h:63
double Tol_achieved
Final tolerance achieved by the iteration.
Definition: segregated_fsi_solver.h:128
Definition: problem.h:151
double Newton_solver_tolerance
Definition: problem.h:596
double & time()
Return the current value of continuous time.
Definition: problem.cc:11531
Definition: segregated_fsi_solver.h:168
convergence_criteria
Enumerated flags for convergence criteria.
Definition: segregated_fsi_solver.h:410
@ Assess_convergence_based_on_relative_solid_change
Definition: segregated_fsi_solver.h:412
@ Assess_convergence_based_on_absolute_solid_change
Definition: segregated_fsi_solver.h:411
@ Assess_convergence_based_on_max_global_residual
Definition: segregated_fsi_solver.h:413
void enable_pointwise_aitken(const unsigned &pointwise_aitken_start)
Definition: segregated_fsi_solver.h:366
void enable_irons_and_tuck_extrapolation()
Use Irons and Tuck extrapolation for solid dofs.
Definition: segregated_fsi_solver.h:397
bool Recheck_convergence_after_pointwise_aitken
Have we just done a pointwise Aitken step.
Definition: segregated_fsi_solver.h:567
void extrapolate_solid_data()
Extrapolate solid data and update fluid mesh during unsteady run.
Definition: segregated_fsi_solver.cc:39
Vector< std::vector< bool > > Solid_value_is_pinned
Definition: segregated_fsi_solver.h:537
void setup_segregated_solver(const bool &full_setup_of_fluid_and_solid_dofs=true)
Definition: segregated_fsi_solver.cc:1111
void use_only_fluid_elements()
Definition: segregated_fsi_solver.cc:138
Vector< Mesh * > Orig_sub_mesh_pt
Backup for the pointers to the submeshes in the original problem.
Definition: segregated_fsi_solver.h:554
bool Use_pointwise_aitken
Use pointwise Aitken extrapolation?
Definition: segregated_fsi_solver.h:490
Vector< Data * > Fluid_data_pt
Definition: segregated_fsi_solver.h:524
bool Use_irons_and_tuck_extrapolation
Definition: segregated_fsi_solver.h:608
solve_type
Enumerated flags to indicate which solve is taking place.
Definition: segregated_fsi_solver.h:419
@ Full_solve
Definition: segregated_fsi_solver.h:420
@ Fluid_solve
Definition: segregated_fsi_solver.h:421
@ Solid_solve
Definition: segregated_fsi_solver.h:422
virtual void actions_after_segregated_solve()
Definition: segregated_fsi_solver.h:176
void restart_timer()
Definition: segregated_fsi_solver.h:450
void assess_convergence_based_on_max_global_residual()
Definition: segregated_fsi_solver.h:320
void use_only_solid_elements()
Definition: segregated_fsi_solver.cc:115
void pin_fluid_dofs()
Pin fluid dofs.
Definition: segregated_fsi_solver.cc:153
void disable_pointwise_aitken()
Disable the use of pointwise Aitken extrapolation.
Definition: segregated_fsi_solver.h:381
Mesh * Solid_mesh_pt
Definition: segregated_fsi_solver.h:551
void enable_pointwise_aitken()
Definition: segregated_fsi_solver.h:375
unsigned Pointwise_aitken_start
Definition: segregated_fsi_solver.h:494
void reset_timer()
Reset timer.
Definition: segregated_fsi_solver.h:439
void rebuild_monolithic_mesh()
Rebuild global mesh for monolithic discretisation.
Definition: segregated_fsi_solver.cc:87
void halt_timer()
Definition: segregated_fsi_solver.h:460
virtual void identify_fluid_and_solid_dofs(Vector< Data * > &fluid_data_pt, Vector< Data * > &solid_data_pt, Mesh *&fluid_mesh_pt, Mesh *&solid_mesh_pt)=0
void restore_solid_dofs()
Restore pinned status of solid dofs.
Definition: segregated_fsi_solver.cc:229
Vector< double > Previous_solid_value
Definition: segregated_fsi_solver.h:541
double R_irons_and_tuck
Irons and Tuck relaxation factor.
Definition: segregated_fsi_solver.h:560
void enable_under_relaxation(const double &omega=1.0)
Definition: segregated_fsi_solver.h:391
void disable_irons_and_tuck_extrapolation()
Do not use Irons and Tuck extrapolation for solid dofs.
Definition: segregated_fsi_solver.h:403
double T_spent_on_actual_solve
Definition: segregated_fsi_solver.h:621
clock_t T_ref
Definition: segregated_fsi_solver.h:616
PicardConvergenceData segregated_solve()
Definition: segregated_fsi_solver.cc:538
void assess_convergence_based_on_max_global_residual(const double &tol)
Definition: segregated_fsi_solver.h:310
Vector< double > Del_irons_and_tuck
Vector of changes in Irons and Tuck under-relaxation.
Definition: segregated_fsi_solver.h:557
PicardConvergenceData steady_segregated_solve()
Definition: segregated_fsi_solver.cc:964
int Convergence_criterion
Convergence criterion (enumerated flag)
Definition: segregated_fsi_solver.h:611
void pointwise_aitken_extrapolate()
Do pointwise Aitken extrapolation for solid.
Definition: segregated_fsi_solver.cc:490
void under_relax_solid()
Under-relax solid, either by classical relaxation or by Irons & Tuck.
Definition: segregated_fsi_solver.cc:354
void assess_convergence_based_on_absolute_solid_change(const double &tol)
Definition: segregated_fsi_solver.h:328
Vector< Vector< double > > Pointwise_aitken_solid_value
Definition: segregated_fsi_solver.h:564
unsigned Max_picard
Max. number of Picard iterations.
Definition: segregated_fsi_solver.h:503
Vector< std::vector< bool > > Fluid_value_is_pinned
Definition: segregated_fsi_solver.h:528
virtual ~SegregatableFSIProblem()
Empty virtual destructor.
Definition: segregated_fsi_solver.h:242
SegregatableFSIProblem()
Definition: segregated_fsi_solver.h:191
bool Doc_max_global_residual
Doc maximum global residual during iteration? (default: false)
Definition: segregated_fsi_solver.h:506
PicardConvergenceData unsteady_segregated_solve(const double &dt)
Definition: segregated_fsi_solver.cc:1033
bool Timer_has_been_halted
boolean flag to indicate if timer has been halted
Definition: segregated_fsi_solver.h:624
void restore_fluid_dofs()
Restore pinned status of fluid dofs.
Definition: segregated_fsi_solver.cc:176
virtual void actions_before_segregated_convergence_check()
Definition: segregated_fsi_solver.h:180
void assess_convergence_based_on_relative_solid_change(const double &tol)
Definition: segregated_fsi_solver.h:346
Vector< Data * > Solid_data_pt
Definition: segregated_fsi_solver.h:533
void pin_solid_dofs()
Pin solid dofs.
Definition: segregated_fsi_solver.cc:206
void get_solid_change(double &rms_change, double &max_change, double &rms_norm)
Definition: segregated_fsi_solver.cc:303
int Pointwise_aitken_counter
Definition: segregated_fsi_solver.h:487
double Convergence_tolerance
Convergence tolerance for Picard iteration.
Definition: segregated_fsi_solver.h:500
Mesh * Fluid_mesh_pt
Definition: segregated_fsi_solver.h:546
double t_spent_on_actual_solve()
Total elapsed time since start of solve.
Definition: segregated_fsi_solver.h:471
double Omega_relax
Definition: segregated_fsi_solver.h:604
void assess_convergence_based_on_absolute_solid_change()
Definition: segregated_fsi_solver.h:338
virtual void actions_before_segregated_solve()
Definition: segregated_fsi_solver.h:172
int Solve_type
Solve that is taking place (enumerated flag)
Definition: segregated_fsi_solver.h:497
void store_solid_dofs()
Definition: segregated_fsi_solver.cc:260
void assess_convergence_based_on_relative_solid_change()
Definition: segregated_fsi_solver.h:356
A class to handle errors in the Segregated solver.
Definition: segregated_fsi_solver.h:144
SegregatedSolverError(const bool &ran_out_of_iterations=false)
Default constructor, does nothing.
Definition: segregated_fsi_solver.h:147
bool Ran_out_of_iterations
Definition: segregated_fsi_solver.h:154
Vector::Scalar omega(const Vector &t, const Vector &s, RealScalar angle)
Definition: IDRS.h:36
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10