16#include <Implicit_steady.h>
17#include <Schema_Euler_Implicite_Stationnaire.h>
18#include <Domaine_VF.h>
19#include <Domaine_Cl_VEF.h>
20#include <Navier_Stokes_std.h>
23#include <Matrice_Bloc.h>
24#include <Assembleur_base.h>
25#include <Schema_Temps_base.h>
27#include <Fluide_Quasi_Compressible.h>
29#include <Probleme_base.h>
47void test_impose_bound_cond(
Equation_base& eqn,DoubleTab& current2,
const char * msg,
int flag)
51 DoubleTab sauv(present);
55 double ecart_max=mp_max_abs_vect(present);
56 Cout<<msg <<
" "<<ecart_max<<finl;
58 if ((ecart_max>1e-10))
68 Matrice_Morse& matrice,
double seuil_resol,DoubleTrav& secmem,
int nb_iter,
int& converge,
int& ok)
77 Cerr <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << finl;
78 Cerr <<
"Implicit_steady solveur can be used only with the Implicit_Euler_Steady_Scheme or Schema_Euler_Implicite_Stationnaire scheme!" << finl;
79 Cerr <<
"Please, contact TRUST support." << finl;
83 DoubleTrav gradP(current);
84 DoubleTrav correction_en_pression(pression);
85 DoubleTrav resu(current);
103 bool need_reassembly = (dt_loc.
size() == 0);
107 if (!need_reassembly)
109 for (
int i = 0; i < dt_loc_new.
size(); i++)
111 double var = std::abs(dt_loc_new[i] - dt_loc[i]) / (dt_loc[i] + 1.e-30);
112 max_var = std::max(max_var, var);
122 if (max_var == 0. && need_reassembly)
123 Cout <<
"Implicit_steady: first iteration -> dt_loc_ initialised, pressure matrix reassembled" << finl;
127 Cout <<
"Implicit_steady: dt_loc max relative variation: " << max_var
128 << (need_reassembly ?
" -> dt_loc_ updated, pressure matrix reassembled"
129 :
" -> dt_loc_ unchanged, pressure matrix reused") << finl;
135 gradient.calculer(pression,gradP);
139 le_solveur_->reinit();
140 Debog::verifier(
"Implicit_steady::iterer_NS resu apres assembler_avec_inertie",resu);
146 Cout <<
"Compute U* :" << finl;
148 test_impose_bound_cond(eqn,current,
"apres resolution ",0);
149 Debog::verifier(
"Implicit_steady::iterer_NS current apres CL",current);
156 Cerr<<
"Steady option is not compatible with the quasi/weakly compressible models !"<<finl;
157 Cerr <<
"Please, contact TRUST support." << finl;
162 divergence.calculer(current,secmem);
169 Cout <<
"Implicit_steady: solving mass equation :" << finl;
172 DoubleVect m_dt(dt_loc);
178 eqnNS.assembleur_pression()->assembler_mat(matrice_en_pression_2, m_dt, 1, 1);
179 solveur_pression_->reinit();
184 secmem,correction_en_pression);
187 gradient->multvect(correction_en_pression,gradP);
190 int size=gradP.
size();
193 DoubleVect dt_loc_velocity(current);
195 assert(dt_loc.
size() * nb_dim == dt_loc_velocity.
size());
197 for (
int i = 0; i < dt_loc_velocity.
size(); i++)
199 if (i != 0 && i % nb_dim == 0) j++;
200 dt_loc_velocity[i] = dt_loc[j];
204 for(
int i=0; i<size; i++)
206 gradP.
addr()[i] *=dt_loc_velocity[i];
211 test_impose_bound_cond(eqn,current,
"apres resolution ",0);
214 divergence.calculer(current,secmem);
217 pression += correction_en_pression;
219 eqnNS.assembleur_pression()->modifier_solution(pression);
220 pression.echange_espace_virtuel();
234 for (
int f = 0; f < volumes_cl.
size(); f++)
235 if (volumes_cl(f) != 0)
236 volumes(f) = volumes_cl(f);
242 const bool has_porosity = (porosite.
size_totale() == size);
244 const bool rho_per_face = (rho.
size_totale() == size);
245 for (
int face = 0; face < size; face++)
247 const double rho_f = rho_per_face ? rho(face) : 1.0;
248 const double por_f = has_porosity ? porosite(face) : 1.0;
249 m_dt(face) = volumes(face) * por_f * rho_f / dt_loc(face);
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
static void verifier(const char *const msg, double)
virtual void imposer_cond_lim(Champ_Inc_base &, double)=0
DoubleVect & volumes_entrelaces()
Class defining operators and methods for all reading operation in an input flow (file,...
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
virtual void assembler_avec_inertie(Matrice_Morse &mat_morse, const DoubleTab &present, DoubleTab &secmem)
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.
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
void iterer_NS(Equation_base &, DoubleTab ¤t, DoubleTab &pression, double, Matrice_Morse &, double, DoubleTrav &, int nb_iter, int &converge, int &ok) override
double seuil_variation_dt_
void calcul_mat_masse_diviser_par_dt(Navier_Stokes_std &eqnNS, DoubleVect &m_dt, const DoubleVect &dt_loc)
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
Matrice class - Generic class in the matrix hierarchy.
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
DoubleVect & porosite_face()
Navier_Stokes_std This class carries the terms of the momentum equation.
const Milieu_base & milieu() const override
Returns the physical medium of the equation (Fluide_base upcast to Milieu_base).
const Champ_Inc_base & inconnue() const override
Returns the velocity (unknown field of the equation) (const version).
const Fluide_base & fluide() const
Returns the incompressible fluid (physical medium of the equation) associated with the equation.
Operateur_Div & operateur_divergence()
Returns the divergence operator associated with the equation.
Operateur_Grad & operateur_gradient()
Returns the gradient operator associated with the equation.
Matrice & matrice_pression()
SolveurSys & solveur_pression()
Returns the pressure solver (const version).
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Operateur_Div Generic class of the hierarchy of operators computing the divergence.
Classe Operateur_Grad Generic class of the hierarchy of operators computing the gradient.
class Parametre_implicite A Parametre_implicite object groups together the various
bool is_dilatable() const
const Schema_Temps_base & schema_temps() const
Returns the time scheme associated with the problem.
static double mp_max(double)
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
DoubleVect & get_dt_loc()
int limpr() const
Returns 1 if there is a need to perform a print (cf dt_impr) Returns 0 otherwise.
double temps_courant() const
Returns the current time.
double pas_de_temps() const
Returns the current time step (delta_t).
const DoubleTab & pas_de_temps_locaux() const
int nb_pas_dt() const
Returns the number of time steps performed.
class SolveurSys A SolveurSys represents any class
int resoudre_systeme(const Matrice_Base &matrice, const DoubleVect &secmem, DoubleVect &solution)
Parametre_implicite & get_and_set_parametre_implicite(Equation_base &eqn)
virtual DoubleTab & appliquer(DoubleTab &) const
Returns appliquer_impl(x/temporal_coefficient) if a temporal coefficient is set, otherwise returns ap...
Base class for output streams.
_SIZE_ size_totale() const
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")