TRUST 1.9.8
HPC thermohydraulic platform
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}
Classe Champ_Inc_base.
classe Champ_base Cette classe est la base de la hierarchie des champs.
Definition Champ_base.h:43
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
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.
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
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.
double calculer_dt_stab() const override
Calcul 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.
classe Operateur_Conv_base Cette classe est la base de la hierarchie des operateurs representant
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 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