TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Inc_base.h
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#ifndef Champ_Inc_base_included
17#define Champ_Inc_base_included
18
19#include <Interface_blocs.h>
20#include <Domaine_forward.h>
21#include <Domaine_VF.h>
22#include <Champ_base.h>
23#include <Domaine_VF.h>
24#include <TRUSTTrav.h>
25#include <TRUST_Ref.h>
26#include <MorEqn.h>
27#include <Roue.h>
28#include <Motcle.h>
29
32class MD_Vector;
33class YAML_data;
34
35/*! @brief Class Champ_Inc_base
36 *
37 * Base class of unknown fields which are fields calculated by an equation.
38 * A Roue type object is associated with Champ_Inc, this wheel allows managing the number of time values for which the field
39 * must remain in memory. It is the time scheme that guides the number of values to keep.
40 * This class can also be used to store fields calculated from other Champ_Inc. In this case, a function calculer_valeurs(...)
41 * is called during mettre_a_jour() and must fill:
42 * - the field values at the current time;
43 * - the derivatives of these values with respect to the unknowns;
44 * - its values at the boundaries (stored in an array, because the field has no
45 * associated BC);
46 *
47 * OWN_PTR(Champ_Inc_base) is a piece of equation because it inherits from MorEqn.
48 *
49 * @sa MorEqn OWN_PTR(Champ_Inc_base) Champ_base Ch_proto Equation_base, Abstract class, Abstract methods:, const Domaine_dis_base& associer_domaine_dis_base(const Domaine_dis_base&), const Domaine_dis_base& domaine_dis_base() const, DoubleTab& remplir_coord_noeuds(DoubleTab& ) const
50 */
51
52class Champ_Inc_base : public Champ_base, public MorEqn
53{
54 Declare_base_sans_constructeur(Champ_Inc_base);
55
56public:
57 Champ_Inc_base() : fonc_calc_(nullptr) { } // by default: no fonc_calc_
58
59 // Reimplemented methods
60 int fixer_nb_valeurs_nodales(int) override;
61 double changer_temps(const double temps) override;
62 void mettre_a_jour(double temps) override;
63 int reprendre(Entree&) override;
64 int sauvegarder(Sortie&) const override;
65
66 Champ_base& affecter_compo(const Champ_base&, int compo) override;
67 void resetTime(double time) override;
68
69 // Pure virtual methods implemented here
70 Champ_base& affecter_(const Champ_base&) override;
71 virtual void verifie_valeurs_cl();
72
73 /*! @brief Returns the array of field values at the current time.
74 *
75 * @return (DoubleTab&) the array of field values
76 */
77 inline DoubleTab& valeurs() override { return les_valeurs->valeurs(); }
78 inline const DoubleTab& valeurs() const override { return les_valeurs->valeurs(); }
79
80 DoubleVect& valeur_a(const DoubleVect& position, DoubleVect& valeurs) const override;
81 DoubleTab& valeur_aux(const DoubleTab& positions, DoubleTab& valeurs) const override;
82 DoubleVect& valeur_aux_compo(const DoubleTab& positions, DoubleVect& valeurs, int ncomp) const override;
83
84 // New methods
85 int nb_valeurs_nodales() const override;
86 virtual int fixer_nb_valeurs_temporelles(int);
87 virtual int nb_valeurs_temporelles() const;
88 double changer_temps_futur(double, int i = 1);
89 double changer_temps_passe(double, int i = 1);
90 double recuperer_temps_futur(int i = 1) const;
91 double recuperer_temps_passe(int i = 1) const;
92 DoubleTab& valeurs(double temps) override;
93 const DoubleTab& valeurs(double temps) const override;
94
95 // Implicit conversion operators
96 operator DoubleTab& () = delete;
97 operator const DoubleTab& () const = delete;
98
99 /*! @brief Returns field values at instant t+i.
100 *
101 * @param (int i) the future time step at which we want the field values
102 * @return (DoubleTab&) the field values at instant t+i
103 */
104 inline DoubleTab& futur(int i = 1) override { return les_valeurs->futur(i).valeurs(); }
105 inline const DoubleTab& futur(int i = 1) const override { return les_valeurs->futur(i).valeurs(); }
106
107 /*! @brief Returns field values at instant t-i.
108 *
109 * @param (int i) the past time step at which we want the field values
110 * @return (DoubleTab&) the field values at instant t-i
111 */
112 inline DoubleTab& passe(int i = 1) override { return les_valeurs->passe(i).valeurs(); }
113 inline const DoubleTab& passe(int i = 1) const override { return les_valeurs->passe(i).valeurs(); }
114
115 Champ_Inc_base& avancer(int i = 1);
116 Champ_Inc_base& reculer(int i = 1);
117
118 int lire_donnees(Entree&);
119 int imprime(Sortie&, int) const override;
120 int a_un_domaine_dis_base() const override { return 1; }
121
122 virtual void associer_eqn(const Equation_base&);
123 virtual void associer_domaine_cl_dis(const Domaine_Cl_dis_base&);
124 void associer_domaine_dis_base(const Domaine_dis_base&) override;
125
126 const Domaine_Cl_dis_base& domaine_Cl_dis() const;
128 const Domaine_dis_base& domaine_dis_base() const override { return le_dom_VF.valeur(); }
129 const Domaine_VF& domaine_vf() const { return le_dom_VF.valeur(); }
130
131 DoubleTab& trace(const Frontiere_dis_base&, DoubleTab&, double, int distant) const override;
132 virtual int remplir_coord_noeuds_et_polys(DoubleTab&, IntVect&) const;
133 virtual int remplir_coord_noeuds_et_polys_compo(DoubleTab&, IntVect&, int) const;
134 virtual DoubleTab& remplir_coord_noeuds(DoubleTab&) const =0;
135 virtual DoubleTab& remplir_coord_noeuds_compo(DoubleTab&, int) const;
136
137 virtual double integrale_espace(int ncomp) const;
138 const Domaine& domaine() const;
139
140 //derivatives of the field with respect to unknowns:
141 //returns derivatives calculated by fonc_calc_ if calculated field, deriv[unknown name] = 1 if true unknown
142 const tabs_t& derivees() const { return deriv_; }
143 tabs_t& derivees() { return deriv_; }
144 DoubleTab& val_bord() { return val_bord_; }
145
146 //field depending on other OWN_PTR(Champ_Inc_base) : setting the calculation function, initialization of val_bord_
147 void init_champ_calcule(const Objet_U& obj, fonc_calc_t fonc);
148 //to force the calculation of all cases on the next mettre_a_jour() (normally done only once)
150
151 void resize_val_bord();
153
154 //uses boundary conditions (instead of valeur_aux() in Champ_base)
155 //result is filled only for boundary faces where the BC imposes a value (val_imp or val_ext)
156 DoubleTab valeur_aux_bords() const override;
157
158 // Obsolete method: signature changed in order to generate a compiler error if old code is not removed
159 virtual void creer_espace_distant(int dummy) { }
160
163
164 void PDI_save_type(bool b) { PDI_save_type_ = b; }
165 virtual std::vector<YAML_data> data_a_sauvegarder() const;
166 Nom get_PDI_dname() const;
167 void set_PDI_dname(const Nom& name) { PDI_dname_ = (Motcle)name; }
168
169protected:
170 // By default we initialize values to zero
171 virtual void creer_tableau_distribue(const MD_Vector&, RESIZE_OPTIONS = RESIZE_OPTIONS::COPY_INIT);
172
173
176 OBS_PTR(Domaine_VF) le_dom_VF;
177
178 /* for fields depending on other OWN_PTR(Champ_Inc_base) */
179 fonc_calc_t fonc_calc_; //calculation function
180 int fonc_calc_init_ = 0; //1 once the field has been calculated at least once
181 RefObjU obj_calc_; //an object to pass as argument
182 DoubleTab val_bord_; //boundary values at current time
183 tabs_t deriv_; //derivatives at current time
185
186 bool PDI_save_type_ = false; // do we save the type of the unknown in pdi format?
187 Nom PDI_dname_; // For restart with PDI: to use if the name of the dataset we want to read is different from the name of the field
188
189};
190
191#endif /* Champ_Inc_base_included */
Class Champ_Inc_base.
const Domaine & domaine() const
void set_via_ch_fonc_reprise()
void set_val_bord_fluide_multiphase(const bool flag)
void associer_domaine_dis_base(const Domaine_dis_base &) override
virtual int remplir_coord_noeuds_et_polys(DoubleTab &, IntVect &) const
DOES NOTHING. Method to override.
virtual void creer_tableau_distribue(const MD_Vector &, RESIZE_OPTIONS=RESIZE_OPTIONS::COPY_INIT)
DoubleTab & futur(int i=1) override
Returns field values at instant t+i.
int fixer_nb_valeurs_nodales(int) override
int lire_donnees(Entree &)
Reads the field values from an input stream.
virtual void associer_domaine_cl_dis(const Domaine_Cl_dis_base &)
DoubleTab & passe(int i=1) override
Returns field values at instant t-i.
DoubleTab & val_bord()
virtual int fixer_nb_valeurs_temporelles(int)
Sets the number of temporal values to keep.
tabs_t & derivees()
void init_champ_calcule(const Objet_U &obj, fonc_calc_t fonc)
virtual int nb_valeurs_temporelles() const
Returns the number of temporal values currently kept.
DoubleVect & valeur_aux_compo(const DoubleTab &positions, DoubleVect &valeurs, int ncomp) const override
Computes the values of the unknown field at the specified positions, for a given component of the fie...
const Domaine_Cl_dis_base & domaine_Cl_dis() const
void mettre_a_jour(double temps) override
Performs a time update of the unknown field.
virtual DoubleTab & remplir_coord_noeuds_compo(DoubleTab &, int) const
Simple call to Champ_Inc_base::remplir_coord_noeuds(DoubleTab&).
void resetTime(double time) override
const Domaine_dis_base & domaine_dis_base() const override
double changer_temps(const double temps) override
Sets the time of the field.
OBS_PTR(Domaine_VF) le_dom_VF
void set_PDI_dname(const Nom &name)
virtual std::vector< YAML_data > data_a_sauvegarder() const
for PDI IO: retrieve name, type and dimensions of the field to save/restore.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
virtual void associer_eqn(const Equation_base &)
Associates the field with the equation of which it represents an unknown.
const DoubleTab & valeurs() const override
OBS_PTR(Domaine_Cl_dis_base) mon_dom_cl_dis
virtual int remplir_coord_noeuds_et_polys_compo(DoubleTab &, IntVect &, int) const
Simple call to: Champ_Inc_base::remplir_coord_noeuds_et_polys(DoubleTab&,IntVect& poly).
virtual void verifie_valeurs_cl()
void PDI_save_type(bool b)
fonc_calc_t fonc_calc_
int sauvegarder(Sortie &) const override
Saves the unknown field to an output stream.
Champ_Inc_base & avancer(int i=1)
Advances the current pointer by i time steps, in the list of kept temporal values.
double changer_temps_passe(double, int i=1)
Sets the time of the i-th past field.
virtual double integrale_espace(int ncomp) const
int nb_valeurs_nodales() const override
Returns the number of "real" geometric positions of the degrees of freedom, or -1 if not applicable (...
const Domaine_VF & domaine_vf() const
DoubleVect & valeur_a(const DoubleVect &position, DoubleVect &valeurs) const override
Computes the value of the unknown field at the specified position.
double recuperer_temps_passe(int i=1) const
Returns the time of the i-th past field.
virtual DoubleTab & remplir_coord_noeuds(DoubleTab &) const =0
int a_un_domaine_dis_base() const override
Champ_Inc_base & reculer(int i=1)
Rewinds the current pointer by i time steps, in the list of kept temporal values.
int reprendre(Entree &) override
Reads an unknown field from an input stream for a restart.
DoubleTab & trace(const Frontiere_dis_base &, DoubleTab &, double, int distant) const override
See Champ_base. Special case (unfortunately) of Champ_P0_VDF:
const DoubleTab & passe(int i=1) const override
DoubleTab & valeur_aux(const DoubleTab &positions, DoubleTab &valeurs) const override
Computes the values of the unknown field at the specified positions.
virtual void creer_espace_distant(int dummy)
Champ_base & affecter_compo(const Champ_base &, int compo) override
Assignment of a component of a generic OWN_PTR(Champ_base) (Champ_base) to a component of an unknown ...
bool via_ch_fonc_reprise() const
Champ_base & affecter_(const Champ_base &) override
Assignment of a generic OWN_PTR(Champ_base) (Champ_base) to an unknown field.
Nom get_PDI_dname() const
for PDI IO: retrieve the name of the HDF5 dataset in which the field will be saved or be restored fro...
DoubleTab val_bord_
const DoubleTab & futur(int i=1) const override
void reset_champ_calcule()
int imprime(Sortie &, int) const override
const tabs_t & derivees() const
DoubleTab valeur_aux_bords() const override
Returns the field value at the boundary faces.
double recuperer_temps_futur(int i=1) const
Returns the time of the i-th future field.
double changer_temps_futur(double, int i=1)
Sets the time of the i-th future field.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
Champ_base()
Default constructor of a Champ_base.
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_VF
Definition Domaine_VF.h:44
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Equation_base The role of an equation is the calculation of one or more fields....
class Frontiere_dis_base Class representing a discretized boundary.
: This class is an OWN_PTR but the pointed object is shared among multiple
Definition MD_Vector.h:48
class MorEqn Class that groups the functionalities of linking with an
Definition MorEqn.h:35
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
Base class for output streams.
Definition Sortie.h:52
YAML_data class: collection of all needed information for data to save/restore in order to write the ...
Definition YAML_data.h:26
Pointer to a wheel.
Definition Roue.h:33