TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Schema_Adams_Moulton_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
17/*! @brief class Schema_Adams_Moulton_base
18 *
19 */
20
21#include <Schema_Adams_Moulton_base.h>
22#include <Equation_base.h>
23#include <Probleme_base.h>
24#include <Probleme_Couple.h>
25#include <Milieu_base.h>
26#include <Param.h>
27#include <communications.h>
28#include <Matrice_Morse.h>
29
30Implemente_base(Schema_Adams_Moulton_base,"Schema_Adams_Moulton_base",Schema_Implicite_Multi_TimeStep_base);
31
32
33// printOn()
34/////
35
37{
39}
40
41//// readOn
42//
43
45{
47}
48
50{
52 // Loop on equations
53 for (int i=0; i<pb_base().nombre_d_equations(); i++)
55}
56
58{
59 eqn.inconnue().Champ_base::changer_temps(temps);
60 eqn.derivee_en_temps().Champ_base::changer_temps(temps);
61 return temps;
62}
63
65{
66 DoubleTab& time_derivative = eqn.derivee_en_temps().futur();
67 time_derivative = data; //here "data" is supposed to contain "vpoint" table
68 modifier_second_membre_full_impl(eqn,time_derivative);
69}
70
72{
73 eqn.inconnue().mettre_a_jour(temps);
75}
76
77void Schema_Adams_Moulton_base::compute_coefficients(double time_step, const DoubleTab& times) const
78{
80}
81
82void Schema_Adams_Moulton_base::add_multi_timestep_data(const Equation_base& eqn, Matrice_Base& mat_morse, DoubleTab& secmem) const
83{
84 Equation_base& eqn_bis = ref_cast_non_const(Equation_base,eqn);
85 double time_step = pas_de_temps();
86 double effective_time_step = -1.;
87 double scaling = -1.;
88
89 // Remark for "pen" interger : we do not penalize matrices and right members even in the case
90 // of Dirichlet or Symetrie boundary conditions
91 int pen = 0;
92 int offset = 0;
93 int i = 0;
94
95 effective_time_step = coefficients()[nb_valeurs_passees()+1] * time_step;
96 scaling = 1./coefficients()[nb_valeurs_passees()+1];
97
98 //Modification due to pressure gradient
99 DoubleTab correction(eqn.inconnue().valeurs());
100
101 correction = 0.;
102 eqn_bis.corriger_derivee_expl(correction);
103 correction *= (scaling-1.);
104 secmem += correction;
105
106 //Modification due to present time and past times
107 DoubleTab dudt(eqn.inconnue().passe(1)); //due to Initialiser_Champs() offset
108 DoubleTab tmp(dudt);
109
110 for (i=0; i<nb_valeurs_passees()+1; ++i)
111 {
112 offset = nb_valeurs_passees()-i; //present time if offset==0 else past times
113 tmp = eqn.derivee_en_temps().passe(offset);
114 tmp *= coefficients()[i] * time_step;
115 dudt += tmp;
116 }
117
118 eqn.solv_masse().ajouter_masse(effective_time_step,secmem,dudt,pen);
119 eqn.solv_masse().ajouter_masse(effective_time_step,mat_morse,pen);
120}
121
122//To get du/dt table without pressure gradient and influences of past and present times
124{
125 Equation_base& eqn_bis = ref_cast_non_const(Equation_base,eqn);
126
127 DoubleTab correction(secmem);
128 correction=0.;
129 eqn_bis.corriger_derivee_expl(correction);
130 eqn.solv_masse().appliquer(correction);
131 secmem-=correction; //on enleve le gradient de pression
132
134 {
135 int i = 0;
136 int offset = 0;
137 double scaling = 1./coefficients()[nb_valeurs_passees()+1];
138
139 for (i=0; i<nb_valeurs_passees()+1; ++i )
140 {
141 offset = nb_valeurs_passees() - i;
142 correction = eqn.derivee_en_temps().passe(offset);//present time if i==nb_valeurs_passees() else past times
143 correction *= coefficients()[i];
144 secmem -= correction;
145 }
146
147 secmem *= scaling;
148 }
149}
150
151//To take into account pressure constraint
153{
154 //Nothing to do
155}
156
157//To take into account pressure constraint
159{
160 //Nothing to do
161}
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.
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....
void set_calculate_time_derivative(int i)
Solveur_Masse_base & solv_masse()
Renvoie le solveur de masse associe a l'equation.
virtual const Champ_Inc_base & inconnue() const =0
virtual DoubleTab & corriger_derivee_expl(DoubleTab &)
virtual const Champ_Inc_base & derivee_en_temps() const
Classe Matrice_Base Classe de base de la hierarchie des matrices.
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 Probleme_base C'est un Probleme_U qui n'est pas un couplage.
virtual int nombre_d_equations() const =0
virtual const Equation_base & equation(int) const =0
void modify_equation_parameters(Equation_base &eqn, DoubleTab &stored_parameters) override
void modifier_second_membre_full_impl(const Equation_base &eqn, DoubleTab &secmem) override
virtual void compute_adams_moulton_coefficients(double time_step, const DoubleTab &times) const =0
void add_multi_timestep_data(const Equation_base &eqn, Matrice_Base &mat_morse, DoubleTab &secmem) const override
const DoubleTab & coefficients() const override
void update_time_derivative(Equation_base &eqn, const DoubleTab &data) override
double changer_temps(Equation_base &eqn, const double temps) 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 store_equation_parameters(Equation_base &eqn, DoubleTab &stored_parameters) override
void associer_pb(const Probleme_base &) override
virtual int nb_pas_dt_seuil() const =0
virtual int nb_valeurs_passees() const =0
virtual void associer_pb(const Probleme_base &)
Probleme_base & pb_base()
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
virtual DoubleTab & appliquer(DoubleTab &) const
renvoie appliquer_impl(x/coeffient_temporelle) si on a un coefficient temporel sinon renvoie applique...
Classe de base des flux de sortie.
Definition Sortie.h:52