MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConvertP4Files.cpp File Reference
#include <string>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <sstream>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include "Math/ExtendedMath.h"
#include "Math/Helpers.h"
#include "Math/Vector.h"

Go to the source code of this file.

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

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

Definition at line 445 of file ConvertP4Files.cpp.

References CFile::copy(), and helpers::writeToFile().

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