ConvertP4Files.cpp File Reference
#include <string>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <sstream>
#include <sys/stat.h>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include "Math/ExtendedMath.h"
#include "Math/Helpers.h"
#include "Math/Vector.h"

Classes

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

Functions

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

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)
429 {
430  if (argc<8)
431  {
432  if (argc < 2)
433  {
434  logger(INFO, "no arguments given, so a test file is converted; to convert your own p4 files, use:\n"
435  "convertP4Files.cpp name xmin xmax ymin ymax zmin zmax [timeMin [timeMax [periodic]]]");
436 
437  helpers::writeToFile("test.p4p",
438  "TIMESTEP PARTICLES\n"
439  "0 2\n"
440  "ID GROUP VOLUME MASS PX PY PZ VX VY VZ Angular_Velocity_X Angular_Velocity_Y Angular_Velocity_Z\n"
441  "1 1 0.52359877559 1 0.5 0.5 0.5 1 0 0 0 0 1\n"
442  "3 1 0.52359877559 1 3.5 0.5 0.5 0 0 0 0 0 0\n"
443  "TIMESTEP PARTICLES\n"
444  "2 2\n"
445  "ID GROUP VOLUME MASS PX PY PZ VX VY VZ Angular_Velocity_X Angular_Velocity_Y Angular_Velocity_Z\n"
446  "1 1 0.52359877559 1 0.5 0.5 0.5 1 0 0 0 0 1\n"
447  "3 1 0.52359877559 1 3.5 0.5 0.5 0 0 0 0 0 0\n"
448  );
449 
450  helpers::writeToFile("test.p4c",
451  "TIMESTEP CONTACTS\n"
452  "0 1\n"
453  "P1 P2 CX CY CZ FX FY FZ\n"
454  "1 3 0 0.5 0.5 1 1 0\n"
455  "TIMESTEP CONTACTS\n"
456  "2 1\n"
457  "P1 P2 CX CY CZ FX FY FZ\n"
458  "1 3 4 0.5 0.5 1 1 0\n"
459  );
460 
461  helpers::writeToFile("test.p4w",
462  "TIMESTEP CONTACTS\n"
463  "0 2\n"
464  "P1 CX CY CZ FX FY FZ\n"
465  "1 0.5 0.5 0 0 0 1\n"
466  "3 3.5 0.5 0 0 0 1\n"
467  "TIMESTEP CONTACTS\n"
468  "2 2\n"
469  "P1 CX CY CZ FX FY FZ\n"
470  "1 0.5 0.5 0 0 0 1\n"
471  "3 3.5 0.5 0 0 0 1\n"
472  );
473 
474  CFile files("test");
475  files.copy(0,4,0,1,0,1,-1,1e20,1);
476  }
477  else
478  {
479  logger(ERROR, "convertP4Files.cpp problem_name xmin xmax ymin ymax zmin zmax [timeMin [timeMax "
480  "[periodic]]]");
481  }
482  }
483  else
484  {
485  std::string name(argv[1]);
486  logger(INFO, "converting %", name);
487 
488  double timeMin = -1;
489  if (argc>8) {
490  timeMin = atof(argv[8]);
491  logger(INFO, "timeMin %", timeMin);
492  }
493 
494  double timeMax = 1e20;
495  if (argc>9) {
496  timeMax = atof(argv[9]);
497  logger(INFO, "timeMax %", timeMax);
498  }
499 
500  unsigned int periodic = 0;
501  if (argc > 10)
502  {
503  periodic = static_cast<unsigned int>(atoi(argv[10]));
504  logger(INFO, "periodic %", periodic);
505  }
506 
507  CFile files(name);
508  files.copy(atof(argv[2]), atof(argv[3]), atof(argv[4]), atof(argv[5]), atof(argv[6]), atof(argv[7]), timeMin,
509  timeMax, periodic);
510 
511  logger(INFO, "finished converting %", name);
512  }
513 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:32
takes data and fstat files and splits them into *.data.???? and *.fstat.???? files
Definition: centerofmass.cpp:19
#define INFO(i)
Definition: mumps_solver.h:54
bool writeToFile(const std::string &filename, const std::string &filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:29
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
string name
Definition: plotDoE.py:33

References CFile::copy(), ERROR, INFO, logger, plotDoE::name, oomph::Global_string_for_annotation::string(), and helpers::writeToFile().