TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Multi_Sch_ThHyd.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 <Multi_Sch_ThHyd.h>
17#include <Probleme_base.h>
18#include <Navier_Stokes_std.h>
19#include <Param.h>
20
21Implemente_instanciable(Multi_Sch_ThHyd,"Multi_Schema_ThHyd",Schema_Temps_base);
22
24{
26}
27
29{
31}
32
33/*! @brief Returns the number of time values to keep.
34 *
35 * Here: the max of the two schemes used.
36 *
37 */
39{
40 return std::max(sch_ns_->nb_valeurs_temporelles(),sch_scalaires_->nb_valeurs_temporelles());
41}
42
43/*! @brief Returns the number of future time values.
44 *
45 * Here: the value common to the two schemes used.
46 *
47 */
49{
50 int n=sch_ns_->nb_valeurs_futures();
51 assert (n==sch_scalaires_->nb_valeurs_futures());
52 return n;
53}
54
55/*! @brief Returns the time at the i-th future value.
56 *
57 * Here: the value common to the two schemes used.
58 *
59 */
61{
62 double t=sch_ns_->temps_futur(i);
63 assert(t==sch_scalaires_->temps_futur(i));
64 return t;
65}
66
67/*! @brief Returns the time that fields should return when calling valeurs().
68 *
69 * Here: the value common to the two schemes used.
70 *
71 */
73{
74 double t=sch_ns_->temps_defaut();
75 assert(t==sch_scalaires_->temps_defaut());
76 return t;
77}
78
79/////////////////////////////////////////
80// //
81// End of scheme characteristics //
82// //
83/////////////////////////////////////////
84
85
87{
88 // OC: I don't understand these lines:
89 /* double dts=dt_;
90 dt_=0;
91 mettre_a_jour();
92 nb_pas_dt_--;
93 dt_=dts;
94 */
95
96 // OC: I would rather have a "completer" method of this kind:
97
98 Schema_Temps_base& le_sch_ns = sch_ns_.valeur();
99 le_sch_ns.set_temps_init()=temps_init();
100 le_sch_ns.set_temps_max()=temps_max();
101 le_sch_ns.set_temps_courant()=temps_courant();
102 le_sch_ns.set_nb_pas_dt()=nb_pas_dt();
103 le_sch_ns.set_nb_pas_dt_max()=nb_pas_dt_max();
104 le_sch_ns.set_dt_min()=pas_temps_min();
105 le_sch_ns.set_dt_max()=pas_temps_max();
106 le_sch_ns.set_dt_sauv()=temps_sauv();
107 le_sch_ns.set_dt_impr()=temps_impr();
108 le_sch_ns.set_facsec()=facteur_securite_pas();
109 le_sch_ns.set_seuil_statio()=seuil_statio();
114 le_sch_ns.set_dt()=pas_de_temps();
115 le_sch_ns.set_mode_dt_start()=mode_dt_start();
118 le_sch_ns.set_lu()=lu();
119
120 Schema_Temps_base& le_sch_scalaires = sch_scalaires_.valeur();
121 le_sch_scalaires.set_temps_init()=temps_init();
122 le_sch_scalaires.set_temps_max()=temps_max();
123 le_sch_scalaires.set_temps_courant()=temps_courant();
124 le_sch_scalaires.set_nb_pas_dt()=nb_pas_dt();
125 le_sch_scalaires.set_nb_pas_dt_max()=nb_pas_dt_max();
126 le_sch_scalaires.set_dt_min()=pas_temps_min();
127 le_sch_scalaires.set_dt_max()=pas_temps_max();
128 le_sch_scalaires.set_dt_sauv()=temps_sauv();
129 le_sch_scalaires.set_dt_impr()=temps_impr();
130 le_sch_scalaires.set_facsec()=facteur_securite_pas();
131 le_sch_scalaires.set_seuil_statio()=seuil_statio();
132 le_sch_scalaires.set_stationnaire_atteint()=isStationary();
133 le_sch_scalaires.set_diffusion_implicite()=diffusion_implicite();
136 le_sch_scalaires.set_dt()=pas_de_temps();
137 le_sch_scalaires.set_mode_dt_start()=mode_dt_start();
140 le_sch_scalaires.set_lu()=lu();
141}
142
144{
146 sch_ns_->mettre_a_jour();
147 sch_scalaires_->mettre_a_jour();
148 return 1;
149}
151{
152 param.ajouter("nb_ss_pas_dt",&nb_ss_pas_dt_);
153 param.ajouter("Schema_Temps_NS",&sch_ns_);
154 param.ajouter("Schema_Temps_scalaires",&sch_scalaires_);
156}
157
158
159/*! @brief Performs one explicit Euler time step on the given equation.
160 *
161 * @param eqn The equation to advance by one time step.
162 * @return Always returns 1.
163 */
165{
166 // double dtok=dt_;
167 if(sub_type(Navier_Stokes_std, eqn))
168 {
169 sch_ns_->set_dt()=pas_de_temps();
170 sch_ns_->faire_un_pas_de_temps_eqn_base(eqn);
171 facteur_securite_pas()=sch_ns_->facteur_securite_pas();
172 }
173 else
174 {
175 //sch_scalaires.preparer_pas_temps();
176 sch_scalaires_->set_dt()=pas_de_temps();
177 sch_scalaires_->faire_un_pas_de_temps_eqn_base(eqn);
178 }
179 set_stationnaire_atteint()=sch_ns_->isStationary() && sch_scalaires_->isStationary() ;
180 return 1;
181}
182
184{
185 Probleme_base& prob=pb_base();
186 double temps=temps_courant_+dt_;
187 int nb_eqn=pb_base().nombre_d_equations();
188 for(int i=nb_eqn-1; i>-1; i--)
189 {
190 Equation_base& eqn_i=prob.equation(i);
191 if (eqn_i.equation_non_resolue())
192 {
193 Cout<< "====================================================" << finl;
194 Cout<< eqn_i.que_suis_je()<<" equation is not solved."<<finl;
195 Cout<< "====================================================" << finl;
196 // Compute the derivative once to obtain the boundary fluxes
197 if (eqn_i.schema_temps().nb_pas_dt()==0)
198 {
199 DoubleTab inconnue_valeurs(eqn_i.inconnue().valeurs());
200 eqn_i.derivee_en_temps_inco(inconnue_valeurs);
201 }
202 }
203 else
204 {
205 eqn_i.domaine_Cl_dis().mettre_a_jour(temps);
207 }
208 }
209 converged=true;
210 return true;
211
212}
213
214/*! @brief Corrects the time step so that dt_min <= dt <= dt_max.
215 *
216 * @return Returns the result of corriger_pas_temps from the base class.
217 */
219{
220 bool ok=sch_ns_->corriger_dt_calcule(dt);
221 ok = ok && sch_scalaires_->corriger_dt_calcule(dt);
223 return ok;
224}
225
226
227/*! @brief Call to the underlying object. Changes the current time.
228 *
229 * @param t The new value of the current time.
230 */
232{
233 sch_ns_->changer_temps_courant(t);
234 sch_scalaires_->changer_temps_courant(t);
235
237}
238
239/*! @brief Call to the underlying object. Returns 1 if the calculation should be stopped for various reasons:
240 *
241 * - the final time has been reached
242 * - the maximum number of time steps has been exceeded
243 * - the stationary state has been reached
244 * - a file-based stop indicator
245 * Returns 0 otherwise.
246 *
247 * @return 1 if the calculation should stop, 0 otherwise.
248 */
250{
251 int ls2 = sch_ns_->stop();
252 int ls3 = sch_scalaires_->stop();
253
254 return (ls2 | ls3 | Schema_Temps_base::stop());
255}
256
257/*! @brief Call to the underlying object. Prints the time scheme to an output stream (if applicable).
258 *
259 * @param os The output stream.
260 */
262{
263 sch_ns_->imprimer(os);
264 sch_scalaires_->imprimer(os);
265
267}
DoubleTab & valeurs() override
Returns the array of field values at the current time.
virtual void mettre_a_jour(double temps)
Performs a time update of all boundary conditions.
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 int equation_non_resolue() const
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.
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
Time scheme that splits the time step between a Navier-Stokes sub-scheme and a scalar sub-scheme.
int faire_un_pas_de_temps_eqn_base(Equation_base &) override
Performs one explicit Euler time step on the given equation.
void completer() override
void imprimer(Sortie &) const override
Call to the underlying object. Prints the time scheme to an output stream (if applicable).
int nb_valeurs_futures() const override
Returns the number of future time values.
int mettre_a_jour() override
Updates the current time (t+=dt) and the number of time steps performed (nb_pas_dt_++).
int stop() const override
Call to the underlying object. Returns 1 if the calculation should be stopped for various reasons:
int nb_valeurs_temporelles() const override
Returns the number of time values to keep.
void set_param(Param &titi) const override
bool iterateTimeStep(bool &converged) override
Calculate the U(n+1) unknown for each equation (if solved) of the problem with the selected time sche...
double temps_defaut() const override
Returns the time that fields should return when calling valeurs().
bool corriger_dt_calcule(double &) const override
Corrects the time step so that dt_min <= dt <= dt_max.
double temps_futur(int i) const override
Returns the time at the i-th future value.
void changer_temps_courant(const double) override
Call to the underlying object. Changes the current time.
Navier_Stokes_std This class carries the terms of the momentum equation.
friend class Sortie
Definition Objet_U.h:70
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
class Probleme_base It is a Probleme_U that is not a coupling.
virtual int nombre_d_equations() const =0
virtual const Equation_base & equation(int) const =0
class Schema_Temps_base
int diffusion_implicite() const
Returns 1 if the time scheme has been read with diffusion_implicite.
bool & set_indice_nb_pas_dt_max_atteint()
virtual bool isStationary() const
Returns 1 if during the last time step, the problem has not evolved.
double temps_courant() const
Returns the current time.
virtual bool corriger_dt_calcule(double &dt) const
Corrects the computed time step passed as parameter and verifies it is not "too" small (< dt_min_).
double temps_sauv() const
Returns a reference to the checkpoint time interval.
double temps_impr() const
Returns a reference to the output time interval.
virtual void set_param(Param &titi) const override
double dt_
Computation time step.
double pas_temps_max() const
Returns the maximum time step.
double temps_max() const
Returns a reference to the maximum time.
virtual void changer_temps_courant(const double)
Changes the current time.
int indice_tps_final_atteint() const
virtual int stop() const
Returns 1 if it is necessary to stop the computation for various reasons:
int & set_niter_max_diffusion_implicite()
Probleme_base & pb_base()
double pas_temps_min() const
Returns the minimum time step.
double pas_de_temps() const
Returns the current time step (delta_t).
double seuil_diffusion_implicite() const
virtual void imprimer(Sortie &os) const
Prints the time step to an output stream if appropriate.
double seuil_statio() const
Returns a reference to the stationarity threshold.
int niter_max_diffusion_implicite() const
int nb_pas_dt() const
Returns the number of time steps performed.
double mode_dt_start() const
double temps_init() const
Returns the initial time.
virtual int mettre_a_jour()
Updates the current time (t+=dt) and the number of time steps performed (nb_pas_dt_++).
double & set_seuil_diffusion_implicite()
int indice_nb_pas_dt_max_atteint() const
bool & set_indice_tps_final_atteint()
int nb_pas_dt_max() const
Returns a reference to the maximum number of time steps.
double facteur_securite_pas() const
Returns the safety factor or multiplier of delta_t.
Base class for output streams.
Definition Sortie.h:52