tAdded xsum visualization in raytracer - 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 4743deb688c7e4cdb64e784c1830e126519c3c6b
 (DIR) parent 47ab0349edbf276aa213941ca185b51b36db7ec1
 (HTM) Author: Anders Damsgaard <adc@geo.au.dk>
       Date:   Wed, 10 Oct 2012 10:12:11 +0200
       
       Added xsum visualization in raytracer
       
       Diffstat:
         M raytracer/main.cpp                  |       9 +++++++--
         M raytracer/rt-kernel.cu              |      14 +++++++++++++-
         M raytracer/rt-kernel.h               |       2 +-
       
       3 files changed, 21 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/raytracer/main.cpp b/raytracer/main.cpp
       t@@ -80,6 +80,7 @@ int main(const int argc, const char* argv[])
            // Single precision arrays used for computations
            float4* p      = new float4[np];
            float*  fixvel = new float[np];
       +    float*  xsum   = new float[np];
            float*  es_dot = new float[np];
            float*  ev_dot = new float[np];
            float*  es     = new float[np];
       t@@ -156,7 +157,8 @@ int main(const int argc, const char* argv[])
            for (unsigned int i=0; i<np; i++) {
              (void)fread(&d, sizeof(d), 1, fin); // fixvel
              fixvel[i] = (float)d;
       -      (void)fread(&blankd, sizeof(blankd), 1, fin); // xsum
       +      (void)fread(&d, sizeof(d), 1, fin); // xsum
       +      xsum[i] = (float)d;
              (void)fread(&d, sizeof(d), 1, fin);  // radius
              p[i].w = (float)d;
              for (int j=0; j<10; j++)
       t@@ -211,6 +213,8 @@ int main(const int argc, const char* argv[])
                visualize = 3; // 3: es view
              if(strcmp(argv[6],"vel") == 0)
                visualize = 4; // 4: velocity view
       +      if(strcmp(argv[6],"xsum") == 0)
       +        visualize = 5; // 5: xsum view
        
              // Read max. value specified in command args.
              max_val = atof(argv[7]);
       t@@ -221,7 +225,7 @@ int main(const int argc, const char* argv[])
            if (strcmp(argv[1],"GPU") == 0) {
        
              // Call cuda wrapper
       -      if (rt(p, np, img, width, height, origo, L, eye, lookat, imgw, visualize, max_val, fixvel, pres, es_dot, es, vel) != 0) {
       +      if (rt(p, np, img, width, height, origo, L, eye, lookat, imgw, visualize, max_val, fixvel, xsum, pres, es_dot, es, vel) != 0) {
                cout << "\nError in rt()\n";
                return 1;
              }
       t@@ -240,6 +244,7 @@ int main(const int argc, const char* argv[])
            // Free dynamically allocated memory
            delete [] p;
            delete [] fixvel;
       +    delete [] xsum;
            delete [] pres;
            delete [] es;
            delete [] ev;
 (DIR) diff --git a/raytracer/rt-kernel.cu b/raytracer/rt-kernel.cu
       t@@ -300,7 +300,12 @@ __host__ int rt(float4* p, Inttype np,
                        rgb* img, unsigned int width, unsigned int height,
                        f3 origo, f3 L, f3 eye, f3 lookat, float imgw,
                        int visualize, float max_val,
       -                float* fixvel, float* pres, float* es_dot, float* es, float* vel)
       +                float* fixvel,
       +                float* xsum,
       +                float* pres,
       +                float* es_dot,
       +                float* es,
       +                float* vel)
        {
          using std::cout;
        
       t@@ -344,6 +349,8 @@ __host__ int rt(float4* p, Inttype np,
            cudaMemcpy(_linarr, es, np*sizeof(float), cudaMemcpyHostToDevice);
          if (visualize == 4)
            cudaMemcpy(_linarr, vel, np*sizeof(float), cudaMemcpyHostToDevice);
       +  if (visualize == 5)
       +    cudaMemcpy(_linarr, xsum, np*sizeof(float), cudaMemcpyHostToDevice);
        
          // Check for errors after memory allocation
          checkForCudaErrors("CUDA error after memory allocation"); 
       t@@ -395,6 +402,11 @@ __host__ int rt(float4* p, Inttype np,
            rayIntersectSpheresColormap<<< blocksPerGrid, threadsPerBlock >>>(
                _ray_origo, _ray_direction,
                _p, _fixvel, _linarr, max_val, _img);
       +  } else if (visualize == 5) { // xsum visualization
       +    cout << "  XSum color map range: [0, " << max_val << "] m\n";
       +    rayIntersectSpheresColormap<<< blocksPerGrid, threadsPerBlock >>>(
       +        _ray_origo, _ray_direction,
       +        _p, _fixvel, _linarr, max_val, _img);
          } else { // Normal visualization
            rayIntersectSpheres<<< blocksPerGrid, threadsPerBlock >>>(
                _ray_origo, _ray_direction,
 (DIR) diff --git a/raytracer/rt-kernel.h b/raytracer/rt-kernel.h
       t@@ -31,5 +31,5 @@ int rt(float4* p, Inttype np,
               rgb* img, unsigned int width, unsigned int height,
               f3 origo, f3 L, f3 eye, f3 lookat, float imgw,
               int visualize, float max_val,
       -       float* fixvel, float* pres, float* es_dot, float* es, float* vel);
       +       float* fixvel, float* xsum, float* pres, float* es_dot, float* es, float* vel);
        #endif