TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Champ_Don_Fonc_txyz.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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_Don_Fonc_txyz.h>
17#include <TRUST_Vector.h>
18#include <Parser_U.h>
19
20Implemente_instanciable(Champ_Don_Fonc_txyz,"Champ_Fonc_txyz",TRUSTChamp_Don_generique<Champ_Don_Type::TXYZ>);
21// XD field_func_txyz champ_don_base champ_fonc_txyz NO_BRACE Field defined by analytical functions. It makes it
22// XD_CONT possible the definition of a field that depends on the time and the space.
23// XD attr dom ref_domaine dom REQ Name of domain of calculation
24// XD attr val listchaine val REQ List of functions on (t,x,y,z).
25// XD ref gravite field_base
26
28
30{
31 Nom motlu;
32 double t0 = 0., T = 1;
33 int dim;
34 dim = -1;
35 Nom nom_dom;
36 is >> motlu;
37
38 if (motlu == "impulsion_t0")
39 {
40 is >> t0;
41 is >> motlu;
42 if (motlu == "impulsion_perio")
43 {
44 is >> T;
45 is >> nom_dom;
46 dim = lire_dimension(is, que_suis_je());
47 }
48 else
49 {
50 nom_dom = motlu;
51 dim = lire_dimension(is, que_suis_je());
52 }
53 }
54 else if (motlu == "impulsion_perio")
55 {
56 is >> T;
57 is >> motlu;
58 if (motlu == "impulsion_t0")
59 {
60 is >> t0;
61 is >> nom_dom;
62 dim = lire_dimension(is, que_suis_je());
63 }
64 else
65 {
66 nom_dom = motlu;
67 //dim = strtol(motlu.getChar(), (char **)nullptr, 10);
68 dim = lire_dimension(is, que_suis_je());
69 }
70 }
71 else
72 {
73 nom_dom = motlu;
74 dim = lire_dimension(is, que_suis_je());
75 }
76
77 fixer_nb_comp(dim);
78 VECT(Parser_U) &fxyz = fonction();
79 fxyz.dimensionner(dim);
80
81 for (int i = 0; i < dim; i++)
82 {
83 Nom tmp;
84 is >> tmp;
85 Cerr << "Reading and interpretation of the function " << tmp << finl;
86 fxyz[i].setNbVar(4);
87 fxyz[i].setString(tmp);
88 fxyz[i].addVar("t");
89 fxyz[i].addVar("x");
90 fxyz[i].addVar("y");
91 fxyz[i].addVar("z");
92 fxyz[i].setImpulsion(t0, T);
93 fxyz[i].parseString();
94 Cerr << "Interpretation of function " << tmp << " Ok" << finl;
95 }
96
97 // On remplit le tableau des valeurs aux elements
98 Domaine& domaine = interprete_get_domaine(nom_dom);
99 int nb_elems = domaine.nb_elem();
100 DoubleTab& mes_val = valeurs();
101 dimensionner(nb_elems, dim);
102 domaine.creer_tableau_elements(mes_val);
104
105 return is;
106}
class Champ_Don_Fonc_txyz Cette classe represente un champ de donnees fonction
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.
int lire_dimension(Entree &, const Nom &)
Verification de la dimension du champ Renvoie la dimension du champ.
double temps() const
Renvoie le temps du champ.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual void fixer_nb_comp(int i)
Fixe le nombre de composantes du champ.
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
VECT(Parser_U) &fonction()
Definition Parser_Eval.h:31
Classe de base des flux de sortie.
Definition Sortie.h:52
Sortie & printOn(Sortie &os) const override
Ecriture de l'objet sur un flot de sortie Methode a surcharger.