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

Constructor & Destructor Documentation

◆ CFile() [1/3]

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

Constructor.

25  {
26  //set file names
27  data_filename.str("");
28  data_filename << name << ".data";
29  com_filename.str("");
30  com_filename << name << ".com";
31 
32  //open in-streams
33  data_file.open(data_filename.str().c_str(), std::fstream::in);
34 
35  if (data_file.fail())
36  {
37  logger(ERROR, "Input file % not found", data_filename.str());
38  data_file.close();
39  std::exit(EXIT_FAILURE);
40  }
41  else
42  {
43  logger(INFO, "Files opened: %\n", data_filename.str(), Flusher::NO_FLUSH);
44  }
45 
46  //open out-stream
47  com_file.open(com_filename.str().c_str(), std::fstream::out);
48 
49  if (com_file.fail())
50  {
51  logger(ERROR, "ERROR: Output file % not found", com_filename.str());
52  com_file.close();
53  std::exit(EXIT_FAILURE);
54  }
55  else
56  {
57  logger(INFO, "Files opened: %", com_filename.str());
58  }
59 
60  splittingradius = 0;
61  splittinginfo = false;
62  }
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:150
std::fstream data_file
Stream used for data files.
Definition: centerofmass.cpp:145
bool splittinginfo
Definition: centerofmass.cpp:151
std::stringstream com_filename
Definition: centerofmass.cpp:142
std::stringstream data_filename
These store the save file names,.
Definition: centerofmass.cpp:141
std::fstream com_file
Definition: centerofmass.cpp:146
string name
Definition: plotDoE.py:33
std::ofstream out("Result.txt")

References com_file, com_filename, data_file, data_filename, ERROR, INFO, logger, plotDoE::name, NO_FLUSH, out(), splittinginfo, and splittingradius.

◆ ~CFile() [1/3]

CFile::~CFile ( )
inline

Destructor.

66  {
67  data_file.close();
68  logger(INFO, "Files closed: %\n", data_filename.str(), Flusher::NO_FLUSH);
69  com_file.close();
70  logger(INFO, "Files closed: %", com_filename.str());
71  }

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

◆ CFile() [2/3]

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

Constructor.

25  : name_(name){
26 
27  //set file names
28  std::string p4pName(name+".p4p");
29  std::string p4cName(name+".p4c");
30  std::string p4wName(name+".p4w");
31 
32  //open input file streams
33  p4p.open(p4pName.c_str(), std::fstream::in);
34  p4c.open(p4cName.c_str(), std::fstream::in);
35  p4w.open(p4wName.c_str(), std::fstream::in);
36 
37  if (p4p.fail() || p4c.fail() || p4w.fail())
38  {
39  if (p4p.fail())
40  logger(WARN, "Input file % not found", p4pName);
41  if (p4c.fail())
42  logger(WARN, "Input file % not found", p4cName);
43  if (p4w.fail())
44  logger(WARN, "Input file % not found", p4wName);
45  p4p.close();
46  p4c.close();
47  p4w.close();
48  exit(-1);
49  }
50  else
51  {
52  logger(INFO, "Files opened: % and % and %", p4pName, p4cName, p4wName);
53  }
54  }
@ WARN
std::fstream p4p
Stream used for data files.
Definition: ConvertP4Files.cpp:417
std::fstream p4c
Definition: ConvertP4Files.cpp:418
std::string name_
These store the save file names,.
Definition: ConvertP4Files.cpp:414
std::fstream p4w
Definition: ConvertP4Files.cpp:419
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

References INFO, logger, plotDoE::name, p4c, p4p, p4w, oomph::Global_string_for_annotation::string(), and WARN.

◆ ~CFile() [2/3]

CFile::~CFile ( )
inline

Destructor.

57  {
58  p4p.close();
59  p4c.close();
60  p4w.close();
61  logger(INFO, "Files closed: %.p4p/p4w/p4c", name_);
62  }

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

◆ CFile() [3/3]

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

Constructor.

23  {
24  //set file names
25  data_filename.str("");
26  data_filename << name << ".data";
27  fstat_filename.str("");
28  fstat_filename << name << ".fstat";
29 
30  //open in-streams
31  data_file.open(data_filename.str().c_str(), std::fstream::in);
32  fstat_file.open(fstat_filename.str().c_str(), std::fstream::in);
33 
34  if (data_file.fail())
35  {
36  logger(ERROR, "Input file % not found", data_filename.str());
37  } else
38  {
39  if (fstat_file.fail())
40  {
41  logger(WARN, "WARN: Input file % not found; only data files will be processed", fstat_filename.str()
42  );
43  logger(INFO, "File opened: %", data_filename.str());
44  }
45  else
46  {
47  logger(INFO, "Files opened: % and %", data_filename.str(), fstat_filename.str());
48  }
49  }
50 
51  }
std::fstream fstat_file
Definition: SplitFiles.cpp:174
std::stringstream fstat_filename
Definition: SplitFiles.cpp:170

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

◆ ~CFile() [3/3]

CFile::~CFile ( )
inline

Destructor.

55  {
56  data_file.close();
57  fstat_file.close();
58  logger(INFO, "Files closed: % and %", data_filename.str(), fstat_filename.str());
59  }

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

Member Function Documentation

◆ copy() [1/3]

bool CFile::copy ( )
inline
73  {
74  unsigned int N;
75  double X, Y, Z;
76  double CX, CY, CZ;
77  double CX1, CY1, CZ1;
78  double CX2, CY2, CZ2;
79  double VX, VY, VZ;
80  double AX, AY, AZ;
81  double WX, WY, WZ;
82  double T, R, M, M1, M2, mass, info;
84  std::stringstream output_filename;
85  std::fstream output_file;
86 
87  data_file >> N;
88  while (data_file.good()) {
89  M = M1 = M2 = 0.0;
90  data_file >> T;
91  //open, write, close output file
92  getline(data_file,line);
93  CX = CY = CZ = 0.0;
94  CX1 = CY1 = CZ1 = 0.0;
95  CX2 = CY2 = CZ2 = 0.0;
96  for (unsigned int i=0; i<N; i++) {
97  data_file >> X >> Y >> Z >> VX >> VY >> VZ >> R >> AX >> AY >> AZ >> WX >> WY >> WZ >> info;
98  mass=R*R*R;
99  getline(data_file,line);
100 
101  if (splittingradius){
102  CX += X*mass; CY += Y*mass; CZ += Z*mass; M+=mass;
103  }
104  if (splittinginfo){
105  if(info==info0||info==info1){
106  CX += X*mass; CY += Y*mass; CZ += Z*mass; M+=mass;
107  }
108  }
109  if (splittingradius) {
110  if (R<splittingradius) {
111  CX1 += X*mass; CY1 += Y*mass; CZ1 += Z*mass; M1+=mass;
112  } else {
113  CX2 += X*mass; CY2 += Y*mass; CZ2 += Z*mass; M2+=mass;
114  }
115  }
116  if (splittinginfo) {
117  //std::cout << "hello" << std::endl;
118  if (info==info0) {
119  //std::cout << "hello" << std::endl;
120  CX1 += X*mass; CY1 += Y*mass; CZ1 += Z*mass; M1+=mass;
121  } else if (info==info1) {
122  CX2 += X*mass; CY2 += Y*mass; CZ2 += Z*mass; M2+=mass;
123  }
124  }
125  }
127  com_file << T << " " << CX/M << " " << CY/M << " " << CZ/M;
128  com_file << " " << CX1/M1 << " " << CY1/M1 << " " << CZ1/M1;
129  com_file << " " << CX2/M2 << " " << CY2/M2 << " " << CZ2/M2 << std::endl;
130  } else {
131  com_file << T << " " << CX/M << " " << CY/M << " " << CZ/M << std::endl;
132  }
133  data_file >> N;
134  }
135  return true;
136  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Eigen::Triplet< double > T
Definition: EigenUnitTest.cpp:11
@ AZ
Definition: StatisticsVector.h:21
@ R
Definition: StatisticsVector.h:21
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12;Map< MatrixXf > M2(M1.data(), 6, 2)
MatrixXf M1
Definition: Tutorial_SlicingCol.cpp:1
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:50
int info0
Definition: centerofmass.cpp:152
int info1
Definition: centerofmass.cpp:152
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
@ N
Definition: constructor.cpp:22
#define X
Definition: icosphere.cpp:20
#define Z
Definition: icosphere.cpp:21
int info
Definition: level2_cplx_impl.h:39
line
Definition: calibrate.py:103
const char Y
Definition: test/EulerAngles.cpp:32

References AZ, com_file, data_file, i, info, info0, info1, calibrate::line, M1, M2(), N, R, splittinginfo, splittingradius, oomph::Global_string_for_annotation::string(), 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
64  {
65  logger(INFO, "copy(..)");
66  xmin_ = xmin;
67  xmax_ = xmax;
68  ymin_ = ymin;
69  ymax_ = ymax;
70  zmin_ = zmin;
71  zmax_ = zmax;
72  periodic_=periodic;
73  writeP4P(timeMin,timeMax);
74  }
double xmax_
Definition: ConvertP4Files.cpp:420
double xmin_
Definition: ConvertP4Files.cpp:420
double zmax_
Definition: ConvertP4Files.cpp:422
double ymax_
Definition: ConvertP4Files.cpp:421
unsigned int periodic_
Definition: ConvertP4Files.cpp:425
double ymin_
Definition: ConvertP4Files.cpp:421
double zmin_
Definition: ConvertP4Files.cpp:422
void writeP4P(double timeMin, double timeMax)
Definition: ConvertP4Files.cpp:76
double zmax
Definition: time_harmonic_fourier_decomposed_linear_elasticity/cylinder/cylinder.cc:71
double zmin
Definition: time_harmonic_fourier_decomposed_linear_elasticity/cylinder/cylinder.cc:69

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

◆ copy() [3/3]

bool CFile::copy ( unsigned int  stepsize,
unsigned int  counter 
)
inline
61  {
62  //return copy_last_time_step();
63  if (fstat_file.fail())
64  return copy_data(stepsize,counter);
65  else
66  return copy_data(stepsize,counter) && copy_fstat(stepsize,counter);
67  }
bool copy_data(unsigned int stepsize, unsigned int counter)
Definition: SplitFiles.cpp:69
bool copy_fstat(unsigned int stepsize, unsigned int counter)
Definition: SplitFiles.cpp:121

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

◆ copy_data()

bool CFile::copy_data ( unsigned int  stepsize,
unsigned int  counter 
)
inline
69  {
70  unsigned int N;
72  std::stringstream output_filename;
73  std::fstream output_file;
74 
75  data_file >> N;
76  while (data_file.good()) {
77  //set output_filename
78  std::stringstream output_filename("");
79  output_filename << data_filename.str() << ".";
80  if (counter < 1000) output_filename << "0";
81  if (counter < 100) output_filename << "0";
82  if (counter < 10) output_filename << "0";
83  output_filename << counter;
84  counter++;
85  //logger(INFO, "Outputfile: %", output_filename.str());
86 
87  //open, write, close output file
88  output_file.open(output_filename.str().c_str(), std::fstream::out);
89  getline(data_file, line);
90  output_file << N << line << std::endl;
91  logger(INFO, "%%", N, line);
92  for (unsigned int i = 0; i < N; i++)
93  {
94  getline(data_file, line);
95  output_file << line << std::endl;
96  }
97  output_file.close();
98  double doubleN = -1;
99  data_file >> doubleN;
100  N = doubleN;
101 
102  // converting N to an integer; skipping the line if there is a problem (this happens when there is a corrupt data file)
103  while (data_file.good() && doubleN != N)
104  {
105  getline(data_file, line, '\n');
106  logger(WARN, "Skipping bad line in data file: %", doubleN);
107  data_file >> doubleN;
108  N = doubleN;
109  }
110 
111  //step over some time steps
112  for(unsigned int j=1; j<stepsize; j++) {
113  for (unsigned int i=0; i<N+1; i++) getline(data_file,line);
114  data_file >> N;
115  }
116 
117  }
118  return true;
119  }
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References data_file, data_filename, i, INFO, j, calibrate::line, logger, N, out(), oomph::Global_string_for_annotation::string(), and WARN.

Referenced by copy().

◆ copy_fstat()

bool CFile::copy_fstat ( unsigned int  stepsize,
unsigned int  counter 
)
inline
121  {
123  std::stringstream output_filename;
124  std::fstream output_file;
125 
126  getline(fstat_file,line);
127  while (fstat_file.good()) {
128  //set output_filename
129  output_filename.str("");
130  output_filename << fstat_filename.str() << ".";
131  if (counter < 1000) output_filename << "0";
132  if (counter < 100) output_filename << "0";
133  if (counter < 10) output_filename << "0";
134  output_filename << counter;
135  counter++;
136 
137  //open, write, close output file
138  output_file.open(output_filename.str().c_str(), std::fstream::out);
139  logger(INFO, "%", line);
140  output_file << line << std::endl;
141  getline(fstat_file, line);
142  output_file << line << std::endl;
143  getline(fstat_file, line);
144  output_file << line << std::endl;
145  getline(fstat_file, line);
146  while (line.c_str()[0] != '#' && fstat_file.good())
147  {
148  getline(fstat_file, line);
149  output_file << line << std::endl;
150  }
151  output_file.close();
152 
153  //step over some time steps
154  for(unsigned int j=1; j<stepsize; j++) {
155  getline(fstat_file,line);
156  getline(fstat_file,line);
157  getline(fstat_file,line);
158  while (line.c_str()[0] != '#'&&fstat_file.good()) {
159  getline(fstat_file,line);
160  }
161  }
162  }
163  return true;
164  }

References fstat_file, fstat_filename, INFO, j, calibrate::line, logger, out(), and oomph::Global_string_for_annotation::string().

Referenced by copy().

◆ getName()

std::string CFile::getName ( std::string  type,
unsigned int  counter 
)
inline
397  {
398  //set dataName
399  std::stringstream name("");
400  name << name_ << "." << type << ".";
401  if (counter < 1000)
402  name << "0";
403  if (counter < 100)
404  name << "0";
405  if (counter < 10)
406  name << "0";
407  name << counter;
408  return name.str();
409  }
type
Definition: compute_granudrum_aor.py:141

References plotDoE::name, name_, and compute_granudrum_aor::type.

Referenced by writeP4P().

◆ writeP4C()

void CFile::writeP4C ( std::fstream &  fstat,
double  timeData 
)
inline
182  {
183  unsigned int N;
185  std::string dummy;
186  double time;
187  double P1, P2, delta, deltat, fn, ft;
188  Vec3D C1, F, n, t;
189 
190  while (p4c.good()) {
191  //read header
192  p4c >> dummy >> dummy;
193  p4c >> time >> N;
194  getline(p4c, line);
195  getline(p4c, line);
196 
197  if (time < timeData * 0.999999)
198  {
199  logger(INFO, "reading p4c (t % N %): below timeMin; skipped", time, N);
200  for (unsigned int i = 0; i < N; i++)
201  getline(p4c, line);
202  continue;
203  }
204 
205  logger(INFO, "reading p4c (t % N %", time, N);
206 
207  //write fstat file
208  fstat << "# " << time << " " << N << std::endl;
209  fstat << "# " << std::endl;
210  fstat << "# " << std::endl;
211  //double P1, P2, CX, CY, CZ, FX, FY, FZ;
212  //time, i, j, x, y, z, delta, deltat, fn, ft, nx, ny, nz, tx, ty, tz
213 
214  for (unsigned int i = 0; i < N; i++)
215  {
216  p4c >> P1
217  >> P2
218  >> C1
219  >> F;
220  //std::cout << i << "|" << P1 << "|" << P2 << "|" << C1 << "|" << F << std::endl;
221  Vec3D C2=C1;
222  Mdouble pos1, pos2;
223  Mdouble *c1, *c2;
224  //std::cout << "C " << C1 << std::endl;
225  if (periodic_)
226  {
227  if (periodic_==1)
228  {
229  pos1 = position_[P1 - 1].X;
230  pos2 = position_[P2 - 1].X;
231  c1 = &C1.X;
232  c2 = &C2.X;
233  }
234  else if (periodic_==2)
235  {
236  pos1 = position_[P1 - 1].Y;
237  pos2 = position_[P2 - 1].Y;
238  c1 = &C1.Y;
239  c2 = &C2.Y;
240  }
241  else //if (periodic_==3)
242  {
243  pos1 = position_[P1 - 1].Z;
244  pos2 = position_[P2 - 1].Z;
245  c1 = &C1.Z;
246  c2 = &C2.Z;
247  }
248  if (pos1 < (xmax_-xmin_)/3.0 && pos2 > 2.0*(xmax_-xmin_)/3.0)
249  {
250  if (*c1 < (xmax_ - xmin_) / 3.0)
251  *c2 += xmax_ - xmin_;
252  else if (*c1 > 2.0*(xmax_ - xmin_) / 3.0)
253  *c1 -= xmax_ - xmin_;
254  }
255  else if (pos1 < (xmax_-xmin_)/3.0 && pos2 > 2.0*(xmax_-xmin_)/3.0)
256  {
257  if (*c1 < (xmax_ - xmin_) / 3.0)
258  *c1 += xmax_ - xmin_;
259  else if (*c1 > 2.0*(xmax_ - xmin_) / 3.0)
260  *c2 -= xmax_ - xmin_;
261  }
262  }
263  //std::cout << "C1 " << C1 << std::endl;
264  //std::cout << "C2 " << C2 << std::endl;
265  //std::cout << "P0 " << position_[P1-1] << std::endl;
266  //std::cout << "P1 " << position_[P2-1] << std::endl;
267  delta=0.0;
268  deltat=0.0;
269  ft=0.0;
270  t.setZero();
271  fn=F.getLength();
272  n=F/fn;
273 
274  fstat << time << " "
275  << id_[P1-1] << " "
276  << id_[P2-1] << " "
277  << C1 << " "
278  << delta << " "
279  << deltat << " "
280  << fn << " "
281  << ft << " "
282  << n << " "
283  << t << std::endl;
284  fstat << time << " "
285  << id_[P2-1] << " "
286  << id_[P1-1] << " "
287  << C2 << " "
288  << delta << " "
289  << deltat << " "
290  << fn << " "
291  << ft << " "
292  << -n << " "
293  << t << std::endl;
294  }
295  writeP4W(fstat, timeData);
296  break;
297  }
298  }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
double Mdouble
Definition: GeneralDefine.h:13
std::vector< Vec3D > position_
Definition: ConvertP4Files.cpp:423
void writeP4W(std::fstream &fstat, double timeData)
Definition: ConvertP4Files.cpp:300
std::vector< unsigned int > id_
Definition: ConvertP4Files.cpp:424
Definition: Kernel/Math/Vector.h:30
double C1
"Mooney Rivlin" coefficient for generalised Mooney Rivlin law
Definition: TwenteMeshGluing.cpp:74
double C2
"Mooney Rivlin" coefficient for generalised Mooney Rivlin law
Definition: mpi/distribution/airy_cantilever/airy_cantilever2.cc:156
int delta
Definition: MultiOpt.py:96
@ F
Definition: octree.h:74
t
Definition: plotPSD.py:36

References Global_Physical_Variables::C1, Global_Physical_Variables::C2, MultiOpt::delta, oomph::OcTreeNames::F, i, id_, INFO, calibrate::line, logger, n, N, p4c, periodic_, position_, oomph::Global_string_for_annotation::string(), plotPSD::t, writeP4W(), xmax_, and xmin_.

Referenced by writeP4P().

◆ writeP4P()

void CFile::writeP4P ( double  timeMin,
double  timeMax 
)
inline
76  {
77  logger(INFO, "writeP4P(..)");
78 
79  unsigned int N;
81  std::fstream data;
82  std::fstream fstat;
83  double time;
84  double ID, GROUP, VOLUME, MASS, VX, VY, VZ, Angular_Velocity_X, Angular_Velocity_Y, Angular_Velocity_Z;
85 
86  unsigned int counter = 0;
87  while (p4p.good())
88  {
89  //read header
90  std::string dummy;
91  p4p >> dummy >> dummy;
92  p4p >> time >> N;
93  getline(p4p,line);
94  getline(p4p,line);
95 
96  if (time > timeMax)
97  {
98  logger(INFO, "reading p4p (t % N %): timeMax reached; terminating", time, N);
99  break;
100  }
101  else if (time < timeMin)
102  {
103  logger(INFO, "reading p4p (t % N %): below timeMin; skipped", time, N);
104  for (unsigned int i = 0; i < N; i++)
105  getline(p4p, line);
106  continue;
107  }
108 
109  logger(INFO, "reading p4p (t % N % timestep #%)", time, N, counter);
110 
111  //open data/fstat file
112  std::string dataName = getName("data", counter);
113  data.open(dataName.c_str(), std::fstream::out);
114  std::string fstatName = getName("fstat", counter);
115  fstat.open(fstatName.c_str(), std::fstream::out);
116  logger(INFO, "Files opened: % and %", dataName, fstatName);
117 
118  //write data file
119  data << N << " "
120  << time << " "
121  << xmin_ << " "
122  << ymin_ << " "
123  << zmin_ << " "
124  << xmax_ << " "
125  << ymax_ << " "
126  << zmax_ << std::endl;
127 
128  position_.resize(N*1.1);
129  id_.resize(N*1.1);
130  for (unsigned int i=0; i<N; i++) {
131  p4p >> ID;
132  if (position_.size()<ID)
133  {
134  position_.resize(ID*1.1);
135  id_.resize(ID*1.1);
136  }
137  Vec3D& P = position_[ID-1];
138  id_[ID-1]=i;
139  p4p >> GROUP
140  >> VOLUME
141  >> MASS
142  >> P.X
143  >> P.Y
144  >> P.Z
145  >> VX
146  >> VY
147  >> VZ
148  >> Angular_Velocity_X
149  >> Angular_Velocity_Y
150  >> Angular_Velocity_Z;
151  data << P.X << " "
152  << P.Y << " "
153  << P.Z << " "
154  << VX << " "
155  << VY << " "
156  << VZ << " "
157  << pow(6.0 / constants::pi * VOLUME, 1.0 / 3.0) / 2.0 << " "
158  << 0 << " "
159  << 0 << " "
160  << 0 << " "
161  << Angular_Velocity_X << " "
162  << Angular_Velocity_Y << " "
163  << Angular_Velocity_Z << " "
164  << 0 << std::endl;
165  //logger(INFO, ID << " ";
166  }
167  logger(INFO, "written %", dataName);
168 
169  writeP4C(fstat, time);
170  logger(INFO, "written %", fstatName);
171 
172  //close data file
173  data.close();
174  fstat.close();
175  ++counter;
176 
177  p4p >> std::ws; //to make sure that p4p.good returns false at end of file
178  }
179  writeRestart(time, MASS/VOLUME);
180  }
int data[]
Definition: Map_placement_new.cpp:1
void writeP4C(std::fstream &fstat, double timeData)
Definition: ConvertP4Files.cpp:182
std::string getName(std::string type, unsigned int counter)
Definition: ConvertP4Files.cpp:396
void writeRestart(double timeData, double density)
Definition: ConvertP4Files.cpp:352
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:625
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:77
const Mdouble pi
Definition: ExtendedMath.h:23

References data, getName(), i, id_, INFO, calibrate::line, logger, N, out(), Global_Physical_Variables::P, p4p, constants::pi, position_, Eigen::bfloat16_impl::pow(), oomph::Global_string_for_annotation::string(), writeP4C(), writeRestart(), xmax_, xmin_, ymax_, ymin_, zmax_, and zmin_.

Referenced by copy().

◆ writeP4W()

void CFile::writeP4W ( std::fstream &  fstat,
double  timeData 
)
inline
301  {
302  unsigned int N;
304  std::string dummy;
305  double time;
306  double P1, delta, deltat, fn, ft;
307  Vec3D C, F, n, t;
308 
309  while (p4w.good()) {
310  //read header
311  p4w >> dummy >> dummy;
312  p4w >> time >> N;
313  getline(p4w, line);
314  getline(p4w, line);
315 
316  if (time < timeData * 0.999999)
317  {
318  logger(INFO, "reading p4w (t % N %): below timeMin; skipped", time, N);
319  for (unsigned int i = 0; i < N; i++)
320  getline(p4w, line);
321  continue;
322  }
323 
324  logger(INFO, "reading p4w (t % N %)", time, N);
325 
326  for (unsigned int i = 0; i < N; i++)
327  {
328  p4w >> P1
329  >> C
330  >> F;
331  delta = 0.0;
332  deltat = 0.0;
333  ft = 0.0;
334  t.setZero();
335  fn = F.getLength();
336  n=F/fn;
337  fstat << time << " "
338  << id_[P1-1] << " "
339  << -1 << " "
340  << C << " "
341  << delta << " "
342  << deltat << " "
343  << fn << " "
344  << ft << " "
345  << n << " "
346  << t << std::endl;
347  }
348  break;
349  }
350  }
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:49
Definition: matrices.h:74

References MultiOpt::delta, oomph::OcTreeNames::F, i, id_, INFO, calibrate::line, logger, n, N, p4w, oomph::Global_string_for_annotation::string(), and plotPSD::t.

Referenced by writeP4C().

◆ writeRestart()

void CFile::writeRestart ( double  timeData,
double  density 
)
inline
353  {
354  logger(INFO, "restart.0000 ", timeData);
355  //open data/fstat file
356  std::fstream restart;
357  restart.open(name_ + ".restart", std::fstream::out);
358  restart <<
359  "restart_version 1.0 name " << name_ << "\n"
360  "dataFile name " << name_ << ".data fileType MULTIPLE_FILES_PADDED saveCount 1 counter 1 nextSavedTimeStep 0\n"
361  "fStatFile name " << name_ << ".fstat fileType MULTIPLE_FILES_PADDED saveCount 1 counter 1 nextSavedTimeStep 0\n"
362  "eneFile name " << name_ << ".ene fileType ONE_FILE saveCount 1 counter 302 nextSavedTimeStep 0\n"
363  "restartFile name " << name_ << ".restart fileType ONE_FILE saveCount 1 counter 1 nextSavedTimeStep 0\n"
364  "statFile name " << name_ << ".stat fileType ONE_FILE saveCount 1 counter 0 nextSavedTimeStep 0\n"
365  //"dataFile fileType MULTIPLE_FILES_PADDED saveCount 1 counter 1 nextSavedTimeStep 0\n"
366  //"fStatFile fileType MULTIPLE_FILES_PADDED saveCount 1 counter 1 nextSavedTimeStep 0\n"
367  //"eneFile fileType ONE_FILE saveCount 1 counter 302 nextSavedTimeStep 0\n"
368  //"restartFile fileType ONE_FILE saveCount 1 counter 1 nextSavedTimeStep 0\n"
369  //"statFile fileType ONE_FILE saveCount 1 counter 0 nextSavedTimeStep 0\n"
370  "xMin " << xmin_<< " xMax " << xmax_<< " yMin " << ymin_<< " yMax " << ymax_<< " zMin " << zmin_<< " zMax " << zmax_<< "\n"
371  "timeStep 0 time " << timeData << " ntimeSteps 0 timeMax " << timeData << "\n"
372  "systemDimensions 3 particleDimensions 3 gravity 0 0 -9.8\n"
373  "Species 1\n"
374  "LinearViscoelasticSpecies id 0 density " << density << " stiffness 0 dissipation 0\n"
375  "Walls 0\n";
376  if (!periodic_)
377  restart << "Boundaries 0\n";
378  else
379  {
380  restart << "Boundaries 1\n";
381  if (periodic_==1)
382  restart << "PeriodicBoundary id 0 normal 1 0 0 scaleFactor 1 distanceLeft " << xmin_ << " distanceRight " << xmax_ << " shift " << xmax_-xmin_ << " 0 0\n";
383  else if (periodic_==2)
384  restart << "PeriodicBoundary id 0 normal 0 1 0 scaleFactor 1 distanceLeft " << ymin_ << " distanceRight " << ymax_ << " shift " << ymax_-ymin_ << " 0 0\n";
385  else
386  restart << "PeriodicBoundary id 0 normal 0 0 1 scaleFactor 1 distanceLeft " << zmin_ << " distanceRight " << zmax_ << " shift " << zmax_-zmin_ << " 0 0\n";
387  }
388  restart <<
389  "Particles 0\n"
390  "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"
391  "Interactions 0\n";
392  restart.close();
393  }
Definition: restart2.cpp:8
density
Definition: UniformPSDSelfTest.py:19

References UniformPSDSelfTest::density, INFO, logger, name_, out(), 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: