TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_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_Parametrique.h>
17#include <Param.h>
18#include <Probleme_base.h>
19#include <EFichier.h>
20#include <EChaine.h>
21#include <string>
22
23Implemente_instanciable( Champ_Parametrique, "Champ_Parametrique", Champ_Don_base );
24// XD Champ_Parametrique champ_don_base Champ_Parametrique BRACE Parametric field
25
27
30std::string Champ_Parametrique::dirnameCompute(int compute)
31{
32 return Champ_Parametrique::dirnameDefault.empty() ? "calcul"+std::to_string(compute) : Champ_Parametrique::dirnameDefault;
33}
34
36{
38 Nom fichier;
39 Param param(que_suis_je());
40 param.ajouter("fichier", &fichier, Param::REQUIRED); // XD_ADD_P chaine
41 // XD_CONT Filename where fields are read
42 param.lire_avec_accolades_depuis(is);
43 // Lecture de tous les lignes du fichier parametrique:
44 EFichier fic(fichier);
45 Motcle motlu;
46 fic >> motlu;
47 if (motlu!="{") Process::exit("Waiting { !");
48 while (motlu!="}")
49 {
50 OWN_PTR(Champ_Don_base) ch;
51 fic >> ch;
52 champs_.add(ch);
53 //Cerr << "[Parameter] Reading: " << ch->que_suis_je() << finl;
54 fic >> motlu;
55 // Pour eviter de surcharger plusieurs methodes de Champ_Don_base:
56 fixer_nb_comp(ch->nb_comp());
57 }
58 // On fixe le premier parametre:
60 return is;
61}
62
64{
65 if (champs_.size()==index_)
66 return "";
67 else
68 {
69 Nom previous_field("");
70 if (index_)
71 {
72 previous_field = " from ";
73 previous_field += champ().que_suis_je();
74 }
75 index_++;
76 Nom next_field = champ().que_suis_je();
77 Cerr << "[Parameter] Updating field" << previous_field << " to " << next_field << finl;
79 }
80}
81
classe Champ_Don_base classe de base des Champs donnes (non calcules)
: class Champ_Parametrique
static std::string dirnameDefault
std::string newCompute() const
Champ_Don_base & champ()
static std::string dirnameCompute(int compute)
Fichier en lecture Cette classe est a la classe C++ ifstream ce que la classe Entree est a la.
Definition EFichier.h:29
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.
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
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
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
@ 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