TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Leap_frog.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 <Equation_base.h>
18#include <Leap_frog.h>
19
20Implemente_instanciable(Leap_frog,"Leap_frog",Schema_Temps_base);
21// XD leap_frog schema_temps_base leap_frog INHERITS_BRACE This is the leap-frog scheme.
22
24{
26}
27
29{
31}
32
33////////////////////////////////
34// //
35// Caracteristiques du schema //
36// //
37////////////////////////////////
38
39
40/*! @brief Renvoie le nombre de valeurs temporelles a conserver.
41 *
42 * Ici : n-2, n-1, n, et n+1, donc 4.
43 *
44 */
46{
47 return 4;
48}
49
50/*! @brief Renvoie le nombre de valeurs temporelles futures.
51 *
52 * Ici : n+1, donc 1.
53 *
54 */
56{
57 return 1 ;
58}
59
60/*! @brief Renvoie le le temps a la i-eme valeur future.
61 *
62 * Ici : t(n+1)
63 *
64 */
65double Leap_frog::temps_futur(int i) const
66{
67 assert(i==1);
68 return temps_courant()+pas_de_temps();
69}
70
71/*! @brief Renvoie le le temps le temps que doivent rendre les champs a l'appel de valeurs()
72 *
73 * Ici : t(n+1)
74 *
75 */
77{
78 return temps_courant()+pas_de_temps();
79}
80
81/////////////////////////////////////////
82// //
83// Fin des caracteristiques du schema //
84// //
85/////////////////////////////////////////
86
87
88/*! @brief Effectue un pas de temps Leap_frog, sur l'equation passee en parametre.
89 *
90 * @param (Equation_base& eq) l'equation que l'on veut faire avancer d'un pas de temps
91 * @return (int) renvoie toujours 1
92 */
94{
95 // EXEMPLE POUR UN SCHEMA EXPLICITE UTILISANT U(n) et U(n+1)
96 // Un+1=Un+dt*F
97 // Un
98 DoubleTab& present = eq.inconnue().valeurs();
99
100 // Un+1
101 DoubleTab& futur = eq.inconnue().futur();
102
103 // Un+1=F
104 eq.derivee_en_temps_inco(futur);
106
107 // ECRIRE ICI LE CALCUL de U(n+1) EN FONCTION DE U(n) ET DE derivee
108 // futur*=dt; Un+1=dt*F
109 // futur+=present; Un+1=Un+dt*F
110 // SI IL S'AGISSAIT D'UN SCHEMA QUI FAIT INTERVENIR U(n-1)
111 // if ((nb_pas_dt_>4) && ((nb_pas_dt_ % 10) != 0)) {
112 // if (nb_pas_dt_>4) {
113 if ((nb_pas_dt_>4) && ((nb_pas_dt_ % 10) != 0))
114 {
115 DoubleTab& passe = eq.inconnue().passe();
116 double gamma=0.2;
117 DoubleTab& passe2 = eq.inconnue().passe(2);
118 DoubleTab& correcteur=passe;
119 correcteur*=(1.-2.*gamma);
120 correcteur.ajoute(gamma, present, VECT_REAL_ITEMS);
121 correcteur.ajoute(gamma, passe2, VECT_REAL_ITEMS);
122 futur*=(2*dt_);
123 futur+=correcteur;
124 }
125 else
126 {
127 futur*=dt_;
128 futur+=present;
129 }
130
132 DoubleTab tmp(futur);
133 tmp -= present;
134 tmp /= dt_;
135 update_critere_statio(tmp, eq);
137
138 return 1;
139}
140
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.
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.
classe Leap_frog Cette classe represente un schema en temps Leap_Frog.
Definition Leap_frog.h:33
double temps_defaut() const override
Renvoie le le temps le temps que doivent rendre les champs a l'appel de valeurs().
Definition Leap_frog.cpp:76
int nb_valeurs_futures() const override
Renvoie le nombre de valeurs temporelles futures.
Definition Leap_frog.cpp:55
int faire_un_pas_de_temps_eqn_base(Equation_base &) override
Effectue un pas de temps Leap_frog, sur l'equation passee en parametre.
Definition Leap_frog.cpp:93
double temps_futur(int i) const override
Renvoie le le temps a la i-eme valeur future.
Definition Leap_frog.cpp:65
int nb_valeurs_temporelles() const override
Renvoie le nombre de valeurs temporelles a conserver.
Definition Leap_frog.cpp:45
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
class Schema_Temps_base
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
void ajoute(_SCALAR_TYPE_ alpha, const TRUSTVect &y, Mp_vect_options opt=VECT_ALL_ITEMS)
Definition TRUSTVect.tpp:52
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")