TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Fonc_Fonction.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_Fonc_Fonction.h>
17#include <EChaine.h>
18
19Implemente_instanciable(Champ_Fonc_Fonction,"Champ_Fonc_Fonction",Champ_Fonc_Tabule);
20// XD champ_fonc_fonction champ_fonc_tabule champ_fonc_fonction NO_BRACE Field that is a function of another field.
21// XD attr dim suppress_param dim OPT del
22// XD attr pb_field suppress_param pb_field OPT del
23// XD attr bloc suppress_param bloc OPT del
24// XD attr problem_name ref_Pb_base problem_name REQ Name of problem.
25// XD attr inco chaine inco REQ Name of the field (for example: temperature).
26// XD attr expression listchaine expression REQ Number of field components followed by the analytical expression for
27// XD_CONT each field component.
28
29Sortie& Champ_Fonc_Fonction::printOn(Sortie& os) const { return os; }
30
31/*! @brief Lecture du Champ a partir d'un flot d'entree, (On ne sait traiter que les champs scalaires.)
32 *
33 * exemple:
34 * Champ_Fonc_Fonction probleme ch
35 * 1 (nombre de composantes)
36 * {
37 * 2
38 * 0 500 0 250 (ch(0)=0 && ch(500)=250
39 * }
40 *
41 * @param (Entree& is) un flot d'entree
42 * @return (Entree&) le flot d'entree modifie
43 * @throws accolade fermante attendue
44 * @throws accolade ouvrante attendue
45 */
47{
48 int nbcomp;
49 Nom val1, val2;
50 is >> val1;
51 is >> val2;
52 // fix if user uses the old syntax ..
53 Champ_Fonc_Tabule::Warn_old_chp_fonc_syntax_V_184("Champ_Fonc_Fonction", val1, val2);
54
55 noms_pbs_.add(val1);
56 noms_champs_parametre_.add(val2);
57 is >> nbcomp;
58 fixer_nb_comp(nbcomp);
59 Cerr<<"We read the analytic function "<<finl;
60 la_table.lire_f(is, nbcomp);
61 return is;
62}
63Implemente_instanciable_sans_constructeur(Sutherland,"Sutherland",Champ_Fonc_Fonction);
64
65Sutherland::Sutherland() : A_(-1.), C_(-1.), Tref_(-1.) { }
66
67Sortie& Sutherland::printOn(Sortie& os) const { return os; }
68
70{
71 Cerr<< "Sutherland::readOn usage { prob A a C c TREF Tref }"<<finl;
72 Cerr<<"== Champ_Fonc_Fonction problem_name Temperature 1 a*(c+Tref)/(c+val)*(val/Tref)^1.5"<<finl;
73 Motcle accferme="}", accouverte="{", motlu;
74 is >> motlu;
75 Cerr<<"Reading Sutherland"<<finl;
76 if (motlu != accouverte)
77 {
78 Cerr<<" We expected "<<accouverte<<" instead of "<<motlu<<finl;
79 abort();
80 }
81
82 Motcles les_mots(3);
83 {
84 les_mots[0] = "A";
85 les_mots[1] = "C";
86 les_mots[2] = "Tref";
87 }
88
89 is >> motlu;
90 while(motlu != accferme )
91 {
92 is >> prob_;
93 int rang=les_mots.search(motlu);
94 switch(rang)
95 {
96 case 0 :
97 is >> A_;
98 break;
99 case 1 :
100 is>> C_;
101 break;
102 case 2 :
103 is>>Tref_;
104 break;
105 default :
106 {
107 Cerr<<"A "<<que_suis_je()<<" doesn't have property "<<motlu<<finl;
108 Cerr<<"We expected a word in:"<<finl<<les_mots<<finl;
109 abort();
110 }
111 }
112 is >> motlu;
113 }
114 if ((C_==-1)||(A_==-1)||(Tref_==-1))
115 {
116 Cerr<<"Sutherland object "<<le_nom()<< " is incorrect"<<finl;
117 if (C_==-1)
118 Cerr<<"You must define C in "<<le_nom()<<finl;
119 if (Tref_==-1)
120 Cerr<<"You must define Tref in "<<le_nom()<<finl;
121 if (A_==-1)
122 Cerr<<"You must define A in "<<le_nom()<<finl;
123 exit();
124 }
125
127 return is;
128}
129
131{
132 // On cree une chaine correspondant a Sutherland
133 // c.a.d Champ_Fonc_fonction 1 prob temperature A * (Tref+C)/(val+C) * pow(val/Tref,1.5);
134 Nom chaine = get_prob();
135 chaine += " temperature 1 ";
136 Nom nA(A_);
137 Nom nT(Tref_);
138 Nom nC(C_);
139 chaine+=nA;
140 chaine+="*(";
141 chaine+=nT;
142 chaine+="+";
143 chaine+=nC;
144 chaine+=")/(val+";
145 chaine+=nC;
146 chaine+=")*(val/";
147 chaine+=nT;
148 chaine+=")^1.5";
149 Cerr<<"Sutherland Ok ? Champ_Fonc_Fonction "<<chaine<<finl;
150 EChaine echaine(chaine);
152 Cerr<<table().val(2)<<finl;
153}
Classe Champ_Fonc_Fonction Classe derivee de Champ_Fonc_Tabule qui represente les.
Classe Champ_Fonc_Tabule Classe derivee de Champ_Fonc_base qui represente les.
const Table & table() const
static void Warn_old_chp_fonc_syntax_V_184(const char *nom_class, const Nom &val1, const Nom &val2)
Une entree dont la source est une chaine de caracteres.
Definition EChaine.h:31
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.
const Nom & le_nom() const override
Renvoie le nom du champ.
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
static void abort()
Routine de sortie de Trio-U sur une erreur abort().
Definition Process.cpp:570
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
double val(const double val_param, int ncomp=0) const
Definition Table.cpp:145