TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Fermeture_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_Systeme_Naire.h>
17#include <Source_Con_Phase_field.h>
18#include <Param.h>
19
20Implemente_instanciable(Fermeture_Systeme_Naire, "Systeme_Naire|Nary_System", Fermeture_Phase_field_base);
21
23{
24 return os << que_suis_je() << " " << le_nom() << finl;
25}
26
28{
29 Cerr << "Reading the " << que_suis_je() << " closures ..." << finl;
31
32 Param param(que_suis_je());
33 param.ajouter("nb_constituants|nb_equation_CH", &nb_constituants_, Param::REQUIRED);
34 param.ajouter("prefacteur_a", &prefactor_, Param::REQUIRED);
35 param.ajouter("multiplicateur_de_kappa", &mult_kappa_, Param::REQUIRED);
36 param.ajouter_non_std("alpha_rotation", (this), Param::REQUIRED);
37 param.ajouter_non_std("potentiel_chimique", (this), Param::REQUIRED);
38 param.ajouter_non_std("beta", (this), Param::REQUIRED);
39 param.ajouter_non_std("kappa_auto_diffusion", (this), Param::REQUIRED);
40 param.lire_avec_accolades_depuis(is);
41
43 kappa_ind_ = 1;
44 else if (type_kappa_auto_diffusion_ == 0)
45 kappa_ind_ = 0;
46
47 return is;
48}
49
51{
52 Motcle motlu;
53 if (mot == "alpha_rotation")
54 {
55 assert(nb_constituants_ > -1);
56 is >> motlu;
57 if (motlu == "oui")
58 {
61
62 if (nb_constituants_ == 2)
63 {
64 Param param("lire_alpha_rotation");
65 param.ajouter("alpha_ref", &alpha_ref_, Param::REQUIRED);
66 param.ajouter("rotation_angle", &angle_alphaMatrix_, Param::REQUIRED);
67 param.ajouter("diagonal_coefficient", &diagonal_coeff_, Param::REQUIRED);
69
70 double coeff_mult = alpha_ref_ / (2 * pow(cos(angle_alphaMatrix_ * PI / 180.0), 2) + diagonal_coeff_ * pow(sin(angle_alphaMatrix_ * PI / 180.0), 2));
71 alphaMatrix_(0) = 2 * pow(cos(angle_alphaMatrix_ * PI / 180.0), 2) + diagonal_coeff_ * pow(sin(angle_alphaMatrix_ * PI / 180.0), 2);
72 alphaMatrix_(1) = 2 * cos(angle_alphaMatrix_ * PI / 180.0) * sin(angle_alphaMatrix_ * PI / 180.0)
73 - diagonal_coeff_ * sin(angle_alphaMatrix_ * PI / 180.0) * cos(angle_alphaMatrix_ * PI / 180.0);
75 alphaMatrix_(3) = 2 * pow(sin(angle_alphaMatrix_ * PI / 180.0), 2) + diagonal_coeff_ * pow(cos(angle_alphaMatrix_ * PI / 180.0), 2);
76 alphaMatrix_ *= coeff_mult;
77 }
78 else
79 {
80 Cerr << "alpha rotation not yet implemented for nb_equation_CH>2" << finl;
82 }
83 }
84 else if (motlu == "non")
85 {
87 is >> motlu;
88 if (motlu != "{")
89 {
90 Cerr << "Fermeture_Systeme_Naire::readOn: We are expecting { after 'non' instead of " << motlu << finl;
92 }
93 is >> motlu;
94 if (motlu == "alpha")
95 {
97 for (int i = 0; i < alphaMatrix_.size(); i++)
98 is >> alphaMatrix_(i);
99 }
100 else
101 {
102 Cerr << "Fermeture_Systeme_Naire::readOn: Error while reading alpha_rotation " << finl;
103 Cerr << motlu << " is not understood. We are expecting the keyword alpha !! " << finl;
105 }
106
107 is >> motlu;
108 if (motlu != "}")
109 {
110 Cerr << "Fermeture_Systeme_Naire::readOn: We are expecting } instead of " << motlu << finl;
112 }
113 }
114 return 1;
115 }
116 else if (mot == "potentiel_chimique")
117 {
118 assert(nb_constituants_ > -1);
119 Motcle temp_potentiel_chimique;
120 is >> temp_potentiel_chimique;
121 if (temp_potentiel_chimique == "defaut")
122 {
124 is >> motlu;
125 if (motlu != "{")
126 {
127 Cerr << "Fermeture_Systeme_Naire::readOn: We are expecting { after 'defaut' instead of " << motlu << finl;
129 }
130 is >> motlu;
131 int cpt1 = 0;
132 Motcles param_potentiel_chimique(2);
133 param_potentiel_chimique[0] = "xEq_phase1";
134 param_potentiel_chimique[1] = "xEq_phase2";
135 while (motlu != "}")
136 {
137 int rang0 = param_potentiel_chimique.search(motlu);
138 switch(rang0)
139 {
140 case 0:
141 {
142 cpt1++;
143 DoubleVect temp_equilibre_phase1(nb_constituants_); //define temp to avoid resize here
144 eq1_ = temp_equilibre_phase1;
145 for (int i = 0; i < temp_equilibre_phase1.size(); i++)
146 is >> eq1_(i);
147 break;
148 }
149 case 1:
150 {
151 cpt1++;
152 DoubleVect temp_equilibre_phase2(nb_constituants_); //define temp to avoid resize here
153 eq2_ = temp_equilibre_phase2;
154 for (int i = 0; i < temp_equilibre_phase2.size(); i++)
155 is >> eq2_(i);
156 break;
157 }
158 default:
159 {
160 Cerr << "Fermeture_Systeme_Naire::readOn: Error while reading potentiel_chimique " << finl;
161 Cerr << motlu << " is not understood." << finl;
162 Cerr << "We are expecting a keyword among " << param_potentiel_chimique << finl;
164 }
165 }
166 is >> motlu;
167 }
168 if (cpt1 != 2)
169 {
170 Cerr << "Fermeture_Systeme_Naire::readOn: Error while reading Fermeture_Systeme_Naire: wrong number of parameters" << finl;
171 Cerr << "You should specify all these parameters: " << param_potentiel_chimique << finl;
173 }
175 }
176 else if (temp_potentiel_chimique == "fonction_analytique")
177 {
179 if (nb_constituants_ == 2)
180 {
181 is >> motlu;
182 if (motlu != "{")
183 {
184 Cerr << "Fermeture_Systeme_Naire::readOn: We are expecting { after 'fonction_analytique' instead of " << motlu << finl;
186 }
187 is >> motlu;
188 int cpt1 = 0;
189 Motcles param_potentiel_analytique_ternaire(5);
190 param_potentiel_analytique_ternaire[0] = "psi";
191 param_potentiel_analytique_ternaire[1] = "xEqComp0";
192 param_potentiel_analytique_ternaire[2] = "xEqComp1";
193 param_potentiel_analytique_ternaire[3] = "aEqComp0";
194 param_potentiel_analytique_ternaire[4] = "aEqComp1";
195 while (motlu != "}")
196 {
197 int rang0 = param_potentiel_analytique_ternaire.search(motlu);
198 switch(rang0)
199 {
200 case 0:
201 {
202 cpt1++;
203 DoubleVect temp_psi(2); //define temp to avoid resize here
204 angle_psi_ = temp_psi;
205 for (int i = 0; i < 2; i++)
206 is >> angle_psi_(i);
207 break;
208 }
209 case 1:
210 {
211 cpt1++;
212 DoubleVect temp_x0Eq(2); //define temp to avoid resize here
213 x0Eq_ = temp_x0Eq;
214 for (int i = 0; i < 2; i++)
215 is >> x0Eq_(i);
216 break;
217 }
218 case 2:
219 {
220 cpt1++;
221 DoubleVect temp_x1Eq(2); //define temp to avoid resize here
222 x1Eq_ = temp_x1Eq;
223 for (int i = 0; i < 2; i++)
224 is >> x1Eq_(i);
225 break;
226 }
227 case 3:
228 {
229 cpt1++;
230 DoubleVect temp_a0Eq(2); //define temp to avoid resize here
231 a0Eq_ = temp_a0Eq;
232 for (int i = 0; i < 2; i++)
233 is >> a0Eq_(i);
234 break;
235 }
236 case 4:
237 {
238 cpt1++;
239 DoubleVect temp_a1Eq(2); //define temp to avoid resize here
240 a1Eq_ = temp_a1Eq;
241 for (int i = 0; i < 2; i++)
242 is >> a1Eq_(i);
243 break;
244 }
245 default:
246 {
247 Cerr << "Fermeture_Systeme_Naire::readOn: Error while reading potentiel_chimique " << finl;
248 Cerr << motlu << " is not understood." << finl;
249 Cerr << "We are expecting a keyword among " << param_potentiel_analytique_ternaire << finl;
251 }
252 }
253 is >> motlu;
254 }
255 if (cpt1 != 5)
256 {
257 Cerr << "Fermeture_Systeme_Naire::readOn: Error while reading Fermeture_Systeme_Naire: wrong number of parameters" << finl;
258 Cerr << "You should specify all these parameters: " << param_potentiel_analytique_ternaire << finl;
260 }
262 }
263 else if (nb_constituants_ == 3)
264 {
265 is >> motlu;
266 if (motlu != "{")
267 {
268 Cerr << "Fermeture_Systeme_Naire::readOn: We are expecting { after 'fonction_analytique' instead of " << motlu << finl;
270 }
271 is >> motlu;
272 int cpt1 = 0;
273 Motcles param_potentiel_analytique_quaternaire(8);
274 param_potentiel_analytique_quaternaire[0] = "psi";
275 param_potentiel_analytique_quaternaire[1] = "phi";
276 param_potentiel_analytique_quaternaire[2] = "xEqComp0";
277 param_potentiel_analytique_quaternaire[3] = "xEqComp1";
278 param_potentiel_analytique_quaternaire[4] = "xEqComp2";
279 param_potentiel_analytique_quaternaire[5] = "aEqComp0";
280 param_potentiel_analytique_quaternaire[6] = "aEqComp1";
281 param_potentiel_analytique_quaternaire[7] = "aEqComp2";
282
283 while (motlu != "}")
284 {
285 int rang0 = param_potentiel_analytique_quaternaire.search(motlu);
286 switch(rang0)
287 {
288 case 0:
289 {
290 cpt1++;
291 DoubleVect temp_psi(2); //define temp to avoid resize here
292 angle_psi_ = temp_psi;
293 for (int i = 0; i < 2; i++)
294 is >> angle_psi_(i);
295 break;
296 }
297 case 1:
298 {
299 cpt1++;
300 DoubleVect temp_phi(2); //define temp to avoid resize here
301 angle_phi_ = temp_phi;
302 for (int i = 0; i < 2; i++)
303 is >> angle_phi_(i);
304 break;
305 }
306 case 2:
307 {
308 cpt1++;
309 DoubleVect temp_x0Eq(2); //define temp to avoid resize here
310 x0Eq_ = temp_x0Eq;
311 for (int i = 0; i < 2; i++)
312 is >> x0Eq_(i);
313 break;
314 }
315 case 3:
316 {
317 cpt1++;
318 DoubleVect temp_x1Eq(2); //define temp to avoid resize here
319 x1Eq_ = temp_x1Eq;
320 for (int i = 0; i < 2; i++)
321 is >> x1Eq_(i);
322 break;
323 }
324 case 4:
325 {
326 cpt1++;
327 DoubleVect temp_x2Eq(2); //define temp to avoid resize here
328 x2Eq_ = temp_x2Eq;
329 for (int i = 0; i < 2; i++)
330 is >> x2Eq_(i);
331 break;
332 }
333 case 5:
334 {
335 cpt1++;
336 DoubleVect temp_a0Eq(2); //define temp to avoid resize here
337 a0Eq_ = temp_a0Eq;
338 for (int i = 0; i < 2; i++)
339 is >> a0Eq_(i);
340 break;
341 }
342 case 6:
343 {
344 cpt1++;
345 DoubleVect temp_a1Eq(2); //define temp to avoid resize here
346 a1Eq_ = temp_a1Eq;
347 for (int i = 0; i < 2; i++)
348 is >> a1Eq_(i);
349 break;
350 }
351 case 7:
352 {
353 cpt1++;
354 DoubleVect temp_a2Eq(2); //define temp to avoid resize here
355 a2Eq_ = temp_a2Eq;
356 for (int i = 0; i < 2; i++)
357 is >> a2Eq_(i);
358 break;
359 }
360 default:
361 {
362 Cerr << "Fermeture_Systeme_Naire::readOn: Error while reading potentiel_chimique " << finl;
363 Cerr << motlu << " is not understood." << finl;
364 Cerr << "We are expecting a keyword among " << param_potentiel_analytique_quaternaire << finl;
366 }
367 }
368 is >> motlu;
369 }
370 if (cpt1 != 8)
371 {
372 Cerr << "Fermeture_Systeme_Naire::readOn: Error while reading Fermeture_Systeme_Naire: wrong number of parameters" << finl;
373 Cerr << "You should specify all these parameters: " << param_potentiel_analytique_quaternaire << finl;
375 }
377 }
378 }
379 else if (temp_potentiel_chimique == "fonction")
380 {
384 }
385 else
386 {
387 Cerr << "Fermeture_Systeme_Naire::readOn: " << temp_potentiel_chimique << " is not a valid keyword in potentiel_chimique block" << finl;
389 }
390 return 1;
391 }
392 else if (mot == "beta")
393 {
394 assert(nb_constituants_ > -1);
396 for (int i = 0; i < nb_constituants_; i++)
397 is >> betaMatrix_(i);
398 return 1;
399 }
400 else if (mot == "kappa_auto_diffusion")
401 {
402 assert(nb_constituants_ > -1);
403 is >> motlu;
404 if (motlu == "oui")
405 {
407 if (nb_constituants_ == 1)
408 {
409 is >> motlu;
410 if (motlu != "{")
411 {
412 Cerr << "Fermeture_Systeme_Naire::readOn: We are expecting { after 'oui' instead of " << motlu << finl;
413 exit();
414 }
415 is >> motlu;
416 while (motlu != "}")
417 {
418 if (motlu == "kappa")
419 is >> kappa_;
420 else if (motlu == "fonction")
421 {
422 kappa_forme_expr_.lire_f(is, 1);
424 }
425 else
426 Process::exit("Problem in kappa_auto_diffusion readOn : Only kappa & fonction keywords are known !");
427 is >> motlu;
428 }
429 }
430 else
431 {
432 is >> motlu;
433 if (motlu != "{")
434 {
435 Cerr << "Fermeture_Systeme_Naire::readOn: We are expecting { after 'oui' instead of " << motlu << finl;
436 exit();
437 }
438 is >> motlu;
439 int cpt1 = 0;
440 Motcles param_mobilite(3);
441 param_mobilite[0] = "coefficient_auto_diffusion";
442 param_mobilite[1] = "temperature";
443 param_mobilite[2] = "volume_molaire";
444 while (motlu != "}")
445 {
446 int rang0 = param_mobilite.search(motlu);
447 switch(rang0)
448 {
449 case 0:
450 {
451 cpt1++;
453 for (int i = 0; i < coeff_auto_diffusion_.size(); i++)
454 is >> coeff_auto_diffusion_(i);
455 break;
456 }
457 case 1:
458 {
459 cpt1++;
460 is >> temperature_; //temperature en Kelvin
461 break;
462 }
463 case 2:
464 {
465 cpt1++;
466 is >> molarVolume_;
467 break;
468 }
469 default:
470 {
471 Cerr << "Fermeture_Systeme_Naire::readOn: Error while reading kappa_auto_diffusion " << finl;
472 Cerr << motlu << " is not understood." << finl;
473 Cerr << "We are expecting a keyword among " << param_mobilite << finl;
474 exit();
475 }
476
477 }
478 is >> motlu;
479 }
480 if (cpt1 != 3)
481 {
482 Cerr << "Fermeture_Systeme_Naire::readOn: Error while reading Fermeture_Systeme_Naire: wrong number of parameters" << finl;
483 Cerr << "You should specify all these parameters: " << param_mobilite << finl;
484 exit();
485 }
487 }
488
489 }
490 else if (motlu == "non")
491 {
493 is >> motlu;
494 if (motlu != "{")
495 {
496 Cerr << "Fermeture_Systeme_Naire::readOn: We are expecting { after 'non' instead of " << motlu << finl;
498 }
499 is >> motlu;
500 while (motlu != "}")
501 {
502 if (motlu == "kappa")
503 {
505 for (int i = 0; i < kappaMatrix_.size(); i++)
506 is >> kappaMatrix_(i);
507 }
508 else
509 {
510 Cerr << "Fermeture_Systeme_Naire::readOn: Error while reading kappa_auto_diffusion " << finl;
511 Cerr << motlu << " is not understood. We are expecting the keyword kappa !!" << finl;
513 }
514 is >> motlu;
515 }
516 }
517 else if (motlu == "defaut")
518 {
520
521 if (nb_constituants_ == 1)
522 {
523 is >> motlu;
524 if (motlu != "{")
525 {
526 Cerr << "Fermeture_Systeme_Naire::readOn: We are expecting { after 'defaut' instead of " << motlu << finl;
527 exit();
528 }
529 is >> motlu;
530 while (motlu != "}")
531 {
532 if (motlu == "kappa")
533 is >> kappa_;
534 else
535 {
536 Cerr << "Fermeture_Systeme_Naire::readOn: Error while reading defaut option. " << finl;
537 Cerr << motlu << " is not understood. We are expecting the keyword kappa !!" << finl;
539 }
540 is >> motlu;
541 }
542 }
544 }
545 return 1;
546 }
547 return -1;
548}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
DoubleTab dWdc_naire_general(const DoubleTab &) const
DoubleTab dWdc_naire_defaut(const DoubleTab &) const
DoubleTab kappa_func_c_naire_defaut(const DoubleTab &) const
DoubleTab(Fermeture_Phase_field_base::* kappa_func_c_naire)(const DoubleTab &) const
DoubleTab dWdc_naire_analytique_quaternaire(const DoubleTab &) const
DoubleTab(Fermeture_Phase_field_base::* dWdc_naire)(const DoubleTab &) const
DoubleTab kappa_func_c_naire_general(const DoubleTab &) const
DoubleTab dWdc_naire_analytique_ternaire(const DoubleTab &) const
DoubleTab kappa_func_auto_diffusion(const DoubleTab &) const
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.
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 const Nom & le_nom() const
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Objet_U.cpp:319
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
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
_SIZE_ size() const
Definition TRUSTVect.tpp:45