TrioCFD 1.9.9_beta
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
Returns field values at instant t+i.
DoubleTab & passe(int i=1) override
Returns field values at instant t-i.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
Champ_Inc_base & avancer(int i=1)
Advances the current pointer by i time steps, in the list of kept temporal values.
Champ_Inc_base & reculer(int i=1)
Rewinds the current pointer by i time steps, in the list of kept temporal values.
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
class Equation_base The role of an equation is the calculation of one or more fields....
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()
Returns the discretized boundary condition domain associated with the equation.
Probleme_base & probleme()
Returns the problem associated with the equation.
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
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
Probleme_Couple This is the historical coupling class of TRUST.
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Probleme_U.h:109
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
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
Returns the current time.
double dt_
Computation time step.
double pas_de_temps() const
Returns the current time step (delta_t).
void update_critere_statio(const DoubleTab &tab_critere, Equation_base &equation)
Updates stationnaire_atteint_ and residu_ (criterion: residu_ < seuil_statio_).
Base class for output streams.
Definition Sortie.h:52