34 #include <sys/types.h>
64 Rocprof_Finalize(
true);
78 Inf.open(restart_file.c_str());
82 Inf >> curStep >> curTime;
85 FILE *fp =
fopen(restart_file.c_str(),
"r");
86 if (fp == NULL)
return 0.0;
88 fscanf(fp,
"%d %le", &curStep, &curTime);
98 if ( name ==
"FluidAlone")
100 else if ( name ==
"FluidBurnAlone")
102 else if ( name ==
"SolidAlone")
104 else if ( name ==
"SolidBurn")
106 else if ( name ==
"SolidFluidSPC")
108 else if ( name ==
"FluidSolidISS")
110 else if ( name ==
"SolidFluidBurnSPC")
112 else if ( name ==
"SolidFluidBurnEnergySPC")
114 else if ( name ==
"Test" || name.empty()){
126 std::cerr <<
"Rocstar: ERROR: Unknown coupling scheme: " << name << std::endl;
127 std::cerr << std::endl;
128 std::cerr <<
"Rocstar: Rocstar Supported coupling schemes: " << std::endl;
129 std::cerr <<
"Rocstar: FluidAlone: Fluid alone with no burn" << std::endl;
130 std::cerr <<
"Rocstar: FluidBurnAlone: Fluid alone with burn" << std::endl;
131 std::cerr <<
"Rocstar: SolidAlone: Solid alone with no burn" << std::endl;
132 std::cerr <<
"Rocstar: SolidFluidBurnSPC: FullyCoupled simple staggered scheme with P-C" << std::endl;
133 std::cerr <<
"Rocstar: SolidFluidSPC: FullyCoupled no burn" << std::endl;
134 std::cerr <<
"Rocstar: FluidSolidISS: FullyCoupled no burn with improved staggered scheme" << std::endl;
135 std::cerr <<
"Rocstar: SolidFluidBurnEnergySPC: FullyCoupled with burn energy" << std::endl;
141 #define COM_DOUBLE_ATTRIBUTE(attrname, varname) \
142 attr = winname+"."+attrname; \
143 COM_new_attribute( attr.c_str(),'w',COM_DOUBLE,1,""); \
144 COM_set_size( attr.c_str(),0,1); \
145 COM_set_array( attr.c_str(),0, &varname);
147 #define COM_INT_ATTRIBUTE(attrname, varname) \
148 attr = winname+"."+attrname; \
149 COM_new_attribute( attr.c_str(),'w',COM_INT,1,""); \
150 COM_set_size( attr.c_str(),0,1); \
151 COM_set_array( attr.c_str(),0, &varname);
153 #define COM_STRING_ATTRIBUTE(attrname, varname) \
154 attr = winname+"."+attrname; \
155 COM_new_attribute( attr.c_str(),'w',COM_CHAR,1,""); \
156 COM_set_size( attr.c_str(),0,MAXLEN); \
157 COM_set_array( attr.c_str(),0,varname,MAXLEN);
159 #define COM_BOOL_ATTRIBUTE(attrname, varname) \
160 attr = winname+"."+attrname; \
161 COM_new_attribute( attr.c_str(),'w',COM_BOOL,1,""); \
162 COM_set_size( attr.c_str(),0,1); \
163 COM_set_array( attr.c_str(),0,&varname);
192 string winname =
"RocmanParam";
256 if (outputModule ==
"Rocout") {
261 else if (outputModule ==
"Rocpanda") {
269 printf(
"Rocstar: Error: Unknown output module %s!\n",
output_module);
298 printf(
"================ Rocstar Control file ================\n");
301 printf(
"Rocstar: MaximumTime: %f\n",
simue_time);
303 printf(
"Rocstar: AutoRestart: %s\n",(
AutoRestart ?
"Yes" :
"No"));
307 printf(
"Rocstar: MaxNumOutputDumps: %d\n",
maxNumDumps);
308 printf(
"Rocstar: CurrentTimeStep: %e\n",
time_step);
310 printf(
"Rocstar: ZoomFactor: %f\n",
zoomFactor);
311 printf(
"Rocstar: TolerTract: %f\n",
tolerTract);
312 printf(
"Rocstar: TolerVelo: %f\n",
tolerVelo);
313 printf(
"Rocstar: TolerMass: %f\n",
tolerMass);
314 printf(
"Rocstar: TolerDisp: %f\n",
tolerDisp);
317 printf(
"=======================================================\n");
361 const std::string filename =
"Rocman/RocmanControl.txt";
365 string winname =
"RocmanControlParam";
397 if (stat(filename.c_str(), &statBuf) == 0)
399 if ( comm_rank == 0) {
406 MPI_Bcast(&
verbose, 1, MPI_INT, 0, comm);
408 MPI_Bcast(&
order, 1, MPI_INT, 0, comm);
410 MPI_Bcast(&
P_ambient, 1, MPI_DOUBLE, 0, comm);
411 MPI_Bcast(&
rhoc, 1, MPI_DOUBLE, 0, comm);
412 MPI_Bcast(&
pressure, 1, MPI_DOUBLE, 0, comm);
413 MPI_Bcast(&
burn_rate, 1, MPI_DOUBLE, 0, comm);
414 MPI_Bcast(&
rfc_verb, 1, MPI_INT, 0, comm);
415 MPI_Bcast(&
rfc_order, 1, MPI_INT, 0, comm);
416 MPI_Bcast(&
rfc_iter, 1, MPI_INT, 0, comm);
417 MPI_Bcast(&
rfc_tol, 1, MPI_DOUBLE, 0, comm);
418 MPI_Bcast(&
PROP_fom, 1, MPI_CHAR, 0, comm);
423 MPI_Bcast(&
async_in, 1, MPI_CHAR, 0, comm);
424 MPI_Bcast(&
async_out, 1, MPI_CHAR, 0, comm);
433 const char *rankWidth =
"4";
437 const char *ioFormat =
"CGNS";
451 printf(
"========== Rocman Parameter file read ==========\n");
452 printf(
"Rocstar: verbosity level is %d\n",
verbose);
453 printf(
"Rocstar: The order of interpolation is %d\n",
order);
454 printf(
"Rocstar: Traction mode is %d (1 for no sheer, 2 for with sheer)\n",
traction_mode);
455 printf(
"Rocstar: ambient pressure is %f\n",
P_ambient);
456 printf(
"Rocstar: Solid density (Rhoc) is %f kg/m^3\n",
rhoc);
457 printf(
"Rocstar: Pressure is %f Pa\n",
pressure);
458 printf(
"Rocstar: Burning rate is %f m/s\n",
burn_rate);
459 printf(
"Rocstar: RFC_verb: %d\n",
rfc_verb);
460 printf(
"Rocstar: Order of quadrature rule (RFC_order): %d\n",
rfc_order);
461 printf(
"Rocstar: Max iterations for iterative solver: %d\n",
rfc_iter);
462 printf(
"Rocstar: tolerance for iterative solver (RFC_tolerance): %f\n",
rfc_tol);
464 printf(
"Rocstar: Using face-offsetting method for surface propagation.\n");
466 printf(
"Rocstar: Using marker-particle method for surface propagation.\n");
468 printf(
"Rocstar: Using Rocon propagation constraints, (ndiv = %d).\n",
PROPCON_ndiv);
469 printf(
"Rocstar: Number of smoothing iterations in Rocprop: %d\n",
PROP_rediter);
470 printf(
"Rocstar: Feature-angle threshold in Rocprop: %f\n",
PROP_fangle);
471 printf(
"Rocstar: Async Input: %c\n",
async_in?
'T':
'F');
472 printf(
"Rocstar: Async Output: %c\n",
async_out?
'T':
'F');
473 printf(
"==================================================\n");
480 MAN_DEBUG(2, (
"\nRocstar: reached_simulation_time returns TRUE with cur_step: %d\n", param.
cur_step));
487 double startTimeLoopTime;
488 if (param.
myRank == 0) startTimeLoopTime = MPI_Wtime();
489 MPI_Bcast( &startTimeLoopTime, 1, MPI_DOUBLE, 0, param.
communicator);
490 const double elaped_time = startTimeLoopTime - param.
startTime;
492 if (param.
myRank == 0 && verb > 1)
493 printf(
"Rocstar: Quitting; elapsed wall clock time = %f\n", elaped_time);
498 MAN_DEBUG(2, (
"\nRocstar: reached_simulation_time: elapsed wall time = %f \n", elaped_time));
504 if (param.
myRank == 0 && verb > 0)
511 if(param.
myRank == 0 && verb > 0)
512 printf(
"Rocstar: Quitting; Reached the maximum number of dumps for this run. (%d)\n",param.
current_dump);
522 if (result ==
true) {
536 int interrupt_code = 0;
537 std::string message(
"Interrupted by file");
540 std::ifstream InterruptFile;
541 InterruptFile.open(
"RocstarInterrupt.txt");
543 std::cout <<
"Rocstar: Processing interrupt from file." << std::endl;
544 InterruptFile >> interrupt_code;
545 std::getline(InterruptFile,message);
546 InterruptFile.close();
547 unlink(
"RocstarInterrupt.txt");
548 std::ofstream InterruptOut;
549 InterruptOut.open(
"RocstarInterrupt.txt.processed");
550 InterruptOut << interrupt_code <<
" " << message << std::endl;
551 InterruptOut.close();
554 MPI_Bcast(&interrupt_code,1,MPI_INTEGER,0,param.
communicator);
555 if(interrupt_code > 0){
556 coup->
Interrupt(&interrupt_code,message.c_str());
557 return(interrupt_code);
568 int comm_rank = param.
myRank;
580 if ( comm_rank == 0 ) {
582 printf(
"Rocstar: Call CouplingInitialize\n");
585 rocman_param.
print();
599 std::cerr <<
"Rocstar: Error: No coupling created. Exiting." << std::endl;
625 if ( comm_rank == 0 && verb > 1) {
626 std::cout <<
"Rocstar: The maximum number of PC-iterations is " << param.
maxNumPredCorrCycles << std::endl;
633 if(!comm_rank && debug)
634 std::cout <<
"Rocstar: Read restart information, initializing" << std::endl;
646 if(comm_rank == 0 && verb > 0)
647 std::cout <<
"Rocstar: Performing time 0 dump..." << std::endl;
652 if(comm_rank == 0 && debug)
653 std::cout <<
"Rocstar: done." << std::endl;
660 if (comm_rank == 0 && verb > 0) {
661 std::cout <<
"Rocstar: Starting with step " << param.
cur_step+1 <<
", at time " << param.
current_time << std::endl;
665 sprintf(header,
"************** Initialization times at time step %d *****************\n", param.
cur_step);
674 int InterfaceConverged;
683 if ( comm_rank == 0 && verb > 0) {
684 std::cout <<
"Rocstar:" << std::endl
685 <<
"Rocstar: ================================================================" << std::endl
686 <<
"Rocstar: System Time Step : " << param.
cur_step <<
" PC(" << iPredCorr <<
")" << std::endl
687 <<
"Rocstar: ================================================================" << std::endl
688 <<
"Rocstar:" << std::endl
689 <<
"Rocstar: CurrentTime, CurrentTimeStep";
691 std::cout <<
", ZoomFactor";
697 std::cout << std::endl <<
"Rocstar:" << std::endl;
725 InterfaceConverged = 1;
729 if ( comm_rank == 0 && debug )
730 std::cout <<
"Rocstar:" << std::endl
731 <<
"Rocstar: iPredCorr = " << iPredCorr <<
" is done" << std::endl;
732 if ( InterfaceConverged ) {
734 if ( comm_rank == 0 && verb > 1)
735 std::cout <<
"Rocstar: Success: predictor-corrector converged at time " << param.
current_time << std::endl;
739 if ( comm_rank == 0 && debug ) {
740 std::cout <<
"Rocstar:" << std::endl
741 <<
"Rocstar: Interface has -NOT- converged!" << std::endl
742 <<
"Rocstar: iPredCorr = " << iPredCorr <<
" is done" << std::endl;
751 if ( !InterfaceConverged) {
753 std::cerr <<
"Rocstar: Disaster: predictor-corrector did not converge" << std::endl;
760 static int didit = 0;
777 if(comm_rank == 0 && verb > 0)
778 std::cout <<
"Rocstar: Dumping restart files... " << std::endl;
789 if(comm_rank == 0 && verb > 0)
790 std::cout <<
"Rocstar: Dumping coupling viz files." << std::endl;
797 sprintf(header,
"************** Solver times up to time step %d since last output *********\n", param.
cur_step);
808 if(comm_rank == 0 && verb > 0)
809 std::cout <<
"Rocstar: Performing final dump..." << std::endl;
813 if(comm_rank == 0 && debug)
814 std::cout <<
"Rocstar: done." << std::endl;
823 MAN_DEBUG(3, (
"[%d] Rocstar: unload_module Rocpanda.\n", param.
myRank));
829 sprintf(header,
"************** Finalization times after time step %d *****************\n", param.
cur_step);
837 std::string fname =
"RocstarProfile";
838 int data = comm_rank;
842 while (numProcs >= u*10) {
846 for (
int i=0;
i<c;
i++) {
882 std::cerr <<
"Rocstar: Rank " << comm_rank <<
" could not open "
887 printf(
"Rocstar: Rank %d using %s instead for timing data!\n", comm_rank, param.
timingDataFile.c_str());
895 fprintf(fd,
"Number of processors = %d\n", NumProcs);
897 fprintf(fd,
"MyId = %d\n", comm_rank);
904 void debug_print(
const std::string str,
int pane,
int pe, MPI_Comm comm,
const char *memo)
907 if (comm_rank == pe) {
910 printf(
"%s %s: before %p\n", str.c_str(), memo?memo:
"", vm);
912 printf(
"%s %s: after %p \n", str.c_str(), memo?memo:
"", vm);
913 for (
int i=0;
i<strid*cap;
i++) printf(
"%.17e ", vm[
i]);
918 void debug_int_print(
const std::string str,
int pane,
int pe, MPI_Comm comm,
const char *memo)
921 if (comm_rank == pe) {
924 printf(
"%s %s: before %p\n", str.c_str(), memo?memo:
"", vm);
926 printf(
"%s %s: after %p \n", str.c_str(), memo?memo:
"", vm);
927 for (
int i=0;
i<strid*cap;
i++) printf(
"%d ", vm[
i]);
int COMMPI_Comm_rank(MPI_Comm c)
virtual void update_integrals(double currentTime)
void update_start_time(int step, double t)
void init_profiling(Control_parameters ¶m, int comm_rank)
void COM_set_debug(bool debug)
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
void write_restart_info(double CurrentTime, int iStep)
void rocstar_driver(int verb, int remeshed, bool debug)
void COM_delete_window(const char *wname)
#define COM_DOUBLE_ATTRIBUTE(attrname, varname)
#define COM_assertion_msg(EX, msg)
void RocstarShutdown(int=0)
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
double get_restart_time(const string &restart_file)
void COM_set_default_communicator(MPI_Comm comm)
#define COM_STRING_ATTRIBUTE(attrname, varname)
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
A Roccom mesh optimization module.
char coupling_scheme[MAXLEN]
int fclose(std::FILE *file)
Close a file, and check for possible errors.
void COM_set_verbose(int i)
void debug_int_print(const std::string str, int pane, int pe, MPI_Comm comm, const char *memo=NULL)
void output_visualization_files(double t)
void restart_at_time(double t, int step)
void schedule()
Schedule the top-level actions of the coupling scheme and the actions of the agents.
bool reached_visdump_time(const Control_parameters ¶m)
int COMMPI_Comm_size(MPI_Comm c)
void init_convergence(int iPredCorr)
void read(MPI_Comm comm, int commrank)
char output_module[MAXLEN]
char timingDataDir[MAXLEN]
void Interrupt(int *, const char *)
#define COM_UNLOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
int strcasecmp(const char *const s1, const char *const s2)
Compare two C-strings, ignoring the case.
virtual void update_distances(double currentTime)
void COM_print_profile(const char *fname, const char *header)
bool reached_restartdump_time(Control_parameters ¶m)
void update_communicator()
void COM_window_init_done(const char *w_str, int pane_changed=true)
Coupling * create_coupling(Control_parameters ¶m, const RocmanControl_parameters &rocman_param)
void debug_print(const std::string str, int pane, int pe, MPI_Comm comm, const char *memo=NULL)
bool reached_simulation_time(const Control_parameters ¶m)
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
void COM_set_profiling(int i)
void COM_call_function(const int wf, int argc,...)
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
std::string timingDataFile
double run(double t, double dt, int iPredCorr, double zoom)
Invoke the scheduler.
void output_restart_files(double t)
RocmanControl_parameters()
void finalize()
Invoke finalization of the actions in the scheduler and the agents.
#define COM_BOOL_ATTRIBUTE(attrname, varname)
void initialize(int reinit=0)
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
int COM_get_function_handle(const char *wfname)
int check_for_interrupt(Coupling *coup, const Control_parameters ¶m)
char fluid_module[MAXLEN]
char solid_module[MAXLEN]
#define COM_INT_ATTRIBUTE(attrname, varname)
#define COM_EXTERN_MODULE(moduleName)
double outputIntervalTime