TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Ecrire_Champ_MED.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 <Ecrire_Champ_MED.h>
17#include <Format_Post_base.h>
18#include <Champ_Don_base.h>
19#include <Probleme_base.h>
20
21Implemente_instanciable(Ecrire_Champ_MED,"Ecrire_Champ_MED",Interprete);
22// XD ecrire_champ_med interprete ecrire_champ_med INHERITS_BRACE Keyword to write a field to MED format into a file.
23// XD attr nom_dom ref_domaine nom_dom REQ domain name
24// XD attr nom_chp ref_field_base nom_chp REQ field name
25// XD attr file chaine file REQ file name
26
28{
29 return Interprete::printOn(os);
30}
31
33{
34 return Interprete::readOn(is);
35}
36
37/*! @brief Fonction principale de l'interprete Ecrire_Champ_MED: erreur si cela echoue.
38 *
39 * @param (Entree& is) un flot d'entree, a partir duquel on lit les arguments
40 * @return (Entree&) le flot d'entree modifie
41 */
43{
44 Nom nom_domaine, nom_champ,nom_fic;
45
46 is >> nom_domaine >> nom_champ >> nom_fic;
47 Objet_U& obj_champ=objet(nom_champ);
48
49 if (!sub_type(Champ_Don_base, obj_champ))
50 {
51 Cerr << "The field "<< nom_champ << " is not of type Champ_Don" << finl;
53 }
54
55 Champ_Don_base& chp = ref_cast(Champ_Don_base,obj_champ);
56
57
58 /* Ecrire_MED ecrmed;
59 ecrmed.ecrire_domaine(nom_fic,dom,nom_domaine);
60 ecrmed.ecrire_champ("CHAMPMAILLE",nom_fic,nom_domaine,"critere",const DoubleTab&val,const Noms& unite,const Nom& type_elem,double time,int compteur)
61 */
62
63 Objet_U& obj_dom=objet(nom_domaine);
64 const Domaine& dom = ref_cast(Domaine,obj_dom);
65 OWN_PTR(Format_Post_base) post_typer;
66 post_typer.typer("format_post_med");
67 Format_Post_base& post=ref_cast(Format_Post_base,post_typer.valeur());
68 Nom nom_fic2(nom_fic);
69 nom_fic2.prefix(".med");
70 post.initialize_by_default(nom_fic2);
71 int est_le_premier_post=1;
72 post.ecrire_entete(0.,0,est_le_premier_post);
73 int reprise = 0;
74 double t_init = 0.;
75
76 // ecriture domaine
77 post.preparer_post(dom.le_nom(),est_le_premier_post,reprise,t_init);
78 post.ecrire_domaine(dom, est_le_premier_post);
79 double tps=chp.temps();
80
81 post.ecrire_temps(tps);
82 post.init_ecriture(tps,-1.,est_le_premier_post,dom);
84 // ecriture champ
85 //chp.postraiter_champ(dom, tps, nom_champ, "ELEM", post);
86 // la nature ne sert pas en MED
87 Nom Nature("pas_defini");
88 post.ecrire_champ(dom,chp.unites(),chp.noms_compo(),-1,tps,Motcle(chp.le_nom()),dom.le_nom(),Motcle("elem"),Nature,chp.valeurs());
89 int fin=1;
90 post.finir(fin);
91 return is;
92}
classe Champ_Don_base classe de base des Champs donnes (non calcules)
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
double temps() const
Renvoie le temps du champ.
void corriger_unite_nom_compo()
cette methode va fixer les unites et le nom des compos elle n'est pas const en realite !...
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
classe Ecrire_Champ_MED
Entree & interpreter(Entree &) override
Fonction principale de l'interprete Ecrire_Champ_MED: erreur si cela echoue.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & le_nom() const override
Renvoie le nom du champ.
const Noms & unites() const
Renvoie les unites des composantes du champ.
const Noms & noms_compo() const
Renvoie le tableau des noms des composantes du champ.
Classe de base des formats de postraitements pour les champs (lata, med, cgns, lml,...
virtual int finir(const int est_le_dernier_post)
virtual int init_ecriture(double temps_courant, double temps_post, int est_le_premier_postraitement_pour_nom_fich_, const Domaine &domaine)
virtual int ecrire_champ(const Domaine &domaine, const Noms &unite_, const Noms &noms_compo, int ncomp, double temps_, const Nom &id_du_champ, const Nom &id_du_domaine, const Nom &localisation, const Nom &nature, const DoubleTab &data)
Ecriture d'un champ dans le fichier de postraitement.
virtual int initialize_by_default(const Nom &file_basename)
Initialise le fichier avec des parametres appropries pour son format (exemple: format ascii,...
virtual int ecrire_temps(const double temps)
Commence l'ecriture d'un pas de temps.
virtual int ecrire_entete(const double temps_courant, const int reprise, const int est_le_premier_post)
virtual int ecrire_domaine(const Domaine &domaine, const int est_le_premier_post)
Ecriture d'un maillage.
virtual int preparer_post(const Nom &id_du_domaine, const int est_le_premier_post, const int reprise, const double t_init)
Classe de base des objets "interprete".
Definition Interprete.h:38
static Objet_U & objet(const Nom &)
Voir Interprete_bloc::objet_global() BM: la classe Interprete n'est pas le meilleur endroit pour cett...
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
Nom & prefix(const char *const)
Definition Nom.cpp:329
friend class Entree
Definition Objet_U.h:76
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
Objet_U()
Constructeur par defaut : attribue un numero d'identifiant unique a l'objet (object_id_),...
Definition Objet_U.cpp:55
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
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