TrioCFD 1.9.9_beta
TrioCFD documentation
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 // Fill the element value array
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 This class represents a data field that is a function
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.
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
virtual void fixer_nb_comp(int i)
Sets the number of components of the field.
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
VECT(Parser_U) &fonction()
Definition Parser_Eval.h:31
Base class for output streams.
Definition Sortie.h:52
Sortie & printOn(Sortie &os) const override
Writes the object to an output stream. Virtual method to override.