TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Generique_base.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 <Champ_Generique_base.h>
17#include <Champs_compris.h>
18#include <Probleme_base.h>
19#include <Interprete.h>
20#include <TRUST_Ref.h>
21#include <Param.h>
22
23Implemente_base(Champ_Generique_base,"Champ_Generique_base",Objet_U);
24// XD champ_generique_base objet_u champ_generique_base BRACE not_set
25// XD listchamp_generique listobj nul BRACE champ_generique_base COMMA XXX
26
27// XD definition_champ objet_lecture nul NO_BRACE Keyword to create new complex field for advanced postprocessing.
28// XD attr name chaine name REQ The name of the new created field.
29// XD attr champ_generique champ_generique_base champ_generique REQ not_set
30
31// XD definition_champs listobj nul BRACE definition_champ NO_COMMA List of definition champ
32
34{
35 return os;
36}
37
39{
40 Journal()<<"Reading data for a "<<que_suis_je()<<" field." <<finl;
41 Param param(que_suis_je());
42 set_param(param);
43 param.lire_avec_accolades_depuis(is);
44 return is;
45}
46
48{
49 return -1;
50}
51
52/*! @brief Returns the dimension of the space in which the field is defined.
53 *
54 * This is the number of components of the coordinates that must be provided in get_xyz_values.
55 * (for example, a field defined on a surface can be of dimension 3 if the
56 * vertex coordinates are 3D, or dimension 2 if it is curvilinear coordinates
57 * along the surface)
58 *
59 */
61{
62 throw Champ_Generique_erreur("NOT_IMPLEMENTED");
63 // We never reach here
64}
65
66/*! @brief Returns the time of the Champ_Generique_base.
67 *
68 */
70{
71 throw Champ_Generique_erreur("NOT_IMPLEMENTED");
72}
73
74/*! @brief Returns the problem that carries the target field
75 *
76 */
78{
79 throw Champ_Generique_erreur("NOT_IMPLEMENTED");
80}
81
82/*! @brief Returns the discretization associated with the problem
83 *
84 */
86{
87 const Objet_U& ob = interprete().objet(nom_pb_);
88 const Probleme_base& pb = ref_cast(Probleme_base,ob);
89 const Discretisation_base& discr = pb.discretisation();
90 return discr;
91}
92
93/*! @brief Returns the directive (champ_elem, champ_sommets, champ_face or pression)
94 * to launch the discretization of the storage space returned by get_champ()
95 *
96 */
98{
99 throw Champ_Generique_erreur("NOT_IMPLEMENTED");
100}
101
103{
104 nom_post_ = nom;
105}
106
108{
109 return nom_post_;
110}
111
112/*! @brief Returns the list of possible "queries" for the field.
113 *
114 */
116{
117 throw Champ_Generique_erreur("NOT_IMPLEMENTED");
118}
119
120/*! @brief Returns the requested property.
121 *
122 * Examples: "DISCRETISATION" : type of discrete field (P0, P1, P1NC, etc...)
123 * "ELEMENT_TYPE" : type of element with the largest dimension ({TRIANGLE}, {TETRAHEDRA}, {QUAD}, {HEXA}, etc)
124 * "DYNAMIC_MESH" : is the mesh dynamic or not ({STATIC}, {DYNAMIC})
125 * "NAME" : name of the field
126 * "COMPONENT_NAMES" : name of the field components ({K,EPSILON} or {VITESSE_X,VITESSE_Y,VITESSE_Z})
127 * "BOUNDARY_NAMES" : name of the boundaries
128 * "COORDINATES" : coordinate system of the nodes ({X}, {X,Y}, {X,Y,Z}, {R,THETA}, etc...)
129 * Exceptions:
130 * - GenericFieldError::INVALID : query not understood
131 *
132 */
134{
135 throw Champ_Generique_erreur("NOT_IMPLEMENTED");
136}
137
138
139/*! @brief Returns the type of geometric entities on which the discrete values are attached (NODE for a P1 field, FACE for a P1NC field, ELEMENT for a
140 *
141 * P0 field, etc). It is recommended to use the get_localisation() syntax without
142 * parameter, unless you know what to do for multi-support fields.
143 * @sa get_nb_localisations()
144 * Parameter : index
145 * Meaning : index of the requested localization (for multi-support fields).
146 * If index = -1 : if the field is multi-support an exception is raised, otherwise the support is returned.
147 * If index >= 0 : returns the i-th support.
148 * Default value : -1
149 * Exceptions:
150 * - GenericFieldError::INVALID : the field is not discretized on these geometric entities
151 * (it can be an analytical field or a multi-localization field), or the field
152 * is multi-support while index = -1 was requested, or the support "index" does not exist.
153 *
154 */
155Entity Champ_Generique_base::get_localisation(const int index) const
156{
157 throw Champ_Generique_erreur("NOT_IMPLEMENTED");
158}
159
161{
162 throw Champ_Generique_erreur("NOT_IMPLEMENTED");
163}
164
165/*! @brief Returns a reference to the array of discrete values if it exists in memory.
166 *
167 * The reference is valid at least until the next call to a non-const method.
168 * The mesh on which these values are defined is accessible through the methods
169 * get_node_coordinates(), get_connectivity(), get_field_type().
170 * Exceptions:
171 * - GenericFieldError::XYZ_ONLY : values are accessible only through get_xyz_values
172 * - GenericFieldError::NO_REF : values are not stored in memory,
173 * must use get_copy_values();
174 * - GenericFieldError::MESH_ONLY : the field carries no values, it serves only to describe a geometry
175 *
176 */
178{
179 // Default implementation : exception NO_REF
180 throw Champ_Generique_erreur("NO_REF");
181}
182
183/*! @brief Fills the values array with the discrete values of the field (creates a copy).
184 *
185 * Exceptions:
186 * - GenericFieldError::XYZ_ONLY : values are accessible only through get_xyz_values
187 * - GenericFieldError::MESH_ONLY : the field carries no values, it serves only to describe a geometry
188 *
189 */
190void Champ_Generique_base::get_copy_values(DoubleTab& values) const
191{
192 throw Champ_Generique_erreur("NOT_IMPLEMENTED");
193}
194
195/*! @brief Computes the point value of the field at the coordinates given in coords and puts them in values.
196 *
197 * validity_flag is filled with 1 if the value is valid
198 * (coordinates inside the domain), 0 otherwise.
199 * Warning in parallel:
200 * Each processor processes the coords array provided to it: one can either have
201 * the same array computed by everyone: in this case, validity_flag indicates on
202 * each processor which values each processor was able to compute, or one knows in
203 * advance which coordinates are computable by each processor and gives the processor
204 * locally only the coordinates it owns. If the same coordinate is requested
205 * from multiple processors, there is no guarantee that all give the same result. In general,
206 * only one will have the validity_flag set for this coordinate.
207 * Exceptions:
208 * - GenericFieldError::NOT_IMPLEMENTED : the lazy one has not coded the interpolation methods
209 * must work with the mesh and the discrete values.
210 * - GenericFieldError::MESH_ONLY : the field carries no values, it serves only to describe a geometry
211 *
212 */
213void Champ_Generique_base::get_xyz_values(const DoubleTab& coords, DoubleTab& values, ArrOfBit& validity_flag) const
214{
215 throw Champ_Generique_erreur("NOT_IMPLEMENTED");
216}
217
218/*! @brief Returns a reference to the array of coordinates of the vertices of the mesh supporting the field, if it exists.
219 *
220 * The array always has two dimensions:
221 * dimension(0) = number of real vertices
222 * dimension(1) = get_dimension() (dimension of the space in which the field is defined)
223 * In parallel, the array is a distributed array with common items.
224 * Exceptions:
225 * - GenericFieldError::INVALID : the array does not exist (analytical field ...)
226 * - GenericFieldError::NO_REF : values are not stored in memory,
227 * must use get_copy_coordinates();
228 *
229 */
231{
232 // Default implementation : exception NO_REF
233 throw Champ_Generique_erreur("NO_REF");
234}
235
236
238{
239 throw Champ_Generique_erreur("NO_REF");
240}
241
242/*! @brief Returns the connectivity array between the geometric entity index1 and entity index2.
243 *
244 * For example
245 * get_ref_connectivity(ELEM, NODE) = Domaine::mes_elems
246 * get_ref_connectivity(ELEM, FACE) = DomaineVF::elem_faces_
247 * get_ref_connectivity(FACE, ELEM) = DomaineVF::face_voisins_
248 * The array always has two dimensions:
249 * dimension(0) = number of real entities "index1"
250 * dimension(1) = number of entities "index2" connected to each entity "index1"
251 * In parallel, the array is a distributed array with common items
252 * Exceptions:
253 * - GenericFieldError::INVALID : the array does not exist (analytical field ...)
254 * - GenericFieldError::NO_REF : values are not stored in memory,
255 * must use get_copy_connectivity();
256 *
257 */
258const IntTab& Champ_Generique_base::get_ref_connectivity(Entity index1, Entity index2) const
259{
260 throw Champ_Generique_erreur("NOT_IMPLEMENTED");
261}
262
263void Champ_Generique_base::get_copy_connectivity(Entity index1, Entity index2, IntTab&) const
264{
265 throw Champ_Generique_erreur("NOT_IMPLEMENTED");
266}
267
268/*! @brief Returns a ref to the domain on which the storage space will be evaluated.
269 *
270 * By default the domain associated with the problem.
271 *
272 */
274{
275 const Objet_U& ob = interprete().objet(nom_pb_);
276 const Probleme_base& pb = ref_cast(Probleme_base,ob);
277 const Domaine& dom = pb.domaine_dis().domaine();
278 return dom;
279}
280
281
282/*! @brief Creates a copy of the domain on which the storage space will be evaluated.
283 *
284 * By default the domain associated with the problem.
285 *
286 */
287void Champ_Generique_base::get_copy_domain(Domaine& domain) const
288{
289 const Domaine& dom = get_ref_domain();
290 domain = dom;
291}
292
293
294/*! @brief Returns a ref to the discretized domain on which the storage space will be evaluated.
295 *
296 * By default the domain associated with the problem.
297 *
298 */
300{
301 const Objet_U& ob = interprete().objet(nom_pb_);
302 const Probleme_base& pb = ref_cast(Probleme_base,ob);
303 const Domaine_dis_base& domaine_dis = pb.domaine_dis();
304 return domaine_dis;
305}
306
307/*! @brief Returns a ref to the discretized boundary conditions domain of the equation carrying the target field.
308 *
309 */
314
316{
317 Motcle nom_champ;
318
319 const Noms nom_champ_post = get_property("nom");
320 nom_champ = Motcle(nom_champ_post[0]);
321 if (nom_champ == nom)
322 return true;
323
324 const Noms syno = get_property("synonyms");
325 for (int i = 0; i < syno.size(); i++)
326 {
327 nom_champ = Motcle(syno[i]);
328 if (nom_champ == nom)
329 return true;
330 }
331
332 const Noms composantes = get_property("composantes");
333 for (const auto &itr : composantes)
334 {
335 nom_champ = Motcle(itr);
336 if (nom_champ == nom)
337 return true;
338 }
339
340 return false; /* nothing found */
341}
342
344{
345 OBS_PTR(Champ_Generique_base) ref_champ;
346
347 Motcle nom_champ;
348 const Noms nom_champ_post = get_property("nom");
349 nom_champ = Motcle(nom_champ_post[0]);
350
351 if (nom_champ==nom)
352 {
353 ref_champ = *this;
354 ref_champ->fixer_identifiant_appel(nom);
355 return ref_champ;
356 }
357 const Noms syno = get_property("synonyms");
358 int nb_syno = syno.size();
359 for (int i=0; i<nb_syno; i++)
360 {
361 nom_champ = Motcle(syno[i]);
362 if (nom_champ==nom)
363 {
364 ref_champ = *this;
365 ref_champ->fixer_identifiant_appel(nom);
366 return ref_champ;
367 }
368 }
369
370 {
371 const Noms composantes = get_property("composantes");
372 for (const auto& itr : composantes)
373 {
374 nom_champ = Motcle(itr);
375 if (nom_champ==nom)
376 {
377 ref_champ = *this;
378 ref_champ->fixer_identifiant_appel(nom);
379 return ref_champ;
380 }
381 }
382 }
383
384 throw std::runtime_error(std::string("Field ") + nom.getString() + std::string(" not found !"));
385}
386
388{
389 Motcle nom_champ;
390 const Noms nom_champ_post = get_property("nom");
391 nom_champ = Motcle(nom_champ_post[0]);
392
393 if (nom_champ==identifiant)
394 return 1;
395 else
396 {
397 const Noms composantes = get_property("composantes");
398 for (const auto& itr : composantes)
399 {
400 nom_champ = Motcle(itr);
401 if (nom_champ==identifiant)
402 return 1;
403 }
404 }
405 return 0;
406}
class Champ_Generique_base
virtual const Noms get_property(const Motcle &query) const
Returns the requested property.
virtual const Domaine_dis_base & get_ref_domaine_dis_base() const
Returns a ref to the discretized domain on which the storage space will be evaluated.
virtual bool has_champ_post(const Motcle &nom) const
virtual void get_property_names(Motcles &list) const
Returns the list of possible "queries" for the field.
virtual const IntTab & get_ref_connectivity(Entity index1, Entity index2) const
Returns the connectivity array between the geometric entity index1 and entity index2.
virtual int comprend_champ_post(const Motcle &identifiant) const
virtual void get_copy_connectivity(Entity index1, Entity index2, IntTab &) const
virtual void set_param(Param &param) const override=0
virtual const Champ_Generique_base & get_champ_post(const Motcle &nom) const
virtual const Domaine_Cl_dis_base & get_ref_zcl_dis_base() const
Returns a ref to the discretized boundary conditions domain of the equation carrying the target field...
virtual double get_time() const
Returns the time of the Champ_Generique_base.
virtual int get_dimension() const
Returns the dimension of the space in which the field is defined.
virtual void get_copy_values(DoubleTab &) const
Fills the values array with the discrete values of the field (creates a copy).
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
virtual int get_nb_localisations() const
virtual void get_copy_domain(Domaine &) const
Creates a copy of the domain on which the storage space will be evaluated.
virtual const DoubleTab & get_ref_coordinates() const
Returns a reference to the array of coordinates of the vertices of the mesh supporting the field,...
virtual void get_xyz_values(const DoubleTab &coords, DoubleTab &values, ArrOfBit &validity_flag) const
Computes the point value of the field at the coordinates given in coords and puts them in values.
virtual const DoubleTab & get_ref_values() const
Returns a reference to the array of discrete values if it exists in memory.
virtual const Nom & get_nom_post() const
virtual const Probleme_base & get_ref_pb_base() const
Returns the problem that carries the target field.
virtual Entity get_localisation(const int index=-1) const
Returns the type of geometric entities on which the discrete values are attached (NODE for a P1 field...
virtual void get_copy_coordinates(DoubleTab &) const
void nommer(const Nom &nom) override
Assigns a name to the Objet_U. Virtual method to override.
virtual const Domaine & get_ref_domain() const
Returns a ref to the domain on which the storage space will be evaluated.
virtual const Motcle get_directive_pour_discr() const
Returns the directive (champ_elem, champ_sommets, champ_face or pression) to launch the discretizatio...
virtual const Discretisation_base & get_discretisation() const
Returns the discretization associated with the problem.
OBS_PTR(Probleme_base) ref_pb_
class Discretisation_base This class represents a spatial discretization scheme, which
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
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
An array of Motcle objects.
Definition Motcle.h:63
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const std::string & getString() const
Definition Nom.h:92
An array of character strings (VECT(Nom)).
Definition Noms.h:26
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68
friend class Entree
Definition Objet_U.h:71
const Interprete & interprete() const
Definition Objet_U.cpp:211
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
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
class Probleme_base It is a Probleme_U that is not a coupling.
const Discretisation_base & discretisation() const
Returns the discretization associated with the problem.
const Domaine_dis_base & domaine_dis() const
Returns the discretized domain associated with the problem (const version).
static Sortie & Journal(int message_level=0)
Returns a static Sortie object used as an event journal.
Definition Process.cpp:592
Base class for output streams.
Definition Sortie.h:52