TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Tabule_Temps.cpp
1/****************************************************************************
2* Copyright (c) 2022, 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_Tabule_Temps.h>
17
18Implemente_instanciable(Champ_Tabule_Temps,"Champ_Tabule_Temps",Champ_Uniforme_inst);
19// XD champ_tabule_temps champ_don_base champ_tabule_temps NO_BRACE Field that is constant in space and tabulated as a
20// XD_CONT function of time.
21// XD attr dim entier dim REQ Number of field components.
22// XD attr bloc bloc_lecture bloc REQ Values as a table. The value of the field at any time is calculated by linear
23// XD_CONT interpolation from this table.
24
25
26
27/*! @brief Does nothing.
28 *
29 * @param (Sortie& os) an output stream
30 * @return (Sortie&) the output stream
31 */
33{
34 return os;
35}
36
37
38/*! @brief Reads the values of the time-tabulated field from an input stream.
39 *
40 * Reads the number of field components (nb_comp) and fills
41 * a table from the nval pairs (vrel_i, tps_i).
42 * Format:
43 * Champ_Tabule_Temps nb_comp { nval tps_1...tps_nval vrel_1...vrel_nval }
44 *
45 * @param (Entree& is) an input stream
46 * @return (Entree&) the modified input stream
47 * @throws opening brace expected
48 * @throws closing brace expected
49 */
51{
52 Motcle motlu;
53 int nb_val;
54 Motcle accolade_ouverte("{");
55 Motcle accolade_fermee("}");
57 if (nb_compo_ <= 0)
58 {
59 Cerr << "Error in Champ_Tabule_Temps::readOn : nb_compo <= 0" << finl;
60 assert(0);
61 exit();
62 }
64 is >> motlu;
65 if (motlu == accolade_ouverte)
66 {
67 nb_val=lire_dimension(is,que_suis_je());
68 DoubleVect param(nb_val);
69 DoubleTab les_valeurs(nb_val, nb_compo_);
70 for (int i = 0; i < nb_val; i++)
71 is >> param[i];
72 for (int i = 0; i < nb_val; i++)
73 for (int k = 0; k < nb_compo_; k++)
74 is >> les_valeurs(i, k);
75 la_table.remplir(param, les_valeurs);
76
77 is >> motlu;
78 if (motlu != accolade_fermee)
79 {
80 Cerr << "Error reading from an object of type Champ_Tabule_Temps" << finl;
81 Cerr << "We expected keyword } instead of " << motlu << finl;
82 exit();
83 }
84 }
85 else
86 {
87 Cerr << "Error reading from an object of type Champ_Tabule_Temps" << finl;
88 Cerr << "We expected keyword { instead of " << motlu << finl;
89 exit();
90 }
91 changer_temps(-1e9);
92 //mettre_a_jour(0.);
93 return is;
94}
95
96
97/*! @brief Updates the tabulated field values in time.
98 *
99 * @param (double tps) the update time
100 */
102{
103 if (temps() != tps)
104 {
105 DoubleVect& mes_valeurs = valeurs();
106 if (mes_valeurs.size() == 1)
107 mes_valeurs[0] = la_table.val(tps);
108 else
109 la_table.valeurs(mes_valeurs,tps);
110 }
111}
void dimensionner(int, int)
Sets the number of components and the number of nodal values.
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
int lire_dimension(Entree &, const Nom &)
Verification of the field dimension Returns the dimension of the field.
Classe Champ_Tabule_Temps Derived class of Champ_Uniforme_inst that represents.
void me_calculer(double t) override
Updates the tabulated field values in time.
Champ_Uniforme_inst A field that is constant in space but time-dependent.
virtual double changer_temps(const double t)
Sets the time at which the field is defined.
double temps() const
Returns the time of the field.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
int nb_compo_
Definition Field_base.h:95
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
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
_SIZE_ size() const
Definition TRUSTVect.tpp:45