TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Masse_VEF_P1NC.cpp
1/****************************************************************************
2* Copyright (c) 2025, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#include <Masse_VEF_P1NC.h>
17#include <Domaine_Cl_VEF.h>
18#include <Domaine_VEF.h>
19#include <Dirichlet.h>
20#include <Dirichlet_homogene.h>
21#include <Symetrie.h>
22#include <Equation_base.h>
23#include <Matrice_Morse.h>
24#include <Milieu_base.h>
25#include <Device.h>
26
27Implemente_instanciable(Masse_VEF_P1NC,"Masse_VEF_P1NC",Solveur_Masse_base);
28
29
30// printOn()
31/////
32
34{
35 return s << que_suis_je() << " " << le_nom();
36}
37
38//// readOn
39//
40
42{
43 return s ;
44}
45
46
47
48///////////////////////////////////////////////////////////////
49//
50// Implementation des fonctions de la classe Masse_VEF_P1NC
51//
52//////////////////////////////////////////////////////////////
53
54
55DoubleTab& Masse_VEF_P1NC::appliquer_impl(DoubleTab& tab_sm) const
56{
57 const Domaine_Cl_VEF& domaine_Cl_VEF = ref_cast(Domaine_Cl_VEF,le_dom_Cl_VEF.valeur());
58 const Domaine_VEF& domaine_VEF = le_dom_VEF.valeur();
59 const DoubleVect& tab_volumes_entrelaces = domaine_VEF.volumes_entrelaces();
60
61 int nfa = domaine_VEF.nb_faces();
62 int num_std = domaine_VEF.premiere_face_std();
63 int num_int = domaine_VEF.premiere_face_int();
64 int nbcomp = tab_sm.line_size();
65
66 if (nfa != tab_sm.dimension(0))
67 {
68 Cerr << "erreur dans Masse_VEF_P1NC : ";
69 Cerr << "nombre de faces : " << nfa
70 << " taille du second membre : " << tab_sm.dimension(0) << finl;
71 exit();
72 }
73
74 // On traite les faces standard qui ne portent pas de conditions aux limites
75 CDoubleArrView porosite_face = equation().milieu().porosite_face().view_ro();
76 CDoubleArrView volumes_entrelaces = tab_volumes_entrelaces.view_ro();
77 DoubleTabView sm = tab_sm.view_rw();
78
79 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),
80 Kokkos::MDRangePolicy<Kokkos::Rank<2>>({num_std,0}, {nfa,nbcomp}),
81 KOKKOS_LAMBDA(int face, int comp)
82 {
83 sm(face, comp) /= (volumes_entrelaces(face) * porosite_face(face));
84 });
85 end_gpu_timer(__KERNEL_NAME__);
86
87 // On traite les faces non standard
88 // les faces des bord sont des faces non standard susceptibles de porter des C.L
89 // les faces internes non standard ne portent pas de C.L
90
91 // On traite les conditions aux limites
92 CIntTabView face_voisins = domaine_VEF.face_voisins().view_ro();
93 CDoubleTabView normales = domaine_VEF.face_normales().view_ro();
94 CDoubleArrView volumes_entrelaces_Cl = domaine_Cl_VEF.volumes_entrelaces_Cl().view_ro();
95 for (int n_bord = 0; n_bord < domaine_VEF.nb_front_Cl(); n_bord++)
96 {
97 const Cond_lim& la_cl = domaine_Cl_VEF.les_conditions_limites(n_bord);
98 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
99 int num1 = le_bord.num_premiere_face();
100 int num2 = num1 + le_bord.nb_faces();
101
102 if ((sub_type(Dirichlet,la_cl.valeur())) ||
103 (sub_type(Dirichlet_homogene,la_cl.valeur())))
104 {
105 // Pour les faces de Dirichlet on met sm a 0
106 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),
107 range_1D(num1, num2),
108 KOKKOS_LAMBDA(const int face)
109 {
110 for (int comp = 0; comp < nbcomp; comp++)
111 sm(face, comp) = 0;
112 });
113 end_gpu_timer(__KERNEL_NAME__);
114 }
115 else if ((sub_type(Symetrie,la_cl.valeur())) && (domaine_Cl_VEF.equation().inconnue().nature_du_champ()==vectoriel))
116 {
117 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),
118 range_1D(num1, num2),
119 KOKKOS_LAMBDA(const int face)
120 {
121 double psc = 0;
122 double surf = 0;
123 for (int comp = 0; comp < nbcomp; comp++)
124 {
125 psc += sm(face,comp) * normales(face,comp);
126 surf += normales(face,comp) * normales(face,comp);
127 }
128 psc /= surf;
129 for(int comp = 0; comp < nbcomp; comp++)
130 {
131 sm(face,comp) -= psc * normales(face,comp);
132 sm(face,comp) /= (volumes_entrelaces_Cl(face) *
133 porosite_face(face));
134 }
135 });
136 end_gpu_timer(__KERNEL_NAME__);
137 }
138 else
139 {
140 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),
141 range_1D(num1, num2),
142 KOKKOS_LAMBDA(
143 const int face)
144 {
145 int elem = face_voisins(face, 0);
146 if (elem == -1) elem = face_voisins(face, 1);
147 for (int comp = 0; comp < nbcomp; comp++)
148 sm(face, comp) /= (volumes_entrelaces_Cl(face) * porosite_face(face));
149 });
150 end_gpu_timer(__KERNEL_NAME__);
151 }
152 }
153
154 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),
155 range_2D({num_int,0}, {num_std,nbcomp}),
156 KOKKOS_LAMBDA(int face, int comp)
157 {
158 sm(face,comp) /= (volumes_entrelaces_Cl(face) * porosite_face(face));
159 });
160 end_gpu_timer(__KERNEL_NAME__);
161
162 //tab_sm.echange_espace_virtuel();
163 //Debog::verifier("Masse_VEF_P1NC::appliquer, tab_sm=",tab_sm);
164 return tab_sm;
165}
166
167
168//
170{
171 le_dom_VEF = ref_cast(Domaine_VEF, le_dom_dis_base);
172}
173
175{
176 le_dom_Cl_VEF = ref_cast(Domaine_Cl_VEF, le_dom_Cl_dis_base);
177}
178
179
180Matrice_Base& Masse_VEF_P1NC::ajouter_masse(double dt, Matrice_Base& matrice, int penalisation) const
181{
182 if (penalisation||(le_dom_Cl_VEF->equation().inconnue().nature_du_champ()!=vectoriel))
183 return Solveur_Masse_base::ajouter_masse(dt,matrice,penalisation);
184 // Sinon on modifie temporairement la nature du champ pour que appliquer_impl ne projette pas sur n.
185 Champ_Inc_base& inco=ref_cast_non_const( Champ_Inc_base,le_dom_Cl_VEF->equation().inconnue());
186 inco.fixer_nature_du_champ(multi_scalaire);
187 Solveur_Masse_base::ajouter_masse(dt,matrice,penalisation);
188 inco.fixer_nature_du_champ(vectoriel);
189 return matrice;
190
191
192}
193
194
195DoubleTab& Masse_VEF_P1NC::ajouter_masse(double dt, DoubleTab& x, const DoubleTab& y, int penalisation, bool use_old_volumes) const
196{
197 if (penalisation||(le_dom_Cl_VEF->equation().inconnue().nature_du_champ()!=vectoriel))
198 return Solveur_Masse_base::ajouter_masse(dt, x, y, penalisation, use_old_volumes);
199
200 // Sinon on modifie temporairement la nature du champ pour que appliquer_impl ne projette pas sur n.
201 Champ_Inc_base& inco=ref_cast_non_const( Champ_Inc_base,le_dom_Cl_VEF->equation().inconnue());
202 inco.fixer_nature_du_champ(multi_scalaire);
203 Solveur_Masse_base::ajouter_masse(dt, x, y, penalisation, use_old_volumes);
204 inco.fixer_nature_du_champ(vectoriel);
205 return x;
206}
207
208DoubleTab& Masse_VEF_P1NC::corriger_solution(DoubleTab& x, const DoubleTab& y, int incr) const
209{
210 // assert(penalisation_==1);
211
212 return Solveur_Masse_base::corriger_solution( x, y, incr) ;
213}
Classe Champ_Inc_base.
classe Cond_lim Classe generique servant a representer n'importe quelle classe
Definition Cond_lim.h:31
Classe Dirichlet_homogene Cette classe est la classe de base de la hierarchie des conditions aux limi...
classe Dirichlet Cette classe est la classe de base de la hierarchie des conditions aux limites de ty...
Definition Dirichlet.h:31
DoubleVect & volumes_entrelaces_Cl()
classe Domaine_Cl_dis_base Les objets Domaine_Cl_dis_base representent les conditions aux limites
const Cond_lim & les_conditions_limites(int) const
Renvoie la i-ieme condition aux limites.
class Domaine_VEF
Definition Domaine_VEF.h:54
int premiere_face_std() const
Definition Domaine_VEF.h:80
int nb_faces() const
renvoie le nombre global de faces.
Definition Domaine_VF.h:471
DoubleVect & volumes_entrelaces()
Definition Domaine_VF.h:99
virtual double face_normales(int face, int comp) const
Definition Domaine_VF.h:47
int premiere_face_int() const
une face est interne ssi elle separe deux elements.
Definition Domaine_VF.h:463
int face_voisins(int num_face, int i) const
renvoie l'element voisin de numface dans la direction i.
Definition Domaine_VF.h:418
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
int nb_front_Cl() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Milieu_base & milieu() const =0
virtual const Champ_Inc_base & inconnue() const =0
virtual Nature_du_champ fixer_nature_du_champ(Nature_du_champ nat)
Fixer la nature d'un champ: scalaire, multiscalaire, vectoriel.
virtual Nature_du_champ nature_du_champ() const
Definition Field_base.h:77
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_premiere_face() const
Definition Front_VF.h:63
DoubleTab & corriger_solution(DoubleTab &x, const DoubleTab &y, int incr=0) const override
void associer_domaine_cl_dis_base(const Domaine_Cl_dis_base &) override
void associer_domaine_dis_base(const Domaine_dis_base &) override
Matrice_Base & ajouter_masse(double dt, Matrice_Base &matrice, int penalisation=1) const override
DoubleTab & appliquer_impl(DoubleTab &sm) const override
Classe Matrice_Base Classe de base de la hierarchie des matrices.
DoubleVect & porosite_face()
Definition Milieu_base.h:62
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual const Nom & le_nom() const
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Objet_U.cpp:319
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
classe Solveur_Masse_base Represente la matrice de masse d'une equation.
virtual Matrice_Base & ajouter_masse(double dt, Matrice_Base &matrice, int penalisation=1) const
virtual DoubleTab & corriger_solution(DoubleTab &x, const DoubleTab &y, int incr=0) const
Classe de base des flux de sortie.
Definition Sortie.h:52
classe Symetrie Sur les faces de symetrie on a les proprietes suivantes:
Definition Symetrie.h:37
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, View< _TYPE_, _SHAPE_ > > view_rw()
Definition TRUSTTab.h:291
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67