[Commits] [svn:einsteintoolkit] incoming/PITTNullCode/SphericalHarmonicReconGen/ (Rev. 101)

reisswig at tapir.caltech.edu reisswig at tapir.caltech.edu
Thu Oct 24 18:24:22 CDT 2013


User: reisswig
Date: 2013/10/24 06:24 PM

Modified:
 /PITTNullCode/SphericalHarmonicReconGen/
  param.ccl
 /PITTNullCode/SphericalHarmonicReconGen/src/
  sph_database.cc, startup.cc

Log:
 Cache data in SpEC-HDF5-v2 format. Allow for single filename specificatioin in par-file.

File Changes:

Directory: /PITTNullCode/SphericalHarmonicReconGen/
===================================================

File [modified]: param.ccl
Delta lines: +11 -0
===================================================================
--- PITTNullCode/SphericalHarmonicReconGen/param.ccl	2013-10-24 21:49:59 UTC (rev 100)
+++ PITTNullCode/SphericalHarmonicReconGen/param.ccl	2013-10-24 23:24:22 UTC (rev 101)
@@ -7,6 +7,7 @@
 {
   ASCII      :: "standard ASCII format: lm-modes and spheres are stored in a 2d array (gnuplot style) for a given timestep"
   DAT        :: "optimized ASCII format: all variables and lm-modes are stored in one row for a given timestep"
+  DAT-v2     :: "optimized ASCII format: all variables and lm-modes are stored in one row for a given timestep. m-modes are in reverse order."
   SpEC-H5    :: "SpEC-HDF5 format: Data is stored in HDF5 files grouped according to SpEC output."
   SpEC-H5-v2 :: "SpEC-HDF5 format (v2): Data is stored in HDF5 files grouped according to new SpEC output."
 } "ASCII"
@@ -68,6 +69,16 @@
 } Goldberg67
 
 
+CCTK_REAL dt_tolerance "A minimum tolerance for which timesteps are considered being identical"
+{
+  0:* :: "Small and positive"
+} 1e-9
+
+STRING file "The boundary data file. If this string is empty, we assume that the user provided files for each quantity individually (parameters below)"
+{
+ ""	:: "a valid filename"
+} ""
+
 STRING path "the directory that contains the input files, leave blank if filenames contain directory paths already"
 {
  ""	:: "a path name"

Directory: /PITTNullCode/SphericalHarmonicReconGen/src/
=======================================================

File [modified]: sph_database.cc
Delta lines: +65 -23
===================================================================
--- PITTNullCode/SphericalHarmonicReconGen/src/sph_database.cc	2013-10-24 21:49:59 UTC (rev 100)
+++ PITTNullCode/SphericalHarmonicReconGen/src/sph_database.cc	2013-10-24 23:24:22 UTC (rev 101)
@@ -528,7 +528,7 @@
             str << "Time-step not strictly monotonic: time[" << i-1 << "] = " << _times[i-1] << ", time[" << i << "] = " << _times[i];
             CCTK_WARN(0, str.str().c_str());
          }
-         if (fabs(_times[i] - _times[i-1] - _delta_t) >= 1e-8)
+         if (verbose && fabs(_times[i] - _times[i-1] - _delta_t) >= 1e-8)
          {
             _delta_t = _times[i]-_times[i-1];
             cout << "SPH_db_DAT " << _fname << ": t = " <<  _times[i-1] << ",    delta_t = " << _delta_t << endl;
@@ -955,7 +955,7 @@
             i -= remove_non_monotonic_steps(i);
             continue;
          }
-         if (fabs(_times[i] - _times[i-1] - _delta_t) >= 1e-8)
+         if (verbose && fabs(_times[i] - _times[i-1] - _delta_t) >= 1e-8)
          {
             _delta_t = _times[i]-_times[i-1];
             cout << "SPH_db_SpEC_H5 " << _fname << ": t = " <<  _times[i-1] << ",    delta_t = " << _delta_t << endl;
@@ -1166,10 +1166,10 @@
             i -= remove_non_monotonic_steps(i);
             continue;
          }
-         if (fabs(_times[i] - _times[i-1] - _delta_t) >= 1e-8)
+         if (verbose && fabs(_times[i] - _times[i-1] - _delta_t) >= 1e-8)
          {
             _delta_t = _times[i]-_times[i-1];
-            cout << "SPH_db_SpEC_H5 " << _fname << ": t = " <<  _times[i-1] << ",    delta_t = " << _delta_t << endl;
+            cout << "SPH_db_SpEC_H5_v2 " << _fname << ": t = " <<  _times[i-1] << ",    delta_t = " << _delta_t << endl;
          }
       }
       // set _delta_t to correspond to initial delta_t
@@ -1186,34 +1186,76 @@
       CCTK_WARN(0, "Requested timestep not in worldtube data file. Stopping!");
    }
 
-   hid_t dataset = H5Dopen(file, varname_table[varno].c_str());//, H5P_DEFAULT);
-   vector<double> buffer((_lmax+1)*(_lmax+1)*2);
+   // check cache if data is there and return it
+   if (is_in_cache(timestep, 2*varno+1, coeff)) return;
+
+   // fill cache -------------------------------------
    
-   hsize_t dimsm[1] = { buffer.size() };
-   hid_t memspace = H5Screate_simple (1, dimsm, NULL);
+   cached_first_timestep = timestep;
    
-   hid_t dataspace = H5Dget_space(dataset);
-   hsize_t dims[2];
-   H5Sget_simple_extent_dims (dataspace, dims, NULL);
+   // set up cache
+   if (setup_cache) {
+      for (size_t t=0; t < cache.size(); ++t) {
+         cache[t].resize(2*_n_variables);
+         for (int v=0; v < 2*_n_variables; ++v) {
+            cache[t][v].resize(_n_spheres);
+            for (int s=0; s < _n_spheres; ++s) {
+               cache[t][v][s].resize(_lmax+1);
+               for (int l=0; l <= _lmax; ++l) {
+                  cache[t][v][s][l].resize(2*l+1);
+               }
+            }
+         }
+      }
+      // cache needs to be setup only at first time
+      setup_cache = false;
+   }
+
    
-   hsize_t offset[2] = { timestep, 1 };
-   hsize_t count[2]  = { 1, buffer.size() };
-   H5Sselect_hyperslab (dataspace, H5S_SELECT_SET, offset, NULL, 
+   const int nsteps = timestep+cache.size() >= steps.size() ? steps.size()-timestep : cache.size();
+
+   for (int v=0; v < _n_variables; ++v) {
+
+      hid_t dataset = H5Dopen(file, varname_table[v].c_str());
+      const int nmodes = (_lmax+1)*(_lmax+1)*2;
+      vector<double> buffer(nmodes*nsteps);
+   
+      hsize_t dimsm[1] = { buffer.size() };
+      hid_t memspace = H5Screate_simple (1, dimsm, NULL);
+   
+      hid_t dataspace = H5Dget_space(dataset);
+      hsize_t dims[2];
+      H5Sget_simple_extent_dims (dataspace, dims, NULL);
+   
+      hsize_t offset[2] = { timestep, 1 };
+      hsize_t count[2]  = { nsteps, nmodes };
+      H5Sselect_hyperslab (dataspace, H5S_SELECT_SET, offset, NULL, 
                                       count, NULL);
    
-   H5Dread(dataset, H5T_NATIVE_DOUBLE, memspace, dataspace, H5P_DEFAULT, &buffer.front());
+      H5Dread(dataset, H5T_NATIVE_DOUBLE, memspace, dataspace, H5P_DEFAULT, &buffer.front());
    
-   H5Sclose(memspace);
-   H5Sclose(dataspace);
-   H5Dclose(dataset);
+      H5Sclose(memspace);
+      H5Sclose(dataspace);
+      H5Dclose(dataset);
    
-   int c = 0;
-   for (int l=0; l <= _lmax; ++l) {
-      for (int m=l; m >= -l; --m, ++c) {
-         //coeff[0][l][m+l] = CCTK_Cmplx(buffer[c], buffer[c + buffer.size()/2]);
-         coeff[0][l][m+l] = CCTK_Cmplx(buffer[2*c], buffer[2*c + 1]);
+      for (int t=0; t < nsteps; ++t) {
+   
+         int c = 0;
+         for (int l=0; l <= _lmax; ++l) {
+            for (int m=l; m >= -l; --m, ++c) {
+               //coeff[0][l][m+l] = CCTK_Cmplx(buffer[2*c], buffer[2*c + 1]);
+               cache[t][2*v  ][0][l][m+l] = buffer[t*nmodes + 2*c]; 
+               cache[t][2*v+1][0][l][m+l] = buffer[t*nmodes + 2*c + 1];
+            }
+         }
+   
       }
+   
    }
+   
+   // finally set coeff array according to cache
+   if (!is_in_cache(timestep, 2*varno+1, coeff)) 
+      CCTK_WARN(0, "Variable not in cache even though I have put it there!");
 }
 
 

File [modified]: startup.cc
Delta lines: +36 -31
===================================================================
--- PITTNullCode/SphericalHarmonicReconGen/src/startup.cc	2013-10-24 21:49:59 UTC (rev 100)
+++ PITTNullCode/SphericalHarmonicReconGen/src/startup.cc	2013-10-24 23:24:22 UTC (rev 101)
@@ -71,39 +71,44 @@
    
    // get all different databases-names
    vector<string> fnames;
-   fnames.push_back(file_gxx[0]);
-   fnames.push_back(file_gxy[0]);
-   fnames.push_back(file_gxz[0]);
-   fnames.push_back(file_gyy[0]);
-   fnames.push_back(file_gyz[0]);
-   fnames.push_back(file_gzz[0]);
-   fnames.push_back(file_shiftx[0]);
-   fnames.push_back(file_shifty[0]);
-   fnames.push_back(file_shiftz[0]);
-   fnames.push_back(file_lapse[0]);
-   fnames.push_back(file_gxx[1]);
-   fnames.push_back(file_gxy[1]);
-   fnames.push_back(file_gxz[1]);
-   fnames.push_back(file_gyy[1]);
-   fnames.push_back(file_gyz[1]);
-   fnames.push_back(file_gzz[1]);
-   fnames.push_back(file_shiftx[1]);
-   fnames.push_back(file_shifty[1]);
-   fnames.push_back(file_shiftz[1]);
-   fnames.push_back(file_lapse[1]);
-   fnames.push_back(file_gxx[2]);
-   fnames.push_back(file_gxy[2]);
-   fnames.push_back(file_gxz[2]);
-   fnames.push_back(file_gyy[2]);
-   fnames.push_back(file_gyz[2]);
-   fnames.push_back(file_gzz[2]);
-   fnames.push_back(file_shiftx[2]);
-   fnames.push_back(file_shifty[2]);
-   fnames.push_back(file_shiftz[2]);
-   fnames.push_back(file_lapse[2]);
+   if (!CCTK_EQUALS(file, "")) {
+      // we have a single file!
+      fnames.resize(30, file);
+   } else {
+      // we have multiple files!
+      fnames.push_back(file_gxx[0]);
+      fnames.push_back(file_gxy[0]);
+      fnames.push_back(file_gxz[0]);
+      fnames.push_back(file_gyy[0]);
+      fnames.push_back(file_gyz[0]);
+      fnames.push_back(file_gzz[0]);
+      fnames.push_back(file_shiftx[0]);
+      fnames.push_back(file_shifty[0]);
+      fnames.push_back(file_shiftz[0]);
+      fnames.push_back(file_lapse[0]);
+      fnames.push_back(file_gxx[1]);
+      fnames.push_back(file_gxy[1]);
+      fnames.push_back(file_gxz[1]);
+      fnames.push_back(file_gyy[1]);
+      fnames.push_back(file_gyz[1]);
+      fnames.push_back(file_gzz[1]);
+      fnames.push_back(file_shiftx[1]);
+      fnames.push_back(file_shifty[1]);
+      fnames.push_back(file_shiftz[1]);
+      fnames.push_back(file_lapse[1]);
+      fnames.push_back(file_gxx[2]);
+      fnames.push_back(file_gxy[2]);
+      fnames.push_back(file_gxz[2]);
+      fnames.push_back(file_gyy[2]);
+      fnames.push_back(file_gyz[2]);
+      fnames.push_back(file_gzz[2]);
+      fnames.push_back(file_shiftx[2]);
+      fnames.push_back(file_shifty[2]);
+      fnames.push_back(file_shiftz[2]);
+      fnames.push_back(file_lapse[2]);
+   }
    
    
-   
    for (int i=0; i < 3*NUM_METRIC_COMPONENTS; ++i)
    {
       int found = -1;



More information about the Commits mailing list