TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Schema_Adams_Bashforth_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_Adams_Bashforth_base.h>
17#include <Equation_base.h>
18#include <Probleme_base.h>
19#include <TRUSTTrav.h>
20
21Implemente_base(Schema_Adams_Bashforth_base,"Schema_Adams_Bashforth_base",Schema_Explicite_Multi_TimeStep_base);
22
24{
26}
27
29{
31}
32
34{
36 // Loop on equations
37 for (int i=0; i<pb_base().nombre_d_equations(); i++)
39}
40
41void Schema_Adams_Bashforth_base::compute_coefficients(double time_step, const DoubleTab& times)
42{
44}
45
47{
49 {
50
51 const Equation_base& eqn_bis = ref_cast(Equation_base,eqn);
52 int i = 0;
53 int offset = 0;
54 double time_step = pas_de_temps(); //tn+1-tn
55
56 DoubleTab times(nb_valeurs_temporelles());
57
58 //Building of a time-in-ascending-order table
60
61 for (i=0; i<nb_valeurs_passees(); ++i)
62 {
63 offset = nb_valeurs_passees()-i;
64 times[i] = eqn_bis.inconnue().recuperer_temps_passe(offset); //past
65 }
66 times[nb_valeurs_passees()] = eqn_bis.inconnue().recuperer_temps_futur(0); //present
67 times[nb_valeurs_passees()+1] = eqn_bis.inconnue().recuperer_temps_futur(1); //future
68
69 compute_coefficients(time_step,times);
70
71 //Modification due to present time and past times
72 secmem*=coefficients()[nb_valeurs_passees()]; //present time
73
74 DoubleTrav dudt(eqn.inconnue().valeurs());
75 DoubleTrav tmp(dudt);
76 // Compute sum(coeff*dudt)
77 for (i=0; i<nb_valeurs_passees(); ++i)
78 {
79 offset = nb_valeurs_passees()-i;
80 tmp = eqn.derivee_en_temps().passe(offset);
81 tmp *= coefficients()[i];
82 dudt += tmp; //past time
83 }
84 // secmem+=Mdu/dt
85 eqn.solv_masse().ajouter_masse(1.,secmem,dudt,0);
86 }
87}
88
DoubleTab & passe(int i=1) override
Returns field values at instant t-i.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
double recuperer_temps_passe(int i=1) const
Returns the time of the i-th past field.
double recuperer_temps_futur(int i=1) const
Returns the time of the i-th future field.
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....
void set_calculate_time_derivative(int i)
Solveur_Masse_base & solv_masse()
Returns the mass solver associated with the equation.
virtual const Champ_Inc_base & inconnue() const =0
virtual const Champ_Inc_base & derivee_en_temps() const
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 Probleme_base It is a Probleme_U that is not a coupling.
virtual int nombre_d_equations() const =0
virtual const Equation_base & equation(int) const =0
void compute_coefficients(double time_step, const DoubleTab &times) override
void modifier_second_membre(const Equation_base &eqn, DoubleTab &secmem) override
virtual void compute_adams_bashforth_coefficients(double time_step, const DoubleTab &times)=0
void associer_pb(const Probleme_base &) override
const DoubleTab & coefficients() const override
virtual int nb_valeurs_passees() const =0
virtual int nb_pas_dt_seuil() const =0
virtual void associer_pb(const Probleme_base &)
Probleme_base & pb_base()
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 int nb_valeurs_temporelles() const =0
virtual Matrice_Base & ajouter_masse(double dt, Matrice_Base &matrice, int penalisation=1) const
Base class for output streams.
Definition Sortie.h:52