TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Schema_Euler_Semi_Implicite.cpp
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#include <Schema_Euler_Semi_Implicite.h>
17
18Implemente_instanciable(Schema_Euler_Semi_Implicite,"Schema_euler_semi_implicite|Scheme_euler_semi_implicit",Schema_Euler_Implicite);
19// XD Schema_euler_semi_implicite schema_implicite_base Schema_euler_semi_implicite INHERITS_BRACE Semi-implicit Euler
20// XD_CONT time-integration scheme (parent of Schema_Cahn_Hilliard).
21// XD attr theta floattant theta REQ Semi-implicit weight (0 = fully explicit, 1 = fully implicit).
22
24{
25 s << "----------> Coefficient theta for semi-implicit scheme = " << theta_ << finl;
27}
28
30{
32 Cout << finl;
33 Cout << "Semi-implicit Euler time scheme (theta interpolation) is chosen."<< finl;
34 Cout << "----------> Coefficient theta for semi-implicit scheme = " << theta_ << finl;
35
36 return s;
37}
38
44
45/*! @brief Renvoie TRUE si le schéma semi-implicite est totalement explicite (important, car theta = 0 pose problème)
46 * @return (bool)
47 */
49{
50 return abs(theta_) < 1.e-16;
51}
52
54{
55 Cerr << "[Schema_Euler_Semi_Implicite] Coupled problems are not taken into account yet." << finl;
56 exit();
57 return 1;
58}
59
61{
62 DoubleTab& passe = eqn.inconnue().passe();
63 DoubleTab& present = eqn.inconnue().valeurs();
64 DoubleTab& futur = eqn.inconnue().futur();
65 int compteur = 0, ok = 1;
66 bool convergence_eqn = false;
67 passe = present;
68 // futur=present;
69 // sert pour la pression et les couplages
71 //present=futur;
72
73 // Cas semi-implicite
74 if (!is_explicit())
75 {
76 compteur=0;
77 Cout << finl;
78 while ((!convergence_eqn)&&(compteur<nb_ite_max))
79 {
80 compteur++;
81 Cout<<"==================================================================================" << finl;
82 Cout<<"Schema_Euler_Semi_Implicite: Implicit iteration " << compteur << " on the "<<eqn.que_suis_je() << " equation of the problem "<< eqn.probleme().le_nom()<< " :" <<finl;
83 Cout<<"==================================================================================" << finl;
84 const DoubleTab& inut=futur;
85 // On résout pour un demi-pas de temps
86 convergence_eqn=le_solveur->iterer_eqn(eqn, inut, present, theta_*dt_, compteur, ok);
87 if (!ok) return 0; //si echec total
88 futur=present;
90 present=futur;
91 }
92 DoubleTrav passe_with_theta(passe);
93 passe_with_theta = passe;
94 passe_with_theta *= (1 - theta_);
95 present -= passe_with_theta;
96 present/=theta_;
97 update_critere_statio(present, eqn);
98 present = passe;
99 }
100 else
101 {
102 Cout<<"==================================================================================" << finl;
103 Cout<<"Schema_Euler_Semi_Implicite: Explicit case on the "<<eqn.que_suis_je() << " equation of the problem "<< eqn.probleme().le_nom()<< " :" <<finl;
104 Cout<<"==================================================================================" << finl;
105
106 DoubleTrav dudt(futur); // just for initializing the array structure ... Trav is highly recommanded!! Otherwise we allocate at each time step!!
107
108 eqn.inconnue().avancer();
109 eqn.derivee_en_temps_inco(dudt);
110 eqn.inconnue().reculer();
111
112 // Un+1=Un+dt_*dU/dt
113 futur = dudt;
114 futur *= dt_;
115 futur += present;
116
118 update_critere_statio(dudt, eqn);
119
120 }
121
122 return 1;
123}
DoubleTab & futur(int i=1) override
Renvoie les valeurs du champs a l'instant t+i.
DoubleTab & passe(int i=1) override
Renvoie les valeurs du champs a l'instant t-i.
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
Champ_Inc_base & avancer(int i=1)
Avance le pointeur courant de i pas de temps, dans la liste des valeurs temporelles conservees.
Champ_Inc_base & reculer(int i=1)
Recule le pointeur courant de i pas de temps, dans la liste des valeurs temporelles conservees.
virtual void imposer_cond_lim(Champ_Inc_base &, double)=0
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Equation_base Le role d'une equation est le calcul d'un ou plusieurs champs....
virtual const Champ_Inc_base & inconnue() const =0
virtual DoubleTab & derivee_en_temps_inco(DoubleTab &)
Returns the time derivative of the unknown I of the equation: dI/dt = M-1*(sum(operators(I) + sources...
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Renvoie le domaine des conditions aux limite discretisee associee a l'equation.
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
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
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
@ REQUIRED
Definition Param.h:115
classe Probleme_Couple C'est la classe historique de couplage de TRUST.
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Probleme_U.h:109
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
void set_param(Param &) const override
class Schema_Euler_Semi_Implicite Il herite de schema Euler implicite et porte un solveur,...
void set_param(Param &) const override
int faire_un_pas_de_temps_eqn_base(Equation_base &) override
int faire_un_pas_de_temps_pb_couple(Probleme_Couple &, int &ok) override
bool is_explicit()
Renvoie TRUE si le schéma semi-implicite est totalement explicite (important, car theta = 0 pose prob...
double temps_courant() const
Renvoie le temps courant.
double dt_
Pas de temps de calcul.
double pas_de_temps() const
Renvoie le pas de temps (delta_t) courant.
void update_critere_statio(const DoubleTab &tab_critere, Equation_base &equation)
//Actualisation de stationnaire_atteint_ et residu_ (critere residu_<seuil_statio_)
Classe de base des flux de sortie.
Definition Sortie.h:52