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