TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Sch_CN_iteratif.h
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Sch_CN_iteratif_included
17#define Sch_CN_iteratif_included
18
19#include <Schema_Temps_base.h>
20#include <TRUSTTabs_forward.h>
21
22/*! @brief Time scheme alternating a half implicit Euler step and a half LeapFrog step.
23 *
24 * The implicit solve is iterative (fixed-point).
25 * The time step is computed as the product of the explicit stability time step by a facsec.
26 * The facsec is adjusted automatically so that the solve converges in a predefined number of iterations.
27 * Characteristics of each iteration are written to the file dt_CN.
28 *
29 * The solve is governed by 4 parameters (default values in parentheses):
30 * * seuil (1e-3) : convergence threshold. The lower, the more accurate the solve.
31 * * facsec_max (2) : maximum facsec value (to avoid instabilities and capture physical phenomena).
32 * * niter_min (2) : minimum number of iterations. Below this, iteration continues even if convergence seems reached.
33 * * niter_avg (3) : target number of iterations to reach convergence.
34 * * niter_max (6) : number of iterations beyond which a smaller facsec is retried.
35 *
36 * Advice for choosing facsec adjustment parameters:
37 * * Choose seuil based on desired precision.
38 * * Choose niter_min: 2 guarantees a second-order time scheme.
39 * * If seeking a steady state, choose seuil_statio >= seuil.
40 * * Choose facsec_max based on the physical phenomena to capture.
41 * * Start by testing with a large value of niter_avg. Observe the number of iterations.
42 * It will plateau at a maximum before dropping back.
43 * * Choose niter_avg at 2/3 of this maximum, and niter_max at approximately 4/3 or double.
44 *
45 *
46 * @sa Schema_Temps_base
47 */
49{
50 Declare_instanciable(Sch_CN_iteratif);
51
52public :
53
54 ////////////////////////////////
55 // //
56 // Scheme characteristics //
57 // //
58 ////////////////////////////////
59
60 int nb_valeurs_temporelles() const override;
61 int nb_valeurs_futures() const override;
62 double temps_futur(int i) const override;
63 double temps_defaut() const override;
64
65 /////////////////////////////////////////
66 // //
67 // End of scheme characteristics //
68 // //
69 /////////////////////////////////////////
70
71 bool initTimeStep(double dt) override;
72 bool iterateTimeStep(bool& converged) override;
73
75
76 void completer() override {}
77 void set_param(Param& titi) const override;
78
79protected :
80
82
83 virtual bool convergence(const DoubleTab& u0, const DoubleTab& up1, const DoubleTab& delta, int p) const;
84 virtual bool divergence(const DoubleTab& u0, const DoubleTab& up1, const DoubleTab& delta, int p) const;
85 virtual void ajuster_facsec(type_convergence cv);
86
87 virtual bool iterateTimeStepOnEquation(int i,bool& converged);
88
89 double seuil=1.e-3; // To determine convergence
90 int niter_min=2; // Minimum number of iterations (before, continue to iterate)
91 int niter_max=6; // Maximum number of iterations (after, considered as not convergent)
92 int niter_avg=3; // Average number of iterations wanted (facsec adjusted to fit that number)
93 double facsec_max=2; // Maximum facsec (not to miss the physics)
94
95 // Used internally.
96 int iteration = -1; // Number of iterations done for the current time step.
97 double last_facsec = -100.; // facsec at the beginning of time step resolution,
98 // to avoid changing facsec several times for the same time step.
99};
100
101#endif
class Equation_base The role of an equation is the calculation of one or more fields....
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
Time scheme alternating a half implicit Euler step and a half LeapFrog step.
virtual bool iterateTimeStepOnEquation(int i, bool &converged)
Computes one iteration of the resolution on equation i.
bool initTimeStep(double dt) override
int faire_un_pas_de_temps_eqn_base(Equation_base &) override
virtual bool divergence(const DoubleTab &u0, const DoubleTab &up1, const DoubleTab &delta, int p) const
Indicates whether the iterative computation has diverged.
bool iterateTimeStep(bool &converged) override
Calculate the U(n+1) unknown for each equation (if solved) of the problem with the selected time sche...
virtual bool convergence(const DoubleTab &u0, const DoubleTab &up1, const DoubleTab &delta, int p) const
Indicates whether the iterative computation has converged.
int nb_valeurs_futures() const override
Returns the number of future time values.
void set_param(Param &titi) const override
int nb_valeurs_temporelles() const override
Returns the number of time values to keep.
double temps_futur(int i) const override
Returns the time at the i-th future value.
double temps_defaut() const override
Returns the time that fields should use when calling valeurs().
void completer() override
virtual void ajuster_facsec(type_convergence cv)
class Schema_Temps_base