Skip to content

Commit

Permalink
Partially addresses #2765. Changes internal representation of Grid::_…
Browse files Browse the repository at this point in the history
…dims

to match new API, which results in a ~10% improvement in performance.
  • Loading branch information
clyne committed Jul 6, 2021
1 parent af6d8c1 commit 2087772
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 5 additions & 6 deletions include/vapor/Grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,17 @@ class VDF_API Grid {
//! the constructor. If the parameter has less than 3 values, then
//! number 1 will be filled.
//!
DimsType GetDimensions() const
const DimsType &GetDimensions() const
{
auto tmp = DimsType{1, 1, 1};
std::copy(_dims.begin(), _dims.end(), tmp.begin());
return tmp;
return _dims;
}

//! Return the useful number of dimensions of grid connectivity array
//!
//! \param[out] dims The number of values of \p dims parameter provided to
//! the constructor.
//!
size_t GetNumDimensions() const { return _dims.size(); }
size_t GetNumDimensions() const { return _nDims; }

//! Return the dimensions of the specified coordinate variable
//!
Expand Down Expand Up @@ -1229,7 +1227,8 @@ class VDF_API Grid {
}

private:
std::vector<size_t> _dims; // dimensions of grid arrays
DimsType _dims; // dimensions of grid arrays
size_t _nDims;
DimsType _bs = {{1, 1, 1}}; // dimensions of each block
DimsType _bdims = {{1, 1, 1}}; // dimensions (specified in blocks) of ROI
std::vector<size_t> _bsDeprecated; // legacy API
Expand Down
6 changes: 4 additions & 2 deletions lib/vdc/Grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ Grid::Grid(const std::vector<size_t> &dims, const std::vector<size_t> &bs, const
VAssert(blks.size() == 0 || // dataless
blks.size() == std::accumulate(_bdims.begin(), _bdims.end(), 1, std::multiplies<size_t>()));

_dims = dims;
_dims = {1,1,1};
_nDims = dims.size();
std::copy(dims.begin(), dims.begin() + dims.size(), _dims.begin());
_periodic = vector<bool>(topology_dimension, false);
_topologyDimension = topology_dimension;
_missingValue = INFINITY;
_hasMissing = false;
_interpolationOrder = 0;
_nodeIDOffset = 0;
_cellIDOffset = 0;
_minAbs = vector<size_t>(_dims.size(), 0);
_minAbs = vector<size_t>(_nDims, 0);

//
// Shallow copy blocks
Expand Down

0 comments on commit 2087772

Please sign in to comment.