TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Format_Post_CGNS.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 <Format_Post_CGNS.h>
17#include <My_Comm_Group.h>
18#include <Option_CGNS.h>
19#include <PE_Groups.h>
20#include <EChaine.h>
21#include <Param.h>
22
23Implemente_instanciable_sans_constructeur(Format_Post_CGNS, "Format_Post_CGNS", Format_Post_base);
24
25static void init_my_com_group()
26{
28 {
29 const int nb_nodes = PE_Groups::get_node_group().get_number_of_nodes();
30 if (nb_nodes > 1)
31 {
35 Nom ech = "{ Group_nb ";
36 ech += Nom(nb_nodes);
37 ech += " }";
38
39 My_Comm_Group comm;
40 EChaine ech2(ech);
41
42 ech2 >> comm;
43 }
44 }
45}
46
51
53{
54 cgns_basename_ = "??";
55}
56
58{
59 Process::exit("Format_Post_CGNS::printOn - Should not be called ! ");
60 return os;
61}
62
64{
65 Process::exit("Format_Post_CGNS::readOn - Should not be called ! ");
66 verify_if_cgns(__func__);
67 init_my_com_group();
68 return Format_Post_base::readOn(is);
69}
70
72{
73 Process::exit("Format_Post_CGNS::readOn - Should not be called ! ");
74 verify_if_cgns(__func__);
75 param.ajouter("nom_fichier", &cgns_basename_, Param::REQUIRED);
76}
77
78void Format_Post_CGNS::resetTime(double t, const std::string dirname)
79{
80 if (dirname.empty())
81 Process::exit("\nError in Format_Post_CGNS::resetTime. The name of the directory is empty. This is forbidden !!! \n");
82
83#ifdef HAS_CGNS
84 cgns_writer_.cgns_resetTime(t, dirname, cgns_basename_);
85#endif
86}
87
89{
90 verify_if_cgns(__func__);
91 init_my_com_group();
92 cgns_basename_ = file_basename;
93#ifdef HAS_CGNS
94 cgns_writer_.cgns_set_base_name(cgns_basename_);
95#endif
96 return 1;
97}
98
99int Format_Post_CGNS::initialize(const Nom& file_basename, const int format, const Nom& option_para)
100{
101 verify_if_cgns(__func__);
102 init_my_com_group();
103 cgns_basename_ = file_basename;
104#ifdef HAS_CGNS
105 cgns_writer_.cgns_set_base_name(cgns_basename_);
106#endif
107 return 1;
108}
109
110int Format_Post_CGNS::ecrire_entete(const double temps_courant,const int reprise,const int est_le_premier_post)
111{
112 verify_if_cgns(__func__);
113
114 if (est_le_premier_post)
115 {
116#ifdef HAS_CGNS
117 cgns_writer_.cgns_open_file();
118#endif
119 }
120 return 1;
121}
122
124{
125#ifdef HAS_CGNS
126 cgns_writer_.cgns_set_discr_type(type);
127#endif
128}
129
131{
132#ifdef HAS_CGNS
133 cgns_writer_.cgns_set_postraiter_domain();
134#endif
135}
136
138{
139#ifdef HAS_CGNS
140 cgns_writer_.cgns_set_is_deformable_domain();
141#endif
142}
143
145{
146#ifdef HAS_CGNS
147 cgns_writer_.cgns_set_lagrangian_domain();
148#endif
149}
150
151void Format_Post_CGNS::set_loc_vector(const std::vector<std::string>& vec)
152{
153#ifdef HAS_CGNS
154 cgns_writer_.cgns_set_loc_vector(vec);
155#endif
156}
157
159{
160#ifdef HAS_CGNS
161 cgns_writer_.cgns_add_time(t);
162#endif
163 return 1;
164}
165
166int Format_Post_CGNS::finir_ecriture(double temps_courant)
167{
168#ifdef HAS_CGNS
169 cgns_writer_.finir_ecriture(temps_courant);
170#endif
171 return 1;
172}
173
174int Format_Post_CGNS::finir(const int est_le_dernier_post)
175{
176 if (est_le_dernier_post)
177 {
178#ifdef HAS_CGNS
179 cgns_writer_.cgns_finir();
180#endif
181 }
182 return 1;
183}
184
185void Format_Post_CGNS::ecrire_domaine_dual(const Domaine& domaine, const int est_le_premier_post)
186{
187#ifdef HAS_CGNS
188 cgns_writer_.cgns_write_domaine_dual(domaine.le_nom(), est_le_premier_post);
189#endif
190}
191
192int Format_Post_CGNS::ecrire_domaine_low_level(const Domaine * dom,const Nom& nom_dom, const DoubleTab& som, const IntTab& elem, const Motcle& type_e)
193{
194#ifdef HAS_CGNS
195 cgns_writer_.cgns_write_domaine(dom, nom_dom, som, elem, type_e);
196#endif
197 return 1;
198}
199
200int Format_Post_CGNS::ecrire_domaine_dis(const Domaine& domaine,const OBS_PTR(Domaine_dis_base)& domaine_dis_base,const int est_le_premier_post)
201{
202 if (domaine_dis_base)
203 {
204 domaine_dis_ = domaine_dis_base;
205#ifdef HAS_CGNS
206 cgns_writer_.cgns_associer_domaine_dis(domaine_dis_base.valeur());
207#endif
208 }
209 return ecrire_domaine(domaine, est_le_premier_post);
210}
211
212int Format_Post_CGNS::ecrire_domaine(const Domaine& domaine, const int est_le_premier_post)
213{
214 Motcle type_e = domaine.type_elem()->que_suis_je();
215 ecrire_domaine_low_level(&domaine, domaine.le_nom(), domaine.les_sommets(), domaine.les_elems(), type_e);
216
217 // Si on a des frontieres domaine, on les ecrit egalement
218 const LIST(OBS_PTR(Domaine)) &bords = domaine.domaines_frontieres();
219 for (auto &itr : bords) ecrire_domaine(itr.valeur(), est_le_premier_post);
220 return 1;
221}
222
223int Format_Post_CGNS::ecrire_champ(const Domaine& domaine, const Noms& unite_, const Noms& noms_compo, int ncomp, double temps,
224 const Nom& id_du_champ, const Nom& id_du_domaine, const Nom& localisation,
225 const Nom& nature, const DoubleTab& valeurs)
226{
227#ifdef HAS_CGNS
228 cgns_writer_.cgns_write_field(domaine, noms_compo, temps, id_du_champ, id_du_domaine, localisation, valeurs );
229#endif
230 return 1;
231}
int get_number_of_nodes() const
Definition Comm_Group.h:204
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
Une entree dont la source est une chaine de caracteres.
Definition EChaine.h:31
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Format_Post_CGNS
void set_lagrangian_domain() override
void ecrire_domaine_dual(const Domaine &, const int) override
int ecrire_domaine(const Domaine &, const int) override
Ecriture d'un maillage.
void set_loc_vector(const std::vector< std::string > &) override
void set_discr_type(const Nom &) override
int ecrire_champ(const Domaine &, const Noms &, const Noms &, int, double, const Nom &, const Nom &, const Nom &, const Nom &, const DoubleTab &) override
Ecriture d'un champ dans le fichier de postraitement.
int initialize_by_default(const Nom &) override
Initialise le fichier avec des parametres appropries pour son format (exemple: format ascii,...
int initialize(const Nom &, const int, const Nom &) override
void set_param(Param &param) const override
int ecrire_domaine_low_level(const Domaine *, const Nom &, const DoubleTab &, const IntTab &, const Motcle &)
Format_Post_CGNS()
int finir(const int) override
void reset() override
void set_deformable_domain() override
int ecrire_entete(const double, const int, const int) override
void set_postraiter_domain() override
void resetTime(double t, const std::string dirname) override
int finir_ecriture(double) override
int ecrire_temps(const double) override
Commence l'ecriture d'un pas de temps.
int ecrire_domaine_dis(const Domaine &, const OBS_PTR(Domaine_dis_base)&, const int) override
Classe de base des formats de postraitements pour les champs (lata, med, cgns, lml,...
OBS_PTR(Domaine_dis_base) domaine_dis_
Reference to the discretized domain - used for face fields.
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
Un tableau de chaine de caracteres (VECT(Nom)).
Definition Noms.h:26
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
static bool LINKED_FILES_PER_COMM_GROUP
Definition Option_CGNS.h:52
static bool PARALLEL_OVER_ZONE
Definition Option_CGNS.h:48
static bool USE_LINKS
Definition Option_CGNS.h:52
static const Comm_Group & get_node_group()
Renvoie une reference au groupe sur les noeuds.
static bool has_user_defined_group()
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
@ REQUIRED
Definition Param.h:115
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52