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);
75void main_pilote_icoco_1(
Probleme_U& pb_to_solve)
78 TRUST_set_library_mode(
false);
90 statistics().start_timeloop();
93 statistics().begin_count(STD_COUNTERS::timeloop);
109 cout <<
"Input Fields for " << pb_name <<
" :" << endl;
110 for (
unsigned i=0; i<sv.size(); i++)
111 std::cout << i <<
". " << sv[i] << std::endl;
114 int nb_elems,nb_comp;
119 afield.set_standalone();
121 nb_elems=afield._nb_elems;
122 nb_comp=afield._nb_field_components;
124 for (
int i=0; i<nb_elems; i++)
132 afield.set_standalone();
134 nb_elems=afield._nb_elems;
135 nb_comp=afield._nb_field_components;
139 double vx=(t>100)?100:t;
140 for (
int i=0; i<nb_elems; i++)
141 for (
int j=0; j<afield._nb_field_components; j++)
142 afield._field[i*nb_comp+j]=(j==0)?vx:0;
170 statistics().end_count(STD_COUNTERS::timeloop);
172 statistics().end_timeloop();
174 statistics().print_TU_files(
"Time loop statistics");
188void main_pilote_icoco_2(
Probleme_U& pb_to_solve)
191 TRUST_set_library_mode(
false);
203 statistics().start_timeloop();
206 statistics().begin_count(STD_COUNTERS::timeloop);
222 cout <<
"Input Fields for " << pb_name <<
" :" << endl;
223 for (
unsigned i=0; i<sv.size(); i++)
224 std::cout << i <<
". " << sv[i] << std::endl;
232 afield.set_standalone();
234 nb_elems=afield._nb_elems;
236 assert(afield._nb_field_components==1);
237 assert(afield._space_dim==2);
238 for (
int i=0; i<nb_elems; i++)
242 for (
int j=0; j<afield._nodes_per_elem; j++)
244 int som=afield._connectivity[afield._nodes_per_elem*i+j];
245 x+=afield._coords[som*2];
246 y+=afield._coords[som*2+1];
248 x/=afield._nodes_per_elem;
249 y/=afield._nodes_per_elem;
250 afield._field[i]=(((x-0.5)*(x-0.5)+(y-0.5)*(y-0.5))<0.3*0.3)*10;
279 statistics().end_count(STD_COUNTERS::timeloop);
281 statistics().end_timeloop();
283 statistics().print_TU_files(
"Time loop statistics");
290void main_pilote_icoco_3(
Probleme_U& pb_to_solve,
int nb_pas_dt_reset)
293 TRUST_set_library_mode(
false);
306 statistics().start_timeloop();
309 statistics().begin_count(STD_COUNTERS::timeloop);
336 if (cnt >= nb_pas_dt_reset && !reset)
338 Cerr <<
"ABOUT TO RESET TIME !!\n";
340 Cerr <<
"RESET TIME DONE!!\n";
352 statistics().end_count(STD_COUNTERS::timeloop);
354 statistics().end_timeloop();
356 statistics().print_TU_files(
"Time loop statistics");
364void main_pilote_icoco_4(
Probleme_U& pb_to_solve,
int sortie_root_directory,
int nstep_stabilized,
int nb_pas_dt_reset)
367 TRUST_set_library_mode(
false);
377 assert(nstep_stabilized < nb_pas_dt_reset);
381 statistics().start_timeloop();
384 statistics().begin_count(STD_COUNTERS::timeloop);
412 if (cnt <= nstep_stabilized)
414 if (sortie_root_directory == 1)
416 else if (sortie_root_directory == 2)
421 if (cnt >= nb_pas_dt_reset && !reset)
423 if (sortie_root_directory == 1)
425 else if (sortie_root_directory == 2)
439 statistics().end_count(STD_COUNTERS::timeloop);
441 statistics().end_timeloop();
443 statistics().print_TU_files(
"Time loop statistics");
461 TRUST_set_library_mode(
false);
470 statistics().start_timeloop();
473 statistics().begin_count(STD_COUNTERS::timeloop);
496 afield.set_standalone();
497 nb_elems=afield._nb_elems;
498 for (
int i=0; i<nb_elems; i++)
499 afield._field[i]=600;
509 Cerr<<
" call of abortTimeStep" <<finl;
517 statistics().end_count(STD_COUNTERS::timeloop);
519 statistics().end_timeloop();
521 statistics().print_TU_files(
"Time loop statistics");
529 int nb_pas_dt_reset = 1000000000;
530 int nstep_stabilized = 0;
531 int sortie_root_directory = 0;
540 param.
ajouter(
"nb_pas_dt_reset",&nb_pas_dt_reset);
543 param.
ajouter(
"nstep_stabilized",&nstep_stabilized);
546 param.
ajouter(
"sortie_root_directory",&sortie_root_directory);
553 main_abort(pb_to_solve);
556 main_pilote_icoco_1(pb_to_solve);
559 main_pilote_icoco_2(pb_to_solve);
562 main_pilote_icoco_3(pb_to_solve, nb_pas_dt_reset);
565 main_pilote_icoco_4(pb_to_solve, sortie_root_directory, nstep_stabilized, nb_pas_dt_reset);
569 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.
Base class for "interpreter" objects.
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
class Nom: a character string for naming TRUST objects.
static bool disable_TU
Flag to disable or not the writing of the .TU files.
const Nom & que_suis_je() const
Returns the string identifying the class.
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
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.
class Pilote_ICoCo Example of driving TRUST via ICoCo in C++
Entree & interpreter(Entree &) override
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Base class for output streams.