16#include <Pilote_ICoCo.h>
17#include <ICoCoTrioField.h>
18#include <ProblemTrio.h>
20#include <Probleme_U.h>
30using ICoCo::TrioField;
32extern void TRUST_set_library_mode(
bool);
76void main_pilote_icoco_1(
Probleme_U& pb_to_solve)
79 TRUST_set_library_mode(
false);
91 statistics().start_timeloop();
94 statistics().begin_count(STD_COUNTERS::timeloop);
110 cout <<
"Input Fields for " << pb_name <<
" :" << endl;
111 for (
unsigned i=0; i<sv.size(); i++)
112 std::cout << i <<
". " << sv[i] << std::endl;
115 int nb_elems,nb_comp;
120 afield.set_standalone();
122 nb_elems=afield._nb_elems;
123 nb_comp=afield._nb_field_components;
125 for (
int i=0; i<nb_elems; i++)
133 afield.set_standalone();
135 nb_elems=afield._nb_elems;
136 nb_comp=afield._nb_field_components;
140 double vx=(t>100)?100:t;
141 for (
int i=0; i<nb_elems; i++)
142 for (
int j=0; j<afield._nb_field_components; j++)
143 afield._field[i*nb_comp+j]=(j==0)?vx:0;
171 statistics().end_count(STD_COUNTERS::timeloop);
173 statistics().end_timeloop();
175 statistics().print_TU_files(
"Time loop statistics");
190void main_pilote_icoco_2(
Probleme_U& pb_to_solve)
193 TRUST_set_library_mode(
false);
205 statistics().start_timeloop();
208 statistics().begin_count(STD_COUNTERS::timeloop);
224 cout <<
"Input Fields for " << pb_name <<
" :" << endl;
225 for (
unsigned i=0; i<sv.size(); i++)
226 std::cout << i <<
". " << sv[i] << std::endl;
234 afield.set_standalone();
236 nb_elems=afield._nb_elems;
238 assert(afield._nb_field_components==1);
239 assert(afield._space_dim==2);
240 for (
int i=0; i<nb_elems; i++)
244 for (
int j=0; j<afield._nodes_per_elem; j++)
246 int som=afield._connectivity[afield._nodes_per_elem*i+j];
247 x+=afield._coords[som*2];
248 y+=afield._coords[som*2+1];
250 x/=afield._nodes_per_elem;
251 y/=afield._nodes_per_elem;
252 afield._field[i]=(((x-0.5)*(x-0.5)+(y-0.5)*(y-0.5))<0.3*0.3)*10;
281 statistics().end_count(STD_COUNTERS::timeloop);
283 statistics().end_timeloop();
285 statistics().print_TU_files(
"Time loop statistics");
292void main_pilote_icoco_3(
Probleme_U& pb_to_solve,
int nb_pas_dt_reset)
295 TRUST_set_library_mode(
false);
308 statistics().start_timeloop();
311 statistics().begin_count(STD_COUNTERS::timeloop);
338 if (cnt >= nb_pas_dt_reset && !reset)
340 Cerr <<
"ABOUT TO RESET TIME !!\n";
342 Cerr <<
"RESET TIME DONE!!\n";
354 statistics().end_count(STD_COUNTERS::timeloop);
356 statistics().end_timeloop();
358 statistics().print_TU_files(
"Time loop statistics");
366void main_pilote_icoco_4(
Probleme_U& pb_to_solve,
int sortie_root_directory,
int nstep_stabilized,
int nb_pas_dt_reset)
369 TRUST_set_library_mode(
false);
379 assert(nstep_stabilized < nb_pas_dt_reset);
383 statistics().start_timeloop();
386 statistics().begin_count(STD_COUNTERS::timeloop);
414 if (cnt <= nstep_stabilized)
416 if (sortie_root_directory == 1)
418 else if (sortie_root_directory == 2)
423 if (cnt >= nb_pas_dt_reset && !reset)
425 if (sortie_root_directory == 1)
427 else if (sortie_root_directory == 2)
441 statistics().end_count(STD_COUNTERS::timeloop);
443 statistics().end_timeloop();
445 statistics().print_TU_files(
"Time loop statistics");
463 TRUST_set_library_mode(
false);
472 statistics().start_timeloop();
475 statistics().begin_count(STD_COUNTERS::timeloop);
498 afield.set_standalone();
499 nb_elems=afield._nb_elems;
500 for (
int i=0; i<nb_elems; i++)
501 afield._field[i]=600;
511 Cerr<<
" call of abortTimeStep" <<finl;
519 statistics().end_count(STD_COUNTERS::timeloop);
521 statistics().end_timeloop();
523 statistics().print_TU_files(
"Time loop statistics");
531 int nb_pas_dt_reset = 1000000000;
532 int nstep_stabilized = 0;
533 int sortie_root_directory = 0;
542 param.
ajouter(
"nb_pas_dt_reset",&nb_pas_dt_reset);
545 param.
ajouter(
"nstep_stabilized",&nstep_stabilized);
548 param.
ajouter(
"sortie_root_directory",&sortie_root_directory);
555 main_abort(pb_to_solve);
558 main_pilote_icoco_1(pb_to_solve);
561 main_pilote_icoco_2(pb_to_solve);
564 main_pilote_icoco_3(pb_to_solve, nb_pas_dt_reset);
567 main_pilote_icoco_4(pb_to_solve, sortie_root_directory, nstep_stabilized, nb_pas_dt_reset);
571 Cerr<<
que_suis_je()<<
" main number "<<methode<<
" not implemented"<<finl;
Class defining operators and methods for all reading operation in an input flow (file,...
void terminate() override
This method is called once at the end, after any other one.
double computeTimeStep(bool &stop) const override
Compute the value the Problem would like for the next time step.
std::vector< std::string > getInputFieldsNames() const override
This method is used to find the names of input fields understood by the Problem.
void validateTimeStep() override
Validates the calculated unknown by moving the present time at the end of the time step.
double presentTime() const override
Returns the present time.
void getInputFieldTemplate(const std::string &name, TrioField &afield) const override
This method is used to get a template of a field expected for the given name.
void resetTime(double time) override
Reset the current time of the Problem to a given value.
void setInputField(const std::string &name, const TrioField &afield) override
This method is used to provide the Problem with an input field.
bool initialize_pb(Probleme_U &pb)
bool initTimeStep(double dt) override
This method allocates and initializes the unknown and given fields for the future time step.
void setInputStringValue(const std::string &name, const std::string &val) override
bool solveTimeStep() override
Calculates the unknown fields for the next time step.
bool isStationary() const override
Tells if the Problem unknowns have changed during the last time step.
void abortTimeStep() override
Aborts the resolution of the current time step.
Classe de base des objets "interprete".
static Objet_U & objet(const Nom &)
Voir Interprete_bloc::objet_global() BM: la classe Interprete n'est pas le meilleur endroit pour cett...
class Nom Une chaine de caractere pour nommer les objets de TRUST
static bool disable_TU
Flag to disable or not the writing of the .TU files.
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Helper class to factorize the readOn method of Objet_U classes.
void dictionnaire(const char *option_name, int value)
Add an (option name, integer value) entry to the dictionary attached to a previously registered integ...
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
int lire_avec_accolades_depuis(Entree &is)
Parse the parameter block { ... } from is.
classe Pilote_ICoCo Exemple de pilotage de Trio via ICoCo en C++
Entree & interpreter(Entree &) override
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Classe de base des flux de sortie.