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[] 
)
450 {
451  if (argc<8)
452  {
453  if (argc < 2)
454  {
455  logger(INFO, "no arguments given, so a test file is converted; to convert your own p4 files, use:\n"
456  "convertP4Files.cpp name xmin xmax ymin ymax zmin zmax [timeMin [timeMax [periodic]]]");
457 
458  helpers::writeToFile("test.p4p",
459  "TIMESTEP PARTICLES\n"
460  "0 2\n"
461  "ID GROUP VOLUME MASS PX PY PZ VX VY VZ Angular_Velocity_X Angular_Velocity_Y Angular_Velocity_Z\n"
462  "1 1 0.52359877559 1 0.5 0.5 0.5 1 0 0 0 0 1\n"
463  "3 1 0.52359877559 1 3.5 0.5 0.5 0 0 0 0 0 0\n"
464  "TIMESTEP PARTICLES\n"
465  "2 2\n"
466  "ID GROUP VOLUME MASS PX PY PZ VX VY VZ Angular_Velocity_X Angular_Velocity_Y Angular_Velocity_Z\n"
467  "1 1 0.52359877559 1 0.5 0.5 0.5 1 0 0 0 0 1\n"
468  "3 1 0.52359877559 1 3.5 0.5 0.5 0 0 0 0 0 0\n"
469  );
470 
471  helpers::writeToFile("test.p4c",
472  "TIMESTEP CONTACTS\n"
473  "0 1\n"
474  "P1 P2 CX CY CZ FX FY FZ\n"
475  "1 3 0 0.5 0.5 1 1 0\n"
476  "TIMESTEP CONTACTS\n"
477  "2 1\n"
478  "P1 P2 CX CY CZ FX FY FZ\n"
479  "1 3 4 0.5 0.5 1 1 0\n"
480  );
481 
482  helpers::writeToFile("test.p4w",
483  "TIMESTEP CONTACTS\n"
484  "0 2\n"
485  "P1 CX CY CZ FX FY FZ\n"
486  "1 0.5 0.5 0 0 0 1\n"
487  "3 3.5 0.5 0 0 0 1\n"
488  "TIMESTEP CONTACTS\n"
489  "2 2\n"
490  "P1 CX CY CZ FX FY FZ\n"
491  "1 0.5 0.5 0 0 0 1\n"
492  "3 3.5 0.5 0 0 0 1\n"
493  );
494 
495  CFile files("test");
496  files.copy(0,4,0,1,0,1,-1,1e20,1);
497  }
498  else
499  {
500  logger(ERROR, "convertP4Files.cpp problem_name xmin xmax ymin ymax zmin zmax [timeMin [timeMax "
501  "[periodic]]]");
502  }
503  }
504  else
505  {
506  std::string name(argv[1]);
507  logger(INFO, "converting %", name);
508 
509  double timeMin = -1;
510  if (argc>8) {
511  timeMin = atof(argv[8]);
512  logger(INFO, "timeMin %", timeMin);
513  }
514 
515  double timeMax = 1e20;
516  if (argc>9) {
517  timeMax = atof(argv[9]);
518  logger(INFO, "timeMax %", timeMax);
519  }
520 
521  unsigned int periodic = 0;
522  if (argc > 10)
523  {
524  periodic = static_cast<unsigned int>(atoi(argv[10]));
525  logger(INFO, "periodic %", periodic);
526  }
527 
528  CFile files(name);
529  files.copy(atof(argv[2]), atof(argv[3]), atof(argv[4]), atof(argv[5]), atof(argv[6]), atof(argv[7]), timeMin,
530  timeMax, periodic);
531 
532  logger(INFO, "finished converting %", name);
533  }
534 }
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
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:53
takes data and fstat files and splits them into *.data.???? and *.fstat.???? files
Definition: centerofmass.cpp:40
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:58
std::string name
Definition: MercuryProb.h:48

References CFile::copy(), ERROR, INFO, logger, units::name, and helpers::writeToFile().