TrioCFD 1.9.9_beta
TrioCFD documentation
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 Main function of the Ecrire_Champ_MED interpreter: error if it fails.
38 *
39 * @param (Entree& is) an input stream from which arguments are read
40 * @return (Entree&) the modified input stream
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 // write domain
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 // write field
85 //chp.postraiter_champ(dom, tps, nom_champ, "ELEM", post);
86 // the nature is not used in 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}
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
double temps() const
Returns the time of the field.
void corriger_unite_nom_compo()
This method will set the units and the name of components, it is not actually const!...
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Ecrire_Champ_MED.
Entree & interpreter(Entree &) override
Main function of the Ecrire_Champ_MED interpreter: error if it fails.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & le_nom() const override
Returns the name of the field.
const Noms & unites() const
Returns the units of the field components.
const Noms & noms_compo() const
Returns the array of names of the field components.
Base class for post-processing output formats for fields (lata, med, cgns, lml, single_lata).
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)
Writing a field to the post-processing file.
virtual int initialize_by_default(const Nom &file_basename)
Initializes the file with parameters appropriate to its format (e.g. ascii format,...
virtual int ecrire_temps(const double temps)
Starts writing a time step.
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)
Writing a mesh.
virtual int preparer_post(const Nom &id_du_domaine, const int est_le_premier_post, const int reprise, const double t_init)
Base class for "interpreter" objects.
Definition Interprete.h:38
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
Nom & prefix(const char *const)
Definition Nom.cpp:324
friend class Entree
Definition Objet_U.h:71
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
Definition Objet_U.cpp:54
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52