Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Coupling Class Reference

#include <Coupling.h>

Inheritance diagram for Coupling:
Collaboration diagram for Coupling:

Public Member Functions

 Coupling (const char *coupl_name, const char *name, Control_parameters *p, const RocmanControl_parameters *mp)
 Constructor. Derived class will add actions for the coupling scheme. More...
 
 Coupling (const char *coupl_name, const char *fluidname, const char *solidname, Control_parameters *p, const RocmanControl_parameters *mp)
 
 Coupling (const char *coupl_name, const char *fluidname, const char *solidname, const char *burnname, Control_parameters *p, const RocmanControl_parameters *mp)
 
virtual ~Coupling ()
 Destructor. More...
 
const char * name ()
 
Agentadd_agent (Agent *)
 Add new agent. More...
 
void schedule ()
 Schedule the top-level actions of the coupling scheme and the actions of the agents. More...
 
void init (double t, double dt, int reinit=0)
 Invoke initialization of the actions in the scheduler and the agents. More...
 
void initialize (int reinit=0)
 
void finalize ()
 Invoke finalization of the actions in the scheduler and the agents. More...
 
double run (double t, double dt, int iPredCorr, double zoom)
 Invoke the scheduler. More...
 
void run_initactions (double t, double dt)
 
void input (double t)
 Invoke input functions of the agents. More...
 
int get_ipc () const
 
int get_max_ipc () const
 
int initial_start () const
 
int in_restart () const
 
int initial_remeshed () const
 true if in initialization step and remeshed is true More...
 
int new_start (double t) const
 
void init_convergence (int iPredCorr)
 
int check_convergence ()
 
virtual void update_integrals (double currentTime)
 
virtual void update_distances (double currentTime)
 
void output_restart_files (double t)
 
void output_visualization_files (double t)
 
const Control_parametersget_control_param ()
 
const RocmanControl_parametersget_rocmancontrol_param ()
 
void read_restart_info ()
 
void write_restart_info (double CurrentTime, int iStep)
 
void restart_at_time (double t, int step)
 
virtual void reload_rocface (const RocmanControl_parameters *param)
 
void print (const char *fname)
 
void Interrupt (int *, const char *)
 
int ProcessInterrupt ()
 

Protected Member Functions

void callMethod (Scheduler_voidfn1_t fn, double t)
 
std::string normalize_modname (const char *mod)
 

Protected Attributes

std::string coupling_name
 
vector< std::string > modules
 
AgentList agents
 
UserScheduler scheduler
 
UserScheduler init_scheduler
 
int comm_rank
 
int init_started
 
int restarting
 
int init_remeshed
 
int iPredCorr
 
int maxPredCorr
 
Control_parametersparam
 
const RocmanControl_parametersrocmanparam
 
std::string restartInfo
 
int overwrite_integ
 
std::string integFname
 
int overwrite_dist
 
std::string distFname
 

Private Member Functions

void baseInit ()
 

Detailed Description

Definition at line 97 of file Coupling.h.

Constructor & Destructor Documentation

Coupling ( const char *  coupl_name,
const char *  name,
Control_parameters p,
const RocmanControl_parameters mp 
)

Constructor. Derived class will add actions for the coupling scheme.

Definition at line 130 of file Coupling.C.

References baseInit(), and modules.

132  :
133  coupling_name(coupl_name), param(param_), rocmanparam(mp)
134 {
135  modules.push_back(name);
136  baseInit();
137 }
std::string coupling_name
Definition: Coupling.h:100
const RocmanControl_parameters * rocmanparam
Definition: Coupling.h:114
Control_parameters * param
Definition: Coupling.h:113
void baseInit()
Definition: Coupling.C:93
const char * name()
Definition: Coupling.h:135
vector< std::string > modules
Definition: Coupling.h:101

Here is the call graph for this function:

Coupling ( const char *  coupl_name,
const char *  fluidname,
const char *  solidname,
Control_parameters p,
const RocmanControl_parameters mp 
)

Definition at line 139 of file Coupling.C.

References baseInit(), and modules.

142  :
143  coupling_name(coupl_name), param(param_), rocmanparam(mp)
144 {
145  modules.push_back(fluidname);
146  modules.push_back(solidname);
147  baseInit();
148 }
std::string coupling_name
Definition: Coupling.h:100
const RocmanControl_parameters * rocmanparam
Definition: Coupling.h:114
Control_parameters * param
Definition: Coupling.h:113
void baseInit()
Definition: Coupling.C:93
vector< std::string > modules
Definition: Coupling.h:101

Here is the call graph for this function:

Coupling ( const char *  coupl_name,
const char *  fluidname,
const char *  solidname,
const char *  burnname,
Control_parameters p,
const RocmanControl_parameters mp 
)

Definition at line 150 of file Coupling.C.

References baseInit(), and modules.

153  :
154  coupling_name(coupl_name), param(param_), rocmanparam(mp)
155 {
156  modules.push_back(fluidname);
157  modules.push_back(solidname);
158  modules.push_back(burnname);
159  baseInit();
160 }
std::string coupling_name
Definition: Coupling.h:100
const RocmanControl_parameters * rocmanparam
Definition: Coupling.h:114
Control_parameters * param
Definition: Coupling.h:113
void baseInit()
Definition: Coupling.C:93
vector< std::string > modules
Definition: Coupling.h:101

Here is the call graph for this function:

~Coupling ( )
virtual

Destructor.

Definition at line 163 of file Coupling.C.

References agents, i, and n.

163  {
164  for ( int i=0, n=agents.size(); i<n; ++i) {
165  delete agents[i];
166  }
167  agents.clear();
168 }
AgentList agents
Definition: Coupling.h:102
blockLoc i
Definition: read.cpp:79
const NT & n

Member Function Documentation

Agent * add_agent ( Agent agent)

Add new agent.

Definition at line 174 of file Coupling.C.

References agents.

Referenced by FluidAlone::FluidAlone(), and FluidBurnAlone::FluidBurnAlone().

175 {
176  agents.push_back(agent);
177  return agent;
178 }
AgentList agents
Definition: Coupling.h:102

Here is the caller graph for this function:

void baseInit ( )
private

Definition at line 93 of file Coupling.C.

References COM_INT, COM_new_attribute(), COM_new_window(), COM_RAWDATA, COM_set_member_function(), COM_set_object(), COM_STRING, COM_VOID, comm_rank, COMMPI_Comm_rank(), Control_parameters::communicator, Control_parameters::current_time, distFname, cimg_library::cimg::fopen(), init_remeshed, init_started, integFname, Interrupt(), iPredCorr, overwrite_dist, overwrite_integ, param, RocmanControl_parameters::remeshed, restartInfo, restarting, and rocmanparam.

Referenced by Coupling().

94 {
95  iPredCorr = 0;
97  restarting = 0;
100  restartInfo = "Restart.txt";
101  integFname = "Rocman/Modout/GENX_integ.txt";
102  distFname = "Rocman/Modout/GENX_dist.txt";
104  if ( param->current_time != 0.0) {
105  FILE *fp = fopen(integFname.c_str(), "r");
106  if (!fp) overwrite_integ = 1;
107  fp = fopen(distFname.c_str(), "r");
108  if (!fp) overwrite_dist = 1;
109  }
110  else {
111  overwrite_integ = 1;
112  overwrite_dist = 1;
113  }
114  // experimental Interrupt
115  std::string manwinname = "Rocman";
116  std::string manfuncname = manwinname+".interrupt";
117  std::string coupobjname = manwinname+".coup";
118  COM_Type types[3];
119  types[0] = COM_RAWDATA;
120  types[1] = COM_INT;
121  types[2] = COM_STRING;
122  COM_new_window(manwinname);
123  COM_new_attribute(coupobjname, 'w',COM_VOID, 1, "");
124  COM_set_object(coupobjname.c_str(),0,this);
125  COM_set_member_function(manfuncname.c_str(),
126  (Member_func_ptr)&Coupling::Interrupt,
127  coupobjname.c_str(),"bii",types);
128 }
int COMMPI_Comm_rank(MPI_Comm c)
Definition: commpi.h:162
int COM_Type
Indices for derived data types.
Definition: roccom_basic.h:122
int iPredCorr
Definition: Coupling.h:110
std::string distFname
Definition: Coupling.h:123
int init_remeshed
Definition: Coupling.h:108
MPI_Comm communicator
Definition: Coupling.h:51
void COM_set_object(const char *wa_str, int pane_id, Type *addr)
Definition: roccom_c++.h:144
const RocmanControl_parameters * rocmanparam
Definition: Coupling.h:114
std::string integFname
Definition: Coupling.h:120
Control_parameters * param
Definition: Coupling.h:113
void Interrupt(int *, const char *)
Definition: Coupling.C:480
std::string restartInfo
Definition: Coupling.h:116
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Definition: roccom_c++.h:86
double current_time
Definition: Coupling.h:54
int comm_rank
Definition: Coupling.h:105
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
Definition: roccom_c++.h:118
void COM_set_member_function(const char *wf_str, Member_func_ptr func, const char *wa_str, const char *intents, const COM_Type *types)
Definition: roccom_c++.h:330
int overwrite_dist
Definition: Coupling.h:122
int init_started
Definition: Coupling.h:106
int overwrite_integ
Definition: Coupling.h:119
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
int restarting
Definition: Coupling.h:107

Here is the call graph for this function:

Here is the caller graph for this function:

void callMethod ( Scheduler_voidfn1_t  fn,
double  t 
)
protected

Definition at line 217 of file Coupling.C.

References agents, i, init_scheduler, n, and scheduler.

Referenced by init().

218 {
219  int i, n;
220 
221  (init_scheduler.*fn)( t);
222 
223  for ( i=0, n=agents.size(); i<n; ++i)
224  agents[i]->callMethod(fn, t);
225 
226  (scheduler.*fn)( t);
227 }
AgentList agents
Definition: Coupling.h:102
blockLoc i
Definition: read.cpp:79
UserScheduler init_scheduler
Definition: Coupling.h:104
const NT & n
void callMethod(Scheduler_voidfn1_t fn, double t)
Definition: Coupling.C:217
UserScheduler scheduler
Definition: Coupling.h:103

Here is the caller graph for this function:

int check_convergence ( )

Definition at line 284 of file Coupling.C.

References agents, i, maxPredCorr, n, param, Control_parameters::tolerMass, Control_parameters::tolerTract, and Control_parameters::tolerVelo.

Referenced by rocstar_driver().

285 {
286  int InterfaceConverged;
287  if ( maxPredCorr>1) {
288  InterfaceConverged = 0;
289  for ( int i=0, n=agents.size(); i<n; ++i)
290  if (!agents[i]->check_convergence( param->tolerMass, param->tolerTract, param->tolerVelo)) return InterfaceConverged;
291  InterfaceConverged = 1;
292  }
293  else
294  InterfaceConverged = 1;
295  return InterfaceConverged;
296 }
AgentList agents
Definition: Coupling.h:102
int check_convergence()
Definition: Coupling.C:284
double tolerTract
Definition: Coupling.h:66
int maxPredCorr
Definition: Coupling.h:111
double tolerMass
Definition: Coupling.h:68
Control_parameters * param
Definition: Coupling.h:113
double tolerVelo
Definition: Coupling.h:67
blockLoc i
Definition: read.cpp:79
const NT & n

Here is the caller graph for this function:

void finalize ( )

Invoke finalization of the actions in the scheduler and the agents.

Definition at line 230 of file Coupling.C.

References agents, Scheduler::finalize_actions(), i, init_scheduler, n, and scheduler.

Referenced by Interrupt(), restart_at_time(), and rocstar_driver().

230  {
233 
234  for ( int i=0, n=agents.size(); i<n; ++i)
235  agents[i]->finalize();
236 }
AgentList agents
Definition: Coupling.h:102
blockLoc i
Definition: read.cpp:79
UserScheduler init_scheduler
Definition: Coupling.h:104
const NT & n
void finalize_actions()
Definition: Scheduler.C:351
void finalize()
Invoke finalization of the actions in the scheduler and the agents.
Definition: Coupling.C:230
UserScheduler scheduler
Definition: Coupling.h:103

Here is the call graph for this function:

Here is the caller graph for this function:

const Control_parameters* get_control_param ( )
inline

Definition at line 183 of file Coupling.h.

Referenced by _load_rocface(), Agent::Agent(), BurnAgent::BurnAgent(), FluidBurnAlone::FluidBurnAlone(), restart_at_time(), and CopyBflagFromBurn::run().

183 { return param; }
Control_parameters * param
Definition: Coupling.h:113

Here is the caller graph for this function:

int get_ipc ( ) const
inline

Definition at line 160 of file Coupling.h.

Referenced by Extrapolate_Linear::run(), Extrapolate_Central::run(), and PhysicsAction::run().

160 { return iPredCorr; }
int iPredCorr
Definition: Coupling.h:110

Here is the caller graph for this function:

int get_max_ipc ( ) const
inline

Definition at line 161 of file Coupling.h.

Referenced by BurnAgent::create_buffer_all(), FluidAgent::create_buffer_all(), SolidAgent::create_buffer_all(), FluidAgent::finalize(), BurnAgent::finalize(), and SolidAgent::finalize().

161 { return maxPredCorr; }
int maxPredCorr
Definition: Coupling.h:111

Here is the caller graph for this function:

int in_restart ( ) const
inline

Definition at line 164 of file Coupling.h.

Referenced by BurnAgent::unload_module(), FluidAgent::unload_module(), and SolidAgent::unload_module().

164 { return restarting; }
int restarting
Definition: Coupling.h:107

Here is the caller graph for this function:

void init ( double  t,
double  dt,
int  reinit = 0 
)

Invoke initialization of the actions in the scheduler and the agents.

Definition at line 191 of file Coupling.C.

References agents, callMethod(), i, Scheduler::init_actions(), FluidAgent::init_module(), n, and Scheduler::restarting().

Referenced by initialize().

191  {
192  int i, n;
193 
194 #if 0
195  for ( i=0, n=agents.size(); i<n; ++i)
196  agents[i]->init_module( t);
197 
198  for ( i=0, n=agents.size(); i<n; ++i)
199  agents[i]->init_buffers( t);
200 #else
201 // void _load_rocface(FluidAgent *fagent, SolidAgent *sagent, const RocmanControl_parameters *param);
202  for ( i=0, n=agents.size(); i<n; ++i) {
203 // if (i==2) _load_rocface(agents[0], agents[1], rocmanparam);
204  agents[i]->init_module( t, dt);
205 // agents[i]->init_buffers( t);
206  }
207 #endif
208 
209  // in warm restart, reset scheduler so that it can be re-inited
210  if (reinit)
212 
214 }
AgentList agents
Definition: Coupling.h:102
blockLoc i
Definition: read.cpp:79
const NT & n
void restarting(double t)
Definition: Scheduler.h:41
void callMethod(Scheduler_voidfn1_t fn, double t)
Definition: Coupling.C:217
void init_actions(double t)
Definition: Scheduler.C:324

Here is the call graph for this function:

Here is the caller graph for this function:

void init_convergence ( int  iPredCorr)

Definition at line 275 of file Coupling.C.

References agents, i, maxPredCorr, and n.

Referenced by rocstar_driver().

276 {
277  if ( maxPredCorr>1 && iPredCorr > 0) {
278  for ( int i=0, n=agents.size(); i<n; ++i) {
279  agents[i]->init_convergence( iPredCorr);
280  }
281  }
282 }
int iPredCorr
Definition: Coupling.h:110
AgentList agents
Definition: Coupling.h:102
int maxPredCorr
Definition: Coupling.h:111
blockLoc i
Definition: read.cpp:79
const NT & n

Here is the caller graph for this function:

int initial_remeshed ( ) const
inline

true if in initialization step and remeshed is true

Definition at line 167 of file Coupling.h.

167 { return init_remeshed; }
int init_remeshed
Definition: Coupling.h:108
int initial_start ( ) const
inline

Definition at line 163 of file Coupling.h.

Referenced by FluidBurnAlone::FluidBurnAlone(), BurnAgent::init_module(), MeshMotionTransfer_SF::run(), TransferSolidDensity::run(), CopyBflagFromBurn::run(), and SolidPropagateSurface_ALE::run().

163 { return init_started; }
int init_started
Definition: Coupling.h:106

Here is the caller graph for this function:

void initialize ( int  reinit = 0)

Definition at line 355 of file Coupling.C.

References Control_parameters::current_time, init(), input(), param, reload_rocface(), rocmanparam, run_initactions(), and Control_parameters::time_step.

Referenced by restart_at_time(), and rocstar_driver().

356 {
357  // invoke input of coupling object (Input of initial data of physics modules)
359 
360  // invoke initialization of coupling object, load modules
361  init( param->current_time, param->time_step, reinit);
362 
363  // reset rocface if restart
364  if (reinit)
366 
367  // initialize each modules by executing init schedulers
369 }
double time_step
Definition: Coupling.h:55
void input(double t)
Invoke input functions of the agents.
Definition: Coupling.C:269
const RocmanControl_parameters * rocmanparam
Definition: Coupling.h:114
void init(double t, double dt, int reinit=0)
Invoke initialization of the actions in the scheduler and the agents.
Definition: Coupling.C:191
Control_parameters * param
Definition: Coupling.h:113
void run_initactions(double t, double dt)
Definition: Coupling.C:258
double current_time
Definition: Coupling.h:54
virtual void reload_rocface(const RocmanControl_parameters *param)
Definition: Coupling.h:190

Here is the call graph for this function:

Here is the caller graph for this function:

void input ( double  t)

Invoke input functions of the agents.

Definition at line 269 of file Coupling.C.

References agents, i, and n.

Referenced by initialize().

269  {
270  for ( int i=0, n=agents.size(); i<n; ++i) {
271  agents[i]->input( t);
272  }
273 }
AgentList agents
Definition: Coupling.h:102
blockLoc i
Definition: read.cpp:79
const NT & n

Here is the caller graph for this function:

void Interrupt ( int *  act,
const char *  message 
)

Definition at line 480 of file Coupling.C.

References Agent::action, Control_parameters::cur_step, Control_parameters::current_time, finalize(), Control_parameters::InterruptFlag, Control_parameters::LastOutputStep, Control_parameters::LastOutputTime, MAN_DEBUG, Control_parameters::myRank, output_restart_files(), param, RocstarShutdown(), and write_restart_info().

Referenced by baseInit(), and check_for_interrupt().

481 {
482  int action = *act;
483  if(!param->myRank){
484  std::cout << "Rocstar::Interrupt invoked." << std::endl
485  << "Rocstar: ***************************************************"
486  << std::endl
487  << "Rocstar: " << (message ? message : "") << std::endl
488  << "Rocstar: ***************************************************"
489  << std::endl;
490  }
491  switch(action){
492  case 0:
493  // Just stop
494  if(!param->myRank)
495  std::cout << "Rocstar: Halting simulation." << std::endl;
496  finalize();
497  RocstarShutdown();
498  break;
499  case 1:
500  // Output solutions and stop.
501  if(!param->myRank)
502  std::cout << "Rocstar: Writing restart files and halting simulation."
503  << std::endl;
505  finalize();
506  RocstarShutdown();
507  break;
508  case 2:
509  //
510  // Restart from last restart dump and increase the output
511  // frequency for debugging.
512  //
513  // 0. Call warm restart function to junk current data, and
514  // re-initialize with last successful solution dump
515  // 1. Reset the max number of timesteps and output interval
516  // 2. Code will stop and dump a soln when it reaches the step just prior
517  // to this one
518  //
519  if(!param->myRank){
520  std::cout << "Rocstar: Directed to warm restart from last dump "
521  << "and increase dump frequency." << std::endl;
522  }
523  param->InterruptFlag = 2;
524  break;
525  case 3:
526  if(!param->myRank)
527  std::cout << "Rocstar: Directed to remesh and warm restart from "
528  << "(time/step): ("
529  << param->LastOutputTime << "," << param->LastOutputStep
530  << ")" << std::endl;
531  param->InterruptFlag = 3;
532  break;
533  case 4:
534  if(!param->myRank)
535  std::cout << "Rocstar: Directed to restart from "
536  << "(time/step): (" << param->LastOutputTime << ","
537  << param->LastOutputStep << ")" << std::endl;
538  if(message)
539  std::cout << "MESSAGE: " << message << std::endl;
540  param->InterruptFlag = 4;
541  break;
542  case 5:
543  if(!param->myRank)
544  std::cout << "Rocstar: Directed to dump at (time/step): ("
545  << param->current_time << "," << param->cur_step
546  << ")" << std::endl;
549  break;
550  case 6:
551  if(!param->myRank)
552  std::cout << "Rocstar: Directed to dump and restart at (time/step): ("
553  << param->current_time << "," << param->cur_step
554  << ")" << std::endl;
557  if(message)
558  std::cout << "MESSAGE: " << message << std::endl;
559  param->InterruptFlag = 4;
560  break;
561  default:
562  if(param->myRank == 0)
563  std::cout << "Rocstar: Unknown interrupt action." << std::endl;
564  MAN_DEBUG(0,("Rocstar: Coupling::Interrupt(unknown action): %s.\n",
565  message));
566  return;
567  }
568 }
void write_restart_info(double CurrentTime, int iStep)
Definition: Coupling.C:337
void RocstarShutdown(int=0)
Control_parameters * param
Definition: Coupling.h:113
double LastOutputTime
Definition: Coupling.h:76
void output_restart_files(double t)
Definition: Coupling.C:299
#define MAN_DEBUG(l, x)
Definition: rocman.h:98
double current_time
Definition: Coupling.h:54
void finalize()
Invoke finalization of the actions in the scheduler and the agents.
Definition: Coupling.C:230

Here is the call graph for this function:

Here is the caller graph for this function:

const char* name ( )
inline

Definition at line 135 of file Coupling.h.

Referenced by run_initactions().

135 { return coupling_name.c_str(); }
std::string coupling_name
Definition: Coupling.h:100

Here is the caller graph for this function:

int new_start ( double  t) const

Definition at line 170 of file Coupling.C.

References Control_parameters::init_time, param, RocmanControl_parameters::remeshed, and rocmanparam.

Referenced by Extrapolate_Linear::run(), Extrapolate_Central::run(), Interpolate_Linear::run(), and Interpolate_Central::run().

170  {
171  return t==0.0 || (rocmanparam->remeshed && t == param->init_time);
172 }
double init_time
Definition: Coupling.h:53
const RocmanControl_parameters * rocmanparam
Definition: Coupling.h:114
Control_parameters * param
Definition: Coupling.h:113

Here is the caller graph for this function:

std::string normalize_modname ( const char *  mod)
protected

Definition at line 464 of file Coupling.C.

References cimg_library::cimg::mod().

465 {
466  std::string mod = modname;
467  if (mod == "RocfluDummy")
468  return "Rocflu";
469  if (mod == "RocfloDummy")
470  return "Rocflo";
471  if (mod == "RocfracDummy")
472  return "Rocfrac";
473  if (mod == "RocsolidDummy")
474  return "Rocsolid";
475  return mod;
476 }
T mod(const T &x, const T &m)
Return the modulo of a number.
Definition: CImg.h:4788

Here is the call graph for this function:

void output_restart_files ( double  t)

Definition at line 299 of file Coupling.C.

References agents, i, and n.

Referenced by Interrupt(), and rocstar_driver().

299  {
300  for ( int i=0, n=agents.size(); i<n; ++i) {
301  agents[i]->output_restart_files( t);
302  }
303 }
AgentList agents
Definition: Coupling.h:102
blockLoc i
Definition: read.cpp:79
const NT & n

Here is the caller graph for this function:

void output_visualization_files ( double  t)

Definition at line 306 of file Coupling.C.

References agents, i, and n.

Referenced by rocstar_driver().

306  {
307  for ( int i=0, n=agents.size(); i<n; ++i) {
308  agents[i]->output_visualization_files( t);
309  }
310 }
AgentList agents
Definition: Coupling.h:102
blockLoc i
Definition: read.cpp:79
const NT & n

Here is the caller graph for this function:

void print ( const char *  fname)

Definition at line 436 of file Coupling.C.

References agents, cimg_library::cimg::fclose(), cimg_library::cimg::fopen(), Agent::get_agent_name(), and i.

437 {
438  FILE *f = fopen(fname, "w");
439 
440  fprintf(f, "graph: { title: \"Coupling\" \n\
441  display_edge_labels: yes \n\
442  layoutalgorithm: tree \n\
443  scaling: maxspect \n\
444  node.color : green \n\
445  node.textcolor : black \n\
446  node.bordercolor: black \n\
447  node.borderwidth: 1 \n\
448  edge.color : blue \n\
449  edge.arrowsize : 7 \n\
450  edge.thickness : 2 \n\
451  edge.fontname:\"helvO08\" \n\
452  node.label: \"no type\" \n");
453 
454 // scheduler.print(f, name());
455  for (unsigned int i=0; i<agents.size(); i++) {
456  agents[i]->print(f);
457  if (i>0) fprintf(f, "edge: { sourcename: \"%s\" targetname: \"%s\" label: \"\"}\n", agents[i-1]->get_agent_name().c_str(), agents[i]->get_agent_name().c_str());
458  }
459 
460  fprintf(f, "} \n");
461  fclose(f);
462 }
AgentList agents
Definition: Coupling.h:102
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
blockLoc i
Definition: read.cpp:79
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the call graph for this function:

int ProcessInterrupt ( )

Definition at line 572 of file Coupling.C.

References Agent::action, agents, Control_parameters::cur_step, Control_parameters::current_time, i, Control_parameters::InterruptFlag, Control_parameters::LastOutputStep, Control_parameters::LastOutputTime, Control_parameters::maxNumTimeSteps, MPI_COMM_WORLD, Control_parameters::myRank, n, Control_parameters::outputIntervalTime, param, restart_at_time(), RocstarShutdown(), and x.

Referenced by rocstar_driver().

573 {
574  int save_step = 0;
575  bool done = false;
576  int fluid_agent_index = 0;
577  int action = param->InterruptFlag;
578  param->InterruptFlag = 0;
579  if(action > 0){
580  if(param->myRank == 0)
581  std::cout << "Rocstar: Processing interrupt." << std::endl;
582  switch(action){
583  case 2:
584  save_step = param->cur_step;
586  param->maxNumTimeSteps = save_step;
587  param->outputIntervalTime /= 10.0;
588  if(!param->myRank){
589  std::cout << "Rocstar: Restarting from (time/step): ("
590  << param->current_time << "," << param->cur_step
591  << ") with output"
592  << " interval, " << param->outputIntervalTime << "."
593  << std::endl;
594  }
595  return(1);
596  break;
597  case 3:
598  for(int i = 0,n=agents.size();i<n && !done;n++){
599  std::string::size_type x = agents[i]->get_agent_name().find("lu");
600  if( x != string::npos){
601  fluid_agent_index = i;
602  done = true;
603  }
604  }
605  if(!done){
606  std::cerr << "Rocstar: Could not find fluid agent. Dying."
607  << std::endl;
608  RocstarShutdown(1);
609  }
610  // char* solver: Path to Rocout directory (i.e. blah/blah/Rocflu)
611  // double time: timestep to read
612  // bool use_parallel_transfer
613  // bool remesh_surf: true=remesh surface false=leave surface alone
614  // bool transfer_surf: true (only valid if remesh_surf = false)
615  // double scaleFactor: scale mesh granularity
616  // int fieldWidth: digits in filename partition id
617  // int fileBase: 0 is partition ids start at 0, 1 otherwise
618  // int debug: 0=off, 1 = some, more = more
619  // int ngLayers: number of ghost layers; 0-9
620  // returns 1 if success; 0 if fail
621  // Rocrem_remesh(const char* solver, double time, bool remesh_surf,
622  // bool transfer_surf, double scaleFactor, MPI_Comm myComm,
623  // int fieldWidth, int fileBase, int debug, int ngLayers)
624  //
625  // Remeshing test case
626  //
627 #ifdef ARM
628  if(!Rocrem_remesh("Rocflu","Rocout","",param->LastOutputTime,true,true,false,1.0,
629  agents[fluid_agent_index]->get_communicator(),
630  4,0,2,2)){
631  if(!param->myRank)
632  std::cerr << "Rocstar: Remeshing failed. Stopping simulation."
633  << std::endl;
634  RocstarShutdown(1);
635  }
636 #else
637  if(!param->myRank){
638  // std::ofstream Ouf;
639  // Ouf.open("needs_remesh");
640  // Ouf.close();
641  std::cerr << "Rocstar: Online remeshing not enabled. Shutting down." << std::endl;
642  }
643  RocstarShutdown(1);
644 #endif
645  MPI_Barrier(MPI_COMM_WORLD);
647  MPI_Barrier(MPI_COMM_WORLD);
648  if(!param->myRank)
649  std::cout << "Rocstar: Restarting after remesh at (time/step): ("
650  << param->current_time << "," << param->cur_step << ")"
651  << std::endl;
652  return(1);
653  break;
654  case 4:
655  MPI_Barrier(MPI_COMM_WORLD);
657  MPI_Barrier(MPI_COMM_WORLD);
658  if(!param->myRank)
659  std::cout << "Rocstar: Warm restarting at (time/step): ("
660  << param->current_time << "," << param->cur_step << ")"
661  << std::endl;
662  return(1);
663  break;
664  default:
665  if(!param->myRank)
666  std::cout << "Rocstar: Unknown interrupt action: " << action << "."
667  << std::endl;
668  return(0);
669  break;
670  }
671  }
672  return(0);
673 }
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_WORLD
AgentList agents
Definition: Coupling.h:102
void RocstarShutdown(int=0)
void restart_at_time(double t, int step)
Definition: Coupling.C:372
Control_parameters * param
Definition: Coupling.h:113
double LastOutputTime
Definition: Coupling.h:76
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
const NT & n
double current_time
Definition: Coupling.h:54
double outputIntervalTime
Definition: Coupling.h:63

Here is the call graph for this function:

Here is the caller graph for this function:

void read_restart_info ( )

Definition at line 313 of file Coupling.C.

References comm_rank, Control_parameters::current_time, cimg_library::cimg::fclose(), cimg_library::cimg::fopen(), MAN_DEBUG, MPI_COMM_WORLD, param, restartInfo, and Control_parameters::update_start_time().

Referenced by rocstar_driver().

314 {
315  if (param->current_time != 0.0) {
316  FILE *fp = fopen(restartInfo.c_str(), "r");
317  if (fp == NULL) {
318  std::cerr << "Rocstar: Error: READ_RESTART: Failed to read file " << restartInfo << std::endl;
319  MPI_Abort( MPI_COMM_WORLD, -1);
320  }
321  int curStep;
322  double initialTime;
323  while (!feof(fp)) {
324  fscanf(fp, "%d %le", &curStep, &initialTime);
325  }
326  fclose(fp);
327  if (comm_rank == 0)
328  MAN_DEBUG(1,("Rocstar: This run is a restart continued at iteration %d with initial time %f.",curStep, initialTime));
329  param->update_start_time(curStep - 1, initialTime); // subtle - it starts from 0
330  }
331  else {
332  if (comm_rank == 0)
333  MAN_DEBUG(2,("Rocstar: This run is not a restart.\n"));
334  }
335 }
void update_start_time(int step, double t)
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_WORLD
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
Control_parameters * param
Definition: Coupling.h:113
std::string restartInfo
Definition: Coupling.h:116
#define MAN_DEBUG(l, x)
Definition: rocman.h:98
double current_time
Definition: Coupling.h:54
int comm_rank
Definition: Coupling.h:105
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void reload_rocface ( const RocmanControl_parameters param)
inlinevirtual

Reimplemented in FullyCoupling.

Definition at line 190 of file Coupling.h.

Referenced by initialize().

190 {}

Here is the caller graph for this function:

void restart_at_time ( double  t,
int  step 
)

Definition at line 372 of file Coupling.C.

References agents, COM_get_window_handle(), COM_UNLOAD_MODULE_STATIC_DYNAMIC, comm_rank, Agent::communicator, finalize(), get_control_param(), i, initialize(), MAN_DEBUG, n, param, restarting, cimg_library::cimg::system(), and Control_parameters::update_start_time().

Referenced by ProcessInterrupt(), and rocstar_driver().

373 {
374  int i, n;
375 
376  MAN_DEBUG(3, ("Rocstar: Coupling::restart_at_time with t: %f step:%d.\n", t, step));
377 
378 #if 0
379  // HACK
380  system("rm RocburnAPN/Rocout/*");
381  if (comm_rank == 0) {
382  system("rm RocburnAPN/Rocout/*");
383  }
384  MPI_Barrier(get_control_param()->communicator);
385 #endif
386 
387  restarting = 1;
388 
389  // reset windows and buffers
390  finalize();
391 
392  // unload modules, only call unload to zero out data, skip dlclose
393  for ( i=0, n=agents.size(); i<n; ++i) {
394  agents[i]->unload_module();
395  }
396 
397  if (COM_get_window_handle("RFC") > 0) {
398  COM_UNLOAD_MODULE_STATIC_DYNAMIC( Rocface, "RFC");
399  }
400  if (COM_get_window_handle("SURF") > 0) {
402  }
403  if (COM_get_window_handle("PROP") > 0) {
405  }
406  if (COM_get_window_handle("PROPCON") > 0) {
408  }
409  if (COM_get_window_handle("BLAS") > 0) {
411  }
412  if (COM_get_window_handle("MAP") > 0) {
413  COM_UNLOAD_MODULE_STATIC_DYNAMIC(Rocmap,"MAP");
414  }
415  // update to given time
416  param->update_start_time( step, t);
417 
418  // load module and call physics routine
419  for ( i=0, n=agents.size(); i<n; ++i) {
420  agents[i]->load_module();
421  }
422 
423  // proceed to initialization phase
424  initialize(1); // reinit
425 
426 /*
427  // read restart data
428  for ( i=0, n=agents.size(); i<n; ++i) {
429  agents[i]->read_restart_data();
430  }
431 */
432  restarting = 0;
433 }
void update_start_time(int step, double t)
AgentList agents
Definition: Coupling.h:102
Control_parameters * param
Definition: Coupling.h:113
#define COM_UNLOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:113
blockLoc i
Definition: read.cpp:79
const NT & n
int system(const char *const command, const char *const module_name=0)
Definition: CImg.h:4491
int COM_get_window_handle(const char *wname)
Definition: roccom_c++.h:404
#define MAN_DEBUG(l, x)
Definition: rocman.h:98
int comm_rank
Definition: Coupling.h:105
Definition: Rocon.H:61
void finalize()
Invoke finalization of the actions in the scheduler and the agents.
Definition: Coupling.C:230
const Control_parameters * get_control_param()
Definition: Coupling.h:183
void initialize(int reinit=0)
Definition: Coupling.C:355
int restarting
Definition: Coupling.h:107

Here is the call graph for this function:

Here is the caller graph for this function:

double run ( double  t,
double  dt,
int  iPredCorr,
double  zoom 
)

Invoke the scheduler.

Definition at line 238 of file Coupling.C.

References agents, comm_rank, i, iPredCorr, MAN_DEBUG, Agent::max_timestep(), min(), n, Scheduler::run_actions(), and scheduler.

Referenced by rocstar_driver().

239 {
240  iPredCorr = pred;
241 
242  // Change dt to the maximum time setp allowed.
243  for ( int i=0, n=agents.size(); i<n; ++i) {
244  dt = std::min( dt, agents[i]->max_timestep(t, dt));
245  }
246 
247  MAN_DEBUG(3, ("[%d] Rocstar: Coupling::run with t: %f dt: %f.\n", comm_rank, t, dt));
248 
249  scheduler.run_actions( t, dt);
250 
251  // Return the new time as t + dt
252  if (zoom > 0.0)
253  return t + dt*zoom;
254  else
255  return t + dt;
256 }
int iPredCorr
Definition: Coupling.h:110
AgentList agents
Definition: Coupling.h:102
blockLoc i
Definition: read.cpp:79
const NT & n
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
#define MAN_DEBUG(l, x)
Definition: rocman.h:98
int comm_rank
Definition: Coupling.h:105
UserScheduler scheduler
Definition: Coupling.h:103
void run_actions(double t, double dt)
Definition: Scheduler.C:339

Here is the call graph for this function:

Here is the caller graph for this function:

void run_initactions ( double  t,
double  dt 
)

Definition at line 258 of file Coupling.C.

References comm_rank, init_remeshed, init_scheduler, init_started, MAN_DEBUG, name(), Scheduler::run_actions(), and Scheduler::set_alpha().

Referenced by initialize().

259 {
260  MAN_DEBUG(3, ("[%d] Rocstar: %s::run_initactions called with t:%e dt:%e.\n", comm_rank, name(), t, dt));
262  init_scheduler.run_actions( t, dt);
263 
264  init_started = 0;
265  init_remeshed = 0;
266 }
int init_remeshed
Definition: Coupling.h:108
void set_alpha(double alpha)
Definition: Scheduler.h:44
UserScheduler init_scheduler
Definition: Coupling.h:104
#define MAN_DEBUG(l, x)
Definition: rocman.h:98
int comm_rank
Definition: Coupling.h:105
const char * name()
Definition: Coupling.h:135
int init_started
Definition: Coupling.h:106
void run_actions(double t, double dt)
Definition: Scheduler.C:339

Here is the call graph for this function:

Here is the caller graph for this function:

void schedule ( )

Schedule the top-level actions of the coupling scheme and the actions of the agents.

Definition at line 181 of file Coupling.C.

References agents, i, init_scheduler, n, UserScheduler::schedule(), and scheduler.

Referenced by rocstar_driver().

181  {
184 
185  for ( int i=0, n=agents.size(); i<n; ++i) {
186  agents[i]->schedule();
187  }
188 }
AgentList agents
Definition: Coupling.h:102
virtual void schedule()
Definition: Scheduler.C:408
blockLoc i
Definition: read.cpp:79
UserScheduler init_scheduler
Definition: Coupling.h:104
const NT & n
UserScheduler scheduler
Definition: Coupling.h:103

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void update_distances ( double  currentTime)
inlinevirtual

Reimplemented in FullyCoupling.

Definition at line 175 of file Coupling.h.

Referenced by rocstar_driver().

175 {}

Here is the caller graph for this function:

virtual void update_integrals ( double  currentTime)
inlinevirtual

Reimplemented in FullyCoupling.

Definition at line 174 of file Coupling.h.

Referenced by rocstar_driver().

174 {}

Here is the caller graph for this function:

void write_restart_info ( double  CurrentTime,
int  iStep 
)

Definition at line 337 of file Coupling.C.

References comm_rank, cimg_library::cimg::fclose(), cimg_library::cimg::fopen(), MPI_COMM_WORLD, and restartInfo.

Referenced by Interrupt(), and rocstar_driver().

338 {
339  FILE *fp;
340  if ( comm_rank == 0 ) {
341  if ( CurrentTime == 0.0)
342  fp = fopen(restartInfo.c_str(), "w");
343  else
344  fp = fopen(restartInfo.c_str(), "a");
345  if (fp == NULL) {
346  std::cerr << "Rocstar: Error: Failed to open restart info file, "
347  << restartInfo << "." << std::endl;
348  MPI_Abort( MPI_COMM_WORLD, -1);
349  }
350  fprintf( fp, "%d %.20le \n", iStep, CurrentTime);
351  fclose( fp);
352  }
353 }
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_WORLD
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
std::string restartInfo
Definition: Coupling.h:116
int comm_rank
Definition: Coupling.h:105
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

std::string coupling_name
protected

Definition at line 100 of file Coupling.h.

std::string distFname
protected

Definition at line 123 of file Coupling.h.

Referenced by baseInit(), and FullyCoupling::update_distances().

int init_remeshed
protected

Definition at line 108 of file Coupling.h.

Referenced by baseInit(), and run_initactions().

UserScheduler init_scheduler
protected
int init_started
protected

Definition at line 106 of file Coupling.h.

Referenced by baseInit(), and run_initactions().

std::string integFname
protected

Definition at line 120 of file Coupling.h.

Referenced by baseInit(), and FullyCoupling::update_integrals().

int iPredCorr
protected

Definition at line 110 of file Coupling.h.

Referenced by baseInit(), and run().

int maxPredCorr
protected
vector<std::string> modules
protected

Definition at line 101 of file Coupling.h.

Referenced by Coupling().

int overwrite_dist
protected

Definition at line 122 of file Coupling.h.

Referenced by baseInit(), and FullyCoupling::update_distances().

int overwrite_integ
protected

Definition at line 119 of file Coupling.h.

Referenced by baseInit(), and FullyCoupling::update_integrals().

std::string restartInfo
protected

Definition at line 116 of file Coupling.h.

Referenced by baseInit(), read_restart_info(), and write_restart_info().

int restarting
protected

Definition at line 107 of file Coupling.h.

Referenced by baseInit(), and restart_at_time().

const RocmanControl_parameters* rocmanparam
protected

Definition at line 114 of file Coupling.h.

Referenced by baseInit(), initialize(), and new_start().

UserScheduler scheduler
protected

The documentation for this class was generated from the following files: