16#include <Champ_P1iP1B_implementation.h>
17#include <Champ_implementation_P1.h>
19#include <Domaine_VEF.h>
20#include <Domaine_Cl_VEF.h>
23#include <Matrice_Morse_Sym.h>
24#include <TRUSTLists.h>
25#include <SolveurSys.h>
29#include <Neumann_sortie_libre.h>
30#include <Champ_P0_VEF.h>
31#include <TRUSTTab_parts.h>
32#include <Frontiere_dis_base.h>
35#include <TRUSTArray_kokkos.tpp>
42 DoubleTab positions(1,dimension);
44 les_polys(0) = le_poly;
45 for (
int i=0; i<dimension; i++)
46 positions(0,i) = position(i);
61 DoubleTab positions(1,dimension);
63 les_polys(0) = le_poly;
64 for (
int i=0; i<dimension; i++)
65 positions(0,i) = position(i);
82 const Domaine& domaine_geom = zvef.
domaine();
84 const IntTab& sommet_poly = domaine_geom.
les_elems();
88 const int les_polys_size=les_polys.
size();
106 CDoubleArrView champ_filtre_v =
static_cast<DoubleVect&
>(
champ_filtre_).view_ro();
107 CIntTabView sommet_poly_v = sommet_poly.
view_ro();
108 CDoubleTabView coord_v = coord.
view_ro();
109 CDoubleTabView positions_v = positions.
view_ro();
110 CIntArrView les_polys_v = les_polys.view_ro();
111 DoubleTabView val_v = val.
view_rw();
112 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),les_polys_size, KOKKOS_LAMBDA(
116 val_v(rang_poly,0) = 0.;
119 int le_poly=les_polys_v(rang_poly);
124 val_v(rang_poly, 0) += champ_filtre_v(le_poly);
128 double xs = positions_v(rang_poly,0);
129 double ys = positions_v(rang_poly,1);
130 double zs = (dimension == 3) ? positions_v(rang_poly,2) : 0;
133 for (
int i=0; i<dimension+1; i++)
135 int som = prs+sommet_poly_v(le_poly,i);
136 double champ_filtre_som = champ_filtre_v(som);
140 li=coord_barycentrique_P1_triangle(sommet_poly_v,
143 else if (dimension == 3)
144 li=coord_barycentrique_P1_tetraedre(sommet_poly_v,
147 val_v(rang_poly,0) += champ_filtre_som * li;
152 end_gpu_timer(__KERNEL_NAME__);
156 Cerr <<
"Are you really here already?" << finl;
165 Cerr <<
"Champ_P1iP1B_implementation::valeur_aux_elems_compo not implemented." << finl;
178 assert(nb_compo_ == tab_val.
line_size());
198 DoubleTabView val = tab_val.
view_rw();
199 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nbs, KOKKOS_LAMBDA(
const int num_som)
201 int som = prs+num_som;
204 end_gpu_timer(__KERNEL_NAME__);
208 Cerr <<
"Are you really here already?" << finl;
222 Cerr <<
"Champ_P1iP1B_implementation::valeur_aux_sommets_compo not implemented." << finl;
231 const Domaine& le_dom=zvef.
domaine();
232 const Domaine& dom=le_dom;
236 const DoubleTab& xg = zvef.
xp();
239 coord.
resize(nbe+nbs,dimension);
243 for(
int i=0; i<nbe; i++)
245 for(
int j=0; j<dimension; j++)
252 for(
int i=0; i<nbs; i++)
254 for(
int j=0; j<dimension; j++)
255 coord(k,j)=coord_sommets(i,j);
264 IntVect& polys)
const
266 Cerr <<
"Not implemented" << finl;
274 matrice.typer(
"Matrice_Morse_Sym");
278 int nnz=nb_som_tot+nb_arete_tot;
281 const Domaine& dom=domaine_VEF.
domaine();
283 IntLists voisins(nb_som_tot);
284 DoubleLists coeffs(nb_som_tot);
285 DoubleVect diag(nb_som_tot);
287 for(
int arete=0; arete<nb_arete_tot; arete++)
289 if (renum_arete_perio[arete]==arete)
299 voisins[som1].add(som2);
305 for (
int i=0; i<nb_som_tot; i++)
314 MatPoisson.
remplir(voisins, coeffs, diag) ;
320static double coeff = 4. / 5.;
321static double coeff_inv = 1 / coeff;
322double second_membre(
const Domaine_VEF& domaine_VEF, ArrOfDouble& Pa, DoubleVect& secmem)
327 const Domaine& dom=domaine_VEF.
domaine();
330 for(
int arete=0; arete<nb_arete_tot; arete++)
332 if (renum_arete_perio[arete]==arete)
343 double norme=mp_norme_vect(secmem);
348void corriger(
const Domaine_VEF& domaine_VEF, DoubleTab& champ_filtre_,
Matrice& matrice,
const int Condition_Neumann_imposee_)
350 int nb_elem=domaine_VEF.
nb_elem();
351 int nb_som=domaine_VEF.
nb_som();
356 Cerr <<
"Error in Champ_P1iP1B_impl.cpp: corriger(...), the field must have both vertex and element parts" << finl;
359 DoubleTab_parts parties_P(champ_filtre_);
360 DoubleVect& Pk = parties_P[0];
361 DoubleVect& Ps = parties_P[1];
368 Cerr<<
"We try to Champ_P1iP1B_impl::corriger but get_renum_arete_perio"<<finl;
374 ToDo_Kokkos(
"critical for P0P1Pa");
375 DoubleVect& Pa = parties_P[2];
378 if (!matrice) assembler(domaine_VEF, matrice);
383 second_membre(domaine_VEF, Pa, secmem);
387 solution.
copy(secmem, RESIZE_OPTIONS::NOCOPY_NOINIT);
391 solveur.typer(
"Solv_GCP");
394 ref_cast(
Solv_GCP,solveur.valeur()).set_precond(p);
395 solveur.
nommer(
"Pa_filter_solver");
399 const Domaine& dom=domaine_VEF.
domaine();
400 for(
int i=0; i<nb_som; i++)
404 solution(i)=solution(som);
408 for(
int som=0; som<nb_som; som++)
409 Ps(som) += solution(som);
415 for(
int arete=0; arete<nb_arete; arete++)
417 if(!ok_arete[arete] && Pa(arete)!=0)
419 Cerr <<
"Pa(arete_superflue)!=0 in Champ_P1iP1B_implementation::corriger" << finl;
420 Cerr <<
"Please contact TRUST support." << finl;
421 Cerr <<
"If this is a restart from an xyz format calculation," << finl;
422 Cerr <<
"you must overwrite the .ok_arete file of your restart calculation" << finl;
423 Cerr <<
"with the .ok_arete file of your previous calculation so as to have the" << finl;
424 Cerr <<
"same superfluous edges." << finl;
427 int som1=aretes_som(arete, 0);
428 int som2=aretes_som(arete, 1);
429 double sigma=solution(som1)+solution(som2);
430 Pa(arete)-=sigma*coeff_inv;
436 for(
int elem=0; elem<nb_elem; elem++)
439 for (
int som=0; som<nb_som_par_elem; som++)
440 sigma+=solution(les_elems(elem,som));
446 double moyenne_K = mp_moyenne_vect(Pk);
453 assert(Condition_Neumann_imposee_!=-1);
455 if (!Condition_Neumann_imposee_)
458 Ps -= mp_moyenne_vect(Ps);
478 && !implicitCoupling)
506 for(
int i=0; i<les_cl.size(); i++)
516 const DoubleTab& cg_faces = domaine_dis.
xv();
522 IntVect elem_voisins(nb_faces_fr);
525 DoubleTab val_interp(nb_faces_fr, 1);
528 for (
int i=0; i<nb_faces_fr; i++)
534 elem_voisins(i) = elem;
539 for (
int num_face=0; num_face<nb_faces_fr; num_face++)
543 cg_faces_fr(num_face,dim) = cg_faces(face,dim);
549 for (
int i=0; i<nb_faces_fr; i++)
551 x(i,0) = val_interp(i);
DoubleTab & valeur_aux_sommets(const Domaine &domain, DoubleTab &result) const override
Returns the values at the vertices of the Domain dom.
void associer_domaine_dis_base(const Domaine_dis_base &) override
DoubleTab & valeurs() override
Returns the array of field values at the current time.
DoubleTab & valeur_aux_elems(const DoubleTab &positions, const IntVect &les_polys, DoubleTab &valeurs) const override
Matrice matrice_filtrage_
DoubleTab & remplir_coord_noeuds(DoubleTab &positions) const override
virtual const Domaine_VEF & domaine_vef() const =0
DoubleTab & filtrage(const Domaine_VEF &, const Champ_base &, bool implicitCoupling=false) const
const double * adresse_champ_filtre_
double valeur_a_elem_compo(const DoubleVect &position, int le_poly, int ncomp) const override
DoubleVect & valeur_a_elem(const DoubleVect &position, DoubleVect &val, int le_poly) const override
DoubleVect & valeur_aux_sommets_compo(const Domaine &, DoubleVect &, int) const override
int remplir_coord_noeuds_et_polys(DoubleTab &positions, IntVect &polys) const override
DoubleTab & trace(const Frontiere_dis_base &fr, const DoubleTab &y, DoubleTab &x, int distant) const
void completer(const Domaine_Cl_dis_base &zcl)
const DoubleTab & champ_filtre() const
int Condition_Neumann_imposee_
DoubleTab & valeur_aux_sommets(const Domaine &, DoubleTab &) const override
DoubleVect & valeur_aux_elems_compo(const DoubleTab &positions, const IntVect &les_polys, DoubleVect &valeurs, int ncomp) const override
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
double temps() const
Returns the time of the field.
virtual Champ_base & le_champ()=0
class Conds_lim This class represents a vector of boundary conditions.
static void verifier(const char *const msg, double)
int_t nb_aretes_tot() const
returns the total number of edges (real+virtual).
const IntTab_t & aretes_som() const
returns the connectivity array edges/vertices.
int_t get_renum_som_perio(int_t i) const
int_t nb_aretes() const
Returns the number of real edges.
const DoubleTab_t & coord_sommets() const
virtual void creer_tableau_sommets(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
Creates an array with one "row" per mesh vertex.
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...
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
const IntVect & get_ok_arete() const
int numero_premier_sommet() const
const ArrOfInt & get_renum_arete_perio() const
double xv(int num_face, int k) 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.
const Domaine & domaine() const
virtual int nb_comp() const
int num_premiere_face() const
class Frontiere_dis_base Class representing a discretized boundary.
Matrice_Morse_Sym class - Represents a sparse symmetric matrix M stored in Morse format.
void compacte(int elim_coeff_nul=0)
Remove duplicates by sorting tab2.
void dimensionner(int n, _SIZE_ nnz)
Size the matrix with n lines and n columns and nnz zero-values coefficients.
void remplir(const IntLists &, const DoubleLists &, const DoubleVect &)
void set_est_definie(int)
Matrice class - Generic class in the matrix hierarchy.
Neumann_sortie_libre This class represents an open boundary without imposed velocity.
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
class SolveurSys A SolveurSys represents any class
int resoudre_systeme(const Matrice_Base &matrice, const DoubleVect &secmem, DoubleVect &solution)
void nommer(const Nom &nom) override
_SIZE_ size_array() const
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_SIZE_ dimension_tot(int) const override
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, ConstView< _TYPE_, _SHAPE_ > > view_ro() const
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, View< _TYPE_, _SHAPE_ > > view_rw()
_SIZE_ dimension(int d) const
void copy(const TRUSTArray< _TYPE_, _SIZE_ > &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")