-
Notifications
You must be signed in to change notification settings - Fork 359
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
make Redistribute()
and other ParticleContainer functions virtual?
#4275
Comments
Are those the only functions you call? That cannot be the case, right? So how do you plan to call other functions. It might be too much to turn the union of all particle containers' functions virtual. |
No, we call other functions. But those are the only functions we call for all particle containers. For other functions, there is at least one particle container for which it does not make sense to call it. So for those cases, we need to do something special anyway. These are just the ones that would eliminate boilerplate code if they were virtual. |
I am not saying it does not make sense to make those functions virtual. I am just saying it can be worked around. I assume you do have a way to get the derived type of a base pointer. Maybe you use the string to obtain the derived type. Whatever you do, in principle, you could do that for Redistribute too. |
Yes, we can do that for now. |
We do implicitly depend on the member functions called by |
We would like to have a container all of ParticleContainers in our simulation, e.g.
std::map<std::string, amrex::ParticleContainerBase*>
.Then we want to be able iterate over this container and invoke
base_ptr->Redistribute()
. Currently, this is not possible becauseRedistribute()
is not virtual. We have to explicitly do, e.g.,dynamic_cast<AmrParticleContainer*>(base_ptr)->Redistribute()
. Since we have to know what derived ParticleContainer to cast it to, we need to duplicate a lot of code to do the casts for all possible cases.The functions of interest are:
Redistribute()
WritePlotFile()
Checkpoint()
The text was updated successfully, but these errors were encountered: