TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Probleme_base.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 <Discretisation_base.h>
17#include <Domaine_Cl_dis_base.h>
18#include <Loi_Fermeture_base.h>
19#include <Domaine_dis_base.h>
20#include <Probleme_base.h>
21#include <Synonyme_info.h>
22#include <Postraitement.h>
23#include <Perf_counters.h>
24#include <EChaine.h>
25#include <Perf_counters.h>
26#include <Debog.h>
27
28Implemente_base_sans_destructeur(Probleme_base,"Probleme_base",Probleme_U);
29
30// XD pb_gen_base objet_u pb_gen_base INHERITS_BRACE Basic class for problems.
31
32// XD Pb_base pb_gen_base Pb_base BRACE Resolution of equations on a domain. A problem is defined by creating an object
33// XD_CONT and assigning the problem type that the user wishes to resolve. To enter values for the problem objects
34// XD_CONT created, the Lire (Read) interpretor is used with a data block.
35// XD attr milieu milieu_base milieu OPT The medium associated with the problem.
36// XD attr constituant constituant constituant OPT Constituent.
37// XD attr postraitement|Post_processing corps_postraitement postraitement OPT One post-processing (without name).
38// XD attr postraitements|Post_processings postraitements postraitements OPT List of Postraitement objects (with name).
39// XD attr liste_de_postraitements liste_post_ok liste_de_postraitements OPT This
40// XD attr liste_postraitements liste_post liste_postraitements OPT This block defines the output files to be written
41// XD_CONT during the computation. The output format is lata in order to use OpenDX to draw the results. This block can
42// XD_CONT be divided in one or several sub-blocks that can be written at different frequencies and in different
43// XD_CONT directories. Attention. The directory lata used in this example should be created before running the
44// XD_CONT computation or the lata files will be lost.
45// XD attr sauvegarde format_file_base sauvegarde OPT Keyword used when calculation results are to be backed up. When a
46// XD_CONT coupling is performed, the backup-recovery file name must be well specified for each problem. In this case,
47// XD_CONT you must save to different files and correctly specify these files when resuming the calculation.
48// XD attr sauvegarde_simple format_file_base sauvegarde_simple OPT The same keyword than Sauvegarde except, the last
49// XD_CONT time step only is saved.
50// XD attr reprise format_file_base reprise OPT Keyword to resume a calculation based on the name_file file (see the
51// XD_CONT class format_file). If format_reprise is xyz, the name_file file should be the .xyz file created by the
52// XD_CONT previous calculation. With this file, it is possible to resume a parallel calculation on P processors,
53// XD_CONT whereas the previous calculation has been run on N (N<>P) processors. Should the calculation be resumed,
54// XD_CONT values for the tinit (see schema_temps_base) time fields are taken from the name_file file. If there is no
55// XD_CONT backup corresponding to this time in the name_file, TRUST exits in error.
56// XD attr resume_last_time format_file_base resume_last_time OPT Keyword to resume a calculation based on the name_file
57// XD_CONT file, resume the calculation at the last time found in the file (tinit is set to last time of saved files).
58// XD attr transparent_medium_radiation_model transparent_medium_radiation_model modele_rayonnement_milieu_transparent OPT Read a transparent medium radiation model associated to a fluid problem
59
60// XD ref domaine domaine
61// XD ref scheme schema_temps_base
62// XD ref loi1 loi_fermeture_base
63// XD ref loi2 loi_fermeture_base
64// XD ref loi3 loi_fermeture_base
65// XD ref loi4 loi_fermeture_base
66// XD ref loi5 loi_fermeture_base
67
68// XD problem_read_generic Pb_base problem_read_generic INHERITS_BRACE The probleme_read_generic differs rom the rest of
69// XD_CONT the TRUST code : The problem does not state the number of equations that are enclosed in the problem. As the
70// XD_CONT list of equations to be solved in the generic read problem is declared in the data file and not pre-defined
71// XD_CONT in the structure of the problem, each equation has to be distinctively associated with the problem with the
72// XD_CONT Associate keyword.
73// XD ref eqn1 eqn_base
74// XD ref eqn2 eqn_base
75// XD ref eqn3 eqn_base
76// XD ref eqn4 eqn_base
77// XD ref eqn5 eqn_base
78// XD ref eqn6 eqn_base
79// XD ref eqn7 eqn_base
80// XD ref eqn8 eqn_base
81// XD ref eqn9 eqn_base
82// XD ref eqn10 eqn_base
83
84
85// XD constituant milieu_base constituant INHERITS_BRACE Constituent.
86// XD attr coefficient_diffusion field_base coefficient_diffusion REQ Constituent diffusion coefficient value (m2.s-1).
87// XD_CONT If a multi-constituent problem is being processed, the diffusivite will be a vectorial and each components
88// XD_CONT will be the diffusion of the constituent.
89// XD attr is_multi_scalar rien is_multi_scalar_diffusion OPT Flag to activate the multi_scalar diffusion operator
90
91// XD format_file_base objet_lecture nul NO_BRACE Format of the file
92// XD attr checkpoint_fname chaine checkpoint_fname REQ Name of file.
93
94// XD binaire format_file_base binaire INHERITS_BRACE Format of the file - binary version
95// XD formatte format_file_base formatte INHERITS_BRACE Format of the file - formatte version
96// XD xyz format_file_base xyz INHERITS_BRACE Format of the file - xyz version
97// XD single_hdf format_file_base single_hdf INHERITS_BRACE Format of the file - single_hdf version
98// XD pdi format_file_base pdi INHERITS_BRACE Format of the file - pdi version
99
100// XD pdi_expert format_file_base pdi_expert BRACE Format of the file - PDI expert version
101// XD attr yaml_fname chaine yaml_fname REQ YAML file name
102
103// Global variables to initialize est_le_premier_postraitement_pour_nom_fic
104// and est_le_dernier_postraitement_pour_nom_fic in a single pass.
105LIST(Nom) glob_noms_fichiers;
106LIST(OBS_PTR(Postraitement)) glob_derniers_posts;
107
109{
110 for (int i = 0; i < nombre_d_equations(); i++)
111 os << equation(i).que_suis_je() << " " << equation(i) << finl;
113 os << le_domaine_dis_.valeur();
114 return os;
115}
116
117/*! @brief Reading of a problem in an input stream, and opening of the save stream.
118 *
119 * Format:
120 * {
121 * medium_name block to read a medium
122 * equation_name block to read an equation
123 * Postraitement block to read postraitement
124 * reprise | sauvegarde | sauvegarde_simple
125 * formatte | binaire | pdi
126 * file_name
127 * }
128 * The sauvegarde_simple option allows saving the problem in the chosen file
129 * by overwriting each time the previous saves : this allows saving disk space.
130 *
131 * @param (Entree& is) input stream
132 * @return (Entree&) the modified input stream
133 * @throws no opening brace at the beginning of the format
134 * @throws keyword "Postraitement" is not there
135 * @throws save format must be "binary" or "formatted"
136 * @throws no closing brace at the end of the data file
137 */
139{
140 Cerr << "Reading of the problem " << le_nom() << finl;
141 Motcle motlu;
142 is >> motlu;
143 if (motlu != "{")
144 Process::exit("We expected { to start to read the problem !!! \n");
145
146 /* 1 : solved_equations + milieu : NEW SYNTAX */
149
150 /* 2 : We read the equations */
151 lire_equations(is, motlu); //"motlu" contains the first word after reading the equations
152
153 /* 3 : Post-processing */
154 // If the postraitement contains the word, we read another one...
155 while (les_postraitements_.lire_postraitements(is, motlu, *this))
156 {
157 is >> motlu;
158 }
159
160 /* 4 : We complete ... */
161 completer();
162 Cerr << "Step verification of data being read in progress..." << finl;
163
164 /* 5 : We verify ... */
165 verifier();
166 Cerr << "The read data are coherent" << finl;
167
168 /* 6 : save/restart management ... */
169 save_restart_.lire_sauvegarde_reprise(is, motlu);
170
171 return is ;
172}
173
175{
176 // NOTA BENE :
177 // Normally we have one medium per problem, except if the problem contains a concentration equation
178 // In that case, we have an additional medium : constituent (don't ask why 2 media ... because I don't know !). to see if we can do better ...
179 int nb_milieu = 1;
180
181 // We search if it's a problem with concentration => with constituent
182 const std::string conc = "Concentration", scal_pass = "Scalaires_Passifs", nom_pb = que_suis_je().getString();
183 if (nom_pb.find(conc) != std::string::npos) nb_milieu = 2; // problem contains concentration !
184
185 le_milieu_.resize(nb_milieu);
186
187 for (int i = 0; i < nb_milieu; i++)
188 {
189 le_milieu_[i].typer_lire_simple(is, "Typing the medium ..."); // We start with reading the medium
190 associer_milieu_base(le_milieu_[i].valeur()); // We associate it with each equation (virtual method for each problem ...)
191 }
192
193 // Medium(s) read ... Lets go ! We discretize the equations
195
196 // uplifting of the unknown to the medium
197 for (int i = 0; i < nombre_d_equations(); i++) equation(i).associer_milieu_equation();
198
199 const bool is_constituant = nb_milieu == 1 ? false : true, is_scal_pass = (nom_pb.find(scal_pass) != std::string::npos) ? true : false;
200 const int ns_ou_cond_eq = 0;
201 int conc_eq = 1; // not const !
202
203 // We discretize the medium/media ... And the concentration equation !
204 if (is_constituant)
205 {
206 assert (nombre_d_equations() > 1);
207 if (nombre_d_equations() == 2)
208 for (int i = 0; i < nombre_d_equations(); i++) equation(i).milieu().discretiser((*this), la_discretisation_.valeur());
209 else if (nombre_d_equations() == 3)
210 {
211 // We have 2 Cases :
212 // - Pb_Thermohydraulique_Concentration (NS, Thermal, Conc)
213 // - Pb_Hydraulique_Concentration_Scalaires_Passifs (NS, Conc + Equations_Scalaires_Passifs (the list) !)
214 conc_eq = is_scal_pass ? 1 /* conc_eq */ : 2;
215 equation(ns_ou_cond_eq).milieu().discretiser((*this), la_discretisation_.valeur()); // NS
216 equation(conc_eq).milieu().discretiser((*this), la_discretisation_.valeur()); // Conc
217 }
218 else
219 {
220 // Rare case : Pb_Thermohydraulique_Concentration_Scalaires_Passifs
221 // Here we have NS, Thermal, Conc + Equations_Scalaires_Passifs (the list) !
222 assert (nombre_d_equations() == 4);
223 conc_eq = 2;
224 equation(ns_ou_cond_eq).milieu().discretiser((*this), la_discretisation_.valeur()); // NS
225 equation(conc_eq).milieu().discretiser((*this), la_discretisation_.valeur()); // Conc
226 }
227 }
228 else /* We discretize the medium of eq 1 and that's all :-) :-) */
229 equation(ns_ou_cond_eq).milieu().discretiser((*this), la_discretisation_.valeur());
230}
231
232/*! @brief Reading of the equations of the problem.
233 *
234 */
236{
237 const int nb_eq = nombre_d_equations();
238 is >> mot;
239 if (nb_eq == 0)
240 return is;
241
242 bool already_read = true;
243
244 if (mot == "correlations")
245 {
246 Cerr << "Reading of the correlations ..." << finl;
248 already_read = false;
249 }
250
251 if (mot == "Modele_rayonnement_milieu_transparent" || mot == "Transparent_medium_radiation_model")
252 {
253 Cerr << "Reading of the radiation model ..." << finl;
254 lire_radiation_models(is, mot);
255 already_read = false;
256 }
257
258 Cerr << "Reading of the equations ..." << finl;
259
260 for (int i = 0; i < nb_eq; i++)
261 {
262 if (!already_read)
263 is >> mot;
264
265 is >> getset_equation_by_name(mot);
266 already_read = false;
267 }
268
270
271 return is;
272}
273
275{
276 Cerr << "The use of a transparent radiation model is not authorized for your problem " << que_suis_je() << " !!!" << finl;
277 Cerr << "This model should only be used with a fluid problem. Update your data file." << finl;
279 return is;
280}
281
282/*! @brief Associates the problem with all its equations.
283 *
284 */
286{
287 save_restart_.assoscier_pb_base(*this);
288
289 for (int i = 0; i < nombre_d_equations(); i++)
290 equation(i).associer_pb_base(*this);
291}
292
293/*! @brief override Objet_U::associer_(Objet_U& ob) Associates different objects with the problem by checking
294 *
295 * the type of the object to be associated at execution.
296 * We can thus associate: a time scheme, a calculation domain.
297 * Uses the routine of the Type_Info class (Utilities)
298 *
299 * @param (Objet_U& ob) the object to associate
300 * @return (int) 1 if association succeeded 0 otherwise 2 if the medium is already associated with another problem
301 * @throws Unknown Objet_U type (not provided)
302 */
304{
305 if (sub_type(Schema_Temps_base, ob))
306 {
308 return 1;
309 }
310 if (sub_type(Domaine, ob))
311 {
312 associer_domaine(ref_cast(Domaine, ob));
313 return 1;
314 }
315 if (sub_type(Loi_Fermeture_base,ob))
316 {
317 Loi_Fermeture_base& loi=ref_cast(Loi_Fermeture_base,ob);
318 liste_loi_fermeture_.add(loi);
319 loi.associer_pb_base(*this);
320 return 1;
321 }
322 if (sub_type(Domaine_32_64<trustIdType>, ob))
323 {
324 Cerr << "ERROR: You are trying to associate a 64-bit Domain to a Problem!" << finl;
325 Cerr <<" -> Keyword 'Domain_64' can *not* be used for a sequential run!" << finl;
326 Cerr<< " -> Keyword 'Domain_64' can only be used for initial partitioning. It must be changed into 'Domain' in the PAR_xxx dataset when running the parallel computation itself!" << finl;
328 }
329 if (sub_type(Milieu_base, ob))
330 {
331 Cerr << "YOU ARE USING AN OLD SYNTAX IN YOUR DATA FILE AND THIS IS NO MORE SUPPORTED !" << finl;
332 Cerr << "STARTING FROM TRUST-v1.9.3 : THE MEDIUM SHOULD BE READ INSIDE THE PROBLEM AND NOT VIA ASSOSCIATION ... " << finl;
333 Cerr << "HAVE A LOOK TO ANY TRUST TEST CASE TO SEE HOW IT SHOULD BE DONE ($TRUST_ROOT/tests/) ... " << finl;
334 Cerr << "OR RUN -convert_data OPTION OF YOUR APPLICATION SCRIPT, FOR TRUST FOR EXAMPLE:" << finl;
335 Cerr << " trust -convert_data " << Objet_U::nom_du_cas() << ".data" << finl;
337 }
338 return 0;
339}
340
341/*! @brief Completes the equations associated with the problem.
342 *
343 * Filling of references, delegated to the equations.
344 *
345 */
347{
348 // Cerr << "Probleme_base::completer()" << finl;
349 for (int i = 0; i < nombre_d_equations(); i++)
350 equation(i).completer();
351
352 for (auto& itr : liste_loi_fermeture_)
353 itr->completer();
354
355 les_postraitements_.completer();
356
357 for (auto &corr : correlations_)
358 corr.second->completer();
359}
360
361/*! @brief Verifies that the object is complete, coherent, .
362 *
363 * .. NOT DEVELOPED ALWAYS RETURNS 1
364 *
365 * @return (int) 1 if the object is correct
366 */
368{
369 return 1;
370}
371
372/*! @brief Associates a domain with the problem.
373 *
374 * Takes un_domaine as support.
375 * calls Domaine_dis::associer_dom(const Domaine& )
376 *
377 * @param (Domaine& un_domaine) the domain
378 */
379void Probleme_base::associer_domaine(const Domaine& un_domaine)
380{
381 le_domaine_ = un_domaine;
382 statistics().record_nb_elem(un_domaine.nb_elem());
383}
384
386{
387 Cerr << "Discretization of the equations of problem " << que_suis_je() << " ..." << finl;
388 for (int i = 0; i < nombre_d_equations(); i++)
389 {
392 }
393}
394
395/*! @brief Assigns a discretization to the problem Discretizes the Domain associated with the problem with the discretization
396 *
397 * Associates the first Domain with the problem's equations
398 * Discretizes the equations associated with the problem
399 *
400 * @param (Discretisation_base& discretisation) a discretization for the problem
401 */
403{
404 associer();
405 la_discretisation_ = une_discretisation;
406 Cerr << "Discretization of the domain associated with the problem " << le_nom() << finl;
407
408 if (!le_domaine_)
409 Process::exit("ERROR: Discretize - You're trying to discretize a problem without having associated a Domain to it!!! Fix your dataset.");
410
411 // Initialization of the renum_som_perio array
412 le_domaine_->init_renum_perio();
413
414 une_discretisation.associer_domaine(le_domaine_.valeur());
415 le_domaine_dis_ = une_discretisation.discretiser();
416 // Can not do this before, since the Domaine_dis is not typed yet:
417 le_domaine_dis_->associer_domaine(le_domaine_);
418
419 for (auto& itr : liste_loi_fermeture_)
420 itr->discretiser(une_discretisation);
421}
422
423/*! @brief Flags the first and last post-processing for each file And initializes the post-processing
424 *
425 */
427{
428 for (auto& itr : les_postraitements_) // For each post-processing
429 {
430 OWN_PTR(Postraitement_base) &der_post = itr;
431
432 // If it is of type Postraitement, initialize premier/dernier _pour_nom_fich
433 if (sub_type(Postraitement, der_post.valeur()))
434 {
435
436 Postraitement& post = ref_cast(Postraitement, der_post.valeur());
437
438 Nom nom_fichier = Sortie_Fichier_base::root;
439 nom_fichier+=post.nom_fich();
440 int rg = glob_noms_fichiers.rang(nom_fichier);
441 if (rg == -1) // This is the first time we encounter this name
442 {
443 glob_noms_fichiers.add(nom_fichier);
444 glob_derniers_posts.add(post);
446 }
447 else // We have already seen this name
448 {
450 Postraitement& autre_post = glob_derniers_posts[rg];
452 glob_derniers_posts[rg] = post;
453
454 // Verify that the post-processing intervals are the same
455 // for everything writing to the same file.
456 if (post.champs_demande() && autre_post.dt_post() != post.dt_post())
457 {
458 Cerr << "Error, the values of dt_post (" << autre_post.dt_post() << " and " << post.dt_post() << ") of two postprocessing blocks writing in the same file" << nom_fichier
459 << " are different!" << finl;
460 Cerr << "Specify the same dt_post, or use two different files for postprocessing." << finl;
461 Cerr << "INFO: For Probleme_couple, if you do not specify different filenames, postpros in subproblems must also have the same dt_post." << finl;
462 exit();
463 }
464 }
466 }
467 }
468 les_postraitements_.init();
469}
470
471int Probleme_base::expression_predefini(const Motcle& motlu, Nom& expression)
472{
473 expression = "";
474 return 0;
475}
476
477/*! @brief Writing of the problem to file for restart.
478 *
479 * Writes the name of the problem and saves the equations.
480 *
481 * @param (Sortie& os) output stream for backup
482 * @return (int) always returns 1
483 */
485{
488 Cerr << "Backup of problem " << le_nom() << finl;
489 int bytes=0;
490 for(int i=0; i<nombre_d_equations(); i++)
491 {
492 bytes += equation(i).sauvegarder(os);
493 assert(bytes % 4 == 0);
494 }
495 bytes += domaine().save_additional_state(os, *this); // save additional state (e.g. moving mesh data)
496 bytes += les_postraitements_.sauvegarder(os);
497 assert(bytes % 4 == 0); // To detect a sauvegarder() method which returns 1 instead of the number of bytes saved.
498 return bytes;
499}
500
501/*! @brief Reading of an input stream (file) for restart after a backup with Probleme_base::sauvegarder(Sortie& os).
502 *
503 * @param (Entree& is) the input stream from which we read the restart
504 * @return (int) always returns 1
505 */
507{
508 statistics().begin_count(STD_COUNTERS::restart,statistics().get_last_opened_counter_level()+1);
511 Cerr << "Resuming the problem " << le_nom() << finl;
512 for(int i=0; i<nombre_d_equations(); i++)
513 equation(i).reprendre(is);
514 domaine().restore_additional_state(is, *this); //restore additional state (e.g. moving mesh data)
515 les_postraitements_.reprendre(is);
516 Cerr << "End of resuming the problem " << le_nom() << " after " << statistics().get_time_since_last_open(STD_COUNTERS::restart) << " s" << finl;
517 statistics().end_count(STD_COUNTERS::restart);
518 return 1;
519}
520
521/*! @brief Asks the time scheme if a print is needed
522 *
523 * @return (int) 1 a print is needed, 0 it's not.
524 */
526{
527 return schema_temps().limpr();
528}
529
530/*! @brief Asks the time scheme if a backup is needed
531 *
532 * @return (int) 1 a backup is needed, 0 it's not.
533 */
535{
536 return schema_temps().lsauv();
537}
538
539/*! @brief Prints the equations associated with the problem if the associated time scheme indicates that it is necessary.
540 *
541 * @param (Sortie& os) output stream
542 */
544{
545 for(int i=0; i<nombre_d_equations(); i++)
546 equation(i).imprimer(os);
547}
548
549/*! @brief Associates a time scheme with the problem.
550 *
551 * Then associates the time scheme with all
552 * the equations of the problem.
553 *
554 * @param (Schema_Temps_base& un_schema_en_temps) the time scheme to associate
555 */
557{
558 if (le_schema_en_temps_)
559 {
560 Cerr << finl;
561 Cerr<<"Error: Problem "<<le_nom()<<" was already associated with the scheme "<< le_schema_en_temps_->le_nom()<<" and we try to associate it with "<<un_schema_en_temps.le_nom() << "." <<finl;
562 exit();
563 }
564 le_schema_en_temps_=un_schema_en_temps;
565 le_schema_en_temps_->associer_pb(*this);
566 for(int i=0; i<nombre_d_equations(); i++)
567 equation(i).associer_sch_tps_base(un_schema_en_temps);
568}
569
570/*! @brief Returns the time scheme associated with the problem.
571 *
572 * (if it is not null) (const version)
573 *
574 * @return (Schema_Temps_base&) the time scheme associated with the problem
575 * @throws the time scheme is not associated with the problem, the reference is null
576 */
578{
579 if(!le_schema_en_temps_)
580 {
581 Cerr << le_nom() << " has not been associated to a time scheme !" << finl;
582 exit();
583 }
584 return le_schema_en_temps_.valeur();
585}
586
587
588/*! @brief Returns the time scheme associated with the problem.
589 *
590 * (if it is not null)
591 *
592 * @return (Schema_Temps_base&) the time scheme associated with the problem
593 * @throws if the time scheme is not associated with the problem, the reference is null
594 */
596{
597 if(!le_schema_en_temps_)
598 {
599 Cerr << le_nom() << " has not been associated to a time scheme !" << finl;
600 exit();
601 }
602 return le_schema_en_temps_.valeur();
603}
604
605
606/*! @brief Returns the domain associated with the problem.
607 *
608 * (const version)
609 *
610 * @return (Domaine&) a domain
611 */
612const Domaine& Probleme_base::domaine() const
613{
614 return le_domaine_.valeur();
615}
616
617/*! @brief Returns the domain associated with the problem.
618 *
619 * @return (Domaine&) a domain
620 */
622{
623 return le_domaine_.valeur();
624}
625
626/*! @brief Returns the discretized domain associated with the problem (const version).
627 *
628 * @return (Domaine_dis_base&) a discretized domain
629 */
631{
632 return le_domaine_dis_.valeur();
633}
634
635/*! @brief Returns the discretized domain associated with the problem.
636 *
637 * @return (Domaine_dis_base&) a discretized domain
638 */
640{
641 return le_domaine_dis_.valeur();
642}
643
644/*! @brief Associates a physical medium with the problem equations.
645 *
646 * Choice of the physical medium.
647 *
648 * @param (Milieu_base& mil) the medium to associate (Solide, Fluide Incompressible ...)
649 */
651{
652 for(int i=0; i<nombre_d_equations(); i++)
654}
655
656/*! @brief Returns the physical medium associated with the problem (const version).
657 *
658 * Returns the medium associated with the first equation.
659 *
660 * @return (Milieu_base&) a physical medium
661 */
663{
664 return equation(0).milieu();
665}
666
667/*! @brief Returns the physical medium associated with the problem.
668 *
669 * Returns the medium associated with the first equation.
670 *
671 * @return (Milieu_base&) a physical medium
672 */
674{
675 return equation(0).milieu();
676}
677
678/*! @brief Returns the equation whose name is specified (const version).
679 *
680 * Equations are indexed by their associated name.
681 * Searches through all equations of the problem for the one
682 * carrying the specified name.
683 *
684 * @param (Nom& type) the name of the equation to return
685 * @return (Equation_base&) an equation
686 * @throws if no equation with the specified name exists
687 */
689{
690 Motcle Type(type), Type_eqn;
691 for (int i = 0; i < nombre_d_equations(); i++)
692 {
693 Type_eqn = equation(i).que_suis_je();
694 if (Type_eqn == Type)
695 return equation(i);
696
697 // test if synonym ...
699 if (syn_info != 0)
700 if (Motcle(syn_info->org_name_()) == Type_eqn)
701 return equation(i);
702 }
703 Cerr << que_suis_je() << " does not contain any equation/medium of type: " << type << finl;
704 Cerr << "Here is the list of possible equations for a " << que_suis_je() << " problem: " << finl;
705 for (int i = 0; i < nombre_d_equations(); i++)
706 Cerr << "\t- " << equation(i).que_suis_je() << finl;
708 // For the compiler;
709 return equation(0);
710}
711
712/*! @brief (B. Math): Virtual method added for problems having several equations
713 * of the same type (Probleme_FT_Disc_gen). In that case, the name of the equation
714 * is not its type...
715 *
716 */
718{
719 return equation(un_nom);
720}
721
722/*! @brief (B. Math): Virtual method added for problems having several equations
723 * of the same type (Probleme_FT_Disc_gen). In that case, the name of the equation
724 * is not its type...
725 * Non-const version. This method is notably called when reading the problem.
726 *
727 */
729{
730 return equation(un_nom);
731}
732
733/*! @brief Returns the equation whose name is specified.
734 *
735 * Equations are indexed by their associated name.
736 * Searches through all equations of the problem for the one
737 * carrying the specified name.
738 *
739 * @param (Nom& type) the name of the equation to return
740 * @return (Equation_base&) an equation
741 * @throws if no equation with the specified name exists
742 */
744{
745 Motcle Type(type), Type_eqn;
746 for (int i = 0; i < nombre_d_equations(); i++)
747 {
748 Type_eqn = equation(i).que_suis_je();
749 if (Type_eqn == Type)
750 return equation(i);
751
752 // test if synonym ...
754 if (syn_info != 0)
755 if (Motcle(syn_info->org_name_()) == Type_eqn)
756 return equation(i);
757 }
758 Cerr << que_suis_je() << " does not contain any equation/medium of type: " << type << finl;
759 Cerr << "Here is the list of possible equations for a " << que_suis_je() << " problem: " << finl;
760 for (int i = 0; i < nombre_d_equations(); i++)
761 Cerr << "\t- " << equation(i).que_suis_je() << finl;
763 // For the compiler;
764 return equation(0);
765}
766
768{
769 domaine().creer_champ(motlu, *this);
770 domaine_dis().creer_champ(motlu, *this);
771 milieu().creer_champ(motlu);
772
773 for (int i = 0; i < nombre_d_equations(); i++)
774 equation(i).creer_champ(motlu);
775
776 for (auto &itr : liste_loi_fermeture_)
777 itr->creer_champ(motlu);
778}
779
780bool Probleme_base::has_champ(const Motcle& un_nom, OBS_PTR(Champ_base) &ref_champ) const
781{
782 if (domaine().has_champ(un_nom, ref_champ))
783 return true;
784
785 if (domaine_dis().has_champ(un_nom, ref_champ))
786 return true;
787
788 for (int i = 0; i < nombre_d_equations(); i++)
789 {
790 if (equation(i).has_champ(un_nom, ref_champ))
791 return true;
792
793 if (equation(i).milieu().has_champ(un_nom, ref_champ))
794 return true;
795 }
796
797 for (const auto &corr : correlations_)
798 if (corr.second->has_champ(un_nom, ref_champ))
799 return true;
800
801 for (const auto &itr : liste_loi_fermeture_)
802 if (itr->has_champ(un_nom, ref_champ))
803 return true;
804
805 return false; /* nothing found */
806}
807
808bool Probleme_base::has_champ(const Motcle& un_nom) const
809{
810 if (domaine().has_champ(un_nom))
811 return true;
812
813 if (domaine_dis().has_champ(un_nom))
814 return true;
815
816 for (int i = 0; i < nombre_d_equations(); i++)
817 {
818 if (equation(i).has_champ(un_nom))
819 return true;
820
821 if (equation(i).milieu().has_champ(un_nom))
822 return true;
823 }
824
825 for (const auto &corr : correlations_)
826 if (corr.second->has_champ(un_nom))
827 return true;
828
829 for (const auto &itr : liste_loi_fermeture_)
830 if (itr->has_champ(un_nom))
831 return true;
832
833 return false; /* nothing found */
834}
835
836const Champ_base& Probleme_base::get_champ(const Motcle& un_nom) const
837{
838 OBS_PTR(Champ_base) ref_champ;
839
840 if (domaine().has_champ(un_nom, ref_champ))
841 return ref_champ;
842
843 if (domaine_dis().has_champ(un_nom, ref_champ))
844 return ref_champ;
845
846 for (int i = 0; i < nombre_d_equations(); i++)
847 {
848 if (equation(i).has_champ(un_nom, ref_champ))
849 return ref_champ;
850
851 if (equation(i).milieu().has_champ(un_nom, ref_champ))
852 return ref_champ;
853 }
854
855 for (const auto &corr : correlations_)
856 if (corr.second->has_champ(un_nom, ref_champ))
857 return ref_champ;
858
859 for (const auto &itr : liste_loi_fermeture_)
860 if (itr->has_champ(un_nom, ref_champ))
861 return ref_champ;
862
863 Cerr << "The field of name " << un_nom << " do not correspond to a field understood by the problem." << finl;
864 Cerr << "It may be a field dedicated only to post-process and defined in the Definition_champs set." << finl;
865 Cerr << "1) If you have request the post-processing of " << un_nom << " in the Champs set" << finl;
866 Cerr << "please remove the localisation elem or som that you may have specified." << finl;
867 Cerr << "2) If you have used " << un_nom << " in Definition_champs, please use 'sources_reference { " << un_nom << " }'" << finl;
868 Cerr << "instead of 'source refchamp { pb_champ " << le_nom() << " " << un_nom << " }'" << finl;
869 Cerr << "3) Check reference manual." << finl;
870 Cerr << "4) Contact TRUST support." << finl;
872
873 throw std::runtime_error(std::string("Field ") + un_nom.getString() + std::string(" not found !"));
874}
875
877{
881 int nb_eq = nombre_d_equations();
882 for (int i=0; i<nb_eq; i++)
884
885 for (const auto& itr : liste_loi_fermeture_)
886 {
887 const Loi_Fermeture_base& loi=itr.valeur();
888 loi.get_noms_champs_postraitables(noms,opt);
889 }
890}
891
893{
894 if (un_nom == "TEMPERATURE_PHYSIQUE") return 0;
895
896 for (const auto &itr : postraitements())
897 {
898 const Postraitement& post = ref_cast(Postraitement, itr.valeur());
899 if (post.comprend_champ_post(un_nom))
900 return 1;
901 }
902 return 0;
903}
904
905bool Probleme_base::has_champ_post(const Motcle& un_nom) const
906{
907 for (const auto &itr : postraitements())
908 if (sub_type(Postraitement, itr.valeur()))
909 {
910 const Postraitement& post = ref_cast(Postraitement, itr.valeur());
911 if (post.has_champ_post(un_nom))
912 return true;
913 }
914
915 return false; /* nothing found */
916}
917
919{
920 for (const auto &itr : postraitements())
921 if (sub_type(Postraitement, itr.valeur()))
922 {
923 const Postraitement& post = ref_cast(Postraitement, itr.valeur());
924 if (post.has_champ_post(un_nom))
925 return post.get_champ_post(un_nom);
926 }
927
928 Cerr << "The field named " << un_nom << " do not correspond to a field understood by the problem." << finl;
929 Cerr << "Check the name of the field indicated into the postprocessing block of the data file " << finl;
930 Cerr << "or in the list of post-processed fields above (in the block 'Reading of fields to be postprocessed')." << finl;
932
933 throw std::runtime_error(std::string("Field ") + un_nom.getString() + std::string(" not found !"));
934}
935
936int Probleme_base::a_pour_IntVect(const Motcle&, OBS_PTR(IntVect)& ) const
937{
938 return 0;
939}
940
941/*! @brief Performs a time update of the problem.
942 *
943 * Performs the update on all equations of the problem.
944 *
945 * @param (double temps) the time step for the update
946 */
948{
949 // Update the name of the problem being debugged
951
952 // Update the equations:
953//statistics().begin_count(STD_COUNTERS::update_variables);
954 for(int i=0; i<nombre_d_equations(); i++)
955 equation(i).mettre_a_jour(temps);
956
957 // Update the media:
958 milieu().mettre_a_jour(temps);
959
960 // Update the conserved fields in the equations (must be done after the media):
961 for(int i=0; i<nombre_d_equations(); i++)
963
964 // Update the post-processing:
965 les_postraitements_.mettre_a_jour(temps);
966
967 // Set conditions to update the domain in ALE:
969
970
971 for (auto& itr : liste_loi_fermeture_)
972 {
973 Loi_Fermeture_base& loi=itr.valeur();
974 loi.mettre_a_jour(temps);
975 }
976 for (auto &corr : correlations_)
977 corr.second->mettre_a_jour(temps);
978 //statistics().end_count(STD_COUNTERS::update_variables);
979}
980
981/*! @brief Prepares the computation: initializes the medium parameters and prepares the computation of each equation.
982 *
983 */
985{
986 const double temps = schema_temps().temps_courant();
987 // Modification of the Qdm array held by domaine_dis() in the case
988 // where there are periodic boundary conditions.
989 // Note: if one of the equations has a periodic boundary condition
990 // then the others must necessarily have it too.
991 equation(0).domaine_dis().modifier_pour_Cl(equation(0).domaine_Cl_dis().les_conditions_limites());
992 milieu().initialiser(temps);
993 for (int i = 0; i < nombre_d_equations(); i++)
996 for (int i = 0; i < nombre_d_equations(); i++) /* we can now fill the conserved fields */
998
999 save_restart_.preparer_calcul();
1000
1001 for (auto& itr : liste_loi_fermeture_)
1002 {
1003 Loi_Fermeture_base& loi = itr.valeur();
1004 loi.preparer_calcul();
1005 }
1006
1007 if (correlations_.size() > 0)
1008 mettre_a_jour(temps);
1009}
1010
1011
1012/*! @brief Computes the value of the next time step for the problem.
1013 *
1014 * Computes the minimum of the time steps of the equations associated
1015 * with the problem.
1016 *
1017 * @return (double) the maximum allowed time step for this problem
1018 */
1020{
1022 double dt=schema_temps().pas_temps_max();
1023 for(int i=0; i<nombre_d_equations(); i++)
1024 dt=std::min(dt,equation(i).calculer_pas_de_temps());
1025 return dt;
1026}
1027
1029{
1030 Cerr<<"The postprocessing of interfaces is only possible for"<<finl;
1031 Cerr<<"a problem type Pb_Front_Tracking, not a "<<que_suis_je()<<finl;
1032 exit();
1033
1034}
1035void Probleme_base::postraiter_interfaces(const Nom& nomfich, Sortie& s, const Nom& format, double temps)
1036{
1037 Cerr<<que_suis_je()<<" must overloaded :postraiter_interfaces"<<finl;
1038 // exit();
1039}
1040
1042{
1043 return milieu().is_dilatable();
1044}
1045
1046/*! @brief Verifies that the necessary disk space exists.
1047 *
1048 */
1050{
1051 save_restart_.allocation();
1052}
1053
1054/*! @brief If force=1, performs post-processing regardless of the post-processing frequencies.
1055 *
1056 * The post-processing is updated and any treatments on
1057 * probes, fields and statistics are performed.
1058 * If force=0, respects the requested output frequencies.
1059 *
1060 */
1062{
1063 statistics().begin_count(STD_COUNTERS::postreatment,statistics().get_last_opened_counter_level()+1);
1066 if (sch.nb_pas_dt() != 0)
1067 imprimer(Cout);
1068 if (force)
1069 {
1070 if (Process::nproc()>=100) Cerr << "[Post] Probleme_base::postraiter... " << finl;
1071 //Post-processable sources (Terme_Source_Acceleration) are not updated
1072 //for the final time and are not part of the champs_crees_ of the post-processing
1073 //which are updated by les_postraitements.mettre_a_jour.
1074 //We therefore update them here
1075
1076 const int nb_pas_dt_max = sch.nb_pas_dt_max();
1077 bool& indice_nb_pas_dt = sch.set_indice_nb_pas_dt_max_atteint();
1078 bool& indice_tps_final = sch.set_indice_tps_final_atteint();
1079 const double t_init = sch.temps_init();
1080 const double t_max = sch.temps_max();
1081
1082 //Test to avoid repeating post-processing at the initial time
1083 //This avoids a crash in the case of post-processing in meshtv format
1084
1085 if (!(indice_nb_pas_dt && nb_pas_dt_max == 0) && !(indice_tps_final && est_egal(t_init, t_max)))
1086 {
1087 for (int i = 0; i < nombre_d_equations(); i++)
1088 equation(i).sources().mettre_a_jour(schema_temps().temps_courant());
1089
1090 les_postraitements_.mettre_a_jour(schema_temps().temps_courant());
1091 les_postraitements_.postraiter();
1092 if (nb_pas_dt_max == 0)
1093 indice_nb_pas_dt = true;
1094 if (est_egal(t_init, t_max))
1095 indice_tps_final = true;
1096 }
1097 if (Process::nproc()>=100) Cerr << "[Post] Done in " << statistics().get_time_since_last_open(STD_COUNTERS::postreatment) << " s. If too slow consider using CGNS format." << finl;
1098 }
1099 else
1100 les_postraitements_.traiter_postraitement();
1101
1102 statistics().end_count(STD_COUNTERS::postreatment);
1103 //Start specific postraitements for mobile domain (like ALE)
1104 if(!save_restart_.is_restart_in_progress() && le_domaine_dis_)
1105 {
1106 //no projection during the iteration of resumption of computation
1107 double temps = le_schema_en_temps_->temps_courant();
1108 le_domaine_dis_->domaine().update_after_post(temps);
1109 }
1110
1111 save_restart_.set_restart_in_progress(false); //reset to false in order to make the following projections
1112 // end specific postraitements for mobile domain (like ALE)
1113
1114 return 1;
1115}
1116
1117/*! @brief Writes to file for restart (backup).
1118 *
1119 */
1121{
1122 statistics().begin_count(STD_COUNTERS::backup_file,statistics().get_last_opened_counter_level()+1);
1123 int bytes = save_restart_.sauver();
1125 Cout << "[IO] " << statistics().get_time_since_last_open(STD_COUNTERS::backup_file) << " s to write save file." << finl;
1126 statistics().end_count(STD_COUNTERS::backup_file,1,bytes);
1127}
1128
1129/*! @brief Finalizes post-processing and saves the problem to a file.
1130 *
1131 * Closes the file associated with post-processing. (Postraitement::finir())
1132 *
1133 */
1135{
1137 schema_temps().finir(); // Close the .dt_ev file
1138 les_postraitements_.finir(); // Close post-processing files
1139 for (auto os : get_set_out_files())
1140 if (os->is_open())
1141 os->close(); // Close .out files
1142 // Clear the following global variables (useful for resetTime in the same directory)
1143 glob_noms_fichiers.vide();
1144 glob_derniers_posts.vide();
1145
1146 if (schema_temps().temps_sauv() > 0.0)
1147 sauver();
1148 save_restart_.finir();
1149}
1150
1152{
1153 static const std::string param_name = "SORTIE_ROOT_DIRECTORY";
1154 std::string new_root_dir = (str_params_.count(param_name) == 0) ? "" : getOutputStringValue(param_name);
1155
1156 resetTimeWithDir_impl(*this, time, new_root_dir);
1157}
1158
1159/*! @brief Searches for parametric fields and for each, moves to the next parameter.
1160 *
1161 */
1163{
1164 std::string dirname="";
1165 // Loop over fields of boundary conditions:
1166 for (int i = 0; i < nombre_d_equations(); i++)
1167 {
1168 const Equation_base& eq = equation(i);
1169 const Conds_lim& condsLim = eq.domaine_Cl_dis().les_conditions_limites();
1170 for (auto const &condLim : condsLim)
1171 {
1172 const Cond_lim_base& la_cl_base = condLim.valeur();
1173 if (sub_type(Champ_front_Parametrique, la_cl_base.champ_front()))
1174 {
1175 const Champ_front_Parametrique& champ_front = ref_cast(Champ_front_Parametrique, la_cl_base.champ_front());
1176 dirname = champ_front.newCompute();
1177 }
1178 }
1179 }
1180 // Loop over source fields:
1182 {
1183 for (int i = 0; i < nombre_d_equations(); i++)
1184 {
1185 const Equation_base& eq = equation(i);
1186 const Sources& sources = eq.sources();
1187 for (auto &source: sources)
1188 {
1189 for (auto const &champ_don: source->champs_don())
1190 {
1191 if (sub_type(Champ_Parametrique, champ_don.valeur()))
1192 {
1193 const Champ_Parametrique& champ = ref_cast(Champ_Parametrique, champ_don.valeur());
1194 dirname = champ.newCompute();
1195 }
1196 }
1197 }
1198 }
1199 // Loop over medium fields:
1200 for (auto const &champ_don: milieu().champs_don())
1201 {
1202 if (sub_type(Champ_Parametrique, champ_don.valeur()))
1203 {
1204 const Champ_Parametrique& champ = ref_cast(Champ_Parametrique, champ_don.valeur());
1205 dirname = champ.newCompute();
1206 }
1207 }
1208 }
1209 return dirname;
1210}
1211
1213{
1214 /* reading of optional equations */
1215 Noms noms_eq, noms_eq_maj; //names of all possible equations!
1216 Type_info::les_sous_types(Nom("Equation_base"), noms_eq);
1217 for (auto& itr : noms_eq) noms_eq_maj.add(Motcle(itr)); //ha ha ha
1218 for (is >> mot; noms_eq_maj.rang(mot) >= 0; is >> mot)
1219 {
1220 eq_opt_.add(OWN_PTR(Equation_base)()); //another optional equation
1221 eq_opt_.dernier().typer(mot); //we give it the correct type
1222 Equation_base& eq = eq_opt_.dernier().valeur();
1223 //same associations as for the other equations: problem, medium, time scheme
1224 eq.associer_pb_base(*this);
1226 eq.associer_sch_tps_base(le_schema_en_temps_);
1228 eq.discretiser(); //must be done before reading the equation
1229 is >> eq; //and off we go!
1230 eq.associer_milieu_equation(); //propagate back to the medium
1231 }
1232 return is;
1233}
1234
1236{
1237 Motcle mot;
1238 is >> mot;
1239 if (mot != "{")
1240 {
1241 Cerr << "correlations : { expected instead of " << mot << finl;
1242 Process::exit();
1243 }
1244 for (is >> mot; mot != "}"; is >> mot)
1245 if (correlations_.count(mot.getString())) Process::exit(que_suis_je() + " : a correlation already exists for " + mot + " !");
1246 else
1248
1249 return is;
1250}
1251
1253 const std::vector<double>& x,
1254 const std::vector<double>& y,
1255 const std::vector<double>& z,
1256 std::vector<double>& vals, int compo)
1257{
1259 Process::exit("Probleme_base::getOutputPointValues not implemented in // !! \n");
1260
1261 assert (compo > -1);
1262
1263 const int size_x = static_cast<int>(x.size());
1264 const int size_y = static_cast<int>(y.size());
1265 const int size_z = static_cast<int>(z.size());
1266 const int size_vals = static_cast<int>(vals.size());
1267
1268 if (size_x != size_y)
1269 Process::exit("Error in Probleme_base::getOutputPointValues => vectors x and y must have same dimensions !!!");
1270
1271 if (Objet_U::dimension > 2 && (size_x != size_z))
1272 Process::exit("Error in Probleme_base::getOutputPointValues => vectors x, y and z must have same dimensions !!!");
1273
1274 if (size_vals == 0)
1275 vals.resize(size_x);
1276 else
1277 {
1278 if (size_vals != size_x)
1279 Process::exit("Error in Probleme_base::getOutputPointValues => vectors x, y/z and vals must have same dimensions !!!");
1280 }
1281
1282 DoubleTrav les_positions; // TODO FIXME : attribute ?
1283 les_positions.resize(size_x, Objet_U::dimension);
1284
1285 for (int i = 0; i < size_x; i++)
1286 {
1287 les_positions(i, 0) = x[i];
1288 les_positions(i, 1) = y[i];
1289 if (Objet_U::dimension > 2) les_positions(i, 2) = z[i];
1290 }
1291
1292 IntVect elem; // TODO FIXME : attribute ?
1293
1294 if(elem.size() != size_x)
1295 elem.resize(size_x);
1296
1297 le_domaine_->chercher_elements(les_positions, elem, 1);
1298
1299 // Check if some probes are outside the domain:
1300 ArrOfDouble tmp(size_x);
1301 for (int i = 0; i < size_x; i++)
1302 tmp[i] = elem[i];
1304 for (int i = 0; i < size_x; i++)
1305 if (tmp[i] == -1)
1306 {
1307 Cerr << "Error in Probleme_base::getOutputPointValues => The point number " << i + 1 << " is outside the computational domain !!! " << finl;
1308 Process::exit();
1309 }
1310
1311 DoubleTrav valeurs_locales;
1312 valeurs_locales.resize(size_x, 1);
1313
1314 // TODO FIXME : remaining issue of som/grav ... to refactor with Sonde::initialiser()
1315 if (has_champ(Motcle(name)))
1316 {
1317 OBS_PTR(Champ_base) champ_ref = get_champ(Motcle(name));
1318
1319 if (champ_ref->nb_comp() == 1)
1320 {
1321 assert(champ_ref->valeurs().line_size() == 1);
1322 champ_ref->valeur_aux_elems(les_positions, elem, valeurs_locales);
1323 }
1324 else
1325 {
1326 assert(compo < champ_ref->nb_comp());
1327 champ_ref->valeur_aux_elems_compo(les_positions, elem, valeurs_locales, compo);
1328 }
1329 }
1330 else /* from post like ICoCo*/
1331 {
1332 OBS_PTR(Champ_Generique_base) ref_ch = findOutputField(name);
1333
1334 if (!ref_ch)
1335 {
1336 Cerr << "Error in Probleme_base::getOutputPointValues => No output fields of name " << name << finl;
1337 Process::exit();
1338 }
1339
1340 OWN_PTR(Champ_base) espace_stockage;
1341 const Champ_base& ma_source = ref_ch->get_champ(espace_stockage);
1342
1343 if (ma_source.nb_comp() == 1)
1344 {
1345 assert(ma_source.valeurs().line_size() == 1);
1346 ma_source.valeur_aux_elems(les_positions, elem, valeurs_locales);
1347 }
1348 else
1349 {
1350 assert(compo < ma_source.nb_comp());
1351 ma_source.valeur_aux_elems_compo(les_positions, elem, valeurs_locales, compo);
1352 }
1353 }
1354
1355 for (int i = 0; i < size_x; i++)
1356 vals[i] = valeurs_locales(i, 0);
1357}
class Champ_Generique_base
: class Champ_Parametrique
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
virtual DoubleVect & valeur_aux_elems_compo(const DoubleTab &positions, const IntVect &les_polys, DoubleVect &valeurs, int ncomp) const
Causes an error! Must be overridden by derived classes.
virtual DoubleTab & valeur_aux_elems(const DoubleTab &positions, const IntVect &les_polys, DoubleTab &valeurs) const
Causes an error! Must be overridden by derived classes.
: class Champ_front_Parametrique
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
Champ_front_base & champ_front()
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
static void typer_lire_correlation(OWN_PTR(Correlation_base)&, const Probleme_base &, const Nom &, Entree &)
static void set_nom_pb_actuel(const Nom &nom)
Definition Debog.cpp:44
class Discretisation_base This class represents a spatial discretization scheme, which
virtual Domaine_dis_base & discretiser() const
void associer_domaine(const Domaine &dom)
class Domaine_32_64 A Domain is a mesh composed of a set of geometric elements of the same type.
Definition Domaine.h:62
int_t nb_elem() const
Definition Domaine.h:131
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
virtual int restore_additional_state(Entree &, Probleme_base &)
virtual void setUpdateTheGrid(bool)
virtual int save_additional_state(Sortie &, const Probleme_base &) const
void creer_champ(const Motcle &motlu) override
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
void creer_champ(const Motcle &motlu) override
void associer_domaine(const Domaine &)
Associates a Domain with the object.
virtual void modifier_pour_Cl(const Conds_lim &)=0
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Equation_base The role of an equation is the calculation of one or more fields....
virtual void associer_milieu_equation()
virtual void associer_milieu_base(const Milieu_base &)=0
int reprendre(Entree &) override
We resume the unknown from an input stream.
virtual const Milieu_base & milieu() const =0
virtual void associer_domaine_dis(const Domaine_dis_base &)
Associates the discretized domain with the equation.
virtual void imprimer(Sortie &os) const
Prints the equation operators if the time scheme indicates it is necessary.
virtual void associer_pb_base(const Probleme_base &)
Associates with the Problem passed as parameter.
Sources & sources()
Returns the source terms associated with the equation.
virtual void mettre_a_jour_champs_conserves(double temps, int reset=0)
virtual void mettre_a_jour(double temps)
The value of the unknown at the time step has been calculated.
virtual void completer()
Completes the construction (initialization) of objects associated with the equation.
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
virtual int preparer_calcul()
Everything that does not depend on other possible problems.
int sauvegarder(Sortie &) const override
We save the unknown, then the source terms to an output stream.
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
virtual void associer_sch_tps_base(const Schema_Temps_base &)
Associates the time scheme with the equation.
void creer_champ(const Motcle &motlu) override
virtual void discretiser()
Discretizes the equation.
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
virtual int nb_comp() const
Definition Field_base.h:56
: Base class of closure laws.
virtual void associer_pb_base(const Probleme_base &)
This method is the first called by the problem to construct the object when it is associated with the...
virtual void preparer_calcul()
This method is called by the problem after preparer_calcul() of equations and medium.
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
virtual void mettre_a_jour(double temps)
This method is called by the problem after mettre_a_jour() of equations and medium.
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
virtual int initialiser(const double temps)
virtual bool is_dilatable() const
virtual void mettre_a_jour(double temps)
virtual void preparer_calcul()
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
virtual void discretiser(const Probleme_base &pb, const Discretisation_base &dis)
void creer_champ(const Motcle &motlu) override
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const std::string & getString() const
Definition Nom.h:92
const Nom & le_nom() const override
Returns *this.
Definition Nom.cpp:555
An array of character strings (VECT(Nom)).
Definition Noms.h:26
int rang(const char *const ch) const
Definition Noms.cpp:65
friend class Entree
Definition Objet_U.h:71
static int dimension
Definition Objet_U.h:94
friend class Sortie
Definition Objet_U.h:70
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
static const Nom & nom_du_cas()
Returns a constant reference to the case name. This method is static.
Definition Objet_U.cpp:145
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
Definition Objet_U.cpp:54
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Base class for all post-processing objects.
class Postraitement. The class holds -a list of generic fields champs_post_complet_ containing
double dt_post() const
int comprend_champ_post(const Motcle &identifiant) const
Nom nom_fich() const
virtual const Champ_Generique_base & get_champ_post(const Motcle &nom) const
int & est_le_dernier_postraitement_pour_nom_fich()
virtual bool has_champ_post(const Motcle &nom) const
int & est_le_premier_postraitement_pour_nom_fich()
Probleme_U.
Definition Probleme_U.h:46
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Probleme_U.h:109
virtual std::string getOutputStringValue(const std::string &name)
std::map< std::string, std::string > str_params_
Definition Probleme_U.h:114
void resetTimeWithDir_impl(Probleme_base &pb, double time, std::string direname)
class Probleme_base It is a Probleme_U that is not a coupling.
int sauvegarder(Sortie &) const override
Writing of the problem to file for restart.
int limpr() const override
Asks the time scheme if a print is needed.
virtual void associer_milieu_base(const Milieu_base &)
Associates a physical medium with the problem equations.
virtual Entree & lire_equations(Entree &is, Motcle &dernier_mot)
Reading of the equations of the problem.
virtual void typer_lire_milieu(Entree &is)
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
void getOutputPointValues(const Nom &name, const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z, std::vector< double > &vals, int compo) override
virtual void discretiser(Discretisation_base &)
Assigns a discretization to the problem Discretizes the Domain associated with the problem with the d...
std::string newCompute() override
Searches for parametric fields and for each, moves to the next parameter.
virtual void lire_postraitement_interfaces(Entree &is)
virtual void associer_domaine(const Domaine &)
Associates a domain with the problem.
virtual void discretiser_equations()
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
int postraiter(int force=1) override
If force=1, performs post-processing regardless of the post-processing frequencies.
virtual void postraiter_interfaces(const Nom &nom_fich, Sortie &s, const Nom &format, double temps)
bool is_dilatable() const
void creer_champ(const Motcle &motlu) override
int associer_(Objet_U &) override
override Objet_U::associer_(Objet_U& ob) Associates different objects with the problem by checking
virtual Entree & lire_correlations(Entree &is)
void sauver() const override
Writes to file for restart (backup).
const Domaine & domaine() const
Returns the domain associated with the problem.
const Champ_base & get_champ(const Motcle &nom) const override
Entree & read_optional_equations(Entree &is, Motcle &mot)
virtual bool has_champ_post(const Motcle &nom) const
virtual void preparer_calcul()
Prepares the computation: initializes the medium parameters and prepares the computation of each equa...
void init_postraitements()
Flags the first and last post-processing for each file And initializes the post-processing.
Postraitements & postraitements()
virtual double calculer_pas_de_temps() const
Computes the value of the next time step for the problem.
Postraitements les_postraitements_
virtual int a_pour_IntVect(const Motcle &, OBS_PTR(IntVect)&) const
virtual int comprend_champ_post(const Motcle &nom) const
virtual void mettre_a_jour(double temps)
Performs a time update of the problem.
Save_Restart save_restart_
void resetTime(double time) override
Reset the current time of the Problem to a given value.
int lsauv() const override
Asks the time scheme if a backup is needed.
virtual void allocation() const final
Verifies that the necessary disk space exists.
virtual void associer_sch_tps_base(const Schema_Temps_base &)
Associates a time scheme with the problem.
virtual void finir()
Finalizes post-processing and saves the problem to a file.
virtual const Champ_Generique_base & get_champ_post(const Motcle &nom) const
std::vector< OWN_PTR(Milieu_base)> le_milieu_
virtual const Milieu_base & milieu() const
Returns the physical medium associated with the problem (const version).
std::map< std::string, OWN_PTR(Correlation_base)> correlations_
const Schema_Temps_base & schema_temps() const
Returns the time scheme associated with the problem.
virtual int nombre_d_equations() const =0
OBS_PTR(Field_base) findInputField(const Nom &name) const override
virtual Entree & lire_radiation_models(Entree &is, Motcle &mot)
virtual const Equation_base & equation(int) const =0
virtual void imprimer(Sortie &os) const
Prints the equations associated with the problem if the associated time scheme indicates that it is n...
virtual int verifier()
Verifies that the object is complete, coherent, .
virtual void completer()
Completes the equations associated with the problem.
virtual int expression_predefini(const Motcle &motlu, Nom &expression)
virtual void lire_solved_equations(Entree &is)
const Domaine_dis_base & domaine_dis() const
Returns the discretized domain associated with the problem (const version).
virtual const Equation_base & get_equation_by_name(const Nom &) const
(B. Math): Virtual method added for problems having several equations of the same type (Probleme_FT_D...
int reprendre(Entree &) override
Reading of an input stream (file) for restart after a backup with Probleme_base::sauvegarder(Sortie& ...
virtual void associer()
Associates the problem with all its equations.
virtual Equation_base & getset_equation_by_name(const Nom &)
(B. Math): Virtual method added for problems having several equations of the same type (Probleme_FT_D...
static void mp_max_for_each_item(TRUSTArray< _TYPE_ > &x, int n=-1)
Definition Process.cpp:197
static bool is_parallel()
Definition Process.cpp:108
static int nproc()
Returns the number of processors in the current group. See Comm_Group::nproc() and PE_Groups::current...
Definition Process.cpp:102
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
class Schema_Temps_base
bool & set_indice_nb_pas_dt_max_atteint()
int limpr() const
Returns 1 if there is a need to perform a print (cf dt_impr) Returns 0 otherwise.
const Nom & le_nom() const override
overrides Objet_U::le_nom() Returns the name of the time scheme
double temps_courant() const
Returns the current time.
int sauvegarder(Sortie &) const override
Saves the current time and the number of time steps to an output stream.
double pas_temps_max() const
Returns the maximum time step.
virtual void associer_pb(const Probleme_base &)
double temps_max() const
Returns a reference to the maximum time.
int nb_pas_dt() const
Returns the number of time steps performed.
int reprendre(Entree &) override
Restarts (reads) the current time and the number of time steps performed from an input stream.
double temps_init() const
Returns the initial time.
bool & set_indice_tps_final_atteint()
int nb_pas_dt_max() const
Returns a reference to the maximum number of time steps.
void finir() const
Closes the .dt_ev file.
static std::string root
Base class for output streams.
Definition Sortie.h:52
class Sources Sources represents a list of Source objects.
Definition Sources.h:31
void mettre_a_jour(double temps)
Time update of all sources in the list.
Definition Sources.cpp:109
Models synonym information for Objet_U objects.
static const Synonyme_info * synonyme_info_from_name(const char *synonyme_name)
Static method that returns a pointer to the Synonyme_info whose name is "synonyme_name".
const char * org_name_() const
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ size() const
Definition TRUSTVect.tpp:45
int line_size() const
Definition TRUSTVect.tpp:67
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91
static int les_sous_types(const Nom &, Noms &sous_types)
Returns the names of the subtypes for a parent type identified by name.