TrioCFD 1.9.9_beta
TrioCFD documentation
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 // Reading of all lines of the parametric file:
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 // We set the first parameter:
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 // To ensure continuity with the previous field:
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 // Unsteady uniform field
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 // Unsteady variable fields
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
Computes the rate of change of the field between t1 and t2 and stores it in Gpoint_.
const DoubleTab & derivee_en_temps() const override
DoubleTab & valeurs_au_temps(double temps) override
class Champ_front_base Base class for the hierarchy of boundary fields.
virtual const DoubleTab & derivee_en_temps() const
virtual void calculer_derivee_en_temps(double t1, double t2)
Computes the rate of change of the field between t1 and t2 and stores it in Gpoint_.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
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
@ REQUIRED
Definition Param.h:115
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
static void set_root(const std::string dirname)
Base class for output streams.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133