TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Conv_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_Conv_Coloc_base.h>
17#include <Domaine_Cl_Coloc.h>
18#include <Champ_Inc_base.h>
19#include <Momentum_Euler.h>
20#include <Domaine_Coloc.h>
21#include <EcrFicPartage.h>
22#include <Pb_Euler.h>
23
24Implemente_base(Op_Conv_Coloc_base,"Op_Conv_Coloc_base",Operateur_Conv_base);
25
28
30{
31 if (!sub_type(Pb_Euler, equation().probleme()))
32 {
33 Cerr << "WHAT !! Operator " << que_suis_je() << " is only available for Pb_Euler not " << equation().probleme().que_suis_je() << " !! " << finl;
35 }
36
38 assert(le_dom_coloc_);
39}
40
42{
43 le_dom_coloc_ = ref_cast(Domaine_Coloc, domaine_dis);
44 le_dcl_coloc_ = ref_cast(Domaine_Cl_Coloc, zcl);
45 le_champ_inco = ref_cast(Champ_Inc_base,inc);
46}
47
49{
50 le_dcl_coloc_ = ref_cast(Domaine_Cl_Coloc, zcl);
51}
52
53void Op_Conv_Coloc_base::ajouter_blocs(matrices_t mats, DoubleTab& secmem, const tabs_t& semi_impl) const
54{
55
56 const Domaine_Coloc& domaine = ref_cast(Domaine_Coloc, le_dom_coloc_.valeur());
57 const DoubleVect& fs = domaine.face_surfaces();
58 const IntTab& f_e = domaine.face_voisins();
59 const int n = secmem.line_size();
60 const int nb_faces = domaine.nb_faces();
61 DoubleTrav num_flux(nb_faces, n);
62 Riemann_solver(num_flux);
63
64 for (int f = 0; f < nb_faces; f++)
65 for (int i = 0; i < 2; i++)
66 {
67 const int e = f_e(f, i);
68 if (e >= 0 && e < domaine.nb_elem())
69 {
70 for (int k = 0; k < n; k++)
71 secmem(e, k) -= (i ? -1 : 1) * num_flux(f, k) * fs(f);
72 }
73 }
74}
75
77{
78 const Domaine& mon_dom = le_dom_coloc_->domaine();
79 const int impr_mom = mon_dom.moments_a_imprimer() && sub_type(Momentum_Euler, equation());
80 const int impr_sum = (mon_dom.bords_a_imprimer_sum().est_vide() ? 0 : 1);
81 const int impr_bord = (mon_dom.bords_a_imprimer().est_vide() ? 0 : 1);
82 const Schema_Temps_base& sch = le_dcl_coloc_->equation().probleme().schema_temps();
83 DoubleTab& tab_flux_bords = flux_bords();
84 int nb_comp = tab_flux_bords.nb_dim() > 1 ? tab_flux_bords.dimension(1) : 0;
85 DoubleVect bilan(nb_comp);
86 DoubleTab xgr;
87 if (impr_mom)
88 xgr = le_dom_coloc_->calculer_xgr();
89 if (nb_comp == 0)
90 return 1;
91 int k, face;
92 int nb_front_Cl = le_dom_coloc_->nb_front_Cl();
93 DoubleTrav flux_bords2(5, nb_front_Cl, nb_comp);
94 flux_bords2 = 0;
95 for (int num_cl = 0; num_cl < nb_front_Cl; num_cl++)
96 {
97 const Cond_lim& la_cl = le_dcl_coloc_->les_conditions_limites(num_cl);
98 const Front_VF& frontiere_dis = ref_cast(Front_VF, la_cl->frontiere_dis());
99 int ndeb = frontiere_dis.num_premiere_face();
100 int nfin = ndeb + frontiere_dis.nb_faces();
101 for (face = ndeb; face < nfin; face++)
102 {
103 for (k = 0; k < nb_comp; k++)
104 {
105 flux_bords2(0, num_cl, k) += tab_flux_bords(face, k);
106 if (mon_dom.bords_a_imprimer_sum().contient(frontiere_dis.le_nom()))
107 flux_bords2(3, num_cl, k) += tab_flux_bords(face, k);
108 } /* fin for k */
109 if (impr_mom)
110 {
111 if (dimension == 2)
112 {
113 flux_bords2(4, num_cl, 0) += tab_flux_bords(face, 1) * xgr(face, 0) - tab_flux_bords(face, 0) * xgr(face, 1);
114 }
115 else
116 {
117 flux_bords2(4, num_cl, 0) += tab_flux_bords(face, 2) * xgr(face, 1) - tab_flux_bords(face, 1) * xgr(face, 2);
118 flux_bords2(4, num_cl, 1) += tab_flux_bords(face, 0) * xgr(face, 2) - tab_flux_bords(face, 2) * xgr(face, 0);
119 flux_bords2(4, num_cl, 2) += tab_flux_bords(face, 1) * xgr(face, 0) - tab_flux_bords(face, 0) * xgr(face, 1);
120 }
121 }
122 } /* fin for face */
123 }
124 mp_sum_for_each_item(flux_bords2);
125
126 if (je_suis_maitre())
127 {
128 ouvrir_fichier(Flux, "", 1);
129 ouvrir_fichier(Flux_moment, "moment", impr_mom);
130 ouvrir_fichier(Flux_sum, "sum", impr_sum);
131 Flux.add_col(sch.temps_courant());
132 if (impr_mom)
133 Flux_moment.add_col(sch.temps_courant());
134 if (impr_sum)
135 Flux_sum.add_col(sch.temps_courant());
136 for (int num_cl = 0; num_cl < nb_front_Cl; num_cl++)
137 {
138 for (k = 0; k < nb_comp; k++)
139 {
140 Flux.add_col(flux_bords2(0, num_cl, k));
141 if (impr_sum)
142 Flux_sum.add_col(flux_bords2(3, num_cl, k));
143 bilan(k) += flux_bords2(0, num_cl, k);
144 }
145 if (dimension == 3)
146 {
147 for (k = 0; k < nb_comp; k++)
148 if (impr_mom)
149 Flux_moment.add_col(flux_bords2(4, num_cl, k));
150 }
151 else
152 {
153 if (impr_mom)
154 Flux_moment.add_col(flux_bords2(4, num_cl, 0));
155 }
156 } /* fin for num_cl */
157 for (k = 0; k < nb_comp; k++)
158 Flux.add_col(bilan(k));
159 Flux << finl;
160 if (impr_sum)
161 Flux_sum << finl;
162 if (impr_mom)
163 Flux_moment << finl;
164 }
165
166 const LIST(Nom) &Liste_bords_a_imprimer = le_dom_coloc_->domaine().bords_a_imprimer();
167 if (!Liste_bords_a_imprimer.est_vide())
168 {
169 EcrFicPartage Flux_face;
170 ouvrir_fichier_partage(Flux_face, "", impr_bord);
171 for (int num_cl = 0; num_cl < nb_front_Cl; num_cl++)
172 {
173 const Frontiere_dis_base& la_fr = le_dcl_coloc_->les_conditions_limites(num_cl)->frontiere_dis();
174 const Cond_lim& la_cl = le_dcl_coloc_->les_conditions_limites(num_cl);
175 const Front_VF& frontiere_dis = ref_cast(Front_VF, la_cl->frontiere_dis());
176 int ndeb = frontiere_dis.num_premiere_face();
177 int nfin = ndeb + frontiere_dis.nb_faces();
178 if (mon_dom.bords_a_imprimer().contient(la_fr.le_nom()))
179 {
180 if (je_suis_maitre())
181 {
182 Flux_face << "# Flux par face sur " << la_fr.le_nom() << " au temps ";
183 sch.imprimer_temps_courant(Flux_face);
184 Flux_face << " : " << finl;
185 }
186 for (face = ndeb; face < nfin; face++)
187 {
188 if (dimension == 2)
189 Flux_face << "# Face a x= " << le_dom_coloc_->xv(face, 0) << " y= " << le_dom_coloc_->xv(face, 1) << " : ";
190 else if (dimension == 3)
191 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) << " : ";
192 for (k = 0; k < nb_comp; k++)
193 Flux_face << tab_flux_bords(face, k) << " ";
194 Flux_face << finl;
195 }
196 Flux_face.syncfile();
197 }
198 }
199 }
200
201 return 1;
202}
Class Champ_Inc_base.
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
int moments_a_imprimer() const
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Sortie & syncfile() override
Triggers writing to disk of the data accumulated on the different processors since the last call to s...
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Probleme_base & probleme()
Returns the problem associated with the 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
class Frontiere_dis_base Class representing a discretized boundary.
const Nom & le_nom() const override
Returns the name of the geometric boundary.
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
static int dimension
Definition Objet_U.h:94
friend class Sortie
Definition Objet_U.h:70
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
virtual void Riemann_solver(DoubleTab &num_flux) const =0
void completer() override
Associates the operator with the domaine_dis, the domaine_Cl_dis, and the unknown of its equation.
int impr(Sortie &os) const override
DOES NOTHING - to override in derived classes.
void associer(const Domaine_dis_base &, const Domaine_Cl_dis_base &, const Champ_Inc_base &) override
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
void associer_domaine_cl_dis(const Domaine_Cl_dis_base &zcl) override
Operateur_Conv_base This class is the base of the hierarchy of operators representing.
void ouvrir_fichier_partage(EcrFicPartage &, const Nom &, const int flag=1) const
Opening/creation of a shared file for printing an operator. To override in derived classes.
virtual void completer()
Associates the operator with the domaine_dis, the domaine_Cl_dis, and the unknown of its equation.
DoubleTab & flux_bords()
void ouvrir_fichier(SFichier &os, const Nom &, const int flag=1) const
Opening/creation of a file for printing an operator. To override in derived classes.
static void mp_sum_for_each_item(TRUSTArray< _TYPE_ > &x, int n=-1)
Definition Process.cpp:194
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
Definition Process.cpp:82
class Schema_Temps_base
double temps_courant() const
Returns the current time.
void imprimer_temps_courant(SFichier &) const
Base class for output streams.
Definition Sortie.h:52
int nb_dim() const
Definition TRUSTTab.h:199
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67