TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Schema_Adams_Moulton_order_3.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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
17/*! @brief class Schema_Adams_Moulton_order_3
18 *
19 */
20
21#include <Schema_Adams_Moulton_order_3.h>
22#include <Equation_base.h>
23#include <Probleme_base.h>
24#include <Probleme_Couple.h>
25#include <Milieu_base.h>
26#include <Param.h>
27#include <communications.h>
28#include <Matrice_Morse.h>
29
30Implemente_instanciable(Schema_Adams_Moulton_order_3,"Schema_Adams_Moulton_order_3",Schema_Adams_Moulton_base);
31// XD schema_adams_moulton_order_3 schema_implicite_base schema_adams_moulton_order_3 INHERITS_BRACE not_set
32// XD attr facsec_max floattant facsec_max OPT Maximum ratio allowed between time step and stability time returned by
33// XD_CONT CFL condition. The initial ratio given by facsec keyword is changed during the calculation with the implicit
34// XD_CONT scheme but it couldn\'t be higher than facsec_max value.NL2 Warning: Some implicit schemes do not permit high
35// XD_CONT facsec_max, example Schema_Adams_Moulton_order_3 needs facsec=facsec_max=1. NL2 Advice:NL2 The calculation
36// XD_CONT may start with a facsec specified by the user and increased by the algorithm up to the facsec_max limit. But
37// XD_CONT the user can also choose to specify a constant facsec (facsec_max will be set to facsec value then). Faster
38// XD_CONT convergence has been seen and depends on the kind of calculation: NL2-Hydraulic only or thermal hydraulic
39// XD_CONT with forced convection and low coupling between velocity and temperature (Boussinesq value beta low), facsec
40// XD_CONT between 20-30NL2-Thermal hydraulic with forced convection and strong coupling between velocity and
41// XD_CONT temperature (Boussinesq value beta high), facsec between 90-100 NL2-Thermohydralic with natural convection,
42// XD_CONT facsec around 300NL2 -Conduction only, facsec can be set to a very high value (1e8) as if the scheme was
43// XD_CONT unconditionally stableNL2These values can also be used as rule of thumb for initial facsec with a facsec_max
44// XD_CONT limit higher.
45
46
47
48// printOn()
49/////
50
52{
54}
55
56//// readOn
57//
58
60{
62}
63
64//On calcule la valeur moyenne entre borne_inf et borne_sup du polynome de lagrange de degre 2 :
65//- qui vaut 0 en a et en b
66//- qui vaut 1 en c
67static double integrate_lagrangian_basis(double a, double b, double c, double borne_inf, double borne_sup)
68{
69 double result = 0.;
70 double scaling = (c-a)*(c-b);
71 double dt = borne_sup-borne_inf;
72
73 double prod = a*b;
74 double sum = -0.5*(a+b);
75
76 double tmp_sup = borne_sup*(prod+borne_sup*(borne_sup/3.+sum));
77 double tmp_inf = borne_inf*(prod+borne_inf*(borne_inf/3.+sum));
78
79 result = tmp_sup-tmp_inf;
80 result/=(scaling*dt);
81
82 return result;
83}
84
85
86/*! @brief Renvoie le nombre de valeurs temporelles a conserver.
87 *
88 * 3 valeurs temporelles : tn-1, tn, tn+1
89 * 1 valeur de plus pour le fonctionnement des algorithmes de l'implicite
90 *
91 */
96
98{
99 return 1;
100}
101
103{
104 return 1;
105}
106
107void Schema_Adams_Moulton_order_3::compute_adams_moulton_coefficients(double time_step, const DoubleTab& times) const
108{
109 if (nb_pas_dt()<100 && limpr() && (facteur_securite_pas()>1.0 || facsec_max_>1.0))
110 {
111 Cerr << finl;
112 Cerr << "********************* Warning (printed only on the first 100 time steps) ************************"<< finl;
113 Cerr << "The Adams Moulton order 3 scheme is recommended with a facsec and facsec_max set to 1.0 or lower."<< finl;
114 Cerr << "*************************************************************************************************"<< finl;
115 // See $TRUST_ROOT/tests/Reference/Schema_Adams_Moulton_order_3 test case.
116 }
117 assert(times.size_array() == 3); //past, present and future times, stored in ascending order inside "times" table
118
119 if ( adams_moulton_coefficients_.size_array() != 3)
120 {
121 adams_moulton_coefficients_.resize(3,RESIZE_OPTIONS::NOCOPY_NOINIT);
122 }
123
124 double past_time = times[0];
125 double present_time = times[1];
126 double future_time = times[2];
127
128 adams_moulton_coefficients_[0] = integrate_lagrangian_basis(present_time,future_time,past_time,present_time,future_time);
129 adams_moulton_coefficients_[1] = integrate_lagrangian_basis(past_time,future_time,present_time,present_time,future_time);
131}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
void compute_adams_moulton_coefficients(double time_step, const DoubleTab &times) const override
int nb_valeurs_temporelles() const override
Renvoie le nombre de valeurs temporelles a conserver.
int limpr() const
Renvoie 1 s'il y a lieu d'effectuer une impression (cf dt_impr) Renvoie 0 sinon.
int nb_pas_dt() const
Renvoie le nombre de pas de temps effectues.
double facteur_securite_pas() const
Renvoie le facteur de securite ou multiplicateur de delta_t.
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ size_array() const