60 MPI_Comm_rank(comm,&rank);
63 std::string rocremdir(
"Rocrem");
66 std::string solver(path);
67 std::string rocman(
"Rocman");
68 std::string ddrocm(
"../"+rocman);
69 std::string rocburnapn(
"RocburnAPN");
70 std::string ddsolver(
"../"+solver);
71 std::string ddrocb(
"../"+rocburnapn);
74 if(stat(solver.c_str(),&fstat)){
75 std::cerr <<
"TRAIL_RemeshRunDirSetup: ERROR: Solver directory, "
76 << solver <<
", does not exist. Exiting." << std::endl;
79 if(stat(rocremdir.c_str(),&fstat))
80 mkdir(rocremdir.c_str(),S_IRWXU | S_IRWXG);
82 chdir(rocremdir.c_str());
84 unlink(solver.c_str());
85 symlink(ddsolver.c_str(),solver.c_str());
86 if(!stat(ddrocm.c_str(),&fstat)){
87 unlink(rocman.c_str());
88 symlink(ddrocm.c_str(),rocman.c_str());
90 if(!stat(ddrocb.c_str(),&fstat)){
91 unlink(rocburnapn.c_str());
92 symlink(ddrocb.c_str(),rocburnapn.c_str());
95 symlink(rocstarrundir.c_str(),
"rocstardir");
110 unsigned int ndb = gp.
_db.size();
124 *db.
_out <<
"TRAIL_RemeshInitFluSurfData:Enter" << std::endl;
125 unsigned int ntri = db.
_triconn.size()/3;
126 unsigned int nquad = db.
_quadconn.size()/4;
127 unsigned int nnodes = db.
NNodes();
128 unsigned int n_elem = ntri + nquad;
130 *db.
_out <<
"TRAIL_RemeshInitFluSurfData: Ntri = " << ntri
131 <<
" Nquad = " << nquad << endl
132 <<
"TRAIL_RemeshInitFluSurfData: Solution sizes("
133 << nnodes <<
"," << n_elem <<
")" << endl;
134 unsigned int ind = 0;
135 unsigned int cdind = 0;
136 unsigned int vind = 0;
241 *db.
_out <<
"TRAIL_RemeshInitFluSurfData: No data to process." << std::endl;
243 *db.
_out <<
"TRAIL_RemeshInitFluSurfData:Exit" << std::endl;
253 unsigned int ntet = gp.
_tetconn.size()/4;
254 unsigned int nhex = gp.
_hexconn.size()/8;
255 unsigned int npris = gp.
_prisconn.size()/6;
256 unsigned int npyr = gp.
_pyrconn.size()/5;
257 unsigned int nnodes = gp.
_nc.size()/3;
258 unsigned int ncells = ntet + nhex + npris + npyr;
263 unsigned int ind = 0;
264 unsigned int cdind = 0;
265 unsigned int vind = 0;
338 const std::string &src,
339 const std::string &srcpath,
340 const std::string &trgpath,
341 const std::string &destpath,
346 std::string srcfile(src +
"_in_" + timestring +
".txt");
348 std::string srcwin(src);
349 std::string trailwin(src+
"_trail");
352 std::string format(
"HDF");
353 std::string crpath(trgpath+
"/AutoSurf");
356 MPI_Comm_rank(comm,&rank);
359 if(!stat(crpath.c_str(),&fstat)){
360 rename(crpath.c_str(),(crpath+
"_save").c_str());
361 std::cerr <<
"TRAIL_RemeshAutoSurfer: WARNING: " << crpath <<
" already "
362 <<
"existed. Renaming to " << crpath <<
"_save." << std::endl;
369 *gp.
_out <<
"TRAIL_RemeshAutoSurfer: Creating overlay for coupled surfaces."
376 *gp.
_out <<
"TRAIL_RemeshAutoSurfer: Overlay for coupled surfaces complete."
378 <<
"TRAIL_RemeshAutoSurfer: Transferring data....";
381 std::cout <<
"Roctrail> Transferring data in parallel..." << std::endl;
385 destpath,crpath,t,gp.
_id,comm,gp.
_out);
389 *gp.
_out <<
"TRAIL_AutoSurfer: Transfer for coupled surfaces complete."
391 <<
"TRAIL_AutoSurfer: Writing populated surfaces."
394 std::cout <<
"Roctrail> Transfer done." << std::endl;
409 std::string ssd(
"Modin");
410 std::string rsd(
"Rocout");
411 std::string strg(
"Modin.remesh_"+timestring);
412 std::string strg0(
"Modin.remesh_"+time0string);
413 std::string rtrg(
"Rocout.remesh_"+timestring);
414 std::string rtrg0(
"Rocout.remesh_"+time0string);
415 std::string solversrc(solver+
"/"+ssd);
416 std::string solvertrg0(solver+
"/"+strg0);
417 std::string solvertrg(solver+
"/"+strg);
418 std::string rocstarsrc(solver+
"/"+rsd);
419 std::string rocstartrg(solver+
"/"+rtrg);
420 std::string rocstartrg0(solver+
"/"+rtrg0);
421 std::string rocstarlast(solver+
"/Rocout.remesh_last");
422 std::string solverlast(solver+
"/Modin.remesh_last");
425 if(lstat(rocstarsrc.c_str(),&fstat0)){
426 std::cerr <<
"TRAIL_Remesh::DirectoryShuffling: ERROR: " << rocstarsrc
427 <<
" does not exist. Exiting." << std::endl;
432 if(S_ISDIR(fstat0.st_mode)){
434 std::cout <<
"TRAIL_RemeshShuffle: " << rocstarsrc <<
" directory exists."
439 if(!stat(rocstartrg0.c_str(),&fstat1)){
440 std::string savepath(rocstarsrc+
".remesh_save_"+time0string);
441 rename(rocstartrg0.c_str(),savepath.c_str());
442 std::cerr <<
"TRAIL_Remesh::DirectoryShuffling: WARNING: " << rocstartrg0
443 <<
" already existed. Saving it as " << savepath <<
"."
446 rename(rocstarsrc.c_str(),rocstartrg0.c_str());
447 symlink(rtrg0.c_str(),rocstarsrc.c_str());
454 std::string pointsto(
ResolveLink(rocstarsrc.c_str()));
456 std::cout <<
"TRAIL_RemeshShuffle: " << rocstarsrc
457 <<
" is a link to " << pointsto <<
"." << std::endl;
458 if(pointsto == rtrg){
460 std::cout <<
"TRAIL_RemeshShuffle: " << rocstarsrc
461 <<
" directory did not exist." << std::endl;
462 if(stat(rocstarlast.c_str(),&fstat1) ||
463 stat(solverlast.c_str(),&fstat1)){
464 std::cerr <<
"TRAIL_Remesh::DirectoryShuffling: ERROR: Detected "
465 <<
"multiple remesh of same dump, but last source cannot "
466 <<
"be found. Exiting." << std::endl;
469 unlink(rocstarsrc.c_str());
470 rename(rocstarlast.c_str(),rocstarsrc.c_str());
471 unlink(solversrc.c_str());
472 rename(solverlast.c_str(),solversrc.c_str());
475 unlink(rocstarlast.c_str());
476 unlink(solverlast.c_str());
480 if(!stat(rocstartrg.c_str(),&fstat0)){
481 std::string savepath(rocstarsrc+
".remesh_save_"+timestring);
482 rename(rocstartrg.c_str(),savepath.c_str());
483 std::cerr <<
"TRAIL_Remesh::DirectoryShuffling: WARNING: " << rocstartrg
484 <<
" already existed. Saving it as " << savepath <<
"."
487 mkdir(rocstartrg.c_str(),S_IRWXG | S_IRWXU);
488 symlink(
ResolveLink(rocstarsrc.c_str()).c_str(),rocstarlast.c_str());
489 if(lstat(solversrc.c_str(),&fstat0)){
490 std::cerr <<
"TRAIL_Remesh::DirectoryShuffling: ERROR: " << solversrc
491 <<
" does not exist. Exiting." << std::endl;
496 if(S_ISDIR(fstat0.st_mode)){
500 if(!stat(solvertrg0.c_str(),&fstat1)){
501 std::string savepath(solversrc+
".remesh_save_"+time0string);
502 rename(solvertrg0.c_str(),savepath.c_str());
503 std::cerr <<
"TRAIL_Remesh::DirectoryShuffling: WARNING: " << solvertrg0
504 <<
" already existed. Saving it as " << savepath <<
"."
507 rename(solversrc.c_str(),solvertrg0.c_str());
508 symlink(strg0.c_str(),solversrc.c_str());
511 if(!stat(solvertrg.c_str(),&fstat0)){
512 std::string savepath(solversrc+
".remesh_save_"+timestring);
513 rename(solvertrg.c_str(),savepath.c_str());
514 std::cerr <<
"TRAIL_Remesh::DirectoryShuffling: WARNING: " << solvertrg
515 <<
" already existed. Saving it as " << savepath <<
"."
518 mkdir(solvertrg.c_str(),S_IRWXG | S_IRWXU);
519 symlink(
ResolveLink(solversrc.c_str()).c_str(),solverlast.c_str());
521 std::string rocburnapn(
"RocburnAPN");
522 std::string rocburnapnsrc(rocburnapn+
"/"+rsd);
523 std::string rocburnapntrg0(rocburnapn+
"/"+rtrg0);
524 std::string rocburnapntrg(rocburnapn+
"/"+rtrg);
525 if(!lstat(rocburnapnsrc.c_str(),&fstat0)){
526 if(S_ISDIR(fstat0.st_mode)){
527 if(!stat(rocburnapntrg0.c_str(),&fstat1)){
530 std::string savepath(rocburnapnsrc+
".remesh_save_"+time0string);
531 rename(rocburnapntrg0.c_str(),savepath.c_str());
532 std::cerr <<
"TRAIL_Remesh::DirectoryShuffling: WARNING: "
533 << rocburnapntrg0 <<
" already existed, backup it up as "
534 << savepath <<
"." << std::endl;
536 rename(rocburnapnsrc.c_str(),rocburnapntrg0.c_str());
537 symlink(rtrg0.c_str(),rocburnapnsrc.c_str());
539 if(!stat(rocburnapntrg.c_str(),&fstat1)){
542 std::string savepath(rocburnapnsrc+
".remesh_save_"+timestring);
543 rename(rocburnapntrg.c_str(),savepath.c_str());
544 std::cerr <<
"TRAIL_Remesh::DirectoryShuffling: WARNING: "
545 << rocburnapntrg <<
" already existed, backup it up as "
546 << savepath <<
"." << std::endl;
548 mkdir(rocburnapntrg.c_str(), S_IRWXG | S_IRWXU);
549 unlink(rocburnapnsrc.c_str());
550 symlink(rtrg.c_str(),rocburnapnsrc.c_str());
796 const std::string &solver,
797 const std::string &srcd,
798 const std::string &trgd,
799 double t,MPI_Comm comm,
800 bool surftrans,
bool rocstarshuffle)
803 std::string source_directory(srcd);
804 std::string target_directory(trgd);
805 std::string rocstarrunsrc(
"Rocout");
807 if(source_directory.empty())
808 source_directory = rocstarrunsrc;
809 if(target_directory.empty())
810 target_directory = defaultrocstartrg;
813 std::string solversrc(solver+
"/Modin");
814 std::string strg(
"Modin.remesh_"+timestring);
815 std::string solvertrg(solver+
"/"+strg);
816 std::string rocstarsrc(solver+
"/"+source_directory);
817 std::string rtrg(target_directory);
818 std::string rocstartrg(solver+
"/"+rtrg);
819 std::string volcntl(
"remesh_vol_in_"+timestring+
".txt");
820 std::string surfcntl(
"remesh_surf_in_"+timestring+
".txt");
821 std::string fluvolcntl(rocstartrg+
"/fluid_in_"+timestring+
".txt");
822 std::string flusurfcntl(rocstartrg+
"/ifluid_in_"+timestring+
".txt");
826 MPI_Comm_rank(comm,&rank);
828 MPI_Comm_size(comm,&nproc);
832 std::string rocstardir(
"..");
838 std::string solverdir(rocstardir+
"/"+solver);
841 std::cerr <<
"TRAIL_RemeshWrite: Fatal Error: Source directory, "
842 << rocstarsrc <<
" does not exist. Exiting." << std::endl;
844 *gp.
_out <<
"TRAIL_RemeshWrite: Fatal Error: Souce directory, "
845 << rocstarsrc <<
" does not exist. Exiting." << std::endl;
850 std::cerr <<
"TRAIL_RemeshWrite: Fatal Error: Source directory, "
851 << solversrc <<
" does not exist. Exiting." << std::endl;
853 *gp.
_out <<
"TRAIL_RemeshWrite: Fatal Error: Souce directory, "
854 << solversrc <<
" does not exist. Exiting." << std::endl;
862 *gp.
_out <<
"TRAIL_RemeshWrite: WARNING: communicator is "
863 << (comm == MPI_COMM_NULL ?
"null." :
"not worldly.")
866 *gp.
_out <<
"TRAIL_RemeshWrite: Preparing to write remeshed dataset for "
867 << solver <<
"." << std::endl;
870 std::cout << std::endl
871 <<
"Roctrail> Processing solver data for " << solver
876 *gp.
_out <<
"TRAIL_RemeshWrite: Window test..." << std::endl;
880 *gp.
_out <<
" creation..." << std::endl;
885 *gp.
_out <<
" destruction..." << std::endl;
890 *gp.
_out <<
"TRAIL_RemeshWrite: Window test passed, graduating..."
894 if(solver ==
"Rocflu"){
898 *gp.
_out <<
"TRAIL_RemeshWrite: Initializing solver data..." << std::endl;
906 *gp.
_out <<
"TRAIL_RemeshWrite: Solver data init done." << std::endl
907 <<
"TRAIL_RemeshWrite: Writing native files (pass 1)..."
913 *gp.
_out <<
"TRAIL_RemeshWrite: Solver native files written (pass 1)."
915 <<
"TRAIL_RemeshWrite: Populating remote border indices..."
922 *gp.
_out <<
"TRAIL_RemeshWrite: Remote border indices populated."
924 <<
"TRAIL_RemeshWrite: Writing native files (pass 2)..."
931 *gp.
_out <<
"TRAIL_RemeshWrite: Solver native files written (pass 2)."
933 <<
"TRAIL_RemeshWrite: Initializing volume data..."
940 *gp.
_out <<
"TRAIL_RemeshWrite: Volume data initialized."
942 <<
"TRAIL_RemeshWrite: Initializing surface data..."
949 *gp.
_out <<
"TRAIL_RemeshWrite: Surface data initialized."
951 <<
"TRAIL_RemeshWrite: Initializing Roccom Windows..."
955 std::cout <<
"Roctrail> Creating Roccom Windows" << std::endl;
960 *gp.
_out <<
"TRAIL_RemeshWrite: Roccom windows initialized."
962 <<
"TRAIL_RemeshWrite: Registering surface meshes..."
969 *gp.
_out <<
"TRAIL_RemeshWrite: Surface meshes registered."
971 <<
"TRAIL_RemeshWrite: Registering volume solution..."
978 *gp.
_out <<
"TRAIL_RemeshWrite: Volume soln registered."
980 <<
"TRAIL_RemeshWrite: Registering surface solution..."
987 *gp.
_out <<
"TRAIL_RemeshWrite: Surface soln registered."
993 std::cout <<
"Roctrail> Writing windows to Rocstar format"
997 *gp.
_out <<
" writing..." << std::endl;
1005 *gp.
_out <<
" done writing" << std::endl;
1011 std::cout <<
"Roctrail> Setting up Rocin control files for Rocstar"
1014 rename(fluvolcntl.c_str(),(fluvolcntl+
".orig").c_str());
1017 rename(flusurfcntl.c_str(),(flusurfcntl+
".orig").c_str());
1018 symlink(volcntl.c_str(),fluvolcntl.c_str());
1019 symlink(surfcntl.c_str(),flusurfcntl.c_str());
1024 std::cout <<
"Roctrail> Proceeding with surface data transfer..."
1027 *gp.
_out <<
"TRAIL_RemeshWrite: Performing surface data transfer..."
1030 rocstartrg,rocstartrg,t,comm);
1035 std::cout <<
"Roctrail> Resetting Rocin control files"
1037 unlink(flusurfcntl.c_str());
1038 surfcntl.assign(
"new_surf_in_"+timestring+
".txt");
1039 symlink(surfcntl.c_str(),flusurfcntl.c_str());
1043 std::cout <<
"Roctrail> Surface data transfer done." << std::endl;
1045 *gp.
_out <<
"TRAIL_RemeshWrite: Surface transfer complete."
1054 std::cout <<
"Roctrail> Preparing Rocstar restart directories."
1056 std::string rocstarbackup0(rocstardir+
"/"+solver+
1057 "/Rocout.remesh_00.000000");
1058 if(rocstartrg != rocstarrunsrc){
1064 rename((solverdir+
"/"+rocstarrunsrc).c_str(),
1065 rocstarbackup0.c_str());
1068 unlink((solverdir+
"/"+rocstarrunsrc).c_str());
1070 std::cout <<
"Roctrail> Attempting to link " << rocstarrunsrc
1071 <<
" to " << rtrg <<
"." << std::endl;
1072 symlink(rtrg.c_str(),(solverdir+
"/"+rocstarrunsrc).c_str());
1074 std::string solverbackup0(rocstardir+
"/"+solver+
1075 "/Modin.remesh_00.000000");
1079 rename((rocstardir+
"/"+solversrc).c_str(),solverbackup0.c_str());
1082 unlink((rocstardir+
"/"+solversrc).c_str());
1084 std::cout <<
"Roctrail> Attempting to link " << solversrc <<
" to "
1085 << strg <<
"." << std::endl;
1086 symlink(strg.c_str(),(rocstardir+
"/"+solversrc).c_str());
1090 std::cout <<
"Roctrail> Rocstar restart data done." << std::endl;
1093 *gp.
_out <<
"TRAIL_RemeshWrite: All done." << std::endl
1094 <<
"TRAIL_RemeshWrite: Exit" << std::endl;
1096 std::cout <<
"Roctrail> Goodbye" << std::endl;
1101 *gp.
_out <<
"TRAIL_RemeshWrite::Error: Unknown solver, " << solver <<
"."
1103 << (gp.
_debug ?
"TRAIL_RemeshWrite: Exit" :
"") << std::endl;
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
bool InitRoccomWindows(const std::string &wname)
bool TRAIL_FILEEXISTS(const std::string &fname)
void TRAIL_RemeshShutdown(MPI_Comm comm)
bool TRAIL_FluInitSolver(GEM_Partition &gp, const std::string &prefix="./")
void COM_delete_window(const char *wname)
std::vector< unsigned int > _tetconn
std::vector< std::vector< int > > _int_data
bool TRAIL_TransferSurfDataFILE(const std::string &src, const std::string &trg, const std::string &dest, const std::string &srcpath, const std::string &trgpath, const std::string &destpath, const std::string &crpath, double t, unsigned int id, MPI_Comm comm, std::ostream *=NULL)
This file contains the prototypes for Roccom API.
void TRAIL_AutoSurfer(const std::string &src, const std::string &trg, const std::string &srcpath=".", const std::string &trgpath=".", const std::string &destpath=".", double t=0, MPI_Comm comm=MPI_COMM_NULL, std::ostream *=NULL)
unsigned int NNodes(void)
int TRAIL_CD(const std::string &path, std::ostream *=NULL)
bool TRAIL_FluInitVolSoln(GEM_Partition &gp)
std::vector< unsigned int > _quadconn
bool TRAIL_ISDIR(const std::string &fname)
GEM_UserData _solver_data
void TRAIL_SafeRemove(const std::string &fname, const std::string &ext)
bool WriteRocstar(const std::string &, double t=0.0)
std::vector< std::vector< double > > _field_data
bool TRAIL_FluInitSurfSoln(GEM_DomainBoundary &db, const std::string &, bool all=true)
std::vector< int > _stride_int
bool TRAIL_RemeshWrite(GEM_Partition &gp, const std::string &path, double t=0.0, MPI_Comm comm=MPI_COMM_NULL, bool=false)
std::string TRAIL_TimeString(double t)
bool TRAIL_FluRegisterSurfMesh(GEM_Partition &gp)
std::vector< unsigned int > _triconn
std::vector< GEM_DomainBoundary > _db
std::string TRAIL_CWD(void)
bool TRAIL_FluRegisterSurfSoln(GEM_DomainBoundary &db, const std::string &wname, bool all=true)
bool TRAIL_FluWriteNative(GEM_Partition &gp, const std::string &path)
bool TRAIL_RemeshInitFluVolData(GEM_Partition &gp, int src_index=0)
std::vector< unsigned int > _pyrconn
std::vector< unsigned int > _hexconn
std::vector< int > _stride_field
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
void COM_set_profiling(int i)
bool TRAIL_FluPopRemBordIndFILE(GEM_Partition &gp, double t=0.0, bool unsteady=true, const std::string &path="./")
std::string volume_window
int TRAIL_CreateDirectory(const std::string &fname)
void TRAIL_MergeRocinFiles(const std::string &srcname, const std::string &trgname, const std::string &path="./", double t=0, unsigned int np=1, std::ostream *=NULL)
GEM_UserData _solver_data
void TRAIL_RemeshFixRocstarFiles(GEM_Partition &gp, const std::string &path, double t)
std::vector< double > _nc
std::vector< unsigned int > _prisconn
bool TRAIL_FluRegisterVolSoln(GEM_Partition &gp, bool all=true)
bool TRAIL_RemeshInitFluSurfData(GEM_Partition &gp)
bool TRAIL_ISLINK(const std::string &fname)
void TRAIL_FluCopyCaseFiles(GEM_Partition &gp, const std::string &path)
void TRAIL_RemeshShuffle(const std::string &solver, double t=0, bool debug=false)
std::string surface_window
bool TRAIL_RemeshAutoSurfer(GEM_Partition &gp, const std::string &src, const std::string &srcpath, const std::string &trgpath, const std::string &destpath, double t, MPI_Comm comm)
void TRAIL_RemeshRunDirSetup(const std::string &path, double t, MPI_Comm comm, bool shuffle=false)
#define COM_EXTERN_MODULE(moduleName)
std::string ResolveLink(const std::string &path)