tforcechains.cpp - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
 (HTM) git clone git://src.adamsgaard.dk/sphere
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
       tforcechains.cpp (3662B)
       ---
            1 // Including library files
            2 #include <iostream>
            3 #include <string>
            4 #include <cstdlib>
            5 
            6 // Including user files
            7 #include "constants.h"
            8 #include "datatypes.h"
            9 #include "sphere.h"
           10 
           11 //////////////////
           12 // MAIN ROUTINE //
           13 //////////////////
           14 // The main loop returns the value 0 to the shell, if the program terminated
           15 // successfully, and 1 if an error occured which caused the program to crash.
           16 int main(const int argc, const char *argv[]) 
           17 {
           18     // Default values
           19     int verbose = 0;
           20     int nfiles = 0; // number of input files
           21     int threedim = 1; // 0 if 2d, 1 if 3d
           22     double lowercutoff = 0.0;
           23     double uppercutoff = 1.0e9;
           24     std::string format = "interactive"; // gnuplot terminal type
           25 
           26     // Process input parameters
           27     int i;
           28     for (i=1; i<argc; ++i) {        // skip argv[0]
           29 
           30         std::string argvi = std::string(argv[i]);
           31 
           32         // Display help if requested
           33         if (argvi == "-h" || argvi == "--help") {
           34             std::cout << argv[0] << ": sphere force chain visualizer\n"
           35                 << "Usage: " << argv[0] << " [OPTION[S]]... [FILE1 ...] > "
           36                 "outputfile\nOptions:\n"
           37                 "-h, --help\t\tPrint help\n"
           38                 "-V, --version\t\tPrint version information and exit\n"
           39                 "-v, --verbose\t\tDisplay in-/output file names\n"
           40                 "-lc <val>, --lower-cutoff <val>\t\tOnly show contacts where "
           41                 "the force value is greater\n"
           42                 "-uc <val>, --upper-cutoff <val>\t\tOnly show contacts where "
           43                 "the force value is greater\n"
           44                 "-f, --format\t\tOutput format to stdout, interactive default. "
           45                 "Possible values:\n"
           46                 "\t\t\tinteractive, png, epslatex, epslatex-color\n"
           47                 "-2d\t\t\twrite output as 2d coordinates (3d default)\n"
           48                 "The values below the cutoff are not visualized, the values "
           49                 "above are truncated to the upper limit\n"
           50                 << std::endl;
           51             return 0; // Exit with success
           52         }
           53 
           54         // Display version with fancy ASCII art
           55         else if (argvi == "-V" || argvi == "--version") {
           56             std::cout << "Force chain calculator, sphere version " << VERSION
           57                 << std::endl;
           58             return 0;
           59         }
           60 
           61         else if (argvi == "-v" || argvi == "--verbose")
           62             verbose = 1;
           63 
           64         else if (argvi == "-f" || argvi == "--format")
           65             format = argv[++i];
           66 
           67         else if (argvi == "-lc" || argvi == "--lower-cutoff")
           68             lowercutoff = atof(argv[++i]);
           69 
           70         else if (argvi == "-uc" || argvi == "--upper-cutoff")
           71             uppercutoff = atof(argv[++i]);
           72 
           73         else if (argvi == "-2d")
           74             threedim = 0;
           75 
           76         // The rest of the values must be input binary files
           77         else {
           78             nfiles++;
           79 
           80             if (verbose == 1)
           81                 std::cout << argv[0] << ": processing input file: " << argvi <<
           82                     std::endl;
           83 
           84             // Create DEM class, read data from input binary, check values
           85             DEM dem(argvi, verbose, 0, 0, 0);
           86 
           87             // Calculate porosity and save as file
           88             dem.forcechains(format, threedim, lowercutoff, uppercutoff);
           89 
           90         }
           91     }
           92 
           93     // Check whether there are input files specified
           94     if (!argv[0] || argc == 1 || nfiles == 0) {
           95         std::cerr << argv[0] << ": missing input binary file\n"
           96             << "See `" << argv[0] << " --help` for more information"
           97             << std::endl;
           98         return 1; // Return unsuccessful exit status
           99     }
          100 
          101     return 0; // Return successfull exit status
          102 } 
          103 // END OF FILE
          104 // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4