TrioCFD 1.9.9_beta
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 // Reading of all lines of the parametric file:
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 // To avoid overloading multiple methods of Champ_Don_base:
56 fixer_nb_comp(ch->nb_comp());
57 }
58 // We set the first parameter:
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
class Champ_Don_base base class of Given Fields (not calculated)
: class Champ_Parametrique
static std::string dirnameDefault
std::string newCompute() const
Champ_Don_base & champ()
static std::string dirnameCompute(int compute)
File for reading. This class is to the C++ ifstream class what the Entree class is to the.
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)
Sets the number of components of the field.
A character string (Nom) in uppercase.
Definition Motcle.h:26
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
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)
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