TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Champ_front_Parametrique.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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_front_Parametrique.h>
17#include <Param.h>
18#include <Probleme_base.h>
19#include <EFichier.h>
20#include <EChaine.h>
21
22
23Implemente_instanciable(Champ_front_Parametrique,"Champ_front_Parametrique",Champ_front_base);
24// XD Champ_front_Parametrique front_field_base Champ_front_Parametrique BRACE Parametric boundary field
25
27{
29}
30
32{
33 Nom fichier;
34 Param param(que_suis_je());
35 param.ajouter("fichier", &fichier, Param::REQUIRED); // XD_ADD_P chaine
36 // XD_CONT Filename where boundary fields are read
37 param.lire_avec_accolades_depuis(is);
38 // Lecture de tous les lignes du fichier parametrique:
39 EFichier fic(fichier);
40 Motcle motlu;
41 fic >> motlu;
42 if (motlu!="{") Process::exit("Waiting { !");
43 while (motlu!="}")
44 {
45 OWN_PTR(Champ_front_base) ch;
46 fic >> ch;
47 champs_.add(ch);
48 //Cerr << "[Parameter] Reading: " << ch->que_suis_je() << finl; //" " << ch.valeur() << finl;
49 fic >> motlu;
50 }
51 // On fixe le premier parametre:
53 return is;
54}
55
57{
58 if (champs_.size()==index_)
59 return "";
60 else
61 {
62 Nom previous_field("");
63 if (index_)
64 {
65 previous_field = " from ";
66 previous_field += champ().que_suis_je();
67 }
68 index_++;
69 Nom next_field = champ().que_suis_je();
70 Cerr << "[Parameter] Updating boundary field" << previous_field << " to " << next_field << finl;
72 }
73}
74
76{
77 if (t1<last_t2_ && index_>1)
78 {
79 // Pour assurer la continuite avec le champ precedent:
80 if (std::abs(t2-t1) < DMINFLOAT)
81 {
82 Gpoint_ = 0;
83 }
84 else
85 {
86 const DoubleTab& v1 = champs_[index_-2]->valeurs_au_temps(last_t2_);
87 const DoubleTab& v2 = valeurs_au_temps(t2);
88 if (v1.dimension(0) == 1)
89 {
90 // Champ instationnaire uniforme
91 int dim = v1.dimension(1);
92 if (Gpoint_.size() != dim) Gpoint_.resize(dim);
93 for (int i = 0; i < dim; i++)
94 Gpoint_(i) = (v2(0, i) - v1(0, i)) / (t2 - t1);
95 }
96 else
97 {
98 // Champs instationnaire variable
99 Gpoint_ = v1;
100 Gpoint_ *= -1;
101 Gpoint_ += v2;
102 Gpoint_ /= (t2 - t1);
103 }
104 }
105 }
106 else
107 {
110 }
111 last_t2_ = t2;
112}
113
115{
116 return Gpoint_;
117}
static std::string dirnameCompute(int compute)
: class Champ_front_Parametrique
void calculer_derivee_en_temps(double t1, double t2) override
Calcule le taux d'accroissement du champ entre t1 et t2 et le stocke dans Gpoint_.
const DoubleTab & derivee_en_temps() const override
DoubleTab & valeurs_au_temps(double temps) override
classe Champ_front_base Classe de base pour la hierarchie des champs aux frontieres.
virtual const DoubleTab & derivee_en_temps() const
virtual void calculer_derivee_en_temps(double t1, double t2)
Calcule le taux d'accroissement du champ entre t1 et t2 et le stocke dans Gpoint_.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
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
@ REQUIRED
Definition Param.h:115
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
static void set_root(const std::string dirname)
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133