TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Fonc_t.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_Fonc_t.h>
17#include <algorithm>
18
19Implemente_instanciable(Champ_Fonc_t,"Champ_Fonc_t",Champ_Uniforme_inst);
20// XD champ_fonc_t champ_don_base champ_fonc_t NO_BRACE Field that is constant in space and is a function of time.
21// XD attr val listchaine val REQ Values of field components (time dependant functions).
22
23
24/*! @brief NE FAIT RIEN
25 *
26 * @param (Sortie& os) un flot de sortie
27 * @return (Sortie&) le flot de sortie
28 */
30{
31 return os;
32}
33
34/*! @brief Lecture des parametres dans le fichier data.
35 *
36 * On attend
37 * nb_composantes expression_composante1(t) expression_composante2(t) ...
38 * Exemple:
39 * 3 SIN(t) t*t 1.+t
40 *
41 */
43{
44 int nb_compo;
45 nb_compo=lire_dimension(is,que_suis_je());
46 if (nb_compo <= 0)
47 {
48 Cerr << "Error in Champ_Fonc_t::readOn : nb_compo <= 0" << finl;
49 assert(0);
50 exit();
51 }
52 dimensionner(1, nb_compo);
53 ft.dimensionner(nb_compo);
54 for (int i_parser = 0; i_parser < nb_compo; i_parser++)
55 {
56 Nom expression;
57 is >> expression;
58 const char* s = expression.getChar();
59 std::string ss(s);
60 std::transform(ss.begin(), ss.end(), ss.begin(), ::toupper);
61 ft[i_parser].setNbVar(1);
62 ft[i_parser].setString(ss);
63 ft[i_parser].addVar("t");
64 ft[i_parser].parseString();
65 }
66
67 me_calculer(0.);
68
69 return is;
70}
71
72/*! @brief Calcul du tableau "valeurs()" au temps t a partir des fonctions analytiques lues dans le readOn
73 *
74 */
76{
77 int i = 0;
78 DoubleTab& val = valeurs();
79 for (i = 0; i < ft.size(); i++)
80 {
81 //Parser & p = parser_array_[i];
82 //p.setVar(0, t);
83 //const double v = p.eval();
84 ft[i].setVar(0, t);
85 const double v = ft[i].eval();
86 val(0, i) = v;
87 }
88}
void dimensionner(int, int)
Fixe le nombre de composantes et le nombre de valeurs nodales.
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
Classe Champ_Fonc_t Cette classe derivee de Champ_Uniforme_inst qui represente.
void me_calculer(double t) override
Calcul du tableau "valeurs()" au temps t a partir des fonctions analytiques lues dans le readOn.
int lire_dimension(Entree &, const Nom &)
Verification de la dimension du champ Renvoie la dimension du champ.
classe Champ_Uniforme_inst Un champ constant dans l'espace mais dependant du temps.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const char * getChar() const
Definition Nom.h:91
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52