MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CFile Class Reference

takes data and fstat files and splits them into *.data.???? and *.fstat.???? files More...

Public Member Functions

 CFile (std::string name)
 Constructor. More...
 
 ~CFile ()
 Destructor. More...
 
bool copy ()
 
 CFile (std::string name)
 Constructor. More...
 
 ~CFile ()
 Destructor. More...
 
void copy (double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, double timeMin, double timeMax, unsigned int periodic)
 
void writeP4P (double timeMin, double timeMax)
 
void writeP4C (std::fstream &fstat, double timeData)
 
void writeP4W (std::fstream &fstat, double timeData)
 
void writeRestart (double timeData, double density)
 
std::string getName (std::string type, unsigned int counter)
 
 CFile (std::string name)
 Constructor. More...
 
 ~CFile ()
 Destructor. More...
 
bool copy (unsigned int stepsize, unsigned int counter)
 
bool copy_data (unsigned int stepsize, unsigned int counter)
 
bool copy_fstat (unsigned int stepsize, unsigned int counter)
 

Public Attributes

double splittingradius
 
bool splittinginfo
 
int info0
 
int info1
 

Private Attributes

std::stringstream data_filename
 These store the save file names,. More...
 
std::stringstream com_filename
 
std::fstream data_file
 Stream used for data files. More...
 
std::fstream com_file
 
std::string name_
 These store the save file names,. More...
 
std::fstream p4p
 Stream used for data files. More...
 
std::fstream p4c
 
std::fstream p4w
 
double xmin_
 
double xmax_
 
double ymin_
 
double ymax_
 
double zmin_
 
double zmax_
 
std::vector< Vec3Dposition_
 
std::vector< unsigned intid_
 
unsigned int periodic_
 
std::stringstream fstat_filename
 
std::fstream fstat_file
 

Detailed Description

takes data and fstat files and splits them into *.data.???? and *.fstat.???? files

Definition at line 38 of file centerofmass.cpp.

Constructor & Destructor Documentation

CFile::CFile ( std::string  name)
inline

Constructor.

Definition at line 43 of file centerofmass.cpp.

References com_file, com_filename, data_file, data_filename, splittinginfo, and splittingradius.

43  {
44  //set file names
45  data_filename.str("");
46  data_filename << name << ".data";
47  com_filename.str("");
48  com_filename << name << ".com";
49 
50  //open in-streams
51  data_file.open(data_filename.str().c_str(), std::fstream::in);
52 
53  if (data_file.fail())
54  {
55  std::cerr << "ERROR: Input file " << data_filename.str() << " not found" << std::endl;
56  data_file.close();
57  exit(-1);
58  } else {
59  std::cout << "Files opened: " << data_filename.str() << std::endl;
60  }
61 
62  //open out-stream
63  com_file.open(com_filename.str().c_str(), std::fstream::out);
64 
65  if (com_file.fail())
66  {
67  std::cerr << "ERROR: Output file " << com_filename.str() << " not found" << std::endl;
68  com_file.close();
69  exit(-1);
70  } else {
71  std::cout << "Files opened: " << com_filename.str() << std::endl;
72  }
73 
75  splittinginfo=false;
76  }
std::stringstream com_filename
double splittingradius
std::fstream data_file
Stream used for data files.
std::fstream com_file
bool splittinginfo
std::stringstream data_filename
These store the save file names,.
CFile::~CFile ( )
inline

Destructor.

Definition at line 79 of file centerofmass.cpp.

References com_file, com_filename, data_file, and data_filename.

79  {
80  data_file.close();
81  std::cout << "Files closed: " << data_filename.str() << std::endl;
82  com_file.close();
83  std::cout << "Files closed: " << com_filename.str() << std::endl;
84  }
std::stringstream com_filename
std::fstream data_file
Stream used for data files.
std::fstream com_file
std::stringstream data_filename
These store the save file names,.
CFile::CFile ( std::string  name)
inline

Constructor.

Definition at line 46 of file ConvertP4Files.cpp.

References p4c, p4p, and p4w.

46  : name_(name){
47 
48  //set file names
49  std::string p4pName(name+".p4p");
50  std::string p4cName(name+".p4c");
51  std::string p4wName(name+".p4w");
52 
53  //open input file streams
54  p4p.open(p4pName.c_str(), std::fstream::in);
55  p4c.open(p4cName.c_str(), std::fstream::in);
56  p4w.open(p4wName.c_str(), std::fstream::in);
57 
58  if (p4p.fail() || p4c.fail() || p4w.fail())
59  {
60  if (p4p.fail())
61  std::cerr << "ERROR: Input file " << p4pName << " not found" << std::endl;
62  if (p4c.fail())
63  std::cerr << "ERROR: Input file " << p4cName << " not found" << std::endl;
64  if (p4w.fail())
65  std::cerr << "ERROR: Input file " << p4wName << " not found" << std::endl;
66  p4p.close();
67  p4c.close();
68  p4w.close();
69  exit(-1);
70  } else {
71  std::cout << "Files opened: " << p4pName << " and " << p4cName << " and " << p4wName << std::endl;
72  }
73  }
std::fstream p4w
std::string name_
These store the save file names,.
std::fstream p4c
std::fstream p4p
Stream used for data files.
CFile::~CFile ( )
inline

Destructor.

Definition at line 76 of file ConvertP4Files.cpp.

References name_, p4c, p4p, and p4w.

76  {
77  p4p.close();
78  p4c.close();
79  p4w.close();
80  std::cout << "Files closed: " << name_ << ".p4p/p4w/p4c" << std::endl;
81  }
std::fstream p4w
std::string name_
These store the save file names,.
std::fstream p4c
std::fstream p4p
Stream used for data files.
CFile::CFile ( std::string  name)
inline

Constructor.

Definition at line 43 of file SplitFiles.cpp.

References data_file, data_filename, fstat_file, and fstat_filename.

43  {
44  //set file names
45  data_filename.str("");
46  data_filename << name << ".data";
47  fstat_filename.str("");
48  fstat_filename << name << ".fstat";
49 
50  //open in-streams
51  data_file.open(data_filename.str().c_str(), std::fstream::in);
52  fstat_file.open(fstat_filename.str().c_str(), std::fstream::in);
53 
54  if (data_file.fail() || fstat_file.fail())
55  {
56  std::cerr << "ERROR: Input file " << data_filename.str() << " or " << fstat_filename.str() << " not found" << std::endl;
57  data_file.close();
58  fstat_file.close();
59  exit(-1);
60  } else {
61  std::cout << "Files opened: " << data_filename.str() << " and " << fstat_filename.str() << std::endl;
62  }
63  }
std::fstream fstat_file
Definition: SplitFiles.cpp:169
std::stringstream fstat_filename
Definition: SplitFiles.cpp:165
std::fstream data_file
Stream used for data files.
std::stringstream data_filename
These store the save file names,.
CFile::~CFile ( )
inline

Destructor.

Definition at line 66 of file SplitFiles.cpp.

References data_file, data_filename, fstat_file, and fstat_filename.

66  {
67  data_file.close();
68  fstat_file.close();
69  std::cout << "Files closed: " << data_filename.str() << " and " << fstat_filename.str() << std::endl;
70  }
std::fstream fstat_file
Definition: SplitFiles.cpp:169
std::stringstream fstat_filename
Definition: SplitFiles.cpp:165
std::fstream data_file
Stream used for data files.
std::stringstream data_filename
These store the save file names,.

Member Function Documentation

bool CFile::copy ( unsigned int  stepsize,
unsigned int  counter 
)
inline

Definition at line 72 of file SplitFiles.cpp.

References copy_data(), and copy_fstat().

72  {
73  //return copy_last_time_step();
74  return copy_data(stepsize,counter) && copy_fstat(stepsize,counter);
75  }
bool copy_fstat(unsigned int stepsize, unsigned int counter)
Definition: SplitFiles.cpp:117
bool copy_data(unsigned int stepsize, unsigned int counter)
Definition: SplitFiles.cpp:77
void CFile::copy ( double  xmin,
double  xmax,
double  ymin,
double  ymax,
double  zmin,
double  zmax,
double  timeMin,
double  timeMax,
unsigned int  periodic 
)
inline

Definition at line 83 of file ConvertP4Files.cpp.

References periodic_, writeP4P(), xmax_, xmin_, ymax_, ymin_, zmax_, and zmin_.

83  {
84  std::cout << "copy(..)" << std::endl;
85  xmin_ = xmin;
86  xmax_ = xmax;
87  ymin_ = ymin;
88  ymax_ = ymax;
89  zmin_ = zmin;
90  zmax_ = zmax;
91  periodic_=periodic;
92  writeP4P(timeMin,timeMax);
93  }
unsigned int periodic_
void writeP4P(double timeMin, double timeMax)
double ymin_
double zmin_
double xmax_
double xmin_
double zmax_
double ymax_
bool CFile::copy ( )
inline

Definition at line 86 of file centerofmass.cpp.

References AZ, com_file, data_file, info0, info1, R, splittinginfo, splittingradius, X, Y, and Z.

Referenced by main().

86  {
87  unsigned int N;
88  double X, Y, Z;
89  double CX, CY, CZ;
90  double CX1, CY1, CZ1;
91  double CX2, CY2, CZ2;
92  double VX, VY, VZ;
93  double AX, AY, AZ;
94  double WX, WY, WZ;
95  double T, R, M, M1, M2, mass, info;
96  std::string line;
97  std::stringstream output_filename;
98  std::fstream output_file;
99 
100  data_file >> N;
101  while (data_file.good()) {
102  M = M1 = M2 = 0.0;
103  data_file >> T;
104  //open, write, close output file
105  getline(data_file,line);
106  CX = CY = CZ = 0.0;
107  CX1 = CY1 = CZ1 = 0.0;
108  CX2 = CY2 = CZ2 = 0.0;
109  for (unsigned int i=0; i<N; i++) {
110  data_file >> X >> Y >> Z >> VX >> VY >> VZ >> R >> AX >> AY >> AZ >> WX >> WY >> WZ >> info;
111  mass=R*R*R;
112  getline(data_file,line);
113 
114  if (splittingradius){
115  CX += X*mass; CY += Y*mass; CZ += Z*mass; M+=mass;
116  }
117  if (splittinginfo){
118  if(info==info0||info==info1){
119  CX += X*mass; CY += Y*mass; CZ += Z*mass; M+=mass;
120  }
121  }
122  if (splittingradius) {
123  if (R<splittingradius) {
124  CX1 += X*mass; CY1 += Y*mass; CZ1 += Z*mass; M1+=mass;
125  } else {
126  CX2 += X*mass; CY2 += Y*mass; CZ2 += Z*mass; M2+=mass;
127  }
128  }
129  if (splittinginfo) {
130  //std::cout << "hello" << std::endl;
131  if (info==info0) {
132  //std::cout << "hello" << std::endl;
133  CX1 += X*mass; CY1 += Y*mass; CZ1 += Z*mass; M1+=mass;
134  } else if (info==info1) {
135  CX2 += X*mass; CY2 += Y*mass; CZ2 += Z*mass; M2+=mass;
136  }
137  }
138  }
140  com_file << T << " " << CX/M << " " << CY/M << " " << CZ/M;
141  com_file << " " << CX1/M1 << " " << CY1/M1 << " " << CZ1/M1;
142  com_file << " " << CX2/M2 << " " << CY2/M2 << " " << CZ2/M2 << std::endl;
143  } else {
144  com_file << T << " " << CX/M << " " << CY/M << " " << CZ/M << std::endl;
145  }
146  data_file >> N;
147  }
148  return true;
149  }
double splittingradius
std::fstream data_file
Stream used for data files.
std::fstream com_file
bool splittinginfo
bool CFile::copy_data ( unsigned int  stepsize,
unsigned int  counter 
)
inline

Definition at line 77 of file SplitFiles.cpp.

References data_file, and data_filename.

Referenced by copy().

77  {
78  unsigned int N;
79  std::string line;
80  std::stringstream output_filename;
81  std::fstream output_file;
82 
83  data_file >> N;
84  while (data_file.good()) {
85  //set output_filename
86  std::stringstream output_filename("");
87  output_filename << data_filename.str() << ".";
88  if (counter<1000) output_filename << "0";
89  if (counter<100) output_filename << "0";
90  if (counter<10) output_filename << "0";
91  output_filename << counter;
92  counter ++;
93  //std::cout << "Outputfile: " << output_filename.str() << std::endl;
94 
95  //open, write, close output file
96  output_file.open(output_filename.str().c_str(), std::fstream::out);
97  getline(data_file,line);
98  output_file << N << line << std::endl;
99  std::cout << N << line << std::endl;
100  for (unsigned int i=0; i<N; i++) {
101  getline(data_file,line);
102  output_file << line << std::endl;
103  }
104  output_file.close();
105  data_file >> N;
106 
107  //step over some timesteps
108  for(unsigned int j=1; j<stepsize; j++) {
109  for (unsigned int i=0; i<N+1; i++) getline(data_file,line);
110  data_file >> N;
111  }
112 
113  }
114  return true;
115  }
std::fstream data_file
Stream used for data files.
std::stringstream data_filename
These store the save file names,.
bool CFile::copy_fstat ( unsigned int  stepsize,
unsigned int  counter 
)
inline

Definition at line 117 of file SplitFiles.cpp.

References fstat_file, and fstat_filename.

Referenced by copy().

117  {
118  std::string line;
119  std::stringstream output_filename;
120  std::fstream output_file;
121 
122  getline(fstat_file,line);
123  while (fstat_file.good()) {
124  //set output_filename
125  output_filename.str("");
126  output_filename << fstat_filename.str() << ".";
127  if (counter<1000) output_filename << "0";
128  if (counter<100) output_filename << "0";
129  if (counter<10) output_filename << "0";
130  output_filename << counter;
131  counter ++;
132 
133  //open, write, close output file
134  output_file.open(output_filename.str().c_str(), std::fstream::out);
135  std::cout << line << std::endl;
136  output_file << line << std::endl;
137  getline(fstat_file,line);
138  output_file << line << std::endl;
139  getline(fstat_file,line);
140  output_file << line << std::endl;
141  getline(fstat_file,line);
142  while (line.c_str()[0] != '#'&&fstat_file.good()) {
143  getline(fstat_file,line);
144  output_file << line << std::endl;
145  }
146  output_file.close();
147 
148  //step over some timesteps
149  for(unsigned int j=1; j<stepsize; j++) {
150  getline(fstat_file,line);
151  getline(fstat_file,line);
152  getline(fstat_file,line);
153  while (line.c_str()[0] != '#'&&fstat_file.good()) {
154  getline(fstat_file,line);
155  }
156  }
157  }
158  return true;
159  }
std::fstream fstat_file
Definition: SplitFiles.cpp:169
std::stringstream fstat_filename
Definition: SplitFiles.cpp:165
std::string CFile::getName ( std::string  type,
unsigned int  counter 
)
inline

Definition at line 413 of file ConvertP4Files.cpp.

References name_.

Referenced by writeP4P().

414  {
415  //set dataName
416  std::stringstream name("");
417  name << name_ << "." << type << ".";
418  if (counter < 1000)
419  name << "0";
420  if (counter < 100)
421  name << "0";
422  if (counter < 10)
423  name << "0";
424  name << counter;
425  return name.str();
426  }
std::string name_
These store the save file names,.
void CFile::writeP4C ( std::fstream &  fstat,
double  timeData 
)
inline

Definition at line 201 of file ConvertP4Files.cpp.

References id_, p4c, periodic_, position_, Vec3D::setZero(), writeP4W(), Vec3D::X, xmax_, xmin_, Vec3D::Y, and Vec3D::Z.

Referenced by writeP4P().

201  {
202  unsigned int N;
203  std::string line;
204  std::string dummy;
205  double time;
206  double P1, P2, delta, deltat, fn, ft;
207  Vec3D C1, F, n, t;
208 
209  while (p4c.good()) {
210  //read header
211  p4c >> dummy >> dummy;
212  p4c >> time >> N;
213  getline(p4c,line);
214  getline(p4c,line);
215 
216  if (time<timeData*0.999999)
217  {
218  std::cout << "reading p4c (t " << time << " N " << N << "): below timeMin; skipped" << std::endl;
219  for (unsigned int i=0; i<N; i++)
220  getline(p4c,line);
221  continue;
222  }
223 
224  std::cout << "reading p4c (t " << time << " N " << N << ")" << std::endl;
225 
226  //write fstat file
227  fstat << "# " << time << " " << N << std::endl;
228  fstat << "# " << std::endl;
229  fstat << "# " << std::endl;
230  //double P1, P2, CX, CY, CZ, FX, FY, FZ;
231  //time, i, j, x, y, z, delta, deltat, fn, ft, nx, ny, nz, tx, ty, tz
232 
233  for (unsigned int i=0; i<N; i++) {
234  p4c >> P1
235  >> P2
236  >> C1
237  >> F;
238  //std::cout << i << "|" << P1 << "|" << P2 << "|" << C1 << "|" << F << std::endl;
239  Vec3D C2=C1;
240  Mdouble pos1, pos2;
241  Mdouble *c1, *c2;
242  //std::cout << "C " << C1 << std::endl;
243  if (periodic_)
244  {
245  if (periodic_==1)
246  {
247  pos1 = position_[P1 - 1].X;
248  pos2 = position_[P2 - 1].X;
249  c1 = &C1.X;
250  c2 = &C2.X;
251  }
252  else if (periodic_==2)
253  {
254  pos1 = position_[P1 - 1].Y;
255  pos2 = position_[P2 - 1].Y;
256  c1 = &C1.Y;
257  c2 = &C2.Y;
258  }
259  else //if (periodic_==3)
260  {
261  pos1 = position_[P1 - 1].Z;
262  pos2 = position_[P2 - 1].Z;
263  c1 = &C1.Z;
264  c2 = &C2.Z;
265  }
266  if (pos1 < (xmax_-xmin_)/3.0 && pos2 > 2.0*(xmax_-xmin_)/3.0)
267  {
268  if (*c1 < (xmax_ - xmin_) / 3.0)
269  *c2 += xmax_ - xmin_;
270  else if (*c1 > 2.0*(xmax_ - xmin_) / 3.0)
271  *c1 -= xmax_ - xmin_;
272  }
273  else if (pos1 < (xmax_-xmin_)/3.0 && pos2 > 2.0*(xmax_-xmin_)/3.0)
274  {
275  if (*c1 < (xmax_ - xmin_) / 3.0)
276  *c1 += xmax_ - xmin_;
277  else if (*c1 > 2.0*(xmax_ - xmin_) / 3.0)
278  *c2 -= xmax_ - xmin_;
279  }
280  }
281  //std::cout << "C1 " << C1 << std::endl;
282  //std::cout << "C2 " << C2 << std::endl;
283  //std::cout << "P0 " << position_[P1-1] << std::endl;
284  //std::cout << "P1 " << position_[P2-1] << std::endl;
285  delta=0.0;
286  deltat=0.0;
287  ft=0.0;
288  t.setZero();
289  fn=F.getLength();
290  n=F/fn;
291 
292  fstat << time << " "
293  << id_[P1-1] << " "
294  << id_[P2-1] << " "
295  << C1 << " "
296  << delta << " "
297  << deltat << " "
298  << fn << " "
299  << ft << " "
300  << n << " "
301  << t << std::endl;
302  fstat << time << " "
303  << id_[P2-1] << " "
304  << id_[P1-1] << " "
305  << C2 << " "
306  << delta << " "
307  << deltat << " "
308  << fn << " "
309  << ft << " "
310  << -n << " "
311  << t << std::endl;
312  }
313  writeP4W(fstat, timeData);
314  break;
315  }
316  }
Mdouble X
the vector components
Definition: Vector.h:52
unsigned int periodic_
double Mdouble
void writeP4W(std::fstream &fstat, double timeData)
void setZero()
Sets all elements to zero.
Definition: Vector.cc:52
double xmax_
double xmin_
std::fstream p4c
std::vector< unsigned int > id_
Mdouble Y
Definition: Vector.h:52
std::vector< Vec3D > position_
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble Z
Definition: Vector.h:52
void CFile::writeP4P ( double  timeMin,
double  timeMax 
)
inline

Definition at line 95 of file ConvertP4Files.cpp.

References getName(), id_, p4p, constants::pi, position_, writeP4C(), writeRestart(), Vec3D::X, xmax_, xmin_, Vec3D::Y, ymax_, ymin_, Vec3D::Z, zmax_, and zmin_.

Referenced by copy().

95  {
96  std::cout << "writeP4P(..)" << std::endl;
97 
98  unsigned int N;
99  std::string line;
100  std::fstream data;
101  std::fstream fstat;
102  double time;
103  double ID, GROUP, VOLUME, MASS, VX, VY, VZ, Angular_Velocity_X, Angular_Velocity_Y, Angular_Velocity_Z;
104 
105  unsigned int counter = 0;
106  while (p4p.good())
107  {
108  //read header
109  std::string dummy;
110  p4p >> dummy >> dummy;
111  p4p >> time >> N;
112  getline(p4p,line);
113  getline(p4p,line);
114 
115  if (time>timeMax)
116  {
117  std::cout << "reading p4p (t " << time << " N " << N << "): timeMax reached; terminating" << std::endl;
118  break;
119  }
120  else if (time<timeMin)
121  {
122  std::cout << "reading p4p (t " << time << " N " << N << "): below timeMin; skipped" << std::endl;
123  for (unsigned int i=0; i<N; i++)
124  getline(p4p,line);
125  continue;
126  }
127 
128  std::cout << "reading p4p (t " << time << " N " << N << " timestep #" << counter << ")" << std::endl;
129 
130  //open data/fstat file
131  std::string dataName = getName("data", counter);
132  data.open(dataName.c_str(), std::fstream::out);
133  std::string fstatName = getName("fstat", counter);
134  fstat.open(fstatName.c_str(), std::fstream::out);
135  std::cout << "Files opened: " << dataName << " and " << fstatName << std::endl;
136 
137  //write data file
138  data<< N << " "
139  << time << " "
140  << xmin_ << " "
141  << ymin_ << " "
142  << zmin_ << " "
143  << xmax_ << " "
144  << ymax_ << " "
145  << zmax_ << std::endl;
146 
147  position_.resize(N*1.1);
148  id_.resize(N*1.1);
149  for (unsigned int i=0; i<N; i++) {
150  p4p >> ID;
151  if (position_.size()<ID)
152  {
153  position_.resize(ID*1.1);
154  id_.resize(ID*1.1);
155  }
156  Vec3D& P = position_[ID-1];
157  id_[ID-1]=i;
158  p4p >> GROUP
159  >> VOLUME
160  >> MASS
161  >> P.X
162  >> P.Y
163  >> P.Z
164  >> VX
165  >> VY
166  >> VZ
167  >> Angular_Velocity_X
168  >> Angular_Velocity_Y
169  >> Angular_Velocity_Z;
170  data << P.X << " "
171  << P.Y << " "
172  << P.Z << " "
173  << VX << " "
174  << VY << " "
175  << VZ << " "
176  << pow(6.0/constants::pi*VOLUME,1.0/3.0)/2.0 << " "
177  << 0 << " "
178  << 0 << " "
179  << 0 << " "
180  << Angular_Velocity_X << " "
181  << Angular_Velocity_Y << " "
182  << Angular_Velocity_Z << " "
183  << 0 << std::endl;
184  //std::cout << ID << " ";
185  }
186  std::cout << "written " << dataName << std::endl;
187 
188  writeP4C(fstat, time);
189  std::cout << "written " << fstatName << std::endl;
190 
191  //close data file
192  data.close();
193  fstat.close();
194  ++counter;
195 
196  p4p >> std::ws; //to make sure that p4p.good returns false at end of file
197  }
198  writeRestart(time, MASS/VOLUME);
199  }
Mdouble X
the vector components
Definition: Vector.h:52
double ymin_
double zmin_
void writeP4C(std::fstream &fstat, double timeData)
std::string getName(std::string type, unsigned int counter)
double xmax_
double xmin_
std::vector< unsigned int > id_
const Mdouble pi
Definition: ExtendedMath.h:42
double zmax_
Mdouble Y
Definition: Vector.h:52
std::vector< Vec3D > position_
std::fstream p4p
Stream used for data files.
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble Z
Definition: Vector.h:52
double ymax_
void writeRestart(double timeData, double density)
void CFile::writeP4W ( std::fstream &  fstat,
double  timeData 
)
inline

Definition at line 318 of file ConvertP4Files.cpp.

References id_, p4w, and Vec3D::setZero().

Referenced by writeP4C().

319  {
320  unsigned int N;
321  std::string line;
322  std::string dummy;
323  double time;
324  double P1, delta, deltat, fn, ft;
325  Vec3D C, F, n, t;
326 
327  while (p4w.good()) {
328  //read header
329  p4w >> dummy >> dummy;
330  p4w >> time >> N;
331  getline(p4w,line);
332  getline(p4w,line);
333 
334  if (time<timeData*0.999999)
335  {
336  std::cout << "reading p4w (t " << time << " N " << N << "): below timeMin; skipped" << std::endl;
337  for (unsigned int i=0; i<N; i++)
338  getline(p4w,line);
339  continue;
340  }
341 
342  std::cout << "reading p4w (t " << time << " N " << N << ")" << std::endl;
343 
344  for (unsigned int i=0; i<N; i++) {
345  p4w >> P1
346  >> C
347  >> F;
348  delta=0.0;
349  deltat=0.0;
350  ft=0.0;
351  t.setZero();
352  fn=F.getLength();
353  n=F/fn;
354  fstat << time << " "
355  << id_[P1-1] << " "
356  << -1 << " "
357  << C << " "
358  << delta << " "
359  << deltat << " "
360  << fn << " "
361  << ft << " "
362  << n << " "
363  << t << std::endl;
364  }
365  break;
366  }
367  }
void setZero()
Sets all elements to zero.
Definition: Vector.cc:52
std::fstream p4w
std::vector< unsigned int > id_
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
void CFile::writeRestart ( double  timeData,
double  density 
)
inline

Definition at line 369 of file ConvertP4Files.cpp.

References name_, periodic_, xmax_, xmin_, ymax_, ymin_, zmax_, and zmin_.

Referenced by writeP4P().

370  {
371  std::cout << "restart.0000 " << timeData << std::endl;
372  //open data/fstat file
373  std::fstream restart;
374  restart.open(name_ + ".restart", std::fstream::out);
375  restart <<
376  "restart_version 1.0 name " << name_ << "\n"
377  "dataFile name " << name_ << ".data fileType MULTIPLE_FILES_PADDED saveCount 1 counter 1 nextSavedTimeStep 0\n"
378  "fStatFile name " << name_ << ".fstat fileType MULTIPLE_FILES_PADDED saveCount 1 counter 1 nextSavedTimeStep 0\n"
379  "eneFile name " << name_ << ".ene fileType ONE_FILE saveCount 1 counter 302 nextSavedTimeStep 0\n"
380  "restartFile name " << name_ << ".restart fileType ONE_FILE saveCount 1 counter 1 nextSavedTimeStep 0\n"
381  "statFile name " << name_ << ".stat fileType ONE_FILE saveCount 1 counter 0 nextSavedTimeStep 0\n"
382  //"dataFile fileType MULTIPLE_FILES_PADDED saveCount 1 counter 1 nextSavedTimeStep 0\n"
383  //"fStatFile fileType MULTIPLE_FILES_PADDED saveCount 1 counter 1 nextSavedTimeStep 0\n"
384  //"eneFile fileType ONE_FILE saveCount 1 counter 302 nextSavedTimeStep 0\n"
385  //"restartFile fileType ONE_FILE saveCount 1 counter 1 nextSavedTimeStep 0\n"
386  //"statFile fileType ONE_FILE saveCount 1 counter 0 nextSavedTimeStep 0\n"
387  "xMin " << xmin_<< " xMax " << xmax_<< " yMin " << ymin_<< " yMax " << ymax_<< " zMin " << zmin_<< " zMax " << zmax_<< "\n"
388  "timeStep 0 time " << timeData << " ntimeSteps 0 timeMax " << timeData << "\n"
389  "systemDimensions 3 particleDimensions 3 gravity 0 0 -9.8\n"
390  "Species 1\n"
391  "LinearViscoelasticSpecies id 0 density " << density << " stiffness 0 dissipation 0\n"
392  "Walls 0\n";
393  if (!periodic_)
394  restart << "Boundaries 0\n";
395  else
396  {
397  restart << "Boundaries 1\n";
398  if (periodic_==1)
399  restart << "PeriodicBoundary id 0 normal 1 0 0 scaleFactor 1 distanceLeft " << xmin_ << " distanceRight " << xmax_ << " shift " << xmax_-xmin_ << " 0 0\n";
400  else if (periodic_==2)
401  restart << "PeriodicBoundary id 0 normal 0 1 0 scaleFactor 1 distanceLeft " << ymin_ << " distanceRight " << ymax_ << " shift " << ymax_-ymin_ << " 0 0\n";
402  else
403  restart << "PeriodicBoundary id 0 normal 0 0 1 scaleFactor 1 distanceLeft " << zmin_ << " distanceRight " << zmax_ << " shift " << zmax_-zmin_ << " 0 0\n";
404  }
405  restart <<
406  "Particles 0\n"
407  "BaseParticle id 0 indSpecies 0 position 0 0 0 orientation 0 0 0 0 velocity 0 0 0 angularVelocity 0 0 0 0 force 0 0 0 torque 0 0 0 radius 0.5 invMass 1 invInertia 10\n"
408  "Interactions 0\n";
409  restart.close();
410  }
unsigned int periodic_
double ymin_
double zmin_
double xmax_
double xmin_
std::string name_
These store the save file names,.
double zmax_
double ymax_

Member Data Documentation

std::fstream CFile::com_file
private

Definition at line 159 of file centerofmass.cpp.

Referenced by CFile(), copy(), and ~CFile().

std::stringstream CFile::com_filename
private

Definition at line 155 of file centerofmass.cpp.

Referenced by CFile(), and ~CFile().

std::fstream CFile::data_file
private

Stream used for data files.

Definition at line 158 of file centerofmass.cpp.

Referenced by CFile(), copy(), copy_data(), and ~CFile().

std::stringstream CFile::data_filename
private

These store the save file names,.

Definition at line 154 of file centerofmass.cpp.

Referenced by CFile(), copy_data(), and ~CFile().

std::fstream CFile::fstat_file
private

Definition at line 169 of file SplitFiles.cpp.

Referenced by CFile(), copy_fstat(), and ~CFile().

std::stringstream CFile::fstat_filename
private

Definition at line 165 of file SplitFiles.cpp.

Referenced by CFile(), copy_fstat(), and ~CFile().

std::vector<unsigned int> CFile::id_
private

Definition at line 441 of file ConvertP4Files.cpp.

Referenced by writeP4C(), writeP4P(), and writeP4W().

int CFile::info0

Definition at line 165 of file centerofmass.cpp.

Referenced by copy(), and main().

int CFile::info1

Definition at line 165 of file centerofmass.cpp.

Referenced by copy(), and main().

std::string CFile::name_
private

These store the save file names,.

Definition at line 431 of file ConvertP4Files.cpp.

Referenced by getName(), writeRestart(), and ~CFile().

std::fstream CFile::p4c
private

Definition at line 435 of file ConvertP4Files.cpp.

Referenced by CFile(), writeP4C(), and ~CFile().

std::fstream CFile::p4p
private

Stream used for data files.

Definition at line 434 of file ConvertP4Files.cpp.

Referenced by CFile(), writeP4P(), and ~CFile().

std::fstream CFile::p4w
private

Definition at line 436 of file ConvertP4Files.cpp.

Referenced by CFile(), writeP4W(), and ~CFile().

unsigned int CFile::periodic_
private

Definition at line 442 of file ConvertP4Files.cpp.

Referenced by copy(), writeP4C(), and writeRestart().

std::vector<Vec3D> CFile::position_
private

Definition at line 440 of file ConvertP4Files.cpp.

Referenced by writeP4C(), and writeP4P().

bool CFile::splittinginfo

Definition at line 164 of file centerofmass.cpp.

Referenced by CFile(), copy(), and main().

double CFile::splittingradius

Definition at line 163 of file centerofmass.cpp.

Referenced by CFile(), copy(), and main().

double CFile::xmax_
private

Definition at line 437 of file ConvertP4Files.cpp.

Referenced by copy(), writeP4C(), writeP4P(), and writeRestart().

double CFile::xmin_
private

Definition at line 437 of file ConvertP4Files.cpp.

Referenced by copy(), writeP4C(), writeP4P(), and writeRestart().

double CFile::ymax_
private

Definition at line 438 of file ConvertP4Files.cpp.

Referenced by copy(), writeP4P(), and writeRestart().

double CFile::ymin_
private

Definition at line 438 of file ConvertP4Files.cpp.

Referenced by copy(), writeP4P(), and writeRestart().

double CFile::zmax_
private

Definition at line 439 of file ConvertP4Files.cpp.

Referenced by copy(), writeP4P(), and writeRestart().

double CFile::zmin_
private

Definition at line 439 of file ConvertP4Files.cpp.

Referenced by copy(), writeP4P(), and writeRestart().


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