Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TRAIL_Remesh.H File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool TRAIL_RemeshInitFluSurfData (GEM_Partition &gp)
 
bool TRAIL_RemeshInitFluSurfData (GEM_DomainBoundary &db, int src_index=0)
 
bool TRAIL_RemeshInitFluVolData (GEM_Partition &gp, int src_index=0)
 
bool TRAIL_RemeshWrite (GEM_Partition &gp, const std::string &path, double t=0.0, MPI_Comm comm=MPI_COMM_NULL, bool=false)
 
void TRAIL_RemeshRunDirSetup (const std::string &path, double t, MPI_Comm comm, bool shuffle=false)
 
void TRAIL_RemeshShutdown (MPI_Comm comm)
 
void TRAIL_RemeshShuffle (const std::string &solver, double t=0, bool debug=false)
 
bool TRAIL_RemeshWrite (GEM_Partition &gp, const std::string &solver, const std::string &source_directory, const std::string &target_directory, double t, MPI_Comm comm, bool surftrans, bool restartshuffle)
 

Function Documentation

bool TRAIL_RemeshInitFluSurfData ( GEM_Partition gp)

Definition at line 108 of file RemeshFunctions.C.

References GEM_Partition::_db, n, TRAIL_FluInitSurfSoln(), and TRAIL_RemeshInitFluSurfData().

Referenced by TRAIL_RemeshInitFluSurfData(), and TRAIL_RemeshWrite().

109 {
110  unsigned int ndb = gp._db.size();
111  unsigned int n = 0;
112  if(!TRAIL_FluInitSurfSoln(gp))
113  return false;
114  while(n < ndb)
115  if(!TRAIL_RemeshInitFluSurfData(gp._db[n++],0))
116  return false;
117  return true;
118 }
bool TRAIL_FluInitSurfSoln(GEM_DomainBoundary &db, const std::string &, bool all=true)
std::vector< GEM_DomainBoundary > _db
Definition: GEM.H:305
const NT & n
bool TRAIL_RemeshInitFluSurfData(GEM_Partition &gp)

Here is the call graph for this function:

Here is the caller graph for this function:

bool TRAIL_RemeshInitFluSurfData ( GEM_DomainBoundary db,
int  src_index = 0 
)

Definition at line 121 of file RemeshFunctions.C.

References GEM_DomainBoundary::_data, GEM_DomainBoundary::_debug, GEM_UserData::_field_data, GEM_UserData::_int_data, GEM_DomainBoundary::_out, GEM_DomainBoundary::_quadconn, GEM_DomainBoundary::_solver_data, GEM_UserData::_stride_field, GEM_UserData::_stride_int, GEM_DomainBoundary::_triconn, and GEM_DomainBoundary::NNodes().

122 {
123  if(db._debug && db._out)
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;
129  if(db._debug && db._out)
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;
137  // Deallocate unused datum
138  db._data._field_data[0].resize(0); // gsp's are 0 after remeshing
139  db._data._stride_field[0] = 0;
140  db._data._field_data[1].resize(0); // rhofvf_alp not used
141  db._data._stride_field[1] = 0;
142  db._data._field_data[2].resize(0); // nf_alp not used
143  db._data._stride_field[2] = 0;
144  db._data._field_data[3].resize(0); // rhof_alp not used
145  db._data._stride_field[3] = 0;
146  db._data._field_data[4].resize(0); // pf
147  db._data._stride_field[4] = 0;
148  db._data._field_data[5].resize(0); // qc
149  db._data._stride_field[5] = 0;
150  db._data._field_data[6].resize(0); // qr
151  db._data._stride_field[6] = 0;
152  db._data._field_data[7].resize(0); // tf
153  db._data._stride_field[7] = 0;
154  db._data._field_data[8].resize(0); // Tb_alp
155  db._data._stride_field[8] = 0;
156  db._data._field_data[11].resize(0); // Tf
157  db._data._stride_field[11] = 0;
158  db._data._field_data[12].resize(0); // vm
159  db._data._stride_field[12] = 0;
160  db._data._field_data[13].resize(0); // vs
161  db._data._stride_field[13] = 0;
162  db._data._field_data[14].resize(0); // vs_old
163  db._data._stride_field[14] = 0;
164  db._data._field_data[16].resize(0); // mdot
165  db._data._stride_field[16] = 0;
166  db._data._field_data[17].resize(0); // mdot_old
167  db._data._stride_field[17] = 0;
168  db._data._field_data[18].resize(0); // du_alp
169  db._data._stride_field[18] = 0;
170  db._data._field_data[20].resize(0); // sq_dist
171  db._data._stride_field[20] = 0;
172  if (db._solver_data._field_data.size() == 0){
173  db._data._field_data[9].resize(0);
174  db._data._field_data[10].resize(0);
175  db._data._field_data[15].resize(0);
176  db._data._int_data[0].resize(0);
177  db._data._field_data[19].resize(0);
178  }
179  else if((db._solver_data._stride_field[0] == 2 ||
180  db._solver_data._stride_field[0] == 3)) {
181  assert(db._solver_data._stride_field[1] == 0 ||
182  db._solver_data._stride_field[1] == 3);
183  db._data._int_data[0].resize(n_elem,0);
184  while(ind < n_elem){
185  // Keep mdot, Tflm, bflag, and ts
186  db._data._field_data[9][ind] =
187  db._solver_data._field_data[src_index][cdind++]; // mdot_alp
188  db._data._field_data[10][ind] =
189  db._solver_data._field_data[src_index][cdind++]; // Tflm_alp
190  if(db._data._field_data[9][0] > 0) // if faces on fire, set bflag
191  db._data._int_data[0][ind] = 1;
192  if(db._solver_data._stride_field[0] == 3)
193  db._data._field_data[15][ind] =
194  db._solver_data._field_data[src_index][cdind++]; // ts
195  // if(db_debug && db_out)
196  // *db_out << "Element[" << ind+1 << "] rhof_alp("
197  // << _soln._rhof_alp[ind] << ") _nf_alp<"
198  // << _soln._nf_alp[vind] << ","
199  // << _soln._nf_alp[vind+1] << ","
200  // << _soln._nf_alp[vind+2] << ">" << endl;
201  ind++;
202  vind+=3;
203  }
204  db._solver_data._field_data[src_index].resize(0);
205  db._solver_data._stride_field[src_index] = 0;
206  if(db._data._field_data[9][0] == -9999){
207  db._data._field_data[9].resize(0);
208  db._data._stride_field[9] = 0;
209  db._data._field_data[10].resize(0);
210  db._data._stride_field[10] = 0;
211  db._data._int_data[0].resize(0);
212  db._data._stride_int[0] = 0;
213  }
214  if(db._data._field_data[15][0] == -9999){
215  db._data._field_data[15].resize(0);
216  db._data._stride_field[15] = 0;
217  }
218  src_index++;
219  ind = 0;
220  cdind = 0;
221  if(db._solver_data._stride_field[1] == 3){
222  while(ind < nnodes){
223  db._data._field_data[19][ind*3] =
224  db._solver_data._field_data[src_index][cdind++]; // nc_t0-x
225  db._data._field_data[19][ind*3+1] =
226  db._solver_data._field_data[src_index][cdind++]; // nc_t0-y
227  db._data._field_data[19][ind*3+2] =
228  db._solver_data._field_data[src_index][cdind++]; // nc_t0-z
229  ind++;
230  }
231  }
232  db._solver_data._field_data[src_index].resize(0);
233  db._solver_data._stride_field[src_index] = 0;
234  if(db._data._field_data[19][0] == -9999){
235  db._data._field_data[19].resize(0);
236  db._data._stride_field[19] = 0;
237  }
238  }
239  else
240  if(db._debug && db._out)
241  *db._out << "TRAIL_RemeshInitFluSurfData: No data to process." << std::endl;
242  if(db._debug && db._out)
243  *db._out << "TRAIL_RemeshInitFluSurfData:Exit" << std::endl;
244  return(true);
245 }
std::vector< std::vector< int > > _int_data
Definition: GEM.H:100
unsigned int NNodes(void)
Definition: GEM.C:1103
std::vector< unsigned int > _quadconn
Definition: GEM.H:132
GEM_UserData _solver_data
Definition: GEM.H:138
std::vector< std::vector< double > > _field_data
Definition: GEM.H:95
std::vector< int > _stride_int
Definition: GEM.H:104
std::vector< unsigned int > _triconn
Definition: GEM.H:131
std::vector< int > _stride_field
Definition: GEM.H:103
GEM_UserData _data
Definition: GEM.H:137
std::ostream * _out
Definition: GEM.H:140

Here is the call graph for this function:

bool TRAIL_RemeshInitFluVolData ( GEM_Partition gp,
int  src_index = 0 
)

Definition at line 248 of file RemeshFunctions.C.

References GEM_Partition::_data, GEM_UserData::_field_data, GEM_Partition::_hexconn, GEM_Partition::_nc, GEM_Partition::_prisconn, GEM_Partition::_pyrconn, GEM_Partition::_solver_data, GEM_UserData::_stride_field, GEM_Partition::_tetconn, and TRAIL_FluInitVolSoln().

Referenced by TRAIL_RemeshWrite().

249 {
250  // assert((gp._solver_data._stride_field[0] == 8) &&
251  // (gp._solver_data._stride_field[1] == 3 ||
252  // gp._solver_data._stride_field[1] == 0));
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;
259  // assert(gp._solver_data._field_data[src_index].size() == 8*ncells);
260  // assert(gp._solver_data._field_data[src_index+1].size() == 3*nnodes);
261  if(!TRAIL_FluInitVolSoln(gp))
262  return false;
263  unsigned int ind = 0;
264  unsigned int cdind = 0;
265  unsigned int vind = 0;
266  while(ind < ncells){
267  // rhof
268  gp._data._field_data[2][ind] =
269  gp._solver_data._field_data[src_index][cdind++];
270  // rhovf_x
271  gp._data._field_data[3][vind++] =
272  gp._solver_data._field_data[src_index][cdind++];
273  // rhovf_y
274  gp._data._field_data[3][vind++] =
275  gp._solver_data._field_data[src_index][cdind++];
276  // rhovf_z
277  gp._data._field_data[3][vind++] =
278  gp._solver_data._field_data[src_index][cdind++];
279  // rhoEf
280  gp._data._field_data[4][ind] =
281  gp._solver_data._field_data[src_index][cdind++];
282  // pf
283  gp._data._field_data[5][ind] =
284  gp._solver_data._field_data[src_index][cdind++];
285  // Tf
286  gp._data._field_data[6][ind] =
287  gp._solver_data._field_data[src_index][cdind++];
288  // af
289  gp._data._field_data[7][ind] =
290  gp._solver_data._field_data[src_index][cdind++];
291  ind++;
292  }
293  ind = 0;
294  gp._solver_data._field_data[src_index].resize(0);
295  gp._solver_data._stride_field[src_index] = 0;
296  src_index++;
297  // nodal displacements (disp)
298  if(gp._solver_data._field_data[src_index].size() == 3*nnodes){
299  while(ind < nnodes){
300  gp._data._field_data[8][ind*3] =
301  gp._solver_data._field_data[src_index][ind*3];
302  gp._data._field_data[8][ind*3+1] =
303  gp._solver_data._field_data[src_index][ind*3+1];
304  gp._data._field_data[8][ind*3+2] =
305  gp._solver_data._field_data[src_index][ind*3+2];
306  ind++;
307  }
308  }
309  else{
310  while(ind < nnodes){
311  gp._data._field_data[8][ind*3] = 0.0;
312  gp._data._field_data[8][ind*3+1] = 0.0;
313  gp._data._field_data[8][ind*3+2] = 0.0;
314  ind++;
315  }
316  }
317  // Grid speeds are 0 after remeshing
318  gp._data._field_data[9].resize(0);
319  gp._data._stride_field[9] = 0;
320  gp._solver_data._field_data[src_index].resize(0);
321  gp._solver_data._stride_field[src_index] = 0;
322  return(true);
323 }
GEM_UserData _data
Definition: GEM.H:306
std::vector< unsigned int > _tetconn
Definition: GEM.H:295
bool TRAIL_FluInitVolSoln(GEM_Partition &gp)
std::vector< std::vector< double > > _field_data
Definition: GEM.H:95
std::vector< unsigned int > _pyrconn
Definition: GEM.H:297
std::vector< unsigned int > _hexconn
Definition: GEM.H:301
std::vector< int > _stride_field
Definition: GEM.H:103
GEM_UserData _solver_data
Definition: GEM.H:307
std::vector< double > _nc
Definition: GEM.H:293
std::vector< unsigned int > _prisconn
Definition: GEM.H:299

Here is the call graph for this function:

Here is the caller graph for this function:

void TRAIL_RemeshRunDirSetup ( const std::string &  path,
double  t,
MPI_Comm  comm,
bool  shuffle = false 
)

Definition at line 56 of file RemeshFunctions.C.

References rank, and TRAIL_CWD().

58 {
59  int rank = 0;
60  MPI_Comm_rank(comm,&rank);
61 
62  std::string rocstarrundir(TRAIL_CWD());
63  std::string rocremdir("Rocrem");
64 
65  // For now, only these two are needed
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);
72  struct stat fstat;
73  if(!rank){
74  if(stat(solver.c_str(),&fstat)){
75  std::cerr << "TRAIL_RemeshRunDirSetup: ERROR: Solver directory, "
76  << solver << ", does not exist. Exiting." << std::endl;
77  exit(1);
78  }
79  if(stat(rocremdir.c_str(),&fstat))
80  mkdir(rocremdir.c_str(),S_IRWXU | S_IRWXG);
81  }
82  chdir(rocremdir.c_str());
83  if(!rank){
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());
89  }
90  if(!stat(ddrocb.c_str(),&fstat)){
91  unlink(rocburnapn.c_str());
92  symlink(ddrocb.c_str(),rocburnapn.c_str());
93  }
94  unlink("rocstardir");
95  symlink(rocstarrundir.c_str(),"rocstardir");
96  // if(shuffle)
97  // TRAIL_RemeshShuffle(solver,t);
98  }
99 }
std::string TRAIL_CWD(void)
static int rank
Definition: advectest.C:66

Here is the call graph for this function:

void TRAIL_RemeshShuffle ( const std::string &  solver,
double  t = 0,
bool  debug = false 
)

Definition at line 403 of file RemeshFunctions.C.

References ResolveLink(), and TRAIL_TimeString().

404 {
405  if(t==0.0)
406  return;
407  std::string timestring(TRAIL_TimeString(t));
408  std::string time0string(TRAIL_TimeString(0.0));
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");
423  struct stat fstat0;
424  struct stat fstat1;
425  if(lstat(rocstarsrc.c_str(),&fstat0)){
426  std::cerr << "TRAIL_Remesh::DirectoryShuffling: ERROR: " << rocstarsrc
427  << " does not exist. Exiting." << std::endl;
428  exit(1);
429  }
430  // If the <solver>/Rocout is a directory, then this must be the first remesh
431  // The plan is to mv <solver>/Rocout to <solver>/Rocout.remesh_00.000000
432  if(S_ISDIR(fstat0.st_mode)){
433  if(debug)
434  std::cout << "TRAIL_RemeshShuffle: " << rocstarsrc << " directory exists."
435  << std::endl;
436  // bummer, <solver>/Rocout.remesh_00.000000 already existed. this should
437  // probably never happen, but if it does, warn and back it up as
438  // <solver>/Rocout.remesh_save_00.000000
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 << "."
444  << std::endl;
445  }
446  rename(rocstarsrc.c_str(),rocstartrg0.c_str());
447  symlink(rtrg0.c_str(),rocstarsrc.c_str());
448  }
449  // <solver>/Rocout is not a directory, it is a link, that's okay unless it's
450  // already pointing at <solver>/Rocout.remesh_<timestamp>. In this case, the
451  // most likely scenario is the one where you are remeshing the same timestamp
452  // multiple times without running rocstar.
453  else{
454  std::string pointsto(ResolveLink(rocstarsrc.c_str()));
455  if(debug)
456  std::cout << "TRAIL_RemeshShuffle: " << rocstarsrc
457  << " is a link to " << pointsto << "." << std::endl;
458  if(pointsto == rtrg){
459  if(debug)
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;
467  exit(1);
468  }
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());
473  }
474  else{ // it points to the last remeshing
475  unlink(rocstarlast.c_str());
476  unlink(solverlast.c_str());
477  }
478  }
479  // If rocstartrg already exists, warn and back it up
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 << "."
485  << std::endl;
486  }
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;
492  exit(1);
493  }
494  // If the <solver>/Modin is a directory, then this must be the first remesh
495  // The plan is to mv <solver>/Modin to <solver>/Modin.remesh_00.000000
496  if(S_ISDIR(fstat0.st_mode)){
497  // bummer, <solver>/Modin.remesh_00.000000 already existed. this should
498  // probably never happen, but if it does, warn and back it up as
499  // <solver>/Modin.remesh_save_00.000000
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 << "."
505  << std::endl;
506  }
507  rename(solversrc.c_str(),solvertrg0.c_str());
508  symlink(strg0.c_str(),solversrc.c_str());
509  }
510  // If solvertrg already exists, warn and back it up
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 << "."
516  << std::endl;
517  }
518  mkdir(solvertrg.c_str(),S_IRWXG | S_IRWXU);
519  symlink(ResolveLink(solversrc.c_str()).c_str(),solverlast.c_str());
520  // Deal with RocburnAPN
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)){
528  // RocburnAPN/Rocout is a directory, but RocburnAPN/Rocout.remesh_0
529  // already exists. Warn and back up the previous one.
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;
535  }
536  rename(rocburnapnsrc.c_str(),rocburnapntrg0.c_str());
537  symlink(rtrg0.c_str(),rocburnapnsrc.c_str());
538  }
539  if(!stat(rocburnapntrg.c_str(),&fstat1)){
540  // RocburnAPN/Rocout.remesh_<timestamp> already exists, warn and back it
541  // up.
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;
547  }
548  mkdir(rocburnapntrg.c_str(), S_IRWXG | S_IRWXU);
549  unlink(rocburnapnsrc.c_str());
550  symlink(rtrg.c_str(),rocburnapnsrc.c_str());
551  }
552 }
std::string TRAIL_TimeString(double t)
Definition: TRAIL.C:85
std::string ResolveLink(const std::string &path)

Here is the call graph for this function:

void TRAIL_RemeshShutdown ( MPI_Comm  comm)

Definition at line 102 of file RemeshFunctions.C.

103 {
104  chdir("rocstardir");
105 }
bool TRAIL_RemeshWrite ( GEM_Partition gp,
const std::string &  path,
double  t = 0.0,
MPI_Comm  comm = MPI_COMM_NULL,
bool  = false 
)
bool TRAIL_RemeshWrite ( GEM_Partition gp,
const std::string &  solver,
const std::string &  source_directory,
const std::string &  target_directory,
double  t,
MPI_Comm  comm,
bool  surftrans,
bool  restartshuffle 
)

Definition at line 795 of file RemeshFunctions.C.

References GEM_Partition::_debug, GEM_Partition::_npart, GEM_Partition::_out, COM_delete_window(), COM_new_window(), COM_set_profiling(), GEM_Partition::DestroyWindows(), GEM_Partition::InitRoccomWindows(), MPI_COMM_WORLD, rank, test(), TRAIL_CD(), TRAIL_CreateDirectory(), TRAIL_CWD(), TRAIL_FILEEXISTS(), TRAIL_FluCopyCaseFiles(), TRAIL_FluInitSolver(), TRAIL_FluPopRemBordIndFILE(), TRAIL_FluRegisterSurfMesh(), TRAIL_FluRegisterSurfSoln(), TRAIL_FluRegisterVolSoln(), TRAIL_FluWriteNative(), TRAIL_ISDIR(), TRAIL_ISLINK(), TRAIL_RemeshAutoSurfer(), TRAIL_RemeshInitFluSurfData(), TRAIL_RemeshInitFluVolData(), TRAIL_SafeRemove(), TRAIL_TimeString(), GEM_Partition::WindowInitDone(), and GEM_Partition::WriteRocstar().

801 {
802  // transfer_surface_data = false;
803  std::string source_directory(srcd);
804  std::string target_directory(trgd);
805  std::string rocstarrunsrc("Rocout");
806  std::string defaultrocstartrg("Rocout.remesh_"+TRAIL_TimeString(t));
807  if(source_directory.empty())
808  source_directory = rocstarrunsrc;
809  if(target_directory.empty())
810  target_directory = defaultrocstartrg;
811  std::string homedir(TRAIL_CWD());
812  std::string timestring(TRAIL_TimeString(t));
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");
823 
825  int rank = 0;
826  MPI_Comm_rank(comm,&rank);
827  int nproc = 0;
828  MPI_Comm_size(comm,&nproc);
829  gp._npart = nproc;
830  std::cout << flush;
831  MPI_Barrier(comm);
832  std::string rocstardir("..");
833  if(!rank){
834  TRAIL_CD(rocstardir,gp._out);
835  rocstardir.assign(TRAIL_CWD());
836  TRAIL_CD(homedir,gp._out);
837  }
838  std::string solverdir(rocstardir+"/"+solver);
839  if(!TRAIL_FILEEXISTS(rocstarsrc)){
840  if(!rank)
841  std::cerr << "TRAIL_RemeshWrite: Fatal Error: Source directory, "
842  << rocstarsrc << " does not exist. Exiting." << std::endl;
843  if(gp._out)
844  *gp._out << "TRAIL_RemeshWrite: Fatal Error: Souce directory, "
845  << rocstarsrc << " does not exist. Exiting." << std::endl;
846  exit(1);
847  }
848  if(!TRAIL_FILEEXISTS(solversrc)){
849  if(!rank)
850  std::cerr << "TRAIL_RemeshWrite: Fatal Error: Source directory, "
851  << solversrc << " does not exist. Exiting." << std::endl;
852  if(gp._out)
853  *gp._out << "TRAIL_RemeshWrite: Fatal Error: Souce directory, "
854  << solversrc << " does not exist. Exiting." << std::endl;
855  exit(1);
856  }
857  if(!TRAIL_FILEEXISTS(rocstartrg))
858  TRAIL_CreateDirectory(rocstartrg);
859  if(!TRAIL_FILEEXISTS(solvertrg))
860  TRAIL_CreateDirectory(solvertrg);
861  if(comm != MPI_COMM_WORLD && gp._out)
862  *gp._out << "TRAIL_RemeshWrite: WARNING: communicator is "
863  << (comm == MPI_COMM_NULL ? "null." : "not worldly.")
864  << std::endl;
865  if(gp._debug && gp._out)
866  *gp._out << "TRAIL_RemeshWrite: Preparing to write remeshed dataset for "
867  << solver << "." << std::endl;
868  MPI_Barrier(comm);
869  if(!rank)
870  std::cout << std::endl
871  << "Roctrail> Processing solver data for " << solver
872  << std::endl;
873  MPI_Barrier(comm);
874  if(gp._debug){
875  if(gp._out)
876  *gp._out << "TRAIL_RemeshWrite: Window test..." << std::endl;
877  MPI_Barrier(comm);
878  string test("test");
879  if(gp._out)
880  *gp._out << " creation..." << std::endl;
881  MPI_Barrier(comm);
883  MPI_Barrier(comm);
884  if(gp._out)
885  *gp._out << " destruction..." << std::endl;
886  MPI_Barrier(comm);
888  MPI_Barrier(comm);
889  if(gp._out)
890  *gp._out << "TRAIL_RemeshWrite: Window test passed, graduating..."
891  << std::endl;
892  }
893  // Write Rocflu remesh
894  if(solver == "Rocflu"){
895 
896  // COM_delete_window("ifluid");
897  if(gp._debug && gp._out)
898  *gp._out << "TRAIL_RemeshWrite: Initializing solver data..." << std::endl;
899  if(!TRAIL_FluInitSolver(gp,solver))
900  return(false);
901  // Now that we have Rocflu's paths defined and target directories created,
902  // we can copy in the necessary Rocflu casefiles from the solver source to
903  // the solver target directories.
904  TRAIL_FluCopyCaseFiles(gp,solvertrg);
905  if(gp._debug && gp._out)
906  *gp._out << "TRAIL_RemeshWrite: Solver data init done." << std::endl
907  << "TRAIL_RemeshWrite: Writing native files (pass 1)..."
908  << std::endl;
909  if(!TRAIL_FluWriteNative(gp,solvertrg))
910  return(false);
911  MPI_Barrier(comm);
912  if(gp._debug && gp._out)
913  *gp._out << "TRAIL_RemeshWrite: Solver native files written (pass 1)."
914  << std::endl
915  << "TRAIL_RemeshWrite: Populating remote border indices..."
916  << std::endl;
917  MPI_Barrier(comm);
918  if(!TRAIL_FluPopRemBordIndFILE(gp,0.0,true,solvertrg))
919  return(false);
920  MPI_Barrier(comm);
921  if(gp._debug && gp._out)
922  *gp._out << "TRAIL_RemeshWrite: Remote border indices populated."
923  << std::endl
924  << "TRAIL_RemeshWrite: Writing native files (pass 2)..."
925  << std::endl;
926  MPI_Barrier(comm);
927  if(!TRAIL_FluWriteNative(gp,solvertrg))
928  return(false);
929  MPI_Barrier(comm);
930  if(gp._debug && gp._out)
931  *gp._out << "TRAIL_RemeshWrite: Solver native files written (pass 2)."
932  << std::endl
933  << "TRAIL_RemeshWrite: Initializing volume data..."
934  << std::endl;
935  MPI_Barrier(comm);
936  if(!TRAIL_RemeshInitFluVolData(gp,0))
937  return(false);
938  MPI_Barrier(comm);
939  if(gp._debug && gp._out)
940  *gp._out << "TRAIL_RemeshWrite: Volume data initialized."
941  << std::endl
942  << "TRAIL_RemeshWrite: Initializing surface data..."
943  << std::endl;
944  MPI_Barrier(comm);
946  return(false);
947  MPI_Barrier(comm);
948  if(gp._debug && gp._out)
949  *gp._out << "TRAIL_RemeshWrite: Surface data initialized."
950  << std::endl
951  << "TRAIL_RemeshWrite: Initializing Roccom Windows..."
952  << std::endl;
953  MPI_Barrier(comm);
954  if(!rank)
955  std::cout << "Roctrail> Creating Roccom Windows" << std::endl;
956  if(!gp.InitRoccomWindows("remesh"))
957  return(false);
958  MPI_Barrier(comm);
959  if(gp._debug && gp._out)
960  *gp._out << "TRAIL_RemeshWrite: Roccom windows initialized."
961  << std::endl
962  << "TRAIL_RemeshWrite: Registering surface meshes..."
963  << std::endl;
964  MPI_Barrier(comm);
966  return(false);
967  MPI_Barrier(comm);
968  if(gp._debug && gp._out)
969  *gp._out << "TRAIL_RemeshWrite: Surface meshes registered."
970  << std::endl
971  << "TRAIL_RemeshWrite: Registering volume solution..."
972  << std::endl;
973  MPI_Barrier(comm);
974  if(!TRAIL_FluRegisterVolSoln(gp))
975  return(false);
976  MPI_Barrier(comm);
977  if(gp._debug && gp._out)
978  *gp._out << "TRAIL_RemeshWrite: Volume soln registered."
979  << std::endl
980  << "TRAIL_RemeshWrite: Registering surface solution..."
981  << std::endl;
982  MPI_Barrier(comm);
984  return(false);
985  MPI_Barrier(comm);
986  if(gp._debug && gp._out)
987  *gp._out << "TRAIL_RemeshWrite: Surface soln registered."
988  << std::endl;
989  MPI_Barrier(comm);
990  if(!gp.WindowInitDone())
991  return(false);
992  if(!rank)
993  std::cout << "Roctrail> Writing windows to Rocstar format"
994  << std::endl;
995  MPI_Barrier(comm);
996  if(gp._debug && gp._out)
997  *gp._out << " writing..." << std::endl;
998  MPI_Barrier(comm);
999  if(!gp.WriteRocstar(rocstartrg,t))
1000  return(false);
1001  MPI_Barrier(comm);
1002  TRAIL_CD(homedir,gp._out);
1003  gp.DestroyWindows();
1004  if(gp._debug && gp._out)
1005  *gp._out << " done writing" << std::endl;
1006  MPI_Barrier(comm);
1007 
1008  // Set up Rocin Control Files for Rocstar
1009  if(rocstarshuffle){
1010  if(!rank){
1011  std::cout << "Roctrail> Setting up Rocin control files for Rocstar"
1012  << std::endl;
1013  if(!TRAIL_FILEEXISTS(fluvolcntl+".orig") && TRAIL_FILEEXISTS(fluvolcntl))
1014  rename(fluvolcntl.c_str(),(fluvolcntl+".orig").c_str());
1015  if(!TRAIL_FILEEXISTS(flusurfcntl+".orig") &&
1016  TRAIL_FILEEXISTS(flusurfcntl))
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());
1020  }
1021  }
1022  if(surftrans){
1023  if(!rank)
1024  std::cout << "Roctrail> Proceeding with surface data transfer..."
1025  << std::endl;
1026  if(gp._debug && gp._out)
1027  *gp._out << "TRAIL_RemeshWrite: Performing surface data transfer..."
1028  << std::endl;
1029  TRAIL_RemeshAutoSurfer(gp,"ifluid",rocstarsrc,
1030  rocstartrg,rocstartrg,t,comm);
1031  MPI_Barrier(comm);
1032  // Reset Rocin Control Files for populated surface
1033  if(rocstarshuffle){
1034  if(!rank){
1035  std::cout << "Roctrail> Resetting Rocin control files"
1036  << std::endl;
1037  unlink(flusurfcntl.c_str());
1038  surfcntl.assign("new_surf_in_"+timestring+".txt");
1039  symlink(surfcntl.c_str(),flusurfcntl.c_str());
1040  }
1041  }
1042  if(!rank)
1043  std::cout << "Roctrail> Surface data transfer done." << std::endl;
1044  if(gp._debug && gp._out)
1045  *gp._out << "TRAIL_RemeshWrite: Surface transfer complete."
1046  << std::endl;
1047  MPI_Barrier(comm);
1048  }
1049  MPI_Barrier(comm);
1050  TRAIL_CD(homedir,gp._out);
1051  // Prepare Rocstar restart files
1052  if(rocstarshuffle){
1053  if(!rank){
1054  std::cout << "Roctrail> Preparing Rocstar restart directories."
1055  << std::endl;
1056  std::string rocstarbackup0(rocstardir+"/"+solver+
1057  "/Rocout.remesh_00.000000");
1058  if(rocstartrg != rocstarrunsrc){
1059  // <solver>/Rocout is an actual directory, back it up as
1060  // Rocout.remesh_00.000000
1061  if(TRAIL_ISDIR(solverdir+"/"+rocstarrunsrc) &&
1062  !TRAIL_ISLINK(solverdir+"/"+rocstarrunsrc)){
1063  TRAIL_SafeRemove(rocstarbackup0,".save");
1064  rename((solverdir+"/"+rocstarrunsrc).c_str(),
1065  rocstarbackup0.c_str());
1066  }
1067  else if(TRAIL_ISLINK(solverdir+"/"+rocstarrunsrc))
1068  unlink((solverdir+"/"+rocstarrunsrc).c_str());
1069  if(gp._debug)
1070  std::cout << "Roctrail> Attempting to link " << rocstarrunsrc
1071  << " to " << rtrg << "." << std::endl;
1072  symlink(rtrg.c_str(),(solverdir+"/"+rocstarrunsrc).c_str());
1073  // Modin is a directory, act accordingly
1074  std::string solverbackup0(rocstardir+"/"+solver+
1075  "/Modin.remesh_00.000000");
1076  if(TRAIL_ISDIR(rocstardir+"/"+solversrc) &&
1077  !TRAIL_ISLINK(rocstardir+"/"+solversrc)){
1078  TRAIL_SafeRemove(solverbackup0,".save");
1079  rename((rocstardir+"/"+solversrc).c_str(),solverbackup0.c_str());
1080  }
1081  else if(TRAIL_ISLINK(solversrc))
1082  unlink((rocstardir+"/"+solversrc).c_str());
1083  if(gp._debug)
1084  std::cout << "Roctrail> Attempting to link " << solversrc << " to "
1085  << strg << "." << std::endl;
1086  symlink(strg.c_str(),(rocstardir+"/"+solversrc).c_str());
1087  }
1088  }
1089  if(!rank)
1090  std::cout << "Roctrail> Rocstar restart data done." << std::endl;
1091  }
1092  if(gp._debug && gp._out)
1093  *gp._out << "TRAIL_RemeshWrite: All done." << std::endl
1094  << "TRAIL_RemeshWrite: Exit" << std::endl;
1095  if(!rank)
1096  std::cout << "Roctrail> Goodbye" << std::endl;
1097  MPI_Barrier(comm);
1098  return(true);
1099  }
1100  if(gp._out)
1101  *gp._out << "TRAIL_RemeshWrite::Error: Unknown solver, " << solver << "."
1102  << std::endl
1103  << (gp._debug ? "TRAIL_RemeshWrite: Exit" : "") << std::endl;
1104  return(false);
1105 }
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)
Definition: GEM.C:685
bool TRAIL_FILEEXISTS(const std::string &fname)
bool TRAIL_FluInitSolver(GEM_Partition &gp, const std::string &prefix="./")
void COM_delete_window(const char *wname)
Definition: roccom_c++.h:94
int TRAIL_CD(const std::string &path, std::ostream *=NULL)
bool TRAIL_ISDIR(const std::string &fname)
unsigned int _npart
Definition: GEM.H:285
void TRAIL_SafeRemove(const std::string &fname, const std::string &ext)
bool WriteRocstar(const std::string &, double t=0.0)
Definition: GEM.C:601
std::string TRAIL_TimeString(double t)
Definition: TRAIL.C:85
bool TRAIL_FluRegisterSurfMesh(GEM_Partition &gp)
bool DestroyWindows()
Definition: GEM.C:584
std::ostream * _out
Definition: GEM.H:308
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)
void test(void)
Definition: flotsam.C:99
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Definition: roccom_c++.h:86
void COM_set_profiling(int i)
Definition: roccom_c++.h:550
bool TRAIL_FluPopRemBordIndFILE(GEM_Partition &gp, double t=0.0, bool unsteady=true, const std::string &path="./")
int TRAIL_CreateDirectory(const std::string &fname)
bool WindowInitDone()
Definition: GEM.C:575
bool _debug
Definition: GEM.H:310
static int rank
Definition: advectest.C:66
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)
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)

Here is the call graph for this function: