TrioCFD 1.9.9_beta
TrioCFD documentation
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 call to Schema_Temps_base::printOn(Sortie&). Writes the time scheme to an output stream.
32 *
33 * @param s The output stream.
34 * @return The modified output stream.
35 */
37{
39}
40
41
42/*! @brief Reads the time scheme from an input stream.
43 *
44 * Simple call to Schema_Temps_base::readOn(Entree&).
45 *
46 * @param s The input stream.
47 * @return The modified input stream.
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
Returns field values at instant t-i.
void mettre_a_jour(double temps) override
Performs a time update of the unknown field.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
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....
Solveur_Masse_base & solv_masse()
Returns the mass solver associated with the equation.
virtual const Champ_Inc_base & inconnue() const =0
Matrice_Base class - Base class of the matrix hierarchy.
Navier_Stokes_std This class carries the terms of the momentum equation.
Champ_Inc_base & pression()
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
Base class for Backward Differentiation Formula (BDF) time schemes.
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
Returns the current time step (delta_t).
int nb_pas_dt() const
Returns the number of time steps performed.
virtual Matrice_Base & ajouter_masse(double dt, Matrice_Base &matrice, int penalisation=1) const
Base class for output streams.
Definition Sortie.h:52