TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Op_NConserv_Coloc_base.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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 <Op_NConserv_negligeable.h>
17#include <Op_NConserv_Coloc_base.h>
18#include <Milieu_composite_Euler.h>
19#include <Domaine_Cl_Coloc.h>
20#include <Momentum_Euler.h>
21#include <Champ_Inc_base.h>
22#include <EcrFicPartage.h>
23#include <Domaine_Coloc.h>
24#include <Pb_Euler.h>
25
26Implemente_base(Op_NConserv_Coloc_base, "Op_NConserv_Coloc_base", Operateur_NConserv_base);
27
29
31
33{
34 if (!sub_type(Pb_Euler, equation().probleme()))
35 {
36 Cerr << "WHAT !! Operator " << que_suis_je() << " is only available for Pb_Euler not " << equation().probleme().que_suis_je() << " !! " << finl;
38 }
39
40 // Seulement operateur negligeable si mono-phasique
41 if (!sub_type(Op_NConserv_negligeable, *this))
42 {
43 const Milieu_composite_Euler& mil = ref_cast(Milieu_composite_Euler, equation().probleme().milieu());
44 if (mil.noms_phases().size() == 1)
45 {
46 Cerr << "You are simulating a Single-Phase Euler problem. You need to use a negligible non-conservative operator !!!" << finl;
47 Cerr << "Please remove the non-conservative operator " << que_suis_je() << " from your your equation " << equation().que_suis_je() << " !!" << finl;
49 }
50 }
51
53 assert(le_dom_coloc_);
54}
55
57{
58 le_dom_coloc_ = ref_cast(Domaine_Coloc, domaine_dis);
59 le_dcl_coloc_ = ref_cast(Domaine_Cl_Coloc, zcl);
60 le_champ_inco = ref_cast(Champ_Inc_base, inc);
61}
62
64{
65 le_dcl_coloc_ = ref_cast(Domaine_Cl_Coloc, zcl);
66}
67
69{
70 const Domaine& mon_dom = le_dom_coloc_->domaine();
71 const int impr_mom = mon_dom.moments_a_imprimer() && sub_type(Momentum_Euler, equation());
72 const int impr_sum = (mon_dom.bords_a_imprimer_sum().est_vide() ? 0 : 1);
73 const int impr_bord = (mon_dom.bords_a_imprimer().est_vide() ? 0 : 1);
74 const Schema_Temps_base& sch = le_dcl_coloc_->equation().probleme().schema_temps();
75 DoubleTab& tab_flux_bords = flux_bords();
76 int nb_comp = tab_flux_bords.nb_dim() > 1 ? tab_flux_bords.dimension(1) : 0;
77 DoubleVect bilan(nb_comp);
78 DoubleTab xgr;
79 if (impr_mom)
80 xgr = le_dom_coloc_->calculer_xgr();
81 if (nb_comp == 0)
82 return 1;
83 int k, face;
84 int nb_front_Cl = le_dom_coloc_->nb_front_Cl();
85 DoubleTrav flux_bords2(5, nb_front_Cl, nb_comp);
86 flux_bords2 = 0;
87 for (int num_cl = 0; num_cl < nb_front_Cl; num_cl++)
88 {
89 const Cond_lim& la_cl = le_dcl_coloc_->les_conditions_limites(num_cl);
90 const Front_VF& frontiere_dis = ref_cast(Front_VF, la_cl->frontiere_dis());
91 int ndeb = frontiere_dis.num_premiere_face();
92 int nfin = ndeb + frontiere_dis.nb_faces();
93 for (face = ndeb; face < nfin; face++)
94 {
95 for (k = 0; k < nb_comp; k++)
96 {
97 flux_bords2(0, num_cl, k) += tab_flux_bords(face, k);
98 if (mon_dom.bords_a_imprimer_sum().contient(frontiere_dis.le_nom()))
99 flux_bords2(3, num_cl, k) += tab_flux_bords(face, k);
100 } /* fin for k */
101 if (impr_mom)
102 {
103 if (dimension == 2)
104 {
105 flux_bords2(4, num_cl, 0) += tab_flux_bords(face, 1) * xgr(face, 0) - tab_flux_bords(face, 0) * xgr(face, 1);
106 }
107 else
108 {
109 flux_bords2(4, num_cl, 0) += tab_flux_bords(face, 2) * xgr(face, 1) - tab_flux_bords(face, 1) * xgr(face, 2);
110 flux_bords2(4, num_cl, 1) += tab_flux_bords(face, 0) * xgr(face, 2) - tab_flux_bords(face, 2) * xgr(face, 0);
111 flux_bords2(4, num_cl, 2) += tab_flux_bords(face, 1) * xgr(face, 0) - tab_flux_bords(face, 0) * xgr(face, 1);
112 }
113 }
114 } /* fin for face */
115 }
116 mp_sum_for_each_item(flux_bords2);
117
118 if (je_suis_maitre())
119 {
120 ouvrir_fichier(Flux, "", 1);
121 ouvrir_fichier(Flux_moment, "moment", impr_mom);
122 ouvrir_fichier(Flux_sum, "sum", impr_sum);
123 Flux.add_col(sch.temps_courant());
124 if (impr_mom)
125 Flux_moment.add_col(sch.temps_courant());
126 if (impr_sum)
127 Flux_sum.add_col(sch.temps_courant());
128 for (int num_cl = 0; num_cl < nb_front_Cl; num_cl++)
129 {
130 for (k = 0; k < nb_comp; k++)
131 {
132 Flux.add_col(flux_bords2(0, num_cl, k));
133 if (impr_sum)
134 Flux_sum.add_col(flux_bords2(3, num_cl, k));
135 bilan(k) += flux_bords2(0, num_cl, k);
136 }
137 if (dimension == 3)
138 {
139 for (k = 0; k < nb_comp; k++)
140 if (impr_mom)
141 Flux_moment.add_col(flux_bords2(4, num_cl, k));
142 }
143 else
144 {
145 if (impr_mom)
146 Flux_moment.add_col(flux_bords2(4, num_cl, 0));
147 }
148 } /* fin for num_cl */
149 for (k = 0; k < nb_comp; k++)
150 Flux.add_col(bilan(k));
151 Flux << finl;
152 if (impr_sum)
153 Flux_sum << finl;
154 if (impr_mom)
155 Flux_moment << finl;
156 }
157
158 const LIST(Nom) &Liste_bords_a_imprimer = le_dom_coloc_->domaine().bords_a_imprimer();
159 if (!Liste_bords_a_imprimer.est_vide())
160 {
161 EcrFicPartage Flux_face;
162 ouvrir_fichier_partage(Flux_face, "", impr_bord);
163 for (int num_cl = 0; num_cl < nb_front_Cl; num_cl++)
164 {
165 const Frontiere_dis_base& la_fr = le_dcl_coloc_->les_conditions_limites(num_cl)->frontiere_dis();
166 const Cond_lim& la_cl = le_dcl_coloc_->les_conditions_limites(num_cl);
167 const Front_VF& frontiere_dis = ref_cast(Front_VF, la_cl->frontiere_dis());
168 int ndeb = frontiere_dis.num_premiere_face();
169 int nfin = ndeb + frontiere_dis.nb_faces();
170 if (mon_dom.bords_a_imprimer().contient(la_fr.le_nom()))
171 {
172 if (je_suis_maitre())
173 {
174 Flux_face << "# Flux par face sur " << la_fr.le_nom() << " au temps ";
175 sch.imprimer_temps_courant(Flux_face);
176 Flux_face << " : " << finl;
177 }
178 for (face = ndeb; face < nfin; face++)
179 {
180 if (dimension == 2)
181 Flux_face << "# Face a x= " << le_dom_coloc_->xv(face, 0) << " y= " << le_dom_coloc_->xv(face, 1) << " : ";
182 else if (dimension == 3)
183 Flux_face << "# Face a x= " << le_dom_coloc_->xv(face, 0) << " y= " << le_dom_coloc_->xv(face, 1) << " z= " << le_dom_coloc_->xv(face, 2) << " : ";
184 for (k = 0; k < nb_comp; k++)
185 Flux_face << tab_flux_bords(face, k) << " ";
186 Flux_face << finl;
187 }
188 Flux_face.syncfile();
189 }
190 }
191 }
192
193 return 1;
194}
Classe Champ_Inc_base.
classe Cond_lim Classe generique servant a representer n'importe quelle classe
Definition Cond_lim.h:31
classe Domaine_Cl_dis_base Les objets Domaine_Cl_dis_base representent les conditions aux limites
int moments_a_imprimer() const
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
Sortie & syncfile() override
Provoque l'ecriture sur disque des donnees accumulees sur les differents processeurs depuis le dernie...
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
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
classe Frontiere_dis_base Classe representant une frontiere discretisee.
const Nom & le_nom() const override
Renvoie le nom de la frontiere geometrique.
const Noms & noms_phases() const
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
static int dimension
Definition Objet_U.h:99
friend class Sortie
Definition Objet_U.h:75
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 Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
int impr(Sortie &os) const override
DOES NOTHING - to override in derived classes.
void associer_domaine_cl_dis(const Domaine_Cl_dis_base &zcl) override
void associer(const Domaine_dis_base &, const Domaine_Cl_dis_base &, const Champ_Inc_base &) override
void completer() override
Associe l'operateur au domaine_dis, le domaine_Cl_dis, et a l'inconnue de son equation.
void ouvrir_fichier_partage(EcrFicPartage &, const Nom &, const int flag=1) const
Ouverture/creation d'un fichier d'impression d'un operateur A surcharger dans les classes derivees.
virtual void completer()
Associe l'operateur au domaine_dis, le domaine_Cl_dis, et a l'inconnue de son equation.
DoubleTab & flux_bords()
void ouvrir_fichier(SFichier &os, const Nom &, const int flag=1) const
Ouverture/creation d'un fichier d'impression d'un operateur A surcharger dans les classes derivees.
static void mp_sum_for_each_item(TRUSTArray< _TYPE_ > &x, int n=-1)
Definition Process.cpp:193
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
Definition Process.cpp:86
class Schema_Temps_base
double temps_courant() const
Renvoie le temps courant.
void imprimer_temps_courant(SFichier &) const
Classe de base des flux de sortie.
Definition Sortie.h:52
int nb_dim() const
Definition TRUSTTab.h:199
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133