16#include <Convection_Diffusion_Fluide_Dilatable_base.h>
17#include <Convection_Diffusion_Fluide_Dilatable_Proto.h>
18#include <Navier_Stokes_Fluide_Dilatable_base.h>
19#include <Fluide_Weakly_Compressible.h>
20#include <Convection_Diffusion_std.h>
21#include <EcritureLectureSpecial.h>
22#include <Op_Conv_negligeable.h>
23#include <Discretisation_base.h>
24#include <Schema_Temps_base.h>
25#include <Champ_Uniforme.h>
26#include <Probleme_base.h>
27#include <Matrice_Morse.h>
28#include <TRUST_2_PDI.h>
34#include <Perf_counters.h>
58 op_conv.
ajouter(ch_unite_->valeurs(), Div);
115 if (diffusion_implicite)
117 Cerr <<
"Error: diffusion implicit not implemented in Convection_Diffusion_Chaleur_Fluide_Dilatable_base" << finl;
132 tab_divide_any_shape(derivee, array);
141 DoubleTrav convection(derivee);
147 tab_multiply_any_shape(convection, inco);
157 tab_divide_any_shape(convection, tab_rho);
161 DoubleTrav mass_source_term(derivee);
162 mass_source_term = 0.0;
179 if (!is_expl && has_mass_flux)
180 derivee += mass_source_term;
182 if (diffusion_implicite)
185 DoubleTrav secmem(derivee);
190 secmem += mass_source_term ;
207 derivee += mass_source_term;
217 Matrice_Morse& matrice_morse,
const DoubleTab& inco, DoubleTab& resu)
231 char* theValue = getenv(
"TRUST_TEST_OPERATEUR_IMPLICITE");
232 if (theValue !=
nullptr) test_op=2;
235 char* theValue = getenv(
"TRUST_TEST_OPERATEUR_IMPLICITE_BLOQUANT");
236 if (theValue !=
nullptr) test_op=1;
258 DoubleTrav tab_derivee2(resu);
263 ToDo_Kokkos(
"critical");
264 const auto& tab1 = matrice_morse.
get_tab1();
266 for (
int som=0 ; som<n ; som++)
268 double inv_rho = 1. / tab_rho(som);
269 for (
auto k=tab1(som)-1; k<tab1(som+1)-1; k++)
272 matrice_morse(som,som)+=tab_derivee2(som)*inv_rho;
279 CDoubleArrView rhoCp =
static_cast<const ArrOfDouble&
>(eqn.
get_champ(
"rho_cp_comme_T").valeurs()).view_ro();
280 CDoubleArrView rho =
static_cast<const ArrOfDouble&
>(tab_rho).view_ro();
281 CDoubleArrView derivee2 =
static_cast<const ArrOfDouble&
>(tab_derivee2).view_ro();
282 auto tab1 = matrice_morse.
get_tab1().view_ro();
284 DoubleArrView coeff = matrice_morse.
get_set_coeff().view_wo();
286 Matrice_Morse_View matrice;
287 matrice.set(matrice_morse);
288 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), range_1D(0, n), KOKKOS_LAMBDA(
const int som)
290 double inv_rho = 1. / rho(som);
291 if (is_not_generic) inv_rho = 1.;
292 double rapport = 1. / rhoCp(som);
295 for (
auto k=tab1(som)-1; k<tab1(som+1)-1; k++)
296 coeff(k)= (coeff(k)*inv_rho+coeff_diffusif(k)*rapport);
299 matrice.add(som,som,derivee2(som)*inv_rho);
301 end_gpu_timer(__KERNEL_NAME__);
305 Cerr<<
"The implicit algorithm is available only for perfect gas."<<finl;
316 DoubleTrav diff(resu), conv(resu);
323 if (is_cp_unif) Cp=tab_cp(0,0);
325 for (
int som=0 ; som<n ; som++)
327 if (!is_cp_unif) Cp=tab_cp(som);
328 double inv_rho=1./tab_rho(som);
330 double rapport=1./(tab_rho(som)*Cp);
331 diff(som)=resu(som)-conv(som)*inv_rho-diff(som)*rapport;
334 double err=mp_max_abs_vect(diff);
335 Cerr << eqn.
que_suis_je() <<
" : Assembly error = " << err << finl;
339 DoubleVect& diff_=diff;
340 Cerr<<
" size "<< diff_.
size()<<finl;
341 for (
int i=0; i<diff_.
size(); i++)
342 if (std::fabs(diff_(i))>1e-5) Cerr<<i <<
" "<< diff_(i)<<
" "<<finl;
346 Cerr<<
" problem max cell "<<imin_array(diff)<<
" or " <<imax_array(diff)<<finl;
356 Matrice_Morse *mat = matrices.count(nom_inco)?matrices.at(nom_inco):
nullptr;
363 DoubleTab secmem_tmp(secmem);
365 statistics().end_count(STD_COUNTERS::ajouter_blocs);
367 statistics().begin_count(STD_COUNTERS::source_terms,statistics().get_last_opened_counter_level()+1);
368 for (
int i = 0; i < eqn.
sources().size(); i++)
369 eqn.
sources()(i)->ajouter_blocs({{nom_inco, &mat_diff}}, secmem_tmp, semi_impl);
370 statistics().end_count(STD_COUNTERS::source_terms);
372 statistics().begin_count(STD_COUNTERS::ajouter_blocs,statistics().get_last_opened_counter_level()+1);
385 for (
int som=0 ; som<n ; som++)
387 double inv_rho = 1. / tab_rho(som);
388 for (
auto k=tab1(som)-1; k<tab1(som+1)-1; k++) coeff(k)= (coeff(k)*inv_rho+coeff_diffusif(k)*inv_rho);
390 if(mat) (*mat)(som,som)+=secmem(som)*inv_rho;
398 for (
int som=0 ; som<n ; som++)
400 double inv_rho = 1. / tab_rho(som);
402 double rapport = 1. / rhoCp(som);
405 for (
auto k=tab1(som)-1; k<tab1(som+1)-1; k++) coeff(k)= (coeff(k)*inv_rho+coeff_diffusif(k)*rapport);
408 if(mat) (*mat)(som,som) += secmem(som)*inv_rho;
413 Cerr<<
"The implicit algorithm is available only for perfect gas."<<finl;
434 int nb_dim = p_tab->valeurs().nb_dim();
435 YAML_data pressure(name,
"double", nb_dim);
436 data.push_back(pressure);
444 int bytes=0,a_faire,special;
452 p_tab->
nommer(
"Pression_EOS");
455 Cerr <<
"ATTENTION : For a parallel calculation, the field Pression_EOS is not saved in xyz format ... " << finl;
473 ArrOfDouble garbage( p_th_tab.
nb_dim() );
499 p_tab->
nommer(
"Pression_EOS");
502 Cerr <<
"Error in Convection_Diffusion_Espece_Binaire_WC::reprendre !" << finl;
503 Cerr <<
"Use the sauv file to resume a parallel WC calculation (Pression_EOS is required) ... " << finl;
510 Nom field_tag(p_tab->le_nom());
517 avancer_fichier_with_syno(is,field_tag,field_tag_syno);
521 avancer_fichier(is,field_tag);
523 p_tab->reprendre(is);
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
DoubleTab & futur(int i=1) override
Returns field values at instant t+i.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
virtual DoubleTab & valeurs()=0
void calculer_div_rho_u_impl(DoubleTab &res, const Convection_Diffusion_Fluide_Dilatable_base &eqn) const
virtual bool is_generic() const =0
static std::vector< YAML_data > data_a_sauvegarder(const Convection_Diffusion_std &eq, const Fluide_Dilatable_base &fld)
DoubleTab & derivee_en_temps_inco_sans_solveur_masse_impl(Convection_Diffusion_Fluide_Dilatable_base &eqn, DoubleTab &derivee, const bool is_expl)
Returns the time derivative of the equation's unknown.
virtual bool is_thermal() const =0
public_for_cuda void assembler_impl(Convection_Diffusion_Fluide_Dilatable_base &eqn, Matrice_Morse &mat_morse, const DoubleTab &present, DoubleTab &secmem)
OWN_PTR(Champ_Inc_base) ch_unite_
DoubleVect tab_coeff_diffusif_
static int Reprendre_WC(Entree &is, double temps, Convection_Diffusion_std &eq, Fluide_Dilatable_base &fld, Champ_Inc_base &inco, Probleme_base &pb)
virtual void calculer_div_u_ou_div_rhou(DoubleTab &res) const =0
static int Sauvegarder_WC(Sortie &os, const Convection_Diffusion_std &eq, const Fluide_Dilatable_base &fld)
void assembler_blocs(Convection_Diffusion_Fluide_Dilatable_base &eqn, matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl)
Base class for convection-diffusion equations for a dilatable fluid.
const Fluide_Dilatable_base & fluide() const
const Champ_Inc_base & inconnue() const override
const Domaine_Cl_dis_base & domaine_cl_modif() const
Convection_Diffusion_std This class is the base for equations modelling the transport.
std::vector< YAML_data > data_a_sauvegarder_base() const
int reprendre_base(Entree &)
int sauvegarder_base(Sortie &) const
const Operateur & operateur(int) const override
Returns the operator at the given index: returns terme_diffusif if i = 0,.
virtual bool is_poly_family() const
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
static int is_ecriture_special(int &special, int &a_faire)
Indicates whether the special format was requested in active writing by xyz save.
static int is_lecture_special()
Indicates whether the special format was requested in active reading by xyz restart.
Class defining operators and methods for all reading operation in an input flow (file,...
Sources & sources()
Returns the source terms associated with the equation.
const Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
Solveur_Masse_base & solv_masse()
Returns the mass solver associated with the equation.
Nom create_polymacfamily_syno(const Nom &field_tag) const
Create a synonym of a field name in order to ensure backward compatibility with old names of the Poly...
const Champ_base & get_champ(const Motcle &nom) const override
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
Probleme_base & probleme()
Returns the problem associated with the equation.
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
void Gradient_conjugue_diff_impl(DoubleTrav &secmem, DoubleTab &solution)
const Nom & le_nom() const override
Returns the name of the field.
void nommer(const Nom &) override
Gives a name to the field.
Base class for a dilatable fluid, inheriting from Fluide_base.
const DoubleTab & temperature() const
Returns the array of temperature values.
const Champ_Inc_base & inco_chaleur() const
void update_rho_cp(double temps) override
const Champ_Inc_base & vitesse() const
const Nom type_fluide() const
Fluide_Weakly_Compressible class This class represents a weakly compressible fluid,...
const DoubleTab & pression_th_tab() const
void set_pression_th_tab(DoubleTab &Pth_tab)
virtual DoubleVect & ajouter_multvect(const DoubleVect &x, DoubleVect &r) const
Matrix-vector multiply-accumulate operation (saxpy).
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
const auto & get_tab1() const
virtual const Champ_Don_base & capacite_calorifique() const
Returns the heat capacity of the medium (const version).
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Base class carrying the terms of the momentum equation for a fluid without turbulence modelling under...
class Nom: a character string for naming TRUST objects.
const std::string & getString() const
const Nom & que_suis_je() const
Returns the string identifying the class.
virtual int sauvegarder(Sortie &) const
Saves an Objet_U to an output stream. Virtual method to override.
Classe Op_Conv_negligeable This class represents a negligible convection operator.
Operateur_Conv_base This class is the base of the hierarchy of operators representing.
class Operateur_base This class is the base of the hierarchy of objects representing an
virtual void contribuer_a_avec(const DoubleTab &, Matrice_Morse &) const
DOES NOTHING - to override in derived classes.
virtual void contribuer_au_second_membre(DoubleTab &) const
DOES NOTHING - to override in derived classes.
virtual void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={ }) const
class Operateur Generic class of the operator hierarchy.
virtual Operateur_base & l_op_base()=0
virtual DoubleTab & ajouter(const DoubleTab &, DoubleTab &) const =0
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
class Probleme_base It is a Probleme_U that is not a coupling.
const Domaine & domaine() const
Returns the domain associated with the problem.
const Discretisation_base & discretisation() const
Returns the discretization associated with the problem.
const char * reprise_format_temps() const
static bool is_parallel()
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
int diffusion_implicite() const
Returns 1 if the time scheme has been read with diffusion_implicite.
double temps_courant() const
Returns the current time.
virtual DoubleTab & appliquer(DoubleTab &) const
Returns appliquer_impl(x/temporal_coefficient) if a temporal coefficient is set, otherwise returns ap...
void set_name_of_coefficient_temporel(const Nom &)
Allows choosing the name of the temporal coefficient to use for apply.
Base class for output streams.
Special mass source term for the mass equation (used only during the projection/correction step).
virtual void ajouter_eq_espece(const Convection_Diffusion_Fluide_Dilatable_base &eqn, const Fluide_Dilatable_base &fluide, const bool is_expl, DoubleVect &resu) const =0
void contribuer_a_avec(const DoubleTab &, Matrice_Morse &) const
Contribution to the implicit matrix of source terms. By default, no contribution.
DoubleTab & ajouter(DoubleTab &) const
Adds the contribution of all sources in the list to the array passed as parameter,...
_SIZE_ size_array() const
_SIZE_ dimension_tot(int) const override
_SIZE_ dimension(int d) const
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")
TRUST_2_PDI Encapsulation of PDI methods (library used for IO operations). See the website pdi....
static int is_PDI_checkpoint()
static int is_PDI_restart()
void share_TRUSTTab_dimensions(const DoubleTab &tab, const Nom &name, int write)
Generic method to share the dimensions of a TRUST DoubleTab with PDI.
void TRUST_start_sharing(const std::string &name, const void *data)
YAML_data class: collection of all needed information for data to save/restore in order to write the ...