Cannot get MeshToParticle to interpolate correctly #4810
-
|
This code prints even though as far as I can tell it should print How do I get MeshToParticle to interpolate as intended? Am I calculating x,y,z incorrectly around line 45? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
|
x,y,z should be correct, added (i,j,k) to above output: |
Beta Was this translation helpful? Give feedback.
-
|
Same result with |
Beta Was this translation helpful? Give feedback.
-
|
Looking at the index calculation for the Nearest interpolator, to me it looks like it is for node-centered field arrays, making it half a cell off cell-centered data. amrex/Src/Particle/AMReX_ParticleInterpolators.H Lines 197 to 199 in 5102120 I believe for cell-centered data, the + 0.5 should be removed.
|
Beta Was this translation helpful? Give feedback.

If my understanding of ParticleInterpolator is correct, then the Nearest only works if the grid is node-centered data (but does not explicitly check/convert this), while the Linear interpolator only works for cell-centered data. It also has the offset of +0.5 but this is actually needed since it uses two cells per direction. Other codes based on AMReX typically implement custom interpolators that also support higher orders.
https://github.com/Hi-PACE/hipace/blob/development/src/particles/particles_utils/ShapeFactors.H
https://github.com/BLAST-WarpX/warpx/blob/development/Source/Particles/ShapeFactors.H
Note how every second order has an offset of 0.5. The input for these functions alread…