TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Diff_PolyMAC_CDO_Gen_base.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 <Op_Diff_PolyMAC_CDO_Gen_base.h>
17#include <Domaine_Cl_PolyMAC_family.h>
18#include <Schema_Temps_base.h>
19#include <Domaine_PolyMAC_CDO.h>
20#include <communications.h>
21#include <EcrFicPartage.h>
22#include <Probleme_base.h>
23#include <SFichier.h>
24
25Implemente_base(Op_Diff_PolyMAC_CDO_Gen_base, "Op_Diff_PolyMAC_CDO_Gen_base", Operateur_Diff_base);
26
28
30
32{
33 le_dom_poly_ = ref_cast(Domaine_PolyMAC_CDO, domaine_dis);
34 la_zcl_poly_ = ref_cast(Domaine_Cl_PolyMAC_family, zcl);
35}
36
37DoubleTab& Op_Diff_PolyMAC_CDO_Gen_base::calculer(const DoubleTab& inco, DoubleTab& resu) const
38{
39 resu = 0.;
40 return ajouter(inco, resu);
41}
42
44{
45 const Domaine& mon_dom = le_dom_poly_->domaine();
46 const int impr_mom = mon_dom.moments_a_imprimer();
47 const int impr_sum = (mon_dom.bords_a_imprimer_sum().est_vide() ? 0 : 1);
48 const int impr_bord = (mon_dom.bords_a_imprimer().est_vide() ? 0 : 1);
49 const Schema_Temps_base& sch = la_zcl_poly_->equation().probleme().schema_temps();
50 DoubleTab& tab_flux_bords = flux_bords();
51 int nb_comp = tab_flux_bords.nb_dim() > 1 ? tab_flux_bords.dimension(1) : 0;
52 DoubleVect bilan(nb_comp);
53 DoubleTab xgr;
54 if (impr_mom)
55 xgr = le_dom_poly_->calculer_xgr();
56 int k, face;
57 int nb_front_Cl = le_dom_poly_->nb_front_Cl();
58 DoubleTrav flux_bords2(5, nb_front_Cl, nb_comp);
59 flux_bords2 = 0;
60 for (int num_cl = 0; num_cl < nb_front_Cl; num_cl++)
61 {
62 const Cond_lim& la_cl = la_zcl_poly_->les_conditions_limites(num_cl);
63 const Front_VF& frontiere_dis = ref_cast(Front_VF, la_cl->frontiere_dis());
64 int ndeb = frontiere_dis.num_premiere_face();
65 int nfin = ndeb + frontiere_dis.nb_faces();
66 for (face = ndeb; face < nfin; face++)
67 {
68 for (k = 0; k < nb_comp; k++)
69 {
70 flux_bords2(0, num_cl, k) += tab_flux_bords(face, k);
71 if (mon_dom.bords_a_imprimer_sum().contient(frontiere_dis.le_nom()))
72 flux_bords2(3, num_cl, k) += tab_flux_bords(face, k);
73 } /* fin for k */
74 if (impr_mom)
75 {
76 if (dimension == 2)
77 {
78 flux_bords2(4, num_cl, 0) += tab_flux_bords(face, 1) * xgr(face, 0) - tab_flux_bords(face, 0) * xgr(face, 1);
79 }
80 else
81 {
82 flux_bords2(4, num_cl, 0) += tab_flux_bords(face, 2) * xgr(face, 1) - tab_flux_bords(face, 1) * xgr(face, 2);
83 flux_bords2(4, num_cl, 1) += tab_flux_bords(face, 0) * xgr(face, 2) - tab_flux_bords(face, 2) * xgr(face, 0);
84 flux_bords2(4, num_cl, 2) += tab_flux_bords(face, 1) * xgr(face, 0) - tab_flux_bords(face, 0) * xgr(face, 1);
85 }
86 }
87 } /* fin for face */
88 }
89 mp_sum_for_each_item(flux_bords2);
90
91 if (je_suis_maitre() && nb_comp > 0)
92 {
93 ouvrir_fichier(Flux, "", 1);
94 ouvrir_fichier(Flux_moment, "moment", impr_mom);
95 ouvrir_fichier(Flux_sum, "sum", impr_sum);
96 Flux.add_col(sch.temps_courant());
97 if (impr_mom)
98 Flux_moment.add_col(sch.temps_courant());
99 if (impr_sum)
100 Flux_sum.add_col(sch.temps_courant());
101 for (int num_cl = 0; num_cl < nb_front_Cl; num_cl++)
102 {
103 for (k = 0; k < nb_comp; k++)
104 {
105 Flux.add_col(flux_bords2(0, num_cl, k));
106 if (impr_sum)
107 Flux_sum.add_col(flux_bords2(3, num_cl, k));
108 bilan(k) += flux_bords2(0, num_cl, k);
109 }
110 if (dimension == 3)
111 {
112 for (k = 0; k < nb_comp; k++)
113 if (impr_mom)
114 Flux_moment.add_col(flux_bords2(4, num_cl, k));
115 }
116 else
117 {
118 if (impr_mom)
119 Flux_moment.add_col(flux_bords2(4, num_cl, 0));
120 }
121 } /* fin for num_cl */
122 for (k = 0; k < nb_comp; k++)
123 Flux.add_col(bilan(k));
124 Flux << finl;
125 if (impr_sum)
126 Flux_sum << finl;
127 if (impr_mom)
128 Flux_moment << finl;
129 }
130 const LIST(Nom) &Liste_bords_a_imprimer = le_dom_poly_->domaine().bords_a_imprimer();
131 if (!Liste_bords_a_imprimer.est_vide() && nb_comp > 0)
132 {
133 EcrFicPartage Flux_face;
134 ouvrir_fichier_partage(Flux_face, "", impr_bord);
135 for (int num_cl = 0; num_cl < nb_front_Cl; num_cl++)
136 {
137 const Frontiere_dis_base& la_fr = la_zcl_poly_->les_conditions_limites(num_cl)->frontiere_dis();
138 const Cond_lim& la_cl = la_zcl_poly_->les_conditions_limites(num_cl);
139 const Front_VF& frontiere_dis = ref_cast(Front_VF, la_cl->frontiere_dis());
140 int ndeb = frontiere_dis.num_premiere_face();
141 int nfin = ndeb + frontiere_dis.nb_faces();
142 if (mon_dom.bords_a_imprimer().contient(la_fr.le_nom()))
143 {
144 if (je_suis_maitre())
145 {
146 Flux_face << "# Flux par face sur " << la_fr.le_nom() << " au temps ";
147 sch.imprimer_temps_courant(Flux_face);
148 Flux_face << " : " << finl;
149 }
150 for (face = ndeb; face < nfin; face++)
151 {
152 if (dimension == 2)
153 Flux_face << "# Face a x= " << le_dom_poly_->xv(face, 0) << " y= " << le_dom_poly_->xv(face, 1) << " : ";
154 else if (dimension == 3)
155 Flux_face << "# Face a x= " << le_dom_poly_->xv(face, 0) << " y= " << le_dom_poly_->xv(face, 1) << " z= " << le_dom_poly_->xv(face, 2) << " : ";
156 for (k = 0; k < nb_comp; k++)
157 Flux_face << tab_flux_bords(face, k) << " ";
158 Flux_face << finl;
159 }
160 Flux_face.syncfile();
161 }
162 }
163 }
164 return 1;
165}
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
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.
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
class Op_Diff_PolyMAC_CDO_Gen_base
int impr(Sortie &os) const override
DOES NOTHING - to override in derived classes.
DoubleTab & calculer(const DoubleTab &, DoubleTab &) const override
void associer(const Domaine_dis_base &, const Domaine_Cl_dis_base &, const Champ_Inc_base &) override
Operateur_Diff_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 DoubleTab & ajouter(const DoubleTab &, DoubleTab &) const
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 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