TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Iterateur_VDF_Face_bis.tpp
1/****************************************************************************
2* Copyright (c) 2024, 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#ifndef Iterateur_VDF_Face_bis_TPP_included
17#define Iterateur_VDF_Face_bis_TPP_included
18
19template<class _TYPE_>
32
33template<class _TYPE_>
35{
36 nb_elem = le_dom->nb_elem_tot();
37 orientation.ref(le_dom->orientation());
38 Qdm.ref(le_dom->Qdm());
39 elem.ref(le_dom->face_voisins());
40 elem_faces.ref(le_dom->elem_faces());
41 type_arete_bord.ref(la_zcl->type_arete_bord());
42 type_arete_coin.ref(la_zcl->type_arete_coin());
43 premiere_arete_interne = le_dom->premiere_arete_interne();
44 derniere_arete_interne = premiere_arete_interne + le_dom->nb_aretes_internes();
45 premiere_arete_mixte = le_dom->premiere_arete_mixte();
46 derniere_arete_mixte = premiere_arete_mixte + le_dom->nb_aretes_mixtes();
47 premiere_arete_bord = le_dom->premiere_arete_bord();
48 derniere_arete_bord = premiere_arete_bord + le_dom->nb_aretes_bord();
49 premiere_arete_coin = le_dom->premiere_arete_coin();
50 derniere_arete_coin = premiere_arete_coin + le_dom->nb_aretes_coin();
51}
52
53template<class _TYPE_>
54inline void Iterateur_VDF_Face<_TYPE_>::multiply_by_rho_if_hydraulique(DoubleTab& tab_flux_bords) const
55{
56 Nom nom_eqn = la_zcl->equation().que_suis_je();
57 /* Modif B.Mathieu pour front-tracking: masse_volumique() invalide en f.t.*/
58 if (nom_eqn.debute_par("Navier_Stokes") && nom_eqn != "Navier_Stokes_Melange" && nom_eqn != "Navier_Stokes_FT_Disc")
59 {
60 const Champ_base& rho = la_zcl->equation().milieu().masse_volumique();
61 if (sub_type(Champ_Uniforme, rho))
62 {
63 const double coef = rho.valeurs()(0, 0);
64 const int nb_faces_bord = le_dom->nb_faces_bord();
65 for (int face = 0; face < nb_faces_bord; face++)
66 for (int k = 0; k < tab_flux_bords.line_size(); k++) tab_flux_bords(face, k) *= coef;
67 }
68 }
69}
70
71template<class _TYPE_>
73{
74 const Domaine& mon_dom = le_dom->domaine();
75 const int impr_mom = mon_dom.moments_a_imprimer();
76 const int impr_sum = (mon_dom.bords_a_imprimer_sum().est_vide() ? 0 : 1), impr_bord = (mon_dom.bords_a_imprimer().est_vide() ? 0 : 1);
77 const Schema_Temps_base& sch = la_zcl->equation().probleme().schema_temps();
78 DoubleTab& tab_flux_bords = op_base->flux_bords();
79 DoubleVect bilan(tab_flux_bords.dimension(1));
80 DoubleTab xgr;
81 if (impr_mom) xgr = le_dom->calculer_xgr();
82 int k, face, nb_front_Cl = le_dom->nb_front_Cl();
83 DoubleTrav flux_bords2(5, nb_front_Cl, tab_flux_bords.dimension(1));
84 flux_bords2 = 0;
85 for (int num_cl = 0; num_cl < nb_front_Cl; num_cl++)
86 {
87 const Cond_lim& la_cl = la_zcl->les_conditions_limites(num_cl);
88 const Front_VF& frontiere_dis = ref_cast(Front_VF, la_cl->frontiere_dis());
89 int ndeb = frontiere_dis.num_premiere_face(), nfin = ndeb + frontiere_dis.nb_faces(), periodicite = (type_cl(la_cl) == periodique ? 1 : 0);
90 for (face = ndeb; face < nfin; face++)
91 {
92 for (k = 0; k < tab_flux_bords.dimension(1); k++)
93 {
94 flux_bords2(0, num_cl, k) += tab_flux_bords(face, k);
95 if (periodicite)
96 {
97 if (face < (ndeb + frontiere_dis.nb_faces() / 2))
98 flux_bords2(1, num_cl, k) += tab_flux_bords(face, k);
99 else
100 flux_bords2(2, num_cl, k) += tab_flux_bords(face, k);
101 }
102 if (mon_dom.bords_a_imprimer_sum().contient(frontiere_dis.le_nom()))
103 flux_bords2(3, num_cl, k) += tab_flux_bords(face, k);
104 } /* fin for k */
105 if (impr_mom)
106 {
107 if (dimension == 2)
108 flux_bords2(4, num_cl, 0) += tab_flux_bords(face, 1) * xgr(face, 0) - tab_flux_bords(face, 0) * xgr(face, 1);
109 else
110 {
111 flux_bords2(4, num_cl, 0) += tab_flux_bords(face, 2) * xgr(face, 1) - tab_flux_bords(face, 1) * xgr(face, 2);
112 flux_bords2(4, num_cl, 1) += tab_flux_bords(face, 0) * xgr(face, 2) - tab_flux_bords(face, 2) * xgr(face, 0);
113 flux_bords2(4, num_cl, 2) += tab_flux_bords(face, 1) * xgr(face, 0) - tab_flux_bords(face, 0) * xgr(face, 1);
114 }
115 }
116 } /* fin for face */
117 }
118 mp_sum_for_each_item(flux_bords2);
119 if (je_suis_maitre())
120 {
121 op_base->ouvrir_fichier(Flux, "", 1);
122 op_base->ouvrir_fichier(Flux_moment, "moment", impr_mom);
123 op_base->ouvrir_fichier(Flux_sum, "sum", impr_sum);
124 Flux.add_col(sch.temps_courant());
125 if (impr_mom)
126 Flux_moment.add_col(sch.temps_courant());
127 if (impr_sum)
128 Flux_sum.add_col(sch.temps_courant());
129 for (int num_cl = 0; num_cl < nb_front_Cl; num_cl++)
130 {
131 const Cond_lim& la_cl = la_zcl->les_conditions_limites(num_cl);
132 int periodicite = (type_cl(la_cl) == periodique ? 1 : 0);
133 for (k = 0; k < tab_flux_bords.dimension(1); k++)
134 {
135 if (periodicite)
136 {
137 Flux.add_col(flux_bords2(1, num_cl, k));
138 Flux.add_col(flux_bords2(2, num_cl, k));
139 }
140 else
141 Flux.add_col(flux_bords2(0, num_cl, k));
142
143 if (impr_sum)
144 Flux_sum.add_col(flux_bords2(3, num_cl, k));
145 bilan(k) += flux_bords2(0, num_cl, k);
146 }
147 if (dimension == 3)
148 {
149 for (k = 0; k < tab_flux_bords.dimension(1); k++)
150 if (impr_mom)
151 Flux_moment.add_col(flux_bords2(4, num_cl, k));
152 }
153 else if (impr_mom)
154 Flux_moment.add_col(flux_bords2(4, num_cl, 0));
155 } /* fin for num_cl */
156 for (k = 0; k < tab_flux_bords.dimension(1); k++)
157 Flux.add_col(bilan(k));
158 Flux << finl;
159 if (impr_sum)
160 Flux_sum << finl;
161 if (impr_mom)
162 Flux_moment << finl;
163 }
164 const LIST (Nom)
165 &Liste_bords_a_imprimer = le_dom->domaine().bords_a_imprimer();
166 if (!Liste_bords_a_imprimer.est_vide())
167 {
168 EcrFicPartage Flux_face;
169 op_base->ouvrir_fichier_partage(Flux_face, "", impr_bord);
170 for (int num_cl = 0; num_cl < nb_front_Cl; num_cl++)
171 {
172 const Frontiere_dis_base& la_fr = la_zcl->les_conditions_limites(num_cl)->frontiere_dis();
173 const Cond_lim& la_cl = la_zcl->les_conditions_limites(num_cl);
174 const Front_VF& frontiere_dis = ref_cast(Front_VF, la_cl->frontiere_dis());
175 int ndeb = frontiere_dis.num_premiere_face(), nfin = ndeb + frontiere_dis.nb_faces();
176 if (mon_dom.bords_a_imprimer().contient(la_fr.le_nom()))
177 {
178 if (je_suis_maitre())
179 {
180 Flux_face << "# Flux par face sur " << la_fr.le_nom() << " au temps ";
181 sch.imprimer_temps_courant(Flux_face);
182 Flux_face << " : " << finl;
183 }
184 for (face = ndeb; face < nfin; face++)
185 {
186 if (dimension == 2)
187 Flux_face << "# Face a x= " << le_dom->xv(face, 0) << " y= " << le_dom->xv(face, 1) << " : ";
188 else if (dimension == 3)
189 Flux_face << "# Face a x= " << le_dom->xv(face, 0) << " y= " << le_dom->xv(face, 1) << " z= " << le_dom->xv(face, 2) << " : ";
190 for (k = 0; k < tab_flux_bords.dimension(1); k++)
191 Flux_face << tab_flux_bords(face, k) << " ";
192 Flux_face << finl;
193 }
194 Flux_face.syncfile();
195 }
196 }
197 }
198 return 1;
199}
200
201#endif /* Iterateur_VDF_Face_bis_TPP_included */
virtual DoubleTab & valeurs()=0
Champ_Uniforme Represents a field that is constant in space and time.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
int moments_a_imprimer() const
Sortie & syncfile() override
Triggers writing to disk of the data accumulated on the different processors since the last call to s...
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.
int impr(Sortie &os) const override
Type_Cl_VDF type_cl(const Cond_lim &) const
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
virtual int debute_par(const char *const n) const
Definition Nom.cpp:314
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
static void mp_sum_for_each_item(TRUSTArray< _TYPE_ > &x, int n=-1)
Definition Process.cpp:194
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
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67