diff --git a/Docs/sphinx_documentation/source/RuntimeParameters.rst b/Docs/sphinx_documentation/source/RuntimeParameters.rst index 5672d59609d..4753ab391b9 100644 --- a/Docs/sphinx_documentation/source/RuntimeParameters.rst +++ b/Docs/sphinx_documentation/source/RuntimeParameters.rst @@ -1142,7 +1142,7 @@ Memory .. py:data:: amrex.vector_growth_factor :type: amrex::Real - :value: 1.5 + :value: 1.25 This controls the growth factor of :cpp:`amrex::PODVector` and its derived classes such as :cpp:`amrex::Gpu::DeviceVector`, diff --git a/Src/Base/AMReX_PODVector.H b/Src/Base/AMReX_PODVector.H index e4df8562c1d..97d6d0058f9 100644 --- a/Src/Base/AMReX_PODVector.H +++ b/Src/Base/AMReX_PODVector.H @@ -660,6 +660,21 @@ namespace amrex } } + + void resize_geometric_grow (size_type a_new_size) + { + auto old_size = m_size; + if (m_capacity < a_new_size) { + size_type new_capacity = std::max(a_new_size, GetNewCapacityForPush()); + reserve(new_capacity); + } + m_size = a_new_size; + if (old_size < a_new_size) { + detail::maybe_init_snan(m_data + old_size, + m_size - old_size, (Allocator const&)(*this)); + } + } + void reserve (size_type a_capacity) { if (m_capacity < a_capacity) { diff --git a/Src/Base/AMReX_PODVector.cpp b/Src/Base/AMReX_PODVector.cpp index 4391ae2b705..b7e9f360c77 100644 --- a/Src/Base/AMReX_PODVector.cpp +++ b/Src/Base/AMReX_PODVector.cpp @@ -4,7 +4,7 @@ namespace amrex::VectorGrowthStrategy { - Real growth_factor = 1.5_rt; + Real growth_factor = 1.25_rt; // clamp user input to reasonable values constexpr Real min_factor = 1.001_rt; diff --git a/Src/Particle/AMReX_ParticleCommunication.H b/Src/Particle/AMReX_ParticleCommunication.H index 9e6e6a8a221..6456bac3ee5 100644 --- a/Src/Particle/AMReX_ParticleCommunication.H +++ b/Src/Particle/AMReX_ParticleCommunication.H @@ -49,7 +49,7 @@ struct RedistributeUnpackPolicy } for (auto& kv : tile_sizes) { - kv.first->resize(kv.second); + kv.first->resize_geometric_grow(kv.second); } } }; diff --git a/Src/Particle/AMReX_ParticleTile.H b/Src/Particle/AMReX_ParticleTile.H index 80f7705e266..c1b64cb7316 100644 --- a/Src/Particle/AMReX_ParticleTile.H +++ b/Src/Particle/AMReX_ParticleTile.H @@ -928,6 +928,26 @@ struct ParticleTile m_soa_tile.resize(count); } + void resize_geometric_grow (std::size_t count) + { + if constexpr (ParticleType::is_soa_particle) { + GetStructOfArrays().GetIdCPUData().resize_geometric_grow(count); + } else { + m_aos_tile().resize_geometric_grow(count); + } + for (int j = 0; j < NumRealComps(); ++j) + { + auto& rdata = GetStructOfArrays().GetRealData(j); + rdata.resize_geometric_grow(count); + } + + for (int j = 0; j < NumIntComps(); ++j) + { + auto& idata = GetStructOfArrays().GetIntData(j); + idata.resize_geometric_grow(count); + } + } + /// /// Add one particle to this tile. ///