TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Objet_U.h
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
17#ifndef Objet_U_included
18#define Objet_U_included
19
20// On rencontre des fous
21// qui #define min max ou throw!
22#undef min
23#undef max
24#undef throw
25
26#include <assert.h>
27#include <DecBaseInst.h>
28
29#ifdef LATATOOLS
30#include <LataJournal.h>
31#include <Sortie.h>
32#include <Entree.h>
33#define Cerr Journal()
34#define finl std::endl
35#define tspace " "
36
37#else
38#include <EntreeSortie.h>
39#endif
40
41#include <Process.h>
42
43class Type_info;
44class Interprete;
45class Motcle;
46class Param; // need this forward for pure virtual set_param
47
48/*! @brief classe Objet_U Cette classe est la classe de base des Objets de TRUST
49 *
50 * Dans les classes derivees de Objet_U, on ajoute toujours
51 * une macro Declare_instanciable ou Declare_base qui donne aux
52 * objets les proprietes suivantes:
53 * Un Objet_U peut etre lu dans une Entree ou ecrit dans une Sortie
54 * (entree/sortie standard, jeu de donnees .data, fichier disque,
55 * buffer memoire, buffer de communication parallele).
56 * Il faut donc toujours implementer les methodes readOn et printOn
57 * Un Objet_U d'un type quelconque peut etre instancie grace a une
58 * chaine de caracteres qui l'identifie (que_suis_je()), voir OWN_PTR::typer
59 * Un Objet_U peut etre "sauvegarde" ou "repris" sur disque (au sens sauvegarde
60 * et reprise d'un calcul). Ces operations sont differentes de readOn/printOn
61 * car elles permettent eventuellement une redistribution des donnees paralleles
62 * ou des changements de version.
63 * Un Objet_U, s'il est "Declare_instanciable", peut etre cree dynamiquement et lu
64 * dans le jeu de donnees TRUST (a travers readOn). Il possede alors le nom
65 * (le_nom()) attribue dans le jeu de donnees (voir les classes Interprete_bloc et Lire)
66 * Un Objet_U fait l'objet d'une gestion memoire speciale par le noyau permettant
67 * le debuggage et l'optimisation (operations specifiques a la creation,
68 * a la destruction et a la copie)
69 *
70 * @sa Memoire Objet_U_ptr Process, Classe abstraite
71 */
72class Objet_U : public Process
73{
74public:
75 friend class Sortie;
76 friend class Entree;
77
78 ~Objet_U() override;
79 int numero() const;
80 virtual int duplique() const =0;
81 virtual Sortie& printOn(Sortie& ) const;
82 virtual Entree& readOn(Entree& ) ;
83 virtual unsigned taille_memoire() const =0;
84 virtual int est_egal_a(const Objet_U&) const;
85 virtual const Nom& le_nom() const;
86 static double precision_geom;
87
88 virtual void nommer(const Nom&);
89 virtual int reprendre(Entree& ) ;
90 virtual int sauvegarder(Sortie& ) const;
91
92
93#ifndef LATATOOLS // All the below is not needed in lata_tools:
94 int get_object_id() const;
95
96 // Elie Saikali : add to this to statically test if class templates are REF/OWN_PTR or normal !
97 static constexpr bool HAS_POINTER = false;
98
99 static int dimension;
101 static int axi;
102 static int bidim_axi;
103 static int DEACTIVATE_SIGINT_CATCH; // flag to not enter the overloaded function signal_callback_handler
104 static const Nom& nom_du_cas();
105 static Nom& get_set_nom_du_cas();
106
108 virtual const Type_info* get_info() const;
109 static const Type_info* info();
110
111 const Nom& que_suis_je() const;
112 const char* le_type() const;
113
114 friend int operator ==(const Objet_U&, const Objet_U&);
115 friend int operator !=(const Objet_U&, const Objet_U&);
116 virtual int change_num(const int* const );
117 virtual int lire_motcle_non_standard(const Motcle& motlu, Entree& is);
118 virtual int associer_(Objet_U&) ;
119 const Interprete& interprete() const;
121 /* methode rajoutee pour caster en python */
122 static const Objet_U& self_cast(const Objet_U&);
123 static Objet_U& self_cast( Objet_U&);
124
125 static bool disable_TU; // Flag to disable the writing of the .TU files
126 static bool stat_per_proc_perf_log; // Flag to enable the writing of the statistics detailed per processor in _csv.TU file
127protected:
128 Objet_U();
129 Objet_U(const Objet_U&);
130 const Objet_U& operator=(const Objet_U&);
131
132 // not pure virtual because that would need adapting every derived of Objet_U
133 // and not needed since the macro Declare_xxx_with_param forces to define this anyway
134 // eventually, should only be implemented in derived of Objet_U_With_Params
135 virtual void set_param(Param&) const {}
136
137private:
138 // Numero de l'objet (indice de l'objet dans Memoire::data)
139 // Ce numero peut changer entre la construction et la destruction.
140 int _num_obj_;
141 // Identifiant unique de l'objet (attribue par le constructeur,
142 // et jamais modifie ensuite).
143 const int object_id_;
144
145 // Compteur d'objets crees (incremente par le constructeur).
146 static int static_obj_counter_;
147 static Interprete* l_interprete;
148
149#endif
150};
151
152#ifndef LATATOOLS
153int operator==(const Objet_U& x, const Objet_U& y) ;
154int operator!=(const Objet_U& x, const Objet_U& y) ;
155#endif
156
157#endif
158
159
Classe de base des objets "interprete".
Definition Interprete.h:38
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
classe Objet_U Cette classe est la classe de base des Objets de TRUST
Definition Objet_U.h:73
virtual void set_param(Param &) const
Definition Objet_U.h:135
virtual int duplique() const =0
friend int operator!=(const Objet_U &, const Objet_U &)
Comparaison de deux Objet_U x et y Renvoie 1 - x.
Definition Objet_U.cpp:244
const Objet_U & operator=(const Objet_U &)
Operateur= : ne fait rien (on conserve le numero et l'identifiant).
Definition Objet_U.cpp:87
virtual unsigned taille_memoire() const =0
virtual int lire_motcle_non_standard(const Motcle &motlu, Entree &is)
Lecture des parametres de type non simple d'un objet_U a partir d'un flot d'entree.
Definition Objet_U.cpp:115
friend class Entree
Definition Objet_U.h:76
virtual int associer_(Objet_U &)
Associe l'Objet_U a un autre Objet_U Methode virtuelle a surcharger.
Definition Objet_U.cpp:201
static const Type_info * info()
Donne des informations sur le type de l'Objet_U.
Definition Objet_U.cpp:136
int numero() const
Renvoie l'indice de l'objet dans Memoire::data.
Definition Objet_U.cpp:268
const Interprete & interprete() const
Definition Objet_U.cpp:212
static bool disable_TU
Flag to disable or not the writing of the .TU files.
Definition Objet_U.h:125
static int dimension
Definition Objet_U.h:99
friend class Sortie
Definition Objet_U.h:75
virtual void nommer(const Nom &)
Donne un nom a l'Objet_U Methode virtuelle a surcharger.
Definition Objet_U.cpp:329
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
friend int operator==(const Objet_U &, const Objet_U &)
retourne x.
Definition Objet_U.cpp:231
static double precision_geom
Definition Objet_U.h:86
static bool stat_per_proc_perf_log
Flag to enable the writing of the statistics detailed per processor in _csv.TU file.
Definition Objet_U.h:126
static const Objet_U & self_cast(const Objet_U &)
methode ajoutee pour caster en python
Definition Objet_U.cpp:167
static const Nom & nom_du_cas()
Renvoie une reference constante vers le nom du cas.
Definition Objet_U.cpp:146
virtual int change_num(const int *const)
Change le numero interne de l'Objet_U.
Definition Objet_U.cpp:181
virtual int est_egal_a(const Objet_U &) const
Renvoie 1 si l'objet x et *this sont une seule et meme instance (meme adresse en memoire).
Definition Objet_U.cpp:301
const char * le_type() const
Donne le nom du type de l'Objet_U.
Definition Objet_U.cpp:191
Objet_U()
Constructeur par defaut : attribue un numero d'identifiant unique a l'objet (object_id_),...
Definition Objet_U.cpp:55
virtual const Nom & le_nom() const
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Objet_U.cpp:319
static int bidim_axi
Definition Objet_U.h:102
static int format_precision_geom
Definition Objet_U.h:100
virtual int reprendre(Entree &)
Reprise d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:338
static int DEACTIVATE_SIGINT_CATCH
Definition Objet_U.h:103
static Type_info info_obj
Definition Objet_U.h:107
static Nom & get_set_nom_du_cas()
Renvoie une reference non constante vers le nom du cas (pour pouvoir le modifier).
Definition Objet_U.cpp:156
static constexpr bool HAS_POINTER
Definition Objet_U.h:97
static int axi
Definition Objet_U.h:101
int get_object_id() const
Renvoie l'identifiant unique de l'objet object_id_.
Definition Objet_U.cpp:95
~Objet_U() override
Destructeur, supprime l'objet de la liste d'objets enregistres dans "memoire".
Definition Objet_U.cpp:256
virtual const Type_info * get_info() const
Donne des informations sur le type de l'Objet_U.
Definition Objet_U.cpp:126
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
virtual int sauvegarder(Sortie &) const
Sauvegarde d'un Objet_U sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:352
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
Classe de base de TRUST (notamment Objet_U).
Definition Process.h:50
modelise une information de type pour les Objet_U
Definition Type_info.h:30