-
Notifications
You must be signed in to change notification settings - Fork 9
Interpolation Using Particles #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…de the GPU loops of the particle interpolators
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
Cpp-Linter Report
|
…t mem where needed)
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
|
Thanks for opening this PR, @tamaraevst. It looks like a good start. 🙂 When I do a proper review, I will have more detailed comments on the code. For now, I have some broader points to raise: Persistent particlesSince we usually want to interpolate the same variables at the same points repeatedly during a simulation, we don't want to be adding and redistributing particles each time we want to interpolate. Can you add a method to add a "persistent" interpolation query which can be made once with the particles added just the first time and re-used subsequently? We will need to remember to "redistribute" after a regrid but don't need to if a regrid hasn't happened since the last interpolation call. I believe redistribution is expensive so we should try to minimise it when we can. Maybe the DerivativesThe AMRInterpolator in GRChombo supported interpolating spatial derivatives in each direction of the variables (and this is still present in We might want to defer this to a future PR and just have an error for the moment if derivatives are requested. Derived QuantitiesA key feature we will want is being able to interpolate derived quantities e.g. For now, in this PR perhaps it's worth adding the ability to interpolate data from an arbitrary Unit testCan you make the unit test run on a full "mini" example (i.e. with Development practices
|
- Leave an error message for derivative queries - Track Redistribute() flag and allow the user to override it Other relevant modifications to the interpolation class: - Simplify copying from device to host memory in populate_from_query() - Make check_domain() parity compatible
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
Rewrite a unit test for interpolation to include use of GRAMR and some parameter inputs. More details: - Derived vars interpolation handled via Multifabs (for each level) - We do not have parity supported for derived vars (throw errors in these cases for now) - Interpolation test handles a polynomial as a derived variable and checks for errors using analytical expression
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
in Particle Interpolator test
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
* Remove helper function for MultiFabs in GRAMR * Move Derivative* into ParticleInterpolator * Remove unnecessary param file
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
compilation of an AMREX_GPU_DEVICE lambda is being weird :(
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
|
So I think I have now addressed all of the review comments to the best of my knowledge. I tried to go through the list of comments/new additions again throughly, so hopefully I have not missed anything. I have now also implemented the ability for different ranks to have their own set of query points. This incurred a substantial rewrite of ParticleInterpolator functions and additions of new helper functions. I copied over lots of MPI* related classes from the old GRChombo code and added comments/explanations within those files (the way I understood them), as I was confused about the different structures used there and the logic. We may need to iterate over this part, as I do not rule out I missed other more optimal ways to implement this feature. One remaining item is where to store the particle index (integer AoS or SoA), please see my comment here . I do not see an immediate advantage of using SoA, as we still need to copy AoS, but maybe I have missed something. |
…tion in particle interpolators
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
mirenradia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for taking a while to re-review it. Because it's such a large PR, I've found it quite mentally taxing.
Thanks for making the requested changes from my previous review and the few interim comments. I think we're getting closer! I think most of my comments are now related to naming of variables/functions.
In addition to the comments on files, I have some points which didn't fit elsewhere:
- I find the term "owner" to refer the rank that queried the particle confusing. In my head the owner is the proc which currently has the particle. I think we should remove all uses of the word "owner" and instead just refer to "query" and "answer ranks/procs.
- There are still files in this PR which only have whitespace changes. Even though they won't satisfy the pre-commit checks, please can you revert them to how they are on
developso they are not part of this PR?
Unfortunately, I haven't had any time to profile the particle interpolator yet. I will hopefully get to that in 2 weeks.
| template <int num_components> | ||
| void ParticleInterpolator<num_components>::setup( | ||
| GRAMR *gr_amr_ptr, const BoundaryConditions::params_t &a_bc_params, | ||
| bool a_verbosity, const DerivedParity *parities) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make the final argument a vector of DerivedParitys where the default argument is just a vector of length 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will wait on your reply re how we want to store DerivedParity (see also comment in the ParticleInterpolator) test. Currently, it is {component_number, parity}. So it does not matter in which order the user provides parities, so long as the map comp -> parity is consistent. But maybe for simplicity we want this to be just a vector of parities and implicitly enforce that this is in the right order for each component. Let me know, I will make the default arg accordingly, if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm now wondering if it makes sense to store the parity in InterpolationQueryParticle (specifically as a new member in the out_t struct) as then you would set it at the same time as you add the component to the query. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should work neatly. I will have a go at implementing this.
Tests/ParticleInterpolatorUnitTest/ParticleInterpolatorUnitTest.cpp
Outdated
Show resolved
Hide resolved
Tests/ParticleInterpolatorUnitTest/ParticleInterpolatorUnitTest.cpp
Outdated
Show resolved
Hide resolved
Tests/ParticleInterpolatorUnitTest/ParticleInterpolatorUnitTest.cpp
Outdated
Show resolved
Hide resolved
Tests/ParticleInterpolatorUnitTest/ParticleInterpolatorUnitTest.inputs
Outdated
Show resolved
Hide resolved
mirenradia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for taking a while to re-review it. Because it's such a large PR, I've found it quite mentally taxing.
Thanks for making the requested changes from my previous review and the few interim comments. I think we're getting closer! I think most of my comments are now related to naming of variables/functions.
In addition to the comments on files, I have some points which didn't fit elsewhere:
- I find the term "owner" to refer the rank that queried the particle confusing. In my head the owner is the proc which currently has the particle. I think we should remove all uses of the word "owner" and instead just refer to "query" and "answer ranks/procs.
- There are still files in this PR which only have whitespace changes. Even though they won't satisfy the pre-commit checks, please can you revert them to how they are on
developso they are not part of this PR?
Unfortunately, I haven't had any time to profile the particle interpolator yet. I will hopefully get to that in 2 weeks.
* Renaming of functions * Minor change in ParticleInterpolator test parameter inputs * Changing how some arrays are getting written into
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
|
This PR modifies the following files which are ignored by .lint-ignore: Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
| InterpolationQueryParticle &query, VariableType variable_type, | ||
| const std::string &name_derived, double time_derived /*=0.0*/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just realised that we're passing the VariableType in the query and also as another argument. Can we add a check/assertion in the InterpolationQueryParticle class that all of the VariableTypes in the query are the same and then use that value here rather than passing a separate VariableType argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for a given InterpolationQueryParticle we will be using the same VariableType, maybe I move it out of out_t struct? I can just make variable type a private class member and check that it never changes whenever someone calls addComp() again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And add a getter to get it outside of the class...
| amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, y, y + n, y_d.begin()); | ||
| // coords on device | ||
| amrex::GpuArray<amrex::Gpu::DeviceVector<double>, AMREX_SPACEDIM> coords_d; | ||
| amrex::GpuArray<const double *, AMREX_SPACEDIM> coords_d_ptr = query_coords; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused by this line since query_coords is an array of host pointers and you set the correct values in the loop immediately below.
Perhaps it would be best to just default initialize (which will set them to nullptr) this using {} to minimise confusion?
| amrex::GpuArray<const double *, AMREX_SPACEDIM> coords_d_ptr = query_coords; | |
| amrex::GpuArray<const double *, AMREX_SPACEDIM> coords_d_ptr{}; |
Hello,
This is my preliminary attempt to replace GRChombo's
AMRInterpolatorwith amrex particles, subsequently called asParticleInterpolators(although we can rename it to whatever you like later on). The relevant folder that will eventually replace theAMRInterpolatoris located inSource/ParticleInterpolators. I borrowedInterpolationQuery.hppfrom the originalAMRInterpolator, although renamed it toInterpolationQueryParticle.hppto not have conflicts, as theAMRInterpolatorstill remains in the repo.The key features:
Tests/using a polynomial is implemented to test the Lagrange interpolation.TO-DO for me on a fresh head:
Modify
check_domain()function that checks whether we are inside domain to be parity aware; otherwise it throws errors when we ask to interpolate inside the domain but on the side where symmetries are applied.So far the code compiles on GPUs, but I need to run an example (I am having some technical difficulties). On CPUs everything is fine.
Please let me know your thoughts.