TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Fermeture_Thermo_Systeme_Naire.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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 <Fermeture_Thermo_Systeme_Naire.h>
17
18#include <Param.h>
19#include <Table.h>
20#include <Fermeture_Thermo_base.h>
21
22Implemente_instanciable(Fermeture_Thermo_Systeme_Naire, "Fermeture_Thermo_Systeme_Naire|Thermo_Closure_Nary_System", Fermeture_Thermo_base);
23
25{
26 os << que_suis_je() << finl;
27 os << "Number of order parameters = " << nb_parametres_d_ordre_ << finl;
28 os << "Mobility factor = " << mult_mobilite_ << finl;
29 os << "Kappa has rotation: " << type_kappa_rotation_ << " (0=no, 1=yes)" << finl;
30 os << "Kappa = " << kappa_i_ << finl;
31 os << "Mobility auto diffusion: " << type_mobilite_auto_diffusion_ << " (0=no, 1=yes)" << finl;
32 os << "Mobility = " << mob_i_ << finl;
33 os << "Beta = " << beta_ << finl;
34 os << "Potential = " << mu_ << finl;
35
36 return os;
37}
38
40{
41 Cerr << "Reading the " << que_suis_je() << " closures ..." << finl;
42
43 Param param(que_suis_je());
44 set_param(param);
45
46 param.lire_avec_accolades_depuis(is);
47
48 return is;
49}
50
52{
53 param.ajouter("nb_parametres|nb_equations", &nb_parametres_d_ordre_, Param::REQUIRED);
54 param.ajouter("multiplicateur_de_mobilite", &mult_mobilite_, Param::REQUIRED);
55 param.ajouter_non_std("kappa_rotation", (this), Param::REQUIRED);
56 param.ajouter_non_std("mobilite_auto_diffusion", (this), Param::REQUIRED);
57 param.ajouter_non_std("potentiel_chimique", (this), Param::REQUIRED);
58 param.ajouter_non_std("beta", (this), Param::REQUIRED);
59}
60
62{
63 Motcle motlu;
65 {
66 Process::exit("Fermeture_Thermo_Systeme_Naire: nb_parametres|nb_equations must be read before any other keyword");
67 }
68 // KAPPA --------------------------------------------------------------------------------------------
69 if (mot == "kappa_rotation")
70 {
71 Cerr << "1) Reading kappa_rotation " << finl;
72
73 assert(nb_parametres_d_ordre_ > -1);
74 is >> motlu;
75 if (motlu == "oui")
76 {
79
81 {
82 Param param("lire_kappa_rotation");
83 param.ajouter("kappa_ref", &kappa_ref_, Param::REQUIRED);
84 param.ajouter("rotation_angle", &angle_kappa_, Param::REQUIRED);
85 param.ajouter("diagonal_coefficient", &diagonal_coeff_, Param::REQUIRED);
87 using Kokkos::numbers::pi;
88 constexpr auto pi_s_180 = pi / 180.;
89 const double cos_kappa = cos(angle_kappa_ * pi_s_180);
90 const double sin_kappa = sin(angle_kappa_ * pi_s_180);
91 double coeff_mult = kappa_ref_ / (2 * pow(cos_kappa, 2) + diagonal_coeff_ * pow(sin_kappa, 2));
92 kappa_i_(0) = 2 * pow(cos_kappa, 2) + diagonal_coeff_ * pow(sin_kappa, 2);
93 kappa_i_(1) = 2 * cos_kappa * sin_kappa
94 - diagonal_coeff_ * sin_kappa * cos_kappa;
95 kappa_i_(2) = kappa_i_(1);
96 kappa_i_(3) = 2 * pow(sin_kappa, 2) + diagonal_coeff_ * pow(cos_kappa, 2);
97 kappa_i_ *= coeff_mult;
98 }
99 else
100 {
101 Cerr << "kappa rotation not yet implemented for nb_phases /= 2" << finl;
103 }
104 }
105 else if (motlu == "non")
106 {
108 is >> motlu;
109 if (motlu != "{")
110 {
111 Cerr << "Fermeture_Thermo_Systeme_Naire::readOn: We are expecting { after 'non' instead of " << motlu << finl;
113 }
114 is >> motlu;
115 if (motlu == "kappa")
116 {
118 for (int i = 0; i < kappa_i_.size(); i++)
119 is >> kappa_i_(i);
120 }
121 else
122 {
123 Cerr << "Fermeture_Thermo_Systeme_Naire::readOn: Error while reading kappa_rotation " << finl;
124 Cerr << motlu << " is not understood. We are expecting the keyword kappa !! " << finl;
126 }
127
128 is >> motlu;
129 if (motlu != "}")
130 {
131 Cerr << "Fermeture_Thermo_Systeme_Naire::readOn: We are expecting } instead of " << motlu << finl;
133 }
134 }
135 return 1;
136 }
137 // MOBILITE -----------------------------------------------------------------------------------------
138 else if (mot == "mobilite_auto_diffusion")
139 {
140 Cerr << "2) Reading mobilite_auto_diffusion " << finl;
141
142 assert(nb_parametres_d_ordre_ > -1);
144 is >> motlu;
145 Cout << "Auto diffusion ? " << motlu << finl;
146 // Avec auto-diffusion
147 if (motlu == "oui")
148 {
150 // Cas binaire
151 if (nb_parametres_d_ordre_ == 1)
152 {
153 is >> motlu;
154 if (motlu != "{")
155 {
156 Cerr << "Fermeture_Thermo_Systeme_Naire::readOn: We are expecting { after 'oui' instead of " << motlu << finl;
157 exit();
158 }
159 is >> motlu;
160 while (motlu != "}")
161 {
162 if (motlu == "mobilite")
163 is >> mob_i_;
164 else if (motlu == "fonction")
165 {
166 mobilite_forme_expr_.lire_f(is, 1);
168 mob_i_ = 0;
169 }
170 else
171 Process::exit("Problem in mobilite_auto_diffusion readOn : Only mobilite & fonction keywords are known !");
172 is >> motlu;
173 }
174 }
175 // Cas n-aire
176 else
177 {
178 is >> motlu;
179 if (motlu != "{")
180 {
181 Cerr << "Fermeture_Thermo_Systeme_Naire::readOn: We are expecting { after 'oui' instead of " << motlu << finl;
182 exit();
183 }
184 mob_i_ = 0;
185 is >> motlu;
186 int cpt1 = 0;
187 Motcles param_mobilite(3);
188 param_mobilite[0] = "coefficient_auto_diffusion";
189 param_mobilite[1] = "temperature";
190 param_mobilite[2] = "volume_molaire";
191 while (motlu != "}")
192 {
193 int rang0 = param_mobilite.search(motlu);
194 switch(rang0)
195 {
196 case 0:
197 {
198 cpt1++;
200 for (int i = 0; i < coeff_auto_diffusion_.size(); i++)
201 is >> coeff_auto_diffusion_(i);
202 break;
203 }
204 case 1:
205 {
206 cpt1++;
207 is >> temperature_; //temperature en Kelvin
208 break;
209 }
210 case 2:
211 {
212 cpt1++;
213 is >> molarVolume_;
214 break;
215 }
216 default:
217 {
218 Cerr << "Fermeture_Thermo_Systeme_Naire::readOn: Error while reading mobilite_auto_diffusion " << finl;
219 Cerr << motlu << " is not understood." << finl;
220 Cerr << "We are expecting a keyword among " << param_mobilite << finl;
221 exit();
222 }
223
224 }
225 is >> motlu;
226 }
227 if (cpt1 != 3)
228 {
229 Cerr << "Fermeture_Thermo_Systeme_Naire::readOn: Error while reading Fermeture_Thermo_Systeme_Naire: wrong number of parameters" << finl;
230 Cerr << "You should specify all these parameters: " << param_mobilite << finl;
231 exit();
232 }
234 }
235
236 }
237 // Pas d'auto-diffusion : mobilité constante
238 else if (motlu == "non")
239 {
241 is >> motlu;
242 if (motlu != "{")
243 {
244 Cerr << "Fermeture_Thermo_Systeme_Naire::readOn: We are expecting { after 'non' instead of " << motlu << finl;
246 }
247 is >> motlu;
248 while (motlu != "}")
249 {
250 if (motlu == "mobilite")
251 {
252 for (int i = 0; i < mob_i_.size(); i++)
253 is >> mob_i_(i);
254 }
255 else
256 {
257 Cerr << "Fermeture_Thermo_Systeme_Naire::readOn: Error while reading mobilite_auto_diffusion " << finl;
258 Cerr << motlu << " is not understood. We are expecting the keyword mobilite !!" << finl;
260 }
261 is >> motlu;
262 }
264 }
265 // Mobilité par défaut : cas binaire c(1-c)
266 else if (motlu == "defaut")
267 {
269
270 Cout << "Default case..." << finl;
271 is >> motlu;
272 Cout << "Word: " << motlu << finl;
273 if (motlu != "{")
274 {
275 Cerr << "Fermeture_Thermo_Systeme_Naire::readOn: We are expecting { after 'defaut' instead of " << motlu << finl;
276 exit();
277 }
278 is >> motlu;
279 Cout << "Second word: " << motlu << finl;
280 while (motlu != "}")
281 {
282 Cout << "In the loop: " << motlu << finl;
283 if (motlu == "mobilite")
284 {
285 for (int i = 0; i < mob_i_.size(); i++)
286 is >> mob_i_(i);
287 Cout << "We have read 'mobilite', then it is the value of mobility : " << mob_i_ << finl;
288 }
289 else
290 {
291 Cerr << "Fermeture_Thermo_Systeme_Naire::readOn: Error while reading defaut option. " << finl;
292 Cerr << motlu << " is not understood. We are expecting the keyword mobilite !!" << finl;
294 }
295 is >> motlu;
296 Cout << "Another word after: " << motlu << finl;
297 }
299 }
300 return 1;
301 }
302 else if (mot == "potentiel_chimique")
303 {
304 Cerr << "3) Reading potentiel_chimique " << finl;
305
306 assert(nb_parametres_d_ordre_ > -1);
307 // IMPORTANT : Il faut absolument initialiser le nombre de parametres d'ordre
308 Cerr << "Nombre de paramètres d'ordre lu = " << nb_parametres_d_ordre_<< finl;
309 is >> mu_;
310 mu_->check_compatibility(nb_parametres_d_ordre_);
311 return 1;
312 }
313 else if (mot == "beta")
314 {
315 Cerr << "4) Reading beta" << finl;
316
317 assert(nb_parametres_d_ordre_ > -1);
319 for (int i = 0; i < nb_parametres_d_ordre_; i++)
320 is >> beta_(i);
321 return 1;
322 }
323 else
324 {
325 Cerr << "Fermeture_Thermo_Systeme_Naire::readOn -- Problem while reading parameters..." << finl;
326 exit();
327 return 1;
328 }
329
330}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Fermeture_Thermo_Systeme_Naire
int lire_motcle_non_standard(const Motcle &, Entree &) override
Lecture des parametres de type non simple d'un objet_U a partir d'un flot d'entree.
classe Fermeture_Thermo_base
DoubleTab mobilite_func_auto_diffusion(const DoubleTab &) const
DoubleTab mobilite_func_c_defaut(const DoubleTab &) const
DoubleTab mobilite_func_c_cst(const DoubleTab &) const
DoubleTab(Fermeture_Thermo_base::* mobilite_func_c)(const DoubleTab &) const
DoubleTab mobilite_func_c_general(const DoubleTab &) const
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
Un tableau d'objets de la classe Motcle.
Definition Motcle.h:63
int search(const Motcle &t) const
Definition Motcle.cpp:321
friend class Entree
Definition Objet_U.h:76
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
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
@ REQUIRED
Definition Param.h:115
void ajouter_non_std(const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
Register a keyword handled by Objet_U::lire_motcle_non_standard.
Definition Param.cpp:489
int lire_avec_accolades_depuis(Entree &is)
Parse the parameter block { ... } from is.
Definition Param.cpp:32
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