tConst. mem should not be transfered after the first input file - 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
       ---
 (DIR) commit a06b4c3144cc68a125b24146090ed94c096f8850
 (DIR) parent 9fc0fc43e1fb2089f6e7781b3265724025de521d
 (HTM) Author: Anders Damsgaard <adc@geo.au.dk>
       Date:   Thu, 24 Jan 2013 14:07:13 +0100
       
       Const. mem should not be transfered after the first input file
       
       Diffstat:
         M src/main.cpp                        |      35 ++++++++++++++++++++++---------
         M src/sphere.cpp                      |      40 ++++++++++++++++++++++----------
         M src/sphere.h                        |       3 ++-
       
       3 files changed, 55 insertions(+), 23 deletions(-)
       ---
 (DIR) diff --git a/src/main.cpp b/src/main.cpp
       t@@ -141,16 +141,31 @@ int main(const int argc, const char *argv[])
                    if (verbose == 1)
                        std::cout << argv[0] << ": processing input file: " << argvi << std::endl;
        
       -            // Create DEM class, read data from input binary, check values
       -            DEM dem(argvi, verbose, checkVals, dry);
       -
       -            // Render image if requested
       -            if (render == 1)
       -                dem.render(method, max_val, lower_cutoff);
       -
       -            // Otherwise, start iterating through time
       -            else
       -                dem.startTime();
       +            if (nfiles == 1) {
       +
       +                // Create DEM class, read data from input binary, check values, init cuda, transfer const mem
       +                DEM dem(argvi, verbose, checkVals, dry, 1, 1);
       +                // Render image if requested
       +                if (render == 1)
       +                    dem.render(method, max_val, lower_cutoff);
       +
       +                // Otherwise, start iterating through time
       +                else
       +                    dem.startTime();
       +
       +            } else { 
       +                
       +                // Do not transfer to const. mem after the first file
       +                DEM dem(argvi, verbose, checkVals, dry, 1, 0);
       +
       +                // Render image if requested
       +                if (render == 1)
       +                    dem.render(method, max_val, lower_cutoff);
       +
       +                // Otherwise, start iterating through time
       +                else
       +                    dem.startTime();
       +            }
        
                }
            }
 (DIR) diff --git a/src/sphere.cpp b/src/sphere.cpp
       t@@ -17,7 +17,8 @@ DEM::DEM(const std::string inputbin,
                const int verbosity,
                const int checkVals,
                const int dry,
       -        const int initCuda)
       +        const int initCuda,
       +        const int transferConstMem)
        : verbose(verbosity)
        {
            using std::cout;
       t@@ -48,11 +49,14 @@ DEM::DEM(const std::string inputbin,
                exit(1);
        
            if (initCuda == 1) {
       +
                // Initialize CUDA
                initializeGPU();
        
       -        // Copy constant data to constant device memory
       -        transferToConstantDeviceMemory();
       +        if (transferConstMem == 1) {
       +            // Copy constant data to constant device memory
       +            transferToConstantDeviceMemory();
       +        }
        
                // Allocate device memory for particle variables,
                // tied to previously declared pointers in structures
       t@@ -602,6 +606,11 @@ void DEM::forcechains(const std::string format, const int threedim)
        
        
            } else {
       +
       +        // Format sid so LaTeX won't encounter problems with the extension
       +        std::string s = sid;
       +        std::replace(s.begin(), s.end(), '.', '-');
       +
                // Write Gnuplot header
                cout << "#!/usr/bin/env gnuplot\n" 
                    << "# This Gnuplot script is automatically generated using\n"
       t@@ -610,14 +619,21 @@ void DEM::forcechains(const std::string format, const int threedim)
                    << "set size ratio -1\n";
                if (format == "png") 
                    cout << "set term pngcairo size 50 cm,40 cm\n";
       -        else if (format == "epslatex")
       -            cout << "set term epslatex size 8.6 cm, 8.6 cm\n";
       -        else if (format == "epslatex-color")
       -            cout << "set term epslatex color size 8.6 cm, 8.6 cm\n";
       -        cout << "set xlabel '$x^1$, [m]'\n"
       -            << "set ylabel '$x^2$, [m]'\n"
       -            << "set zlabel '$x^3$, [m]'\n"
       -            << "set cblabel '$||f_n||$, [Pa]'\n"
       +        else if (format == "epslatex") {
       +            cout << "set term epslatex size 8.6 cm, 5.6 cm\n";
       +            cout << "set out 'plots/" << s << "-fc.tex'\n";
       +        } else if (format == "epslatex-color") {
       +            cout << "set term epslatex color size 8.6 cm, 5.6 cm\n";
       +            cout << "set out 'plots/" << s << "-fc.tex'\n";
       +        }
       +        cout << "set xlabel '\\sffamily $x_1$, [m]'\n";
       +        if (threedim == 1) {
       +            cout << "set ylabel '\\sffamily $x_2$, [m]'\n"
       +            << "set zlabel '\\sffamily $x_3$, [m]' offset 2\n";
       +        } else
       +            cout << "set ylabel '\\sffamily $x_3$, [m]' offset 2\n";
       +
       +        cout << "set cblabel '\\sffamily $||\\boldsymbol{f}_n||$, [N]'\n"
                    << "set xyplane at " << x_min.z << '\n'
                    << "set pm3d\n"
                    << "set view 90.0,0.0\n"
       t@@ -677,7 +693,7 @@ void DEM::forcechains(const std::string format, const int threedim)
                            cout << k.x[j].y, ',';
                        cout << k.x[j].z;
                        cout << " nohead "
       -                    << "lw " << ratio * 12.0
       +                    << "lw " << ratio * 8.0
                            << " lc palette cb " << f_n 
                            << endl;
                    }
 (DIR) diff --git a/src/sphere.h b/src/sphere.h
       t@@ -140,7 +140,8 @@ class DEM {
                        const int verbosity = 1,
                        const int checkVals = 1,
                        const int dry = 0,
       -                const int initCuda = 1);
       +                const int initCuda = 1,
       +                const int transferConstMem = 1);
        
                // Destructor
                ~DEM(void);