16#include <Domaine_Cl_EF.h>
17#include <Domaine_EF.h>
19#include <Dirichlet_homogene.h>
22#include <Neumann_homogene.h>
23#include <Periodique.h>
25#include <Champ_P1_EF.h>
30#include <Equation_base.h>
31#include <Champ_front_txyz.h>
32#include <Champ_front_softanalytique.h>
33#include <Static_Int_Lists.h>
34#include <Probleme_base.h>
35#include <Discretisation_base.h>
36#include <Matrice_Morse.h>
37#include <Dirichlet_paroi_fixe_iso_Genepi2.h>
38#include <Champ_Don_base.h>
64 Cerr <<
"Domaine_Cl_EF::completer() prend comme argument un Domaine_EF " << finl;
68void construit_connectivite_sommet(
int type_cl,Static_Int_Lists& som_face_bord,
const Conds_lim& les_conditions_limites_,
const Domaine_EF& domaine_EF)
73 ArrOfInt face_bords(nb_faces_tot);
75 for(
int i=0; i<les_conditions_limites_.size(); i++)
77 const Cond_lim_base& la_cl=les_conditions_limites_[i].valeur();
83 for (
int ind_face=0; ind_face<num2; ind_face++)
86 face_bords[compt++]=face;
90 face_bords.resize_array(compt);
91 ArrOfInt is_sommet_sur_bord(domaine_EF.
nb_som_tot());
93 int nb_som_face=face_sommets.
dimension(1);
94 for (
int fac=0; fac<compt; fac++)
96 int face=face_bords[fac];
97 for (
int som=0; som<nb_som_face; som++)
99 int sommet=face_sommets(face,som);
100 is_sommet_sur_bord[sommet]++;
111 is_sommet_sur_bord=0;
112 for (
int fac=0; fac<compt; fac++)
114 int face=face_bords[fac];
115 for (
int som=0; som<nb_som_face; som++)
117 int sommet=face_sommets(face,som);
118 int n=(is_sommet_sur_bord[sommet])++;
126static void construire_normale_locale_face(
const DoubleTab& face_normales,
127 const IntTab& faces_sommets,
128 const DoubleTab& coord_sommets,
133 ArrOfDouble& normale_locale)
135 for (
int d = 0; d < dimension; d++)
136 normale_locale[d] = face_normales(face, d);
138 if (!(is_bidim_axi && norme_array(normale_locale) < 1e-12))
141 for (
int d = 0; d < dimension; d++)
142 normale_locale[d] = 0.;
144 const int som0 = faces_sommets(face, 0);
145 const int som1 = faces_sommets(face, 1);
146 const double dx = coord_sommets(som1, 0) - coord_sommets(som0, 0);
147 const double dy = coord_sommets(som1, 1) - coord_sommets(som0, 1);
148 normale_locale[0] = -dy;
149 normale_locale[1] = dx;
157 const Domaine& z = le_dom_EF.
domaine();
160 int nb_som_face=faces_sommets.
dimension(1);
165 IntTab titi(nb_som_tot);
175 for (
int ind_face=0; ind_face<num2; ind_face++)
177 int face=le_bord.
num_face(ind_face);
178 for (
int s=0; s<nb_som_face; s++)
180 int som=faces_sommets(face,s);
191 else if ( (sub_type(
Symetrie,la_cl)))
193 for (
int ind_face=0; ind_face<num2; ind_face++)
195 int face=le_bord.
num_face(ind_face);
196 for (
int s=0; s<nb_som_face; s++)
198 int som=faces_sommets(face,s);
208 for (
int ind_face=0; ind_face<num2; ind_face++)
210 int face=le_bord.
num_face(ind_face);
211 for (
int s=0; s<nb_som_face; s++)
213 int som=faces_sommets(face,s);
221 Cerr<<__FILE__<<
":" <<(int)__LINE__<<
" non code pour cette cl "<<la_cl.
que_suis_je()<<finl;
226 for (
int som=0; som<nb_som_tot; som++)
239 Static_Int_Lists sommet_face_symetrie;
245 for (
int som=0; som<nb_som_tot; som++)
256 for (
int f=0; f<nbf; f++)
258 int face=sommet_face_symetrie(som,f);
259 construire_normale_locale_face(face_normales, faces_sommets, coord_sommets, face,
dimension, nb_som_face,
bidim_axi, normale_locale);
261 n[d]+=normale_locale[d];
265 double norm_n=norme_array(n);
268 normales_symetrie_->valeurs()(som,d)=n[d];
271 for (
int f=0; f<nbf; f++)
273 int face=sommet_face_symetrie(som,f);
274 construire_normale_locale_face(face_normales, faces_sommets, coord_sommets, face,
dimension, nb_som_face,
bidim_axi, normale_locale);
277 prod+=normale_locale[d]*n[d];
284 t1[d]=normale_locale[d]-n[d]*prod;
285 s+=normale_locale[d]*normale_locale[d];
290 if (norme_array(t1)>(1e-4*sqrt(s)))
294 if (std::fabs(min_array(t1))>max_array(t1))
307 for (
int f=0; f<nbf; f++)
309 int face=sommet_face_symetrie(som,f);
310 construire_normale_locale_face(face_normales, faces_sommets, coord_sommets, face,
dimension, nb_som_face,
bidim_axi, normale_locale);
311 double prod=0,prod1=0,s=0;
314 prod+=normale_locale[d]*n[d];
316 prod1+=normale_locale[d]*t1[d];
317 s+=normale_locale[d]*normale_locale[d];
321 t2[d]=normale_locale[d]-n[d]*prod-t1[d]*prod1;
323 if (norme_array(t2)>(1e-4*sqrt(s)))
326 if (std::fabs(min_array(t2))>max_array(t2))
329 Cerr<<face<<
" "<<nbf<<
" sommet "<<som<<
" "<<norme_array(t2)/s<<
" on doit annuler une troiseme direction"<<t2[0] <<
" " <<t2[1]<<
" "<<t2[2]<<finl;
330 Cerr<<som<<
" "<<t1[0] <<
" " <<t1[1]<<
" "<<t1[2]<<finl;
331 Cerr<<som<<
" "<<n[0] <<
" " <<n[1]<<
" "<<n[2]<<finl;
342 normales_symetrie_->valeurs().echange_espace_virtuel();
362 const DoubleTab& n =normales_symetrie_->valeurs();
366 for (
int som=0; som<nb_som_tot; som++)
369 for (
int dir=0; dir<dirmax; dir++)
374 prod+=values(som,d)*nn(som,d);
376 values(som,d)-=prod*nn(som,d);
384 int nb_som_face=faces_sommets.
dimension(1);
387 const DoubleTab& n =normales_symetrie_->valeurs();
394 for (
int n_bord=0; n_bord<nbcond; n_bord++)
402 if (sub_type(
Symetrie,la_cl)&&(a_exclure.
rang(nom_bord)>-1))
404 Cerr<<__FILE__<<(int)__LINE__<<
" on impose pas symetrie sur "<<nom_bord<<finl;
405 for (
int ind_face=0; ind_face<num2; ind_face++)
407 int face=le_bord.
num_face(ind_face);
408 for (
int s=0; s<nb_som_face; s++)
410 int som=faces_sommets(face,s);
411 type_sommet_bis[som]=3;
417 for (
int n_bord=0; n_bord<nbcond; n_bord++)
425 if (sub_type(
Symetrie,la_cl)&&(a_exclure.
rang(nom_bord)<0))
427 Cerr<<__FILE__<<(int)__LINE__<<
" on impose symetrie sur "<<nom_bord<<finl;
428 for (
int ind_face=0; ind_face<num2; ind_face++)
430 int face=le_bord.
num_face(ind_face);
431 for (
int s=0; s<nb_som_face; s++)
433 int som=faces_sommets(face,s);
434 if ( type_sommet_bis[som]==1)
436 for (
int dir=0; dir<dirmax; dir++)
441 prod+=values(som,d)*nn(som,d);
443 values(som,d)-=prod*nn(som,d);
457 const DoubleTab& n =normales_symetrie_->valeurs();
463 for (
int dir=0; dir<dirmax; dir++)
468 prod+=grad[d]*nn(som,d);
470 grad_mod[d]+=prod*nn(som,d);
489 const DoubleTab& n =normales_symetrie_->valeurs();
493 const auto& tab1 = la_matrice.
get_tab1();
494 const auto& tab2 = la_matrice.
get_tab2();
499 for (
int som=0; som<nb_som; som++)
502 for (
int dir=0; dir<dirmax; dir++)
505 for (
int d=0; d<
dimension; d++) normale[d]=nn(som,d);
507 auto nb_coeff_ligne=tab1[som*nb_comp+1] - tab1[som*nb_comp];
508 for (
int k=0; k<nb_coeff_ligne; k++)
510 for (
int comp=0; comp<nb_comp; comp++)
512 int j=tab2[tab1[som*nb_comp+comp]-1+k]-1;
516 const double coef_ij=la_matrice(som*nb_comp+comp,j);
518 int comp2=j-som2*nb_comp;
519 secmem(som,comp)-=coef_ij*champ_inconnue(som2,comp2);
524 for (
int comp=0; comp<nb_comp; comp++)
525 somme_b+=secmem(som,comp)*normale[comp];
528 for (
int comp=0; comp<nb_comp; comp++)
529 secmem(som,comp)-=somme_b*normale[comp];
535 for (
int comp=0; comp<nb_comp; comp++)
538 int j0=som*nb_comp+comp;
539 ref+=la_matrice.
coef(j0,j0);
543 for (
int comp=0; comp<nb_comp; comp++)
545 int j0=som*nb_comp+comp;
546 double rap=ref/la_matrice.
coef(j0,j0);
548 for (
int k=0; k<nb_coeff_ligne; k++)
551 int j=tab2[tab1[j0]-1+k]-1;
552 la_matrice(j0,j)*=rap;
554 assert(est_egal(la_matrice(j0,j0),ref));
562 const double tol = 1e-12;
563 for (
int k=0; k<nb_coeff_ligne; k++)
566 for (
int comp=0; comp<nb_comp; comp++)
567 if (std::fabs(normale[comp])>tol)
569 int j=tab2[tab1[som*nb_comp+comp]-1+k]-1;
570 if (j!=(som*nb_comp+comp))
571 if ((j>=(som*nb_comp))&&(j<(som*nb_comp+nb_comp)))
573 la_matrice(som*nb_comp+comp,j)=0;
581 ArrOfDouble somme((
int)nb_coeff_ligne);
582 for (
int k=0; k<nb_coeff_ligne; k++)
585 int j=tab2[tab1[som*nb_comp]-1+k]-1;
586 for (
int comp=0; comp<nb_comp; comp++)
587 somme[k]+=la_matrice(som*nb_comp+comp,j)*normale[comp];
590 for (
int k=0; k<nb_coeff_ligne; k++)
593 int j=tab2[tab1[som*nb_comp]-1+k]-1;
594 for (
int comp=0; comp<nb_comp; comp++)
595 if ((j<(som*nb_comp))||(j>=(som*nb_comp+nb_comp)))
596 la_matrice(som*nb_comp+comp,j)-=(somme[k])*normale[comp];
600 for (
int k=0; k<nb_coeff_ligne; k++)
602 for (
int comp=0; comp<nb_comp; comp++)
604 int j=tab2[tab1[som*nb_comp+comp]-1+k]-1;
606 int comp2=j-som2*nb_comp;
608 const double coef_ij=la_matrice(som*nb_comp+comp,j);
609 secmem(som,comp)+=coef_ij*champ_inconnue(som2,comp2);
617 for (
int comp=0; comp<nb_comp; comp++)
618 somme_b2+=secmem(som,comp)*normale[comp];
620 if (std::fabs(somme_b2) >= 1e-8)
621 Cerr <<
"Domaine_Cl_EF::imposer_symetrie_matrice_secmem: secmem.n != 0 ("
622 << somme_b2 <<
") au sommet " << som <<
", projection appliquee." << finl;
624 for (
int comp=0; comp<nb_comp; comp++)
625 secmem(som,comp)-=somme_b2*normale[comp];
639 DoubleTab& ch_tab = ch.
valeurs(temps);
643 int nb_som_face=faces_sommets.
dimension(1);
660 for (
int ind_face=0; ind_face<num2; ind_face++)
662 int face=le_bord.
num_face(ind_face);
663 for (
int s=0; s<nb_som_face; s++)
665 int som=faces_sommets(face,s);
672 for (
int ncomp=0; ncomp<nb_comp; ncomp++)
693 int avec_valeur_aux_sommets=0;
700 if (avec_valeur_aux_sommets)
703 for (
int ind_face=0; ind_face<num2; ind_face++)
705 int face=le_bord.
num_face(ind_face);
706 for (
int s=0; s<nb_som_face; s++)
708 int som=faces_sommets(face,s);
720 for (
int ncomp=0; ncomp<nb_comp; ncomp++)
726 for (
int ind_face=0; ind_face<num2; ind_face++)
728 int face=le_bord.
num_face(ind_face);
729 for (
int s=0; s<nb_som_face; s++)
731 int som=faces_sommets(face,s);
738 for (
int ncomp=0; ncomp<nb_comp; ncomp++)
765 else if ( (sub_type(
Symetrie,la_cl) ) &&
812 Cerr<<
" Periodicity is not implemented !!!"<<finl;
DoubleTab & valeurs() override
Returns the array of field values at the current time.
Champ_front_softanalytique Class derived from Champ_front_var representing boundary.
class Champ_front_var_instationnaire Derived class from Champ_front_var that represents fields on
virtual int valeur_au_temps_et_au_point_disponible() const
virtual double valeur_au_temps_et_au_point(double temps, int som, double x, double y, double z, int comp) 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 Conds_lim This class represents a vector of boundary conditions.
Classe Dirichlet_homogene This class is the base class of the hierarchy of homogeneous Dirichlet-type...
Dirichlet This class is the base class of the hierarchy of Dirichlet-type boundary conditions.
virtual double val_imp_au_temps(double temps, int i) const
Returns the imposed value on the i-th component of the field at the boundary at the specified time.
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, const Nom &nom, const Nom &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base)&champ, const Nom &sous_type=NOM_VIDE) const
const DoubleTab_t & coord_sommets() const
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.
void remplir_type_elem_Cl(const Domaine_EF &)
Called by remplir_volumes_entrelaces_Cl(): fills type_elem_Cl_.
Domaine_EF & domaine_EF()
int initialiser(double temps) override
Initializes the BCs. Unlike the update methods, the.
void imposer_symetrie(DoubleTab &, int tous_les_sommets_sym=0) const
Imposes symmetry conditions, i.e. cancels the field components along the normal(s).
int nb_bord_periodicite() const
void modifie_gradient(ArrOfDouble &grad_mod, const ArrOfDouble &grad, int num_som) const
void imposer_symetrie_partiellement(DoubleTab &, const Noms &) const
void imposer_symetrie_matrice_secmem(Matrice_Morse &la_matrice, DoubleTab &secmem) const
Transforms la_matrice and secmem to produce a secmem normal to boundaries, plus the matrix needed to ...
void imposer_cond_lim(Champ_Inc_base &, double) override
Imposes boundary conditions at time "temps" of the Champ_Inc.
int nb_faces_sortie_libre() const
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
virtual int initialiser(double temps)
Initializes the BCs. Unlike the update methods, the.
virtual const Champ_Inc_base & inconnue() const
int nb_cond_lim() const
Returns the number of boundary conditions.
void completer()
Calls Cond_lim_base::completer() on each boundary condition.
Conds_lim & les_conditions_limites()
Returns the array of boundary conditions.
Domaine_dis_base & domaine_dis()
Returns a reference to the discretized domain associated with the boundary conditions.
Conds_lim les_conditions_limites_
int nb_faces_tot() const
Returns the total number of faces.
virtual double face_normales(int face, int comp) const
int face_sommets(int i, int j) const
Returns the index of the i-th vertex of face num_face.
const Front_VF & front_VF(int i) const
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,...
virtual const Champ_Inc_base & inconnue() const =0
Probleme_base & probleme()
Returns the problem associated with the equation.
virtual int nb_comp() const
virtual Nature_du_champ nature_du_champ() const
int num_face(const int) const
const Nom & le_nom() const override
Returns the name of the geometric boundary.
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
const auto & get_tab2() const
const auto & get_tab1() const
double coef(int i, int j) const
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Classe Neumann_homogene This class is the base class of the hierarchy of homogeneous Neumann-type bou...
Classe Neumann This class is the base class of the hierarchy of Neumann-type boundary conditions.
class Nom: a character string for naming TRUST objects.
An array of character strings (VECT(Nom)).
int rang(const char *const ch) const
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 Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
class Periodique This class represents a periodic boundary condition.
const Discretisation_base & discretisation() const
Returns the discretization associated with the problem.
static void abort()
Abort routine for TRUST on a fatal error.
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Base class for output streams.
void set_value(int_t i_liste, int_t i_element, int_t valeur)
Assigns "valeur" to the j-th element of the i-th list with 0 <= i < get_nb_lists() and 0 <= j < get_l...
int_t get_list_size(int_t i_liste) const
Returns the number of elements in list i.
void set_list_sizes(const ArrOfInt_t &sizes)
Destroys existing lists and creates new ones.
Symetrie On symmetry faces, the following properties hold:
_SIZE_ size_array() const
_SIZE_ dimension_tot(int) const override
_SIZE_ dimension(int d) const