16#include <Assembleur_P_EF.h>
17#include <Domaine_Cl_EF.h>
18#include <Domaine_EF.h>
19#include <Neumann_sortie_libre.h>
21#include <Matrice_Bloc.h>
23#include <Array_tools.h>
25#include <Connectivite_som_elem.h>
26#include <Static_Int_Lists.h>
27#include <Champ_Fonc_Q1_EF.h>
42void calculer_inv_volume_special(DoubleTab& inv_volumes_som,
const Domaine_Cl_EF& domaine_Cl_EF,
const DoubleTab& volumes_som,
const DoubleTab& marqueur)
44 inv_volumes_som=volumes_som;
48 for (
int i=0; i<taille; i++)
52 double marq_norm2 = 0.;
53 for (
int comp=0; comp<
Objet_U::dimension; comp++) marq_norm2 += marqueur(i,comp)*marqueur(i,comp);
56 inv_volumes_som(i,comp)=1./volumes_som(i,comp);
60void calculer_inv_volume(DoubleTab& inv_volumes_som,
const Domaine_Cl_EF& domaine_Cl_EF,
const DoubleVect& volumes_som)
65 const DoubleTab* doubleT =
dynamic_cast<const DoubleTab*
>(&volumes_som);
68 DoubleTab marqueur(*doubleT);
71 calculer_inv_volume_special(inv_volumes_som, domaine_Cl_EF,*doubleT,marqueur);
76 marqueur=(volumes_som);
83 for (
int i=0; i<taille; i++)
86 inv_volumes_som(i,comp)=1./volumes_som(i);
113 Cerr <<
"The density is not at vertices in Assembleur_P_EF::assembler_rho_variable." << finl;
116 const DoubleVect& volumes_som=ref_cast(
Domaine_EF, le_dom_EF.valeur()).volumes_sommets_thilde();
117 const DoubleVect& masse_volumique=rho.
valeurs();
118 DoubleVect quantitee_som(volumes_som);
120 for (
int i=0; i<size; i++)
121 quantitee_som(i)=(volumes_som(i)*masse_volumique(i));
131 DoubleTab inv_volumes_som;
132 calculer_inv_volume(inv_volumes_som, le_dom_Cl_EF.valeur(), volumes_som);
135 Cerr <<
"Assemblage de la matrice de pression en cours..." << finl;
151 const Domaine_EF& le_dom = le_dom_EF.valeur();
164 Static_Int_Lists som_elem;
165 construire_connectivite_som_elem(nb_sommets_tot,le_dom.
domaine().
les_elems(),som_elem,1);
174 la_matrice.typer(
"Matrice_Bloc");
177 matrice.
get_bloc(0,0).typer(
"Matrice_Morse_Sym");
178 matrice.
get_bloc(0,1).typer(
"Matrice_Morse");
191 int nb_som_elem=sommets_elem.
dimension(1);
192 for (
int elem1=0; elem1<n1; elem1++)
193 for (
int s=0; s<nb_som_elem; s++)
195 int num_som=sommets_elem(elem1,s);
197 for (
int i2=0; i2<nb_voisin; i2++)
199 elem2 = som_elem(num_som,i2);
219 IntTab indice_rr(nb_coeff_rr,2);
220 IntTab indice_rv(nb_coeff_rv,2);
223 for (
int elem1=0; elem1<n1; elem1++)
224 for (
int s=0; s<nb_som_elem; s++)
226 int num_som=sommets_elem(elem1,s);
228 for (
int i2=0; i2<nb_voisin; i2++)
230 elem2 = som_elem(num_som,i2);
235 indice_rr(nb_coeff_rr,0)=elem2;
236 indice_rr(nb_coeff_rr,1)=elem1;
241 indice_rv(nb_coeff_rv,0)=elem2;
242 indice_rv(nb_coeff_rv,1)=elem1;
250 indice_rr(nb_coeff_rr,0)=elem1;
251 indice_rr(nb_coeff_rr,1)=elem2;
258 indice_rv(nb_coeff_rv,0)=elem1;
259 indice_rv(nb_coeff_rv,1)=elem2;
265 tableau_trier_retirer_doublons(indice_rr);
267 tableau_trier_retirer_doublons(indice_rv);
268 for (
int ii=0; ii<indice_rv.
dimension(0); ii++) indice_rv(ii,1)-=n2;
270 if (indice_rv.
size()>0)
276 for (
int elem1=0; elem1<n1; elem1++)
277 for (
int s=0; s<nb_som_elem; s++)
279 int num_som=sommets_elem(elem1,s);
281 for (
int i2=0; i2<nb_voisin; i2++)
283 elem2 = som_elem(num_som,i2);
285 while ((s2<nb_som_elem)&&(num_som!=sommets_elem(elem2,s2))) s2++;
286 assert(num_som==sommets_elem(elem2,s2));
289 val+=Bthilde(elem1,s,dir)*Bthilde(elem2,s2,dir)*inv_volumes_som(num_som,dir);
293 const double r_s = xs(num_som, 0);
294 const double r_e1 = le_dom.
xp(elem1, 0);
295 const double r_e2 = le_dom.
xp(elem2, 0);
296 const double w = r_s / (r_e1 * r_e2);
304 MBrr(elem1,elem2)+=val;
309 MBrv.
coef(elem1,elem2-n2)+=val;
315 DoubleTab test(n1),res(n2);
319 Cerr<<
" laplacien 1 "<<mp_max_abs_vect(res)<<finl;
335 for (
int n_bord=0; n_bord<le_dom.
nb_front_Cl(); n_bord++)
371 for (
int num_som=0; num_som<nb_som; num_som++)
376 if (type_sommet[num_som]==1)
377 for (
int i2=0; i2<nb_voisin; i2++)
379 elem2 = som_elem(num_som,i2);
382 for (
int i1=0; i1<nb_voisin; i1++)
384 int elem1 = som_elem(num_som,i1);
386 while ((s1<nb_som_elem)&&(num_som!=sommets_elem(elem1,s1))) s1++;
388 while ((s2<nb_som_elem)&&(num_som!=sommets_elem(elem2,s2))) s2++;
389 assert(num_som==sommets_elem(elem2,s2));
390 assert(num_som==sommets_elem(elem1,s1));
397 grad[comp]=Bthilde(elem2,s2,comp);
402 val-=Bthilde(elem1,s1,dir)*grad_mod[dir]*inv_volumes_som(num_som,dir);
410 const double r_s = xs(num_som, 0);
411 const double r_e1 = le_dom.
xp(elem1, 0);
412 const double r_e2 = le_dom.
xp(elem2, 0);
413 const double w = r_s / (r_e1 * r_e2);
421 MBrr(elem1,elem2)+=val;
426 MBrv.
coef(elem1,elem2-n2)+=val;
441 Cerr<<
"Pas de pression imposee --> P(0)=0"<<finl;
450 DoubleTab test(n1),res(n2);
454 Cerr<<
" laplacien 1 "<<mp_max_abs_vect(res)<<finl;
463 Cerr <<
"Fin de l'assemblage de la matrice de pression" << finl;
475 Cerr <<
"Assemblage de la matrice de pression pour Quasi Compressible en cours..." << finl;
483 Cerr<<
"Pas de pression imposee --> P(0)=0"<<finl;
485 la_matrice(0,0) *= 2;
489 Cerr <<
"Fin de l'assemblage de la matrice de pression" << finl;
497 const Domaine_EF& le_dom = le_dom_EF.valeur();
504 for (i=0; i<nb_cond_lim; i++)
510 int nfin = ndeb + la_front_dis.
nb_faces();
520 for (
int num_face=ndeb; num_face<nfin; num_face++)
524 secmem[face_voisins(num_face,0)] += coef;
530 bool ch_unif = (Gpt.
nb_dim()==1);
531 for (
int num_face=ndeb; num_face<nfin; num_face++)
536 double Gpoint = ch_unif ? Gpt(k) : Gpt(num_face - ndeb, k);
539 secmem(face_voisins(num_face,0)) += Stt;
559 int n,nb_elem=le_dom_EF->domaine().nb_elem();
560 for(n=0; n<nb_elem; n++)
561 if (pression[n] < press_0)
562 press_0 = pression[n];
565 for(n=0; n<nb_elem; n++)
566 pression[n] -=press_0;
568 pression.echange_espace_virtuel();
575 return le_dom_EF.valeur();
580 return le_dom_Cl_EF.valeur();
const Domaine_dis_base & domaine_dis_base() const override
void associer_domaine_cl_dis_base(const Domaine_Cl_dis_base &) override
void associer_domaine_dis_base(const Domaine_dis_base &) override
const Domaine_Cl_dis_base & domaine_Cl_dis_base() const override
void completer(const Equation_base &) override
int modifier_solution(DoubleTab &) override
DoubleTab les_coeff_pression
int assembler(Matrice &) override
int assembler_QC(const DoubleTab &, Matrice &) override
Assembles the pressure matrix for a quasi-compressible fluid where laplacian(P) is replaced by div(gr...
int assembler_mat(Matrice &, const DoubleVect &, int incr_pression, int resoudre_en_u) override
int modifier_secmem(DoubleTab &) override
int assembler_rho_variable(Matrice &, const Champ_Don_base &rho) override
Assembly of the matrix div(porosity/rho * grad P) The type of the "rho" field to be provided depends ...
int get_resoudre_en_u() const
Returns the value of the resoudre_en_u_ flag (0 or 1) Returns -1 if the flag has not been initialized...
int set_resoudre_en_u(int flag)
Sets the value of the resoudre_en_u__ flag.
int get_resoudre_increment_pression() const
Returns the value of the resoudre_increment_pression_ flag (0 or 1) Returns -1 if the flag has not be...
int set_resoudre_increment_pression(int flag)
Sets the value of the resoudre_increment_pression_ flag.
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
class Champ_front_base Base class for the hierarchy of boundary fields.
virtual const DoubleTab & derivee_en_temps() const
virtual bool instationnaire() const
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
Champ_front_base & champ_front()
class Cond_lim Generic class used to represent any class
static void verifier(const char *const msg, double)
Dirichlet This class is the base class of the hierarchy of Dirichlet-type boundary conditions.
int_t nb_elem_tot() const
DoubleTab_t & les_sommets()
int_t nb_som_tot() const
Returns the total number of vertices of the domain i.e. the number of real and virtual vertices on th...
int_t nb_som() const
Returns the number of vertices of the domain.
const ArrOfInt & get_type_sommet() const
void modifie_gradient(ArrOfDouble &grad_mod, const ArrOfDouble &grad, int num_som) const
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
int nb_cond_lim() const
Returns the number of boundary conditions.
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
const DoubleTab & Bij_thilde() const
const DoubleVect & volumes_sommets_thilde() const
virtual double face_normales(int face, int comp) const
double xp(int num_elem, int k) const
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Domaine & domaine() const
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.
int num_premiere_face() const
virtual DoubleVect & multvect(const DoubleVect &, DoubleVect &) const
Multiplication of a vector by the matrix.
virtual void dimensionner(int N, int M)
virtual const Matrice & get_bloc(int i, int j) const
Matrice_Morse_Sym class - Represents a sparse symmetric matrix M stored in Morse format.
Sortie & imprimer_formatte(Sortie &s) const override
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
void dimensionner(int n, _SIZE_ nnz)
Size the matrix with n lines and n columns and nnz zero-values coefficients.
double coef(int i, int j) const
void set_est_definie(int)
int get_est_definie() const
Matrice class - Generic class in the matrix hierarchy.
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Neumann_sortie_libre This class represents an open boundary without imposed velocity.
virtual double flux_impose(int i) const
Returns the value of the imposed flux on the i-th component of the field representing the flux at the...
const Nom & que_suis_je() const
Returns the string identifying the class.
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
virtual const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
static double mp_min(double)
static double mp_max(double)
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
virtual DoubleTab & appliquer_impl(DoubleTab &x) const =0
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.
int_t get_list_size(int_t i_liste) const
Returns the number of elements in list i.
_SIZE_ size_array() const
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_SIZE_ dimension_tot(int) const override
_SIZE_ dimension(int d) const
_SIZE_ size_totale() const
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")