TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Schema_Explicite_Multi_TimeStep_base.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#include <Schema_Explicite_Multi_TimeStep_base.h>
17#include <Domaine_Cl_dis_base.h>
18#include <Equation_base.h>
19#include <TRUSTTrav.h>
20#include <Debog.h>
21
22Implemente_base(Schema_Explicite_Multi_TimeStep_base,"Schema_Explicite_Multi_TimeStep_base",Schema_Temps_base);
23
25{
27}
28
30{
32}
33
34////////////////////////////////
35// //
36// Schema characteristics //
37// //
38////////////////////////////////
39
40/*! @brief Returns the number of future temporal values.
41 *
42 * Here: n+1, so 1.
43 *
44 */
49
50/*! @brief Returns the time at the i-th future value.
51 *
52 * Here: t(n+1)
53 *
54 */
56{
57 assert(i==1);
58 return temps_courant()+pas_de_temps();
59}
60
61/*! @brief Returns the time that fields must return when valeurs() is called.
62 *
63 * Here: t(n+1)
64 *
65 */
70
71/////////////////////////////////////////
72// //
73// End of schema characteristics //
74// //
75/////////////////////////////////////////
76
77/*! @brief Performs an explicit Euler time step on the equation passed as parameter.
78 *
79 * @param (Equation_base& eqn) the equation to advance by one time step
80 * @return (int) always returns 1
81 */
83{
85
86 double time_step = pas_de_temps(); //tn+1-tn
87 double inv_time_step = 1/time_step;
88
89 // Un
90 const DoubleTab& present = eqn.inconnue().valeurs();
91 Debog::verifier("Schema_Explicite_Multi_TimeStep_base::faire_un_pas_de_temps_eqn_base, present",present);
92
93 // Un+1
94 DoubleTab& futur = eqn.inconnue().futur();
95
96 // used for the pressure and inter-problem couplings
98
99 DoubleTab dudt(futur);
100 /*
101 if (nb_pas_dt() > nb_pas_dt_seuil())
102 {
103 Cout <<"Use of "<<que_suis_je()<<" scheme"<<finl;
104 }
105 else
106 {
107 Cout <<"Use of explicit Euler scheme for time step "<<nb_pas_dt()<<" in "<<que_suis_je()<<" scheme"<<finl;
108 } */
109
110 // Compute du/dt
111 eqn.derivee_en_temps_inco(dudt);
112
113 // Contribution of the unknown at time n
114 futur = dudt;
115 futur *= time_step;
116 futur += present;
117
118 dudt=futur;
119 dudt-=present;
120 dudt*=inv_time_step;
121
122 Debog::verifier("Schema_Explicite_Multi_TimeStep_base::faire_un_pas_de_temps_eqn_base, dudt",dudt);
123
125 update_critere_statio(dudt, eqn);
127
128 //Debog::verifier("Schema_Explicite_Multi_TimeStep_base::faire_un_pas_de_temps_eqn_base, futur fin",futur);
129 return 1;
130}
131
133{
134 Nom equation_name(eqn.que_suis_je());
135 bool authorized = true;
136
137 authorized &= (bool) equation_name.find("FT");
138 authorized &= (bool) equation_name.find("Front_Tracking");
139 authorized &= (bool) equation_name.find("QC");
140 authorized &= (bool) equation_name.find("Quasi_Compressible");
141
142 if (!authorized)
143 {
144 Cerr<<"Error in "<<que_suis_je()<<"::authorized_equation()"<<finl;
145 Cerr<<"Equation "<<equation_name<<" is not allowed with "<<que_suis_je()<<" time scheme"<<finl;
147 }
148}
149
151{
152 Nom equation_name(eqn.que_suis_je());
153 bool authorized = true;
154
155 authorized &= (bool) equation_name.find("FT");
156 authorized &= (bool) equation_name.find("Front_Tracking");
157 authorized &= (bool) equation_name.find("QC");
158 authorized &= (bool) equation_name.find("Quasi_Compressible");
159
160 if (!authorized)
161 {
162 Cerr<<"Error in "<<que_suis_je()<<"::authorized_equation()"<<finl;
163 Cerr<<"Equation "<<equation_name<<" is not allowed with "<<que_suis_je()<<" time scheme"<<finl;
165 }
166}
DoubleTab & futur(int i=1) override
Returns field values at instant t+i.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
static void verifier(const char *const msg, double)
Definition Debog.cpp:21
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.
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
virtual int find(const char *const n) const
Definition Nom.cpp:309
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
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
double temps_defaut() const override
Returns the time that fields must return when valeurs() is called.
int faire_un_pas_de_temps_eqn_base(Equation_base &) override
Performs an explicit Euler time step on the equation passed as parameter.
int nb_valeurs_futures() const override
Returns the number of future temporal values.
double temps_futur(int i) const override
Returns the time at the i-th future value.
class Schema_Temps_base
double temps_courant() const
Returns the current time.
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
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")