Replies: 5 comments 1 reply
-
|
If I change |
Beta Was this translation helpful? Give feedback.
-
|
You are using AMReX with Spacedim==3 for effectively a 2D problem. This is possible to do; however, some functions don't quite work correctly. In this MeshToParticle does interpolation in all 3 dimensions, including the one you don't have in the array. For performance reasons, bounds checking is usually omitted in particle interpolation, and it is assumed that the grids have enough ghost cells, which is not the case here. You can use MeshToParticle with only two dimensions; however, you need to supply your own ParticleInterpolator that does not do any interpolation in the 3rd dimension. Basically you need to copy the implementation but replace AMREX_SPACEDIM with 2 (note: untested): struct NearestInterp2D : public amrex::ParticleInterpolator::Base<NearestInterp2D, int>
{
static constexpr int stencil_width = 1;
int weights[3*stencil_width];
static constexpr int dim = 2;
static constexpr int nx = (dim >= 1) ? stencil_width - 1 : 0;
static constexpr int ny = (dim >= 2) ? stencil_width - 1 : 0;
static constexpr int nz = (dim >= 3) ? stencil_width - 1 : 0;
template <typename P>
AMREX_GPU_DEVICE AMREX_FORCE_INLINE
NearestInterp2D (const P& p,
amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> const& plo,
amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> const& dxi)
{
w = &weights[0];
for (int i = 0; i < dim; ++i) {
amrex::Real l = (p.pos(i) - plo[i]) * dxi[i] + 0.5;
index[i] = static_cast<int>(amrex::Math::floor(l));
w[i] = 1;
}
for (int i = dim; i < 3; ++i) {
index[i] = 0;
w[i] = 1;
}
}
};And then replace |
Beta Was this translation helpful? Give feedback.
-
|
Thanks but looks like problem concerns all dimensions and probably only manifests if particle is located in positive half of last cell in particular dimension. If I change to then I get |
Beta Was this translation helpful? Give feedback.
-
|
Turns out that nearest neighbor interpolator assumes vertex-centered data so would fail whenever particle existed in last half of last cell in grid: #4810 Linear interpolator always needs two cells so how should I prepare my grid to make that work in one cell periodic grid? Should I use |
Beta Was this translation helpful? Give feedback.
-
|
Solved in another question: changing |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Following code
prints
which I can fix by using
IntVect{1, 1, 1}instead ofIntVect{1, 1, 0}but then I get 2 cells in z dimension. Is it possible to have 1 cell in any dimension with (3d?) AMReX?Beta Was this translation helpful? Give feedback.
All reactions