TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Generique_base.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#ifndef Champ_Generique_base_included
17#define Champ_Generique_base_included
18
19#include <TRUST_Deriv.h>
20#include <TRUST_Ref.h>
21#include <Domaine.h>
22#include <ArrOfBit.h>
23#include <YAML_data.h>
24
28class Param;
29class Champ_base;
30
31enum class Entity { NODE, SEGMENT, FACE, ELEMENT };
32
33/*! @brief class Champ_Generique_base
34 *
35 * Base class of generic fields for importing a discrete field and elementary actions on this field
36 *
37 * (post-processing, etc)
38 * Warning: all methods are PARALLEL, they must be called
39 * simultaneously on all processors (get_domain() can for example
40 * build the parallel domain before returning it).
41 *
42 */
44{
45 Declare_base(Champ_Generique_base);
46public:
47
48 /* XXX Elie Saikali : put it here and not in Objet_U */
49 virtual std::vector<YAML_data> data_a_sauvegarder() const { return std::vector<YAML_data>(); };
50 int sauvegarder(Sortie& os) const override { return 0; }
51 int reprendre(Entree& is) override { return 1; }
52
53 virtual void set_param(Param& param) const override=0;
54 int lire_motcle_non_standard(const Motcle&, Entree&) override;
55 virtual int get_dimension() const;
56 virtual double get_time() const; //returns the time of the encapsulated field
57 virtual const Probleme_base& get_ref_pb_base() const;
58 virtual const Discretisation_base& get_discretisation() const;
59 virtual const Motcle get_directive_pour_discr() const;
60
61 void nommer(const Nom& nom) override;
62 virtual const Nom& get_nom_post() const;
63 //returns -1 if identifier is the name, component number otherwise
64 static inline int composante(const Nom& nom_test,const Nom& nom, const Noms& composantes,const Noms& synonyms);
65
66 virtual void get_property_names(Motcles& list) const;
67 virtual const Noms get_property(const Motcle& query) const; //answers requests for name, target_name, units and components
68
69 virtual Entity get_localisation(const int index = -1) const; //localization ELEMENT or NODE are post-processable
70 virtual int get_nb_localisations() const;
71
72 virtual const DoubleTab& get_ref_values() const;
73 virtual void get_copy_values(DoubleTab&) const;
74 virtual void get_xyz_values(const DoubleTab& coords, DoubleTab& values, ArrOfBit& validity_flag) const;
75
76 virtual const Domaine& get_ref_domain() const; //returns a reference to the domain associated with the field
77 virtual void get_copy_domain(Domaine&) const;
78 virtual const Domaine_dis_base& get_ref_domaine_dis_base() const; //returns the discretized domain linked to the domain
79 virtual const Domaine_Cl_dis_base& get_ref_zcl_dis_base() const; //returns the discretized boundary conditions linked to the equation carrying the target field
80
81 virtual const DoubleTab& get_ref_coordinates() const;
82 virtual void get_copy_coordinates(DoubleTab&) const;
83 virtual const IntTab& get_ref_connectivity(Entity index1, Entity index2) const;
84 virtual void get_copy_connectivity(Entity index1, Entity index2, IntTab&) const;
85
86 // Resets the object to the state obtained by the default constructor
87 virtual void reset() = 0;
88 virtual void completer(const Postraitement_base& post) = 0; //Completes the operator possibly carried by the field
89 //and names the sources by default
90 virtual void mettre_a_jour(double temps) = 0; //Updates an operator possibly carried by the field
91
92 // The get_champ() method is in particular called by the post-processing class when
93 // the field must be post-processed (dt_post elapsed).
94 // The caller must provide an untyped "espace_stockage" field as parameter
95 // "espace_stockage".
96 //
97 // Either it returns an existing field (see Champ_Generique_refChamp)
98 // and does not use espace_stockage.
99 // Or it builds a new field stored in espace_stockage,
100 // and the return value is espace_stockage.
101 // The caller retrieves the computation result in the return value,
102 // knowing that it may possibly reference espace_stockage
103 // (so, do not destroy espace_stockage too early).
104
105 // The steps to create the storage space are:
106 // espace_stockage.typer(type_champ)
107 // espace_stockage.associer_domaine_dis_base(un_domaine_dis)
108 // espace_stockage.fixer_nb_comp(nb_comp);
109 // espace_stockage.fixer_nb_valeurs_nodales(nb_ddl);
110 // Computation of values by an instruction of the form
111 // espace_stockage.valeurs() = Operateur.calculer(source.valeurs())
112 // espace_stockage.valeurs().echange_espace_virtuel()
113 //return espace_stockage
114
115 virtual const Champ_base& get_champ(OWN_PTR(Champ_base) &espace_stockage) const = 0;
116 virtual const Champ_base& get_champ_without_evaluation(OWN_PTR(Champ_base)& espace_stockage) const=0;
117
118 //get_champ_post() returns the field if the identifier passed as parameter designates
119 //the field name or one of its components
120 virtual const Champ_Generique_base& get_champ_post(const Motcle& nom) const;
121 virtual bool has_champ_post(const Motcle& nom) const;
122
123 //returns 1 if the field is identified, 0 otherwise
124 virtual int comprend_champ_post(const Motcle& identifiant) const;
125
126 //get_info_type_post() returns 0 if a table must be post-processed, 1 for a tensor
127 virtual int get_info_type_post() const = 0;
128
129 //sets the identifiant_appel_ attribute of the field to indicate whether the request
130 //was launched by the field name or one of its components (cf Champ_Generique_Interpolation)
131 inline void fixer_identifiant_appel(const Nom& identifiant)
132 {
133 identifiant_appel_ = identifiant;
134 }
135
136 virtual const Noms& fixer_noms_compo(const Noms& noms)
137 {
138 Cerr << "The method " << __func__ << " is not overloaded in " << que_suis_je() << finl;
139 throw;
140 }
141 virtual const Noms& fixer_noms_synonyms(const Noms& noms)
142 {
143 Cerr << "The method " << __func__ << " is not overloaded in " << que_suis_je() << finl;
144 throw;
145 }
146
147protected:
148 static void assert_parallel(int);
149
154};
155
156inline int Champ_Generique_base::composante(const Nom& nom_test,const Nom& nom,const Noms& composantes, const Noms& syno)
157{
158 Motcle motlu(nom_test);
159 if (motlu == Motcle(nom))
160 return -1;
161 for (auto& itr : syno)
162 if (itr==motlu) return -1;
163 int n = composantes.size();
164 Motcles les_noms_comp(n);
165 for (int i=0; i<n; i++)
166 les_noms_comp[i] = composantes[i];
167 int ncomp = les_noms_comp.search(motlu);
168 if (ncomp == -1)
169 {
170 Cerr << "Error TRUST, the identifier : " << nom_test << finl
171 << "did not designate the name of the field tested nor any of its components\n";
172 Cerr <<" the components of field named "<<nom <<" are :"<< finl;
173 for (int ii=0; ii<n; ii++)
174 Cerr << composantes[ii] << " ";
175 Cerr << finl;
176 exit();
177 }
178 return ncomp;
179}
180
181/*
182 * @brief class Champ_Generique_erreur
183 *
184 * Class Champ_Generique_erreur
185 */
187{
188public:
190
192 {
193 mot1 = mot2;
194 Cerr<<"Error of type : "<<mot1<<finl;
196 }
197};
198
199#endif /* Champ_Generique_base_included */
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 mettre_a_jour(double temps)=0
virtual const Noms & fixer_noms_compo(const Noms &noms)
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.
static int composante(const Nom &nom_test, const Nom &nom, const Noms &composantes, const Noms &synonyms)
int reprendre(Entree &is) override
Restores an Objet_U from an input stream. Virtual method to override.
virtual const Champ_base & get_champ(OWN_PTR(Champ_base) &espace_stockage) const =0
virtual int comprend_champ_post(const Motcle &identifiant) const
virtual void get_copy_connectivity(Entity index1, Entity index2, IntTab &) const
void fixer_identifiant_appel(const Nom &identifiant)
virtual void set_param(Param &param) const override=0
virtual const Noms & fixer_noms_synonyms(const Noms &noms)
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).
virtual int get_info_type_post() const =0
virtual std::vector< YAML_data > data_a_sauvegarder() const
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...
int sauvegarder(Sortie &os) const override
Saves an Objet_U to an output stream. Virtual method to override.
virtual void get_copy_coordinates(DoubleTab &) const
virtual const Champ_base & get_champ_without_evaluation(OWN_PTR(Champ_base)&espace_stockage) const =0
void nommer(const Nom &nom) override
Assigns a name to the Objet_U. Virtual method to override.
virtual void reset()=0
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_
virtual void completer(const Postraitement_base &post)=0
static void assert_parallel(int)
Champ_Generique_erreur(const Nom &mot2)
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
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.
A character string (Nom) in uppercase.
Definition Motcle.h:26
An array of Motcle objects.
Definition Motcle.h:63
int search(const Motcle &t) const
Definition Motcle.cpp:319
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
friend class Entree
Definition Objet_U.h:71
friend class Sortie
Definition Objet_U.h:70
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
Definition Objet_U.cpp:54
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
Base class for all post-processing objects.
class Probleme_base It is a Probleme_U that is not a coupling.
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466