TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Schema_Backward_Differentiation_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_Backward_Differentiation_base.h>
17
18#include <Equation_base.h>
19#include <Navier_Stokes_std.h>
20#include <Probleme_base.h>
21#include <Probleme_Couple.h>
22#include <Milieu_base.h>
23#include <Param.h>
24
25#include <communications.h>
26#include <Matrice_Morse.h>
27
28Implemente_base(Schema_Backward_Differentiation_base,"Schema_Backward_Differentiation_base",Schema_Implicite_Multi_TimeStep_base);
29
30
31/*! @brief Simple appel a: Schema_Temps_base::printOn(Sortie& ) Ecrit le schema en temps sur un flot de sortie.
32 *
33 * @param (Sortie& s) un flot de sortie
34 * @return (Sortie&) le flot de sortie modifie
35 */
37{
39}
40
41
42/*! @brief Lit le schema en temps a partir d'un flot d'entree.
43 *
44 * Simple appel a: Schema_Temps_base::readOn(Entree& )
45 *
46 * @param (Entree& s) un flot d'entree
47 * @return (Entree&) le flot d'entree modifie
48 */
50{
52}
53
55{
56 eqn.inconnue().Champ_base::changer_temps(temps);
57 return temps;
58}
59
61{
62 //Nothing to do
63}
64
69
70void Schema_Backward_Differentiation_base::compute_coefficients(double time_step, const DoubleTab& times) const
71{
73}
74
75//To take into account pressure constraint
77{
79 {
80 if (sub_type(Navier_Stokes_std,eqn))
81 {
82 Navier_Stokes_std& navier_stokes = ref_cast(Navier_Stokes_std,eqn);
83 stored_parameters = navier_stokes.pression().valeurs(); //store pressure at time tn
84 }
85 }
86}
87
88//To take into account pressure constraint
90{
92 {
93 if (sub_type(Navier_Stokes_std,eqn))
94 {
95 Navier_Stokes_std& navier_stokes = ref_cast(Navier_Stokes_std,eqn);
96
97 DoubleTab& pressure = navier_stokes.pression().valeurs(); //pressure at time tnplus1 that is to say P(n+1)
98 DoubleTab delta_pressure(pressure);
99
100 delta_pressure -= stored_parameters; //contains P(n+1) - P(n)
101 delta_pressure /= coefficients()[nb_valeurs_passees()+1]; //take into account time scheme coefficient
102 pressure = stored_parameters;
103 pressure += delta_pressure;
104 }
105 }
106}
107
109{
110 double time_step = pas_de_temps();
111 double effective_time_step = -1.;
112
113 // Remark for "pen" interger : we do not penalize matrices and right members even in the case
114 // of Dirichlet or Symetrie boundary conditions
115 int pen = 0;
116 int offset = 0;
117 int i = 0;
118
119 effective_time_step = coefficients()[nb_valeurs_passees()+1] * time_step;
120
121 //Modification due to present time and past times
122 DoubleTab dudt(eqn.inconnue().valeurs());
123 DoubleTab tmp(dudt);
124
125 dudt = 0.;
126 for (i=0; i<nb_valeurs_passees()+1; ++i)
127 {
128 offset = nb_valeurs_passees()-i + 1;//due to Initialiser_Champs() offset
129 tmp = eqn.inconnue().passe(offset);
130 tmp *= coefficients()[i] ;
131 dudt += tmp; //past times and present time if i==nb_valeurs_passees()
132 }
133
134 eqn.solv_masse().ajouter_masse(effective_time_step,secmem,dudt,pen);
135 eqn.solv_masse().ajouter_masse(effective_time_step,mat_morse,pen);
136}
137
138
DoubleTab & passe(int i=1) override
Renvoie les valeurs du champs a l'instant t-i.
void mettre_a_jour(double temps) override
Effectue une mise a jour en temps du champ inconnue.
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
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....
Solveur_Masse_base & solv_masse()
Renvoie le solveur de masse associe a l'equation.
virtual const Champ_Inc_base & inconnue() const =0
Classe Matrice_Base Classe de base de la hierarchie des matrices.
classe Navier_Stokes_std Cette classe porte les termes de l'equation de la dynamique
Champ_Inc_base & pression()
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
classe Schema_Backward_Differentiation_base
void store_equation_parameters(Equation_base &eqn, DoubleTab &stored_parameters) override
double changer_temps(Equation_base &eqn, const double temps) override
virtual void compute_backward_differentiation_coefficients(double time_step, const DoubleTab &times) const =0
void modify_equation_parameters(Equation_base &eqn, DoubleTab &stored_parameters) override
void add_multi_timestep_data(const Equation_base &eqn, Matrice_Base &mat_morse, DoubleTab &secmem) const override
void mettre_a_jour_equation(Equation_base &eqn, const double temps) override
void compute_coefficients(double time_step, const DoubleTab &times) const override
void update_time_derivative(Equation_base &eqn, const DoubleTab &data) override
virtual int nb_pas_dt_seuil() const =0
virtual int nb_valeurs_passees() const =0
double pas_de_temps() const
Renvoie le pas de temps (delta_t) courant.
int nb_pas_dt() const
Renvoie le nombre de pas de temps effectues.
virtual Matrice_Base & ajouter_masse(double dt, Matrice_Base &matrice, int penalisation=1) const
Classe de base des flux de sortie.
Definition Sortie.h:52