TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Pred_Cor.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 <Domaine_Cl_dis_base.h>
17#include <Operateur_Conv.h>
18#include <Pred_Cor.h>
19
20Implemente_instanciable(Pred_Cor,"Schema_Predictor_Corrector",Schema_Temps_base);
21// XD schema_predictor_corrector schema_temps_base schema_predictor_corrector INHERITS_BRACE This is the
22// XD_CONT predictor-corrector scheme (second order). It is more accurate and economic than MacCormack scheme. It gives
23// XD_CONT best results with a second ordre convective scheme like quick, centre (VDF).
24
26{
28}
29
31{
33}
34
35
36////////////////////////////////
37// //
38// Schema characteristics //
39// //
40////////////////////////////////
41
42
43/*! @brief Returns the number of temporal values to keep.
44 *
45 * Here: n and n+1, so 2.
46 *
47 */
49{
50 return 2 ;
51}
52
53/*! @brief Returns the number of future temporal values.
54 *
55 * Here: n+1, so 1.
56 *
57 */
59{
60 return 1 ;
61}
62
63/*! @brief Returns the time at the i-th future value.
64 *
65 * Here: t(n+1)
66 *
67 */
68double Pred_Cor::temps_futur(int i) const
69{
70 assert(i==1);
71 return temps_courant()+pas_de_temps();
72}
73
74/*! @brief Returns the time that fields must return when valeurs() is called.
75 *
76 * Here: t(n+1)
77 *
78 */
80{
81 return temps_courant()+pas_de_temps();
82}
83
84/////////////////////////////////////////
85// //
86// End of schema characteristics //
87// //
88/////////////////////////////////////////
89
90
92{
93 DoubleTab& xi=eqn.inconnue().valeurs();
94 DoubleTab& xipls1=eqn.inconnue().futur();
95
96 DoubleTab dudt(xi);
97
98 // PREDICTOR step
99
101
102 // Advance the wheel so that operators use the fields at the future time
103 eqn.inconnue().avancer();
104 eqn.derivee_en_temps_inco(dudt);
105
106 // Xi+1=Xi+dt_*dX/dt(Xi)
107 xipls1 = dudt;
108 xipls1 *= dt_;
109 xipls1 += xi;
110
111 xipls1.echange_espace_virtuel();
112
113 // CORRECTOR step
114 DoubleTab dudtpls1(xipls1);
115 eqn.derivee_en_temps_inco(dudtpls1);
116 eqn.inconnue().reculer();
117
118 dudtpls1 += dudt;
119 dudtpls1 *= 0.5;
120
121 // Xi+1=Xi+dt_*0.5*(dX/dt(Xi)+dX/dt(Xi+1))
122 xipls1 = dudtpls1 ;
123 xipls1 *= dt_;
124 xipls1 += xi ;
125
127 update_critere_statio(dudtpls1, eqn);
128
129 return 1;
130}
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.
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.
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
class Pred_Cor The scheme must be used with an alternating spatial scheme.
Definition Pred_Cor.h:28
int faire_un_pas_de_temps_eqn_base(Equation_base &) override
Definition Pred_Cor.cpp:91
double temps_defaut() const override
Returns the time that fields must return when valeurs() is called.
Definition Pred_Cor.cpp:79
double temps_futur(int i) const override
Returns the time at the i-th future value.
Definition Pred_Cor.cpp:68
int nb_valeurs_futures() const override
Returns the number of future temporal values.
Definition Pred_Cor.cpp:58
int nb_valeurs_temporelles() const override
Returns the number of temporal values to keep.
Definition Pred_Cor.cpp:48
class Schema_Temps_base
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
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")