TrioCFD 1.9.9_beta
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// Some macros may #define min, max or throw — undo them here
21#undef min
22#undef max
23#undef throw
24
25#include <assert.h>
26#include <DecBaseInst.h>
27
28#ifdef LATATOOLS
29#include <LataJournal.h>
30#include <Sortie.h>
31#include <Entree.h>
32#define Cerr Journal()
33#define finl std::endl
34#define tspace " "
35
36#else
37#include <EntreeSortie.h>
38#endif
39
40#include <Process.h>
41
42class Type_info;
43class Interprete;
44class Motcle;
45class Param; // need this forward for pure virtual set_param
46
47/*! @brief Base class for TRUST objects (Objet_U).
48 *
49 * In classes derived from Objet_U, a Declare_instanciable or Declare_base macro is always added,
50 * which gives objects the following properties:
51 * An Objet_U can be read from an Entree or written to a Sortie
52 * (standard I/O, .data dataset, disk file, memory buffer, parallel communication buffer).
53 * The readOn and printOn methods must therefore always be implemented.
54 * An Objet_U of any type can be instantiated using a character string that identifies it
55 * (que_suis_je()), see OWN_PTR::typer.
56 * An Objet_U can be "saved" or "resumed" on disk (in the sense of checkpoint/restart).
57 * These operations differ from readOn/printOn because they optionally allow redistribution
58 * of parallel data or version changes.
59 * An Objet_U, if "Declare_instanciable", can be dynamically created and read from the TRUST
60 * dataset (via readOn). It then has the name (le_nom()) assigned in the dataset
61 * (see Interprete_bloc and Lire classes).
62 * An Objet_U is subject to special memory management by the kernel for debugging and optimization
63 * (specific operations at creation, destruction and copy).
64 *
65 * @sa Memoire Objet_U_ptr Process, Abstract class
66 */
67class Objet_U : public Process
68{
69public:
70 friend class Sortie;
71 friend class Entree;
72
73 ~Objet_U() override;
74 int numero() const;
75 virtual int duplique() const =0;
76 virtual Sortie& printOn(Sortie& ) const;
77 virtual Entree& readOn(Entree& ) ;
78 virtual unsigned taille_memoire() const =0;
79 virtual int est_egal_a(const Objet_U&) const;
80 virtual const Nom& le_nom() const;
81 static double precision_geom;
82
83 virtual void nommer(const Nom&);
84 virtual int reprendre(Entree& ) ;
85 virtual int sauvegarder(Sortie& ) const;
86
87
88#ifndef LATATOOLS // All the below is not needed in lata_tools:
89 int get_object_id() const;
90
91 // Elie Saikali: add this to statically test whether class templates are REF/OWN_PTR or plain objects!
92 static constexpr bool HAS_POINTER = false;
93
94 static int dimension;
96 static int axi;
97 static int bidim_axi;
98 static int DEACTIVATE_SIGINT_CATCH; // flag to not enter the overloaded function signal_callback_handler
99 static const Nom& nom_du_cas();
100 static Nom& get_set_nom_du_cas();
101
103 virtual const Type_info* get_info() const;
104 static const Type_info* info();
105
106 const Nom& que_suis_je() const;
107 const char* le_type() const;
108
109 friend int operator ==(const Objet_U&, const Objet_U&);
110 friend int operator !=(const Objet_U&, const Objet_U&);
111 virtual int change_num(const int* const );
112 virtual int lire_motcle_non_standard(const Motcle& motlu, Entree& is);
113 virtual int associer_(Objet_U&) ;
114 const Interprete& interprete() const;
116 /* method added for casting in Python */
117 static const Objet_U& self_cast(const Objet_U&);
118 static Objet_U& self_cast( Objet_U&);
119
120 static bool disable_TU; // Flag to disable the writing of the .TU files
121 static bool stat_per_proc_perf_log; // Flag to enable the writing of the statistics detailed per processor in _csv.TU file
122protected:
123 Objet_U();
124 Objet_U(const Objet_U&);
125 const Objet_U& operator=(const Objet_U&);
126
127 // not pure virtual because that would need adapting every derived of Objet_U
128 // and not needed since the macro Declare_xxx_with_param forces to define this anyway
129 // eventually, should only be implemented in derived of Objet_U_With_Params
130 virtual void set_param(Param&) const {}
131
132private:
133 // Object number (index of the object in Memoire::data).
134 // This number may change between construction and destruction.
135 int _num_obj_;
136 // Unique identifier of the object (assigned by the constructor
137 // and never modified afterwards).
138 const int object_id_;
139
140 // Counter of created objects (incremented by the constructor).
141 static int static_obj_counter_;
142 static Interprete* l_interprete;
143
144#endif
145};
146
147#ifndef LATATOOLS
148int operator==(const Objet_U& x, const Objet_U& y) ;
149int operator!=(const Objet_U& x, const Objet_U& y) ;
150#endif
151
152#endif
153
154
Base class for "interpreter" objects.
Definition Interprete.h:38
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68
virtual void set_param(Param &) const
Definition Objet_U.h:130
virtual int duplique() const =0
friend int operator!=(const Objet_U &, const Objet_U &)
Returns 1 - x.est_egal_a(y).
Definition Objet_U.cpp:239
const Objet_U & operator=(const Objet_U &)
Assignment operator: does nothing (the number and identifier are preserved).
Definition Objet_U.cpp:86
virtual unsigned taille_memoire() const =0
virtual int lire_motcle_non_standard(const Motcle &motlu, Entree &is)
Reads non-simple-type parameters of an Objet_U from an input stream.
Definition Objet_U.cpp:115
friend class Entree
Definition Objet_U.h:71
virtual int associer_(Objet_U &)
Associates the Objet_U with another Objet_U. Virtual method to override.
Definition Objet_U.cpp:200
static const Type_info * info()
Returns type information for the Objet_U (static version).
Definition Objet_U.cpp:136
int numero() const
Returns the index of the object in Memoire::data.
Definition Objet_U.cpp:264
const Interprete & interprete() const
Definition Objet_U.cpp:211
static bool disable_TU
Flag to disable or not the writing of the .TU files.
Definition Objet_U.h:120
static int dimension
Definition Objet_U.h:94
friend class Sortie
Definition Objet_U.h:70
virtual void nommer(const Nom &)
Assigns a name to the Objet_U. Virtual method to override.
Definition Objet_U.cpp:327
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
friend int operator==(const Objet_U &, const Objet_U &)
Returns x.est_egal_a(y).
Definition Objet_U.cpp:228
static double precision_geom
Definition Objet_U.h:81
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:121
static const Objet_U & self_cast(const Objet_U &)
Method added for casting in Python.
Definition Objet_U.cpp:166
static const Nom & nom_du_cas()
Returns a constant reference to the case name. This method is static.
Definition Objet_U.cpp:145
virtual int change_num(const int *const)
Changes the internal number of the Objet_U.
Definition Objet_U.cpp:180
virtual int est_egal_a(const Objet_U &) const
Returns 1 if x and *this are the same instance (same memory address).
Definition Objet_U.cpp:299
const char * le_type() const
Returns the type name of the Objet_U.
Definition Objet_U.cpp:190
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
Definition Objet_U.cpp:54
virtual const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Objet_U.cpp:317
static int bidim_axi
Definition Objet_U.h:97
static int format_precision_geom
Definition Objet_U.h:95
virtual int reprendre(Entree &)
Restores an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:336
static int DEACTIVATE_SIGINT_CATCH
Definition Objet_U.h:98
static Type_info info_obj
Definition Objet_U.h:102
static Nom & get_set_nom_du_cas()
Returns a non-constant reference to the case name (to allow modification). This method is static.
Definition Objet_U.cpp:154
static constexpr bool HAS_POINTER
Definition Objet_U.h:92
static int axi
Definition Objet_U.h:96
int get_object_id() const
Returns the unique identifier of the object (object_id_).
Definition Objet_U.cpp:95
~Objet_U() override
Destructor. Removes the object from the list of objects registered in "memory".
Definition Objet_U.cpp:251
virtual const Type_info * get_info() const
Returns type information for the Objet_U.
Definition Objet_U.cpp:126
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
virtual int sauvegarder(Sortie &) const
Saves an Objet_U to an output stream. Virtual method to override.
Definition Objet_U.cpp:350
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
Base class of TRUST (in particular Objet_U).
Definition Process.h:48
Models type information for Objet_U objects.
Definition Type_info.h:30