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 int > id_
 
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

Constructor & Destructor Documentation

◆ CFile() [1/3]

CFile::CFile ( std::string  name)
inlineexplicit

Constructor.

46  {
47  //set file names
48  data_filename.str("");
49  data_filename << name << ".data";
50  com_filename.str("");
51  com_filename << name << ".com";
52 
53  //open in-streams
54  data_file.open(data_filename.str().c_str(), std::fstream::in);
55 
56  if (data_file.fail())
57  {
58  logger(ERROR, "Input file % not found", data_filename.str());
59  data_file.close();
60  std::exit(EXIT_FAILURE);
61  }
62  else
63  {
64  logger(INFO, "Files opened: %\n", data_filename.str(), Flusher::NO_FLUSH);
65  }
66 
67  //open out-stream
68  com_file.open(com_filename.str().c_str(), std::fstream::out);
69 
70  if (com_file.fail())
71  {
72  logger(ERROR, "ERROR: Output file % not found", com_filename.str());
73  com_file.close();
74  std::exit(EXIT_FAILURE);
75  }
76  else
77  {
78  logger(INFO, "Files opened: %", com_filename.str());
79  }
80 
81  splittingradius = 0;
82  splittinginfo = false;
83  }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ INFO
@ ERROR
double splittingradius
Definition: centerofmass.cpp:171
std::fstream data_file
Stream used for data files.
Definition: centerofmass.cpp:166
bool splittinginfo
Definition: centerofmass.cpp:172
std::stringstream com_filename
Definition: centerofmass.cpp:163
std::stringstream data_filename
These store the save file names,.
Definition: centerofmass.cpp:162
std::fstream com_file
Definition: centerofmass.cpp:167
std::string name
Definition: MercuryProb.h:48

References com_file, com_filename, data_file, data_filename, ERROR, INFO, logger, units::name, NO_FLUSH, splittinginfo, and splittingradius.

◆ ~CFile() [1/3]

CFile::~CFile ( )
inline

Destructor.

87  {
88  data_file.close();
89  logger(INFO, "Files closed: %\n", data_filename.str(), Flusher::NO_FLUSH);
90  com_file.close();
91  logger(INFO, "Files closed: %", com_filename.str());
92  }

References com_file, com_filename, data_file, data_filename, INFO, logger, and NO_FLUSH.

◆ CFile() [2/3]

CFile::CFile ( std::string  name)
inlineexplicit

Constructor.

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  logger(WARN, "Input file % not found", p4pName);
62  if (p4c.fail())
63  logger(WARN, "Input file % not found", p4cName);
64  if (p4w.fail())
65  logger(WARN, "Input file % not found", p4wName);
66  p4p.close();
67  p4c.close();
68  p4w.close();
69  exit(-1);
70  }
71  else
72  {
73  logger(INFO, "Files opened: % and % and %", p4pName, p4cName, p4wName);
74  }
75  }
@ WARN
std::fstream p4p
Stream used for data files.
Definition: ConvertP4Files.cpp:438
std::fstream p4c
Definition: ConvertP4Files.cpp:439
std::string name_
These store the save file names,.
Definition: ConvertP4Files.cpp:435
std::fstream p4w
Definition: ConvertP4Files.cpp:440

References INFO, logger, units::name, p4c, p4p, p4w, and WARN.

◆ ~CFile() [2/3]

CFile::~CFile ( )
inline

Destructor.

78  {
79  p4p.close();
80  p4c.close();
81  p4w.close();
82  logger(INFO, "Files closed: %.p4p/p4w/p4c", name_);
83  }

References INFO, logger, name_, p4c, p4p, and p4w.

◆ CFile() [3/3]

CFile::CFile ( std::string  name)
inlineexplicit

Constructor.

44  {
45  //set file names
46  data_filename.str("");
47  data_filename << name << ".data";
48  fstat_filename.str("");
49  fstat_filename << name << ".fstat";
50 
51  //open in-streams
52  data_file.open(data_filename.str().c_str(), std::fstream::in);
53  fstat_file.open(fstat_filename.str().c_str(), std::fstream::in);
54 
55  if (data_file.fail())
56  {
57  logger(ERROR, "Input file % not found", data_filename.str());
58  } else
59  {
60  if (fstat_file.fail())
61  {
62  logger(WARN, "WARN: Input file % not found; only data files will be processed", fstat_filename.str()
63  );
64  logger(INFO, "File opened: %", data_filename.str());
65  }
66  else
67  {
68  logger(INFO, "Files opened: % and %", data_filename.str(), fstat_filename.str());
69  }
70  }
71 
72  }
std::fstream fstat_file
Definition: SplitFiles.cpp:195
std::stringstream fstat_filename
Definition: SplitFiles.cpp:191

References data_file, data_filename, ERROR, fstat_file, fstat_filename, INFO, logger, units::name, and WARN.

◆ ~CFile() [3/3]

CFile::~CFile ( )
inline

Destructor.

76  {
77  data_file.close();
78  fstat_file.close();
79  logger(INFO, "Files closed: % and %", data_filename.str(), fstat_filename.str());
80  }

References data_file, data_filename, fstat_file, fstat_filename, INFO, and logger.

Member Function Documentation

◆ copy() [1/3]

bool CFile::copy ( )
inline
94  {
95  unsigned int N;
96  double X, Y, Z;
97  double CX, CY, CZ;
98  double CX1, CY1, CZ1;
99  double CX2, CY2, CZ2;
100  double VX, VY, VZ;
101  double AX, AY, AZ;
102  double WX, WY, WZ;
103  double T, R, M, M1, M2, mass, info;
104  std::string line;
105  std::stringstream output_filename;
106  std::fstream output_file;
107 
108  data_file >> N;
109  while (data_file.good()) {
110  M = M1 = M2 = 0.0;
111  data_file >> T;
112  //open, write, close output file
113  getline(data_file,line);
114  CX = CY = CZ = 0.0;
115  CX1 = CY1 = CZ1 = 0.0;
116  CX2 = CY2 = CZ2 = 0.0;
117  for (unsigned int i=0; i<N; i++) {
118  data_file >> X >> Y >> Z >> VX >> VY >> VZ >> R >> AX >> AY >> AZ >> WX >> WY >> WZ >> info;
119  mass=R*R*R;
120  getline(data_file,line);
121 
122  if (splittingradius){
123  CX += X*mass; CY += Y*mass; CZ += Z*mass; M+=mass;
124  }
125  if (splittinginfo){
126  if(info==info0||info==info1){
127  CX += X*mass; CY += Y*mass; CZ += Z*mass; M+=mass;
128  }
129  }
130  if (splittingradius) {
131  if (R<splittingradius) {
132  CX1 += X*mass; CY1 += Y*mass; CZ1 += Z*mass; M1+=mass;
133  } else {
134  CX2 += X*mass; CY2 += Y*mass; CZ2 += Z*mass; M2+=mass;
135  }
136  }
137  if (splittinginfo) {
138  //std::cout << "hello" << std::endl;
139  if (info==info0) {
140  //std::cout << "hello" << std::endl;
141  CX1 += X*mass; CY1 += Y*mass; CZ1 += Z*mass; M1+=mass;
142  } else if (info==info1) {
143  CX2 += X*mass; CY2 += Y*mass; CZ2 += Z*mass; M2+=mass;
144  }
145  }
146  }
148  com_file << T << " " << CX/M << " " << CY/M << " " << CZ/M;
149  com_file << " " << CX1/M1 << " " << CY1/M1 << " " << CZ1/M1;
150  com_file << " " << CX2/M2 << " " << CY2/M2 << " " << CZ2/M2 << std::endl;
151  } else {
152  com_file << T << " " << CX/M << " " << CY/M << " " << CZ/M << std::endl;
153  }
154  data_file >> N;
155  }
156  return true;
157  }
@ AZ
Definition: StatisticsVector.h:42
@ R
Definition: StatisticsVector.h:42
@ Y
Definition: StatisticsVector.h:42
@ X
Definition: StatisticsVector.h:42
@ Z
Definition: StatisticsVector.h:42
int info0
Definition: centerofmass.cpp:173
int info1
Definition: centerofmass.cpp:173
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

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

Referenced by main().

◆ copy() [2/3]

void CFile::copy ( double  xmin,
double  xmax,
double  ymin,
double  ymax,
double  zmin,
double  zmax,
double  timeMin,
double  timeMax,
unsigned int  periodic 
)
inline
85  {
86  logger(INFO, "copy(..)");
87  xmin_ = xmin;
88  xmax_ = xmax;
89  ymin_ = ymin;
90  ymax_ = ymax;
91  zmin_ = zmin;
92  zmax_ = zmax;
93  periodic_=periodic;
94  writeP4P(timeMin,timeMax);
95  }
double xmax_
Definition: ConvertP4Files.cpp:441
double xmin_
Definition: ConvertP4Files.cpp:441
double zmax_
Definition: ConvertP4Files.cpp:443
double ymax_
Definition: ConvertP4Files.cpp:442
unsigned int periodic_
Definition: ConvertP4Files.cpp:446
double ymin_
Definition: ConvertP4Files.cpp:442
double zmin_
Definition: ConvertP4Files.cpp:443
void writeP4P(double timeMin, double timeMax)
Definition: ConvertP4Files.cpp:97

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

◆ copy() [3/3]

bool CFile::copy ( unsigned int  stepsize,
unsigned int  counter 
)
inline
82  {
83  //return copy_last_time_step();
84  if (fstat_file.fail())
85  return copy_data(stepsize,counter);
86  else
87  return copy_data(stepsize,counter) && copy_fstat(stepsize,counter);
88  }
bool copy_data(unsigned int stepsize, unsigned int counter)
Definition: SplitFiles.cpp:90
bool copy_fstat(unsigned int stepsize, unsigned int counter)
Definition: SplitFiles.cpp:142

References copy_data(), copy_fstat(), and fstat_file.

◆ copy_data()

bool CFile::copy_data ( unsigned int  stepsize,
unsigned int  counter 
)
inline
90  {
91  unsigned int N;
92  std::string line;
93  std::stringstream output_filename;
94  std::fstream output_file;
95 
96  data_file >> N;
97  while (data_file.good()) {
98  //set output_filename
99  std::stringstream output_filename("");
100  output_filename << data_filename.str() << ".";
101  if (counter < 1000) output_filename << "0";
102  if (counter < 100) output_filename << "0";
103  if (counter < 10) output_filename << "0";
104  output_filename << counter;
105  counter++;
106  //logger(INFO, "Outputfile: %", output_filename.str());
107 
108  //open, write, close output file
109  output_file.open(output_filename.str().c_str(), std::fstream::out);
110  getline(data_file, line);
111  output_file << N << line << std::endl;
112  logger(INFO, "%%", N, line);
113  for (unsigned int i = 0; i < N; i++)
114  {
115  getline(data_file, line);
116  output_file << line << std::endl;
117  }
118  output_file.close();
119  double doubleN = -1;
120  data_file >> doubleN;
121  N = doubleN;
122 
123  // converting N to an integer; skipping the line if there is a problem (this happens when there is a corrupt data file)
124  while (data_file.good() && doubleN != N)
125  {
126  getline(data_file, line, '\n');
127  logger(WARN, "Skipping bad line in data file: %", doubleN);
128  data_file >> doubleN;
129  N = doubleN;
130  }
131 
132  //step over some time steps
133  for(unsigned int j=1; j<stepsize; j++) {
134  for (unsigned int i=0; i<N+1; i++) getline(data_file,line);
135  data_file >> N;
136  }
137 
138  }
139  return true;
140  }

References data_file, data_filename, constants::i, INFO, logger, and WARN.

Referenced by copy().

◆ copy_fstat()

bool CFile::copy_fstat ( unsigned int  stepsize,
unsigned int  counter 
)
inline
142  {
143  std::string line;
144  std::stringstream output_filename;
145  std::fstream output_file;
146 
147  getline(fstat_file,line);
148  while (fstat_file.good()) {
149  //set output_filename
150  output_filename.str("");
151  output_filename << fstat_filename.str() << ".";
152  if (counter < 1000) output_filename << "0";
153  if (counter < 100) output_filename << "0";
154  if (counter < 10) output_filename << "0";
155  output_filename << counter;
156  counter++;
157 
158  //open, write, close output file
159  output_file.open(output_filename.str().c_str(), std::fstream::out);
160  logger(INFO, "%", line);
161  output_file << line << std::endl;
162  getline(fstat_file, line);
163  output_file << line << std::endl;
164  getline(fstat_file, line);
165  output_file << line << std::endl;
166  getline(fstat_file, line);
167  while (line.c_str()[0] != '#' && fstat_file.good())
168  {
169  getline(fstat_file, line);
170  output_file << line << std::endl;
171  }
172  output_file.close();
173 
174  //step over some time steps
175  for(unsigned int j=1; j<stepsize; j++) {
176  getline(fstat_file,line);
177  getline(fstat_file,line);
178  getline(fstat_file,line);
179  while (line.c_str()[0] != '#'&&fstat_file.good()) {
180  getline(fstat_file,line);
181  }
182  }
183  }
184  return true;
185  }

References fstat_file, fstat_filename, INFO, and logger.

Referenced by copy().

◆ getName()

std::string CFile::getName ( std::string  type,
unsigned int  counter 
)
inline
418  {
419  //set dataName
420  std::stringstream name("");
421  name << name_ << "." << type << ".";
422  if (counter < 1000)
423  name << "0";
424  if (counter < 100)
425  name << "0";
426  if (counter < 10)
427  name << "0";
428  name << counter;
429  return name.str();
430  }

References units::name, and name_.

Referenced by writeP4P().

◆ writeP4C()

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

References Global_Physical_Variables::C1, constants::i, id_, INFO, logger, n, p4c, periodic_, position_, Vec3D::setZero(), writeP4W(), Vec3D::X, xmax_, xmin_, Vec3D::Y, and Vec3D::Z.

Referenced by writeP4P().

◆ writeP4P()

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

References getName(), constants::i, id_, INFO, logger, Global_Physical_Variables::P, p4p, constants::pi, position_, writeP4C(), writeRestart(), xmax_, xmin_, ymax_, ymin_, zmax_, and zmin_.

Referenced by copy().

◆ writeP4W()

void CFile::writeP4W ( std::fstream &  fstat,
double  timeData 
)
inline
322  {
323  unsigned int N;
324  std::string line;
325  std::string dummy;
326  double time;
327  double P1, delta, deltat, fn, ft;
328  Vec3D C, F, n, t;
329 
330  while (p4w.good()) {
331  //read header
332  p4w >> dummy >> dummy;
333  p4w >> time >> N;
334  getline(p4w, line);
335  getline(p4w, line);
336 
337  if (time < timeData * 0.999999)
338  {
339  logger(INFO, "reading p4w (t % N %): below timeMin; skipped", time, N);
340  for (unsigned int i = 0; i < N; i++)
341  getline(p4w, line);
342  continue;
343  }
344 
345  logger(INFO, "reading p4w (t % N %)", time, N);
346 
347  for (unsigned int i = 0; i < N; i++)
348  {
349  p4w >> P1
350  >> C
351  >> F;
352  delta = 0.0;
353  deltat = 0.0;
354  ft = 0.0;
355  t.setZero();
356  fn = F.getLength();
357  n=F/fn;
358  fstat << time << " "
359  << id_[P1-1] << " "
360  << -1 << " "
361  << C << " "
362  << delta << " "
363  << deltat << " "
364  << fn << " "
365  << ft << " "
366  << n << " "
367  << t << std::endl;
368  }
369  break;
370  }
371  }

References constants::i, id_, INFO, logger, n, p4w, and Vec3D::setZero().

Referenced by writeP4C().

◆ writeRestart()

void CFile::writeRestart ( double  timeData,
double  density 
)
inline
374  {
375  logger(INFO, "restart.0000 ", timeData);
376  //open data/fstat file
377  std::fstream restart;
378  restart.open(name_ + ".restart", std::fstream::out);
379  restart <<
380  "restart_version 1.0 name " << name_ << "\n"
381  "dataFile name " << name_ << ".data fileType MULTIPLE_FILES_PADDED saveCount 1 counter 1 nextSavedTimeStep 0\n"
382  "fStatFile name " << name_ << ".fstat fileType MULTIPLE_FILES_PADDED saveCount 1 counter 1 nextSavedTimeStep 0\n"
383  "eneFile name " << name_ << ".ene fileType ONE_FILE saveCount 1 counter 302 nextSavedTimeStep 0\n"
384  "restartFile name " << name_ << ".restart fileType ONE_FILE saveCount 1 counter 1 nextSavedTimeStep 0\n"
385  "statFile name " << name_ << ".stat fileType ONE_FILE saveCount 1 counter 0 nextSavedTimeStep 0\n"
386  //"dataFile fileType MULTIPLE_FILES_PADDED saveCount 1 counter 1 nextSavedTimeStep 0\n"
387  //"fStatFile fileType MULTIPLE_FILES_PADDED saveCount 1 counter 1 nextSavedTimeStep 0\n"
388  //"eneFile fileType ONE_FILE saveCount 1 counter 302 nextSavedTimeStep 0\n"
389  //"restartFile fileType ONE_FILE saveCount 1 counter 1 nextSavedTimeStep 0\n"
390  //"statFile fileType ONE_FILE saveCount 1 counter 0 nextSavedTimeStep 0\n"
391  "xMin " << xmin_<< " xMax " << xmax_<< " yMin " << ymin_<< " yMax " << ymax_<< " zMin " << zmin_<< " zMax " << zmax_<< "\n"
392  "timeStep 0 time " << timeData << " ntimeSteps 0 timeMax " << timeData << "\n"
393  "systemDimensions 3 particleDimensions 3 gravity 0 0 -9.8\n"
394  "Species 1\n"
395  "LinearViscoelasticSpecies id 0 density " << density << " stiffness 0 dissipation 0\n"
396  "Walls 0\n";
397  if (!periodic_)
398  restart << "Boundaries 0\n";
399  else
400  {
401  restart << "Boundaries 1\n";
402  if (periodic_==1)
403  restart << "PeriodicBoundary id 0 normal 1 0 0 scaleFactor 1 distanceLeft " << xmin_ << " distanceRight " << xmax_ << " shift " << xmax_-xmin_ << " 0 0\n";
404  else if (periodic_==2)
405  restart << "PeriodicBoundary id 0 normal 0 1 0 scaleFactor 1 distanceLeft " << ymin_ << " distanceRight " << ymax_ << " shift " << ymax_-ymin_ << " 0 0\n";
406  else
407  restart << "PeriodicBoundary id 0 normal 0 0 1 scaleFactor 1 distanceLeft " << zmin_ << " distanceRight " << zmax_ << " shift " << zmax_-zmin_ << " 0 0\n";
408  }
409  restart <<
410  "Particles 0\n"
411  "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"
412  "Interactions 0\n";
413  restart.close();
414  }
Definition: restart2.cpp:29

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

Referenced by writeP4P().

Member Data Documentation

◆ com_file

std::fstream CFile::com_file
private

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

◆ com_filename

std::stringstream CFile::com_filename
private

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

◆ data_file

std::fstream CFile::data_file
private

Stream used for data files.

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

◆ data_filename

std::stringstream CFile::data_filename
private

These store the save file names,.

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

◆ fstat_file

std::fstream CFile::fstat_file
private

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

◆ fstat_filename

std::stringstream CFile::fstat_filename
private

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

◆ id_

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

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

◆ info0

int CFile::info0

Referenced by copy(), and main().

◆ info1

int CFile::info1

Referenced by copy(), and main().

◆ name_

std::string CFile::name_
private

These store the save file names,.

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

◆ p4c

std::fstream CFile::p4c
private

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

◆ p4p

std::fstream CFile::p4p
private

Stream used for data files.

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

◆ p4w

std::fstream CFile::p4w
private

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

◆ periodic_

unsigned int CFile::periodic_
private

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

◆ position_

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

Referenced by writeP4C(), and writeP4P().

◆ splittinginfo

bool CFile::splittinginfo

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

◆ splittingradius

double CFile::splittingradius

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

◆ xmax_

double CFile::xmax_
private

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

◆ xmin_

double CFile::xmin_
private

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

◆ ymax_

double CFile::ymax_
private

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

◆ ymin_

double CFile::ymin_
private

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

◆ zmax_

double CFile::zmax_
private

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

◆ zmin_

double CFile::zmin_
private

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


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