TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Uniforme_Morceaux_Tabule_Temps.cpp
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#include <Champ_Uniforme_Morceaux_Tabule_Temps.h>
17#include <Interprete.h>
18#include <Sous_Domaine.h>
19#include <Domaine.h>
20#include <Motcle.h>
21
22Implemente_instanciable(Champ_Uniforme_Morceaux_Tabule_Temps, "Champ_Uniforme_Morceaux_Tabule_Temps", Champ_Uniforme_Morceaux_inst);
23// XD champ_uniforme_morceaux_tabule_temps champ_uniforme_morceaux champ_uniforme_morceaux_tabule_temps INHERITS_BRACE
24// XD_CONT this type of field is constant in space on one or several sub_zones and tabulated as a function of time.
25
26
28
29/*! @brief Lit un champ uniforme par morceaux tabule dans le temps a partir d'un flot d'entree.
30 *
31 * @param (Entree& is) un flot d'entree
32 * @return (Entree&) le flot d'entre modifie
33 * @throws accolade ouvrante attendue
34 * @throws mot clef "defaut" attendu
35 * @throws accolade fermante attendue
36 */
38{
39 int dim;
40 Motcle motlu;
41 Nom nom;
42 int k, poly,nb_val;
43 is >> nom;
44 mon_domaine = ref_cast(Domaine, Interprete::objet(nom));
45 Domaine& le_domaine=mon_domaine.valeur();
47 fixer_nb_comp(dim);
48 valeurs_.resize(0, dim);
50 is >> nom;
51 motlu=nom;
52 if(motlu != Motcle("{") )
53 {
54 Cerr << "Error while reading a " << que_suis_je() << finl;
55 Cerr << "We expected a { instead of " << nom << finl;
56 exit();
57 }
58 is >> nom;
59 motlu=nom;
60 if(motlu != Motcle("defaut") )
61 {
62 Cerr << "Error while reading a " << que_suis_je() << finl;
63 Cerr << "We expected defaut instead of " << nom << finl;
64 exit();
65 }
66 DoubleVect val(dim);
67 for( k=0; k< dim; k++) is >> val(k);
68 for( poly=0; poly<le_domaine.nb_elem(); poly++)
69 for( k=0; k< dim; k++)
70 valeurs_(poly,k)=val(k);
71 is >> nom;
72 motlu=nom;
73 while (motlu != Motcle("}") )
74 {
75 les_sous_domaines.add(le_domaine.ss_domaine(nom));
76 is >> motlu;
77 if (motlu == Motcle("{") )
78 {
79 Table la_table;
80 is >> nb_val;
81 DoubleVect param(nb_val);
82 DoubleTab tab_valeurs(nb_val,dim);
83 for (int i = 0; i < nb_val; i++)
84 is >> param[i];
85 for (int i = 0; i < nb_val; i++)
86 for (k = 0; k < dim; k++)
87 is >> tab_valeurs(i, k);
88 la_table.remplir(param,tab_valeurs);
89 les_tables.add(la_table);
90 is >> motlu;
91 if (motlu != Motcle("}") )
92 {
93 Cerr << "Error while reading an object of type Champ_Uniforme_Morceaux_Tabule_Temps" << finl;
94 Cerr << "We expected keyword } instead of " << motlu << finl;
95 exit();
96 }
97 }
98 else
99 {
100 Cerr << "Error while reading an object of type Champ_Uniforme_Morceaux_Tabule_Temps" << finl;
101 Cerr << "We expected keyword { instead of " << motlu << finl;
102 exit();
103 }
104 is >> nom;
105 motlu=nom;
106 }
107 return is;
108}
109
110/*! @brief Mise a jour en temps du champ (tabule en temps)
111 *
112 * @param (double tps) le temps de mise a jour
113 */
115{
116 if (!est_egal(temps(),tps))
117 {
118
119 auto& list = les_tables.get_stl_list();
120 auto itr2 = les_sous_domaines.get_stl_list().begin();
121
122 if (nb_comp() == 1)
123 {
124 DoubleVect& mes_valeurs = valeurs();
125 double val_ch;
126 for (auto& itr : list)
127 {
128 Sous_Domaine& ssz = (*itr2).valeur();
129 Table& la_table = itr;
130
131 val_ch = la_table.val(tps);
132
133 for( int poly=0; poly<ssz.nb_elem_tot(); poly++)
134 mes_valeurs(ssz(poly)) = val_ch;
135
136 ++itr2;
137 }
138 }
139 else
140 {
141 DoubleTab& mes_valeurs = valeurs();
142 int k,dim = nb_comp();
143 DoubleVect val_loc(dim);
144
145 for (auto& itr : list)
146 {
147 Sous_Domaine& ssz = (*itr2).valeur();
148 Table& la_table = itr;
149
150 la_table.valeurs(val_loc,tps);
151
152 for(int poly=0; poly<ssz.nb_elem_tot(); poly++)
153 for( k=0; k< dim; k++)
154 mes_valeurs(ssz(poly),k) = val_loc(k);
155
156 ++itr2;
157 }
158 }
159 }
161}
162
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
DoubleTab valeurs_
int lire_dimension(Entree &, const Nom &)
Verification de la dimension du champ Renvoie la dimension du champ.
classe Champ_Uniforme_Morceaux_Tabule_Temps Cette classe derivee de Champ_Uniforme_Morceaux_inst repr...
void me_calculer(double t) override
Mise a jour en temps du champ (tabule en temps).
Classe Champ_Uniforme_Morceaux_inst Representent un champ constant par morceaux dans l'espace et depe...
double temps() const
Renvoie le temps du champ.
const Sous_Domaine_t & ss_domaine(int i) const
Definition Domaine.h:290
virtual void creer_tableau_elements(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
creation d'un tableau parallele de valeurs aux elements.
Definition Domaine.cpp:851
int_t nb_elem() const
Definition Domaine.h:131
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.
virtual int nb_comp() const
Definition Field_base.h:56
static Objet_U & objet(const Nom &)
Voir Interprete_bloc::objet_global() BM: la classe Interprete n'est pas le meilleur endroit pour cett...
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
int_t nb_elem_tot() const
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")
Definition Table.h:29
void remplir(const DoubleVect &param, const DoubleTab &val)
Affecte les parametres et les valeurs de la table.
Definition Table.cpp:304
double val(const double val_param, int ncomp=0) const
Definition Table.cpp:145
DoubleTab & valeurs(const DoubleTab &val_param, const DoubleTab &pos, const double tps, DoubleTab &val) const
Definition Table.cpp:292