Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sepin.C File Reference
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <cassert>
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
Include dependency graph for sepin.C:

Go to the source code of this file.

Functions

std::string CWD ()
 
int ChangeDirectory (const std::string &path)
 
int CreateDirectory (const std::string &fname)
 
bool FILEEXISTS (const std::string &fname)
 
int main (int argc, char *argv[])
 

Function Documentation

int ChangeDirectory ( const std::string &  path)

Definition at line 20 of file sepin.C.

Referenced by main().

21 {
22  return(chdir(path.c_str()));
23 }

Here is the caller graph for this function:

int CreateDirectory ( const std::string &  fname)

Definition at line 26 of file sepin.C.

Referenced by main(), and GridConversion::MakeProject().

27 {
28  return(mkdir(fname.c_str(),S_IRGRP | S_IXGRP | S_IRWXU));
29 }

Here is the caller graph for this function:

std::string CWD ( )

Definition at line 13 of file sepin.C.

14 {
15  char buf[1024];
16  return(std::string(getcwd(buf,1024)));
17 }
bool FILEEXISTS ( const std::string &  fname)

Definition at line 32 of file sepin.C.

Referenced by main(), and GridConversion::MakeProject().

33 {
34  struct stat fstat;
35  if(lstat(fname.c_str(),&fstat))
36  return false;
37  return true;
38 }

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 40 of file sepin.C.

References ChangeDirectory(), CreateDirectory(), FILEEXISTS(), and i.

41 {
42  if(argc < 2)
43  return 1;
44  std::string numproc_s(argv[1]);
45  std::istringstream Istr(numproc_s);
46  std::ofstream RocinSurfFile;
47  std::ofstream RocinVolFile;
48  std::ifstream OrigSurfFile;
49  std::ifstream OrigVolFile;
50  OrigSurfFile.open("ifluid_in_00.000000.txt");
51  OrigVolFile.open("fluid_in_00.000000.txt");
52  std::string surfpanes;
53  std::string surffiles;
54  std::string volpanes;
55  std::string volfiles;
56  std::string junk;
57  OrigSurfFile >> junk >> junk >> junk
58  >> surffiles >> junk;
59  std::getline(OrigSurfFile,surfpanes);
60  OrigVolFile >> junk >> junk >> junk
61  >> volfiles >> junk;
62  std::getline(OrigVolFile,volpanes);
63  OrigSurfFile.close();
64  OrigVolFile.close();
65  rename("ifluid_in_00.000000.txt","ifluid_in_00.000000.txt.orig");
66  rename("fluid_in_00.000000.txt","fluid_in_00.000000.txt.orig");
67  RocinSurfFile.open("ifluid_in_00.000000.txt");
68  RocinVolFile.open("fluid_in_00.000000.txt");
69  int np = 0;
70  Istr >> np;
71  for(int i = 0; i < np; i++){
72  RocinSurfFile << "@Proc: " << i << std::endl;
73  RocinVolFile << "@Proc: " << i << std::endl;
74  int fileid = i+1;
75  std::ostringstream Ostr;
76  std::ostringstream Ostr2;
77  Ostr2 << i;
78  int nchar = Ostr2.str().length();
79  nchar = 4 - nchar;
80  while(nchar--)
81  Ostr << "0";
82  Ostr << Ostr2.str();
83  RocinSurfFile << "@Files: " << Ostr.str() << "/" << surffiles << std::endl
84  << "@Panes: " << surfpanes << std::endl << std::endl;
85  RocinVolFile << "@Files: " << Ostr.str() << "/" << volfiles << std::endl
86  << "@Panes: " << volpanes << std::endl << std::endl;
87  CreateDirectory(Ostr.str());
88  ChangeDirectory(Ostr.str());
89  Ostr2.clear();
90  Ostr2.str("");
91  Ostr2 << fileid;
92  nchar = 5 - Ostr2.str().length();
93  Ostr.clear();
94  Ostr.str("");
95  while(nchar--)
96  Ostr << "0";
97  Ostr << fileid;
98  std::ostringstream FNout;
99  std::ostringstream FNout2;
100  FNout << "fluid_" << Ostr.str() << ".hdf";
101  FNout2 << "../fluid_" << Ostr.str() << ".hdf";
102  symlink(FNout2.str().c_str(),FNout.str().c_str());
103  FNout.clear();
104  FNout2.clear();
105  FNout.str("");
106  FNout2.str("");
107  FNout << "ifluid_" << Ostr.str() << ".hdf";
108  FNout2 << "../ifluid_" << Ostr.str() << ".hdf";
109  if(FILEEXISTS(FNout2.str()))
110  symlink(FNout2.str().c_str(),FNout.str().c_str());
111  ChangeDirectory(std::string(".."));
112  }
113  RocinSurfFile.close();
114  RocinVolFile.close();
115  return 0;
116 }
bool FILEEXISTS(const std::string &fname)
Definition: sepin.C:32
blockLoc i
Definition: read.cpp:79
int ChangeDirectory(const std::string &path)
Definition: sepin.C:20
int CreateDirectory(const std::string &fname)
Definition: sepin.C:26

Here is the call graph for this function: