Skip to content

Polymorphic injectors, external currents, and diagnostics#377

Open
JamesMcClung wants to merge 22 commits intopsc-code:mainfrom
JamesMcClung:pr/polymorphism
Open

Polymorphic injectors, external currents, and diagnostics#377
JamesMcClung wants to merge 22 commits intopsc-code:mainfrom
JamesMcClung:pr/polymorphism

Conversation

@JamesMcClung
Copy link
Collaborator

This is the first of (hopefully) several PRs aiming to simplify the process of making a PSC integrator, while also making it more flexible.

As the title says, this PR makes injectors, external currents, and diagnostics inherit from a base class, and the PSC integrator has lists of pointers to each of those base classes.

Benefits of this approach:

  1. Remove the need for amalgamative types like CompositeInjector and DiagnosticsDefault
  2. Remove the need for empty types like ExternalCurrentsNone and InjectParticlesNone
  3. Opting out of e.g. diagnostics requires 0 code, simplifying tests
  4. No need to lock-in specific types for these objects in PscConfig types

Downsides of this approach:

  1. Virtual functions can't be templated, so the classes themselves must be templated by the function parameters (MfieldsState and Mparticles). This would be a problem if these objects a) needed to accept different types of arguments, and b) were expensive to create. Neither (a) nor (b) is currently the case.
  2. Virtual functions can't be inlined (and they require a vtable lookup, but that's relatively negligible), so this approach shouldn't be applied in hot spots.

It seems to me that every component of the PSC integrator could be polymorphic instead of templated, and that is one of the long-term goals of this PR chain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant