Skip to content

Commit

Permalink
radiation: add hook for adding external currents
Browse files Browse the repository at this point in the history
  • Loading branch information
germasch committed Nov 7, 2024
1 parent 69ebd38 commit afe118f
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions src/include/psc.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ inline double courant_length(const Grid_t::Domain& domain)
// ======================================================================
// Psc

template <typename PscConfig, typename Diagnostics, typename InjectParticles>
template <typename PscConfig, typename Diagnostics, typename InjectParticles,
typename ExtCurrent>
struct Psc
{
using Mparticles = typename PscConfig::Mparticles;
Expand All @@ -159,7 +160,7 @@ struct Psc
Psc(const PscParams& params, Grid_t& grid, MfieldsState& mflds,
Mparticles& mprts, Balance& balance, Collision& collision, Checks& checks,
Marder& marder, Diagnostics& diagnostics,
InjectParticles& inject_particles)
InjectParticles& inject_particles, ExtCurrent& ext_current)
: p_{params},
grid_{&grid},
mflds_{mflds},
Expand All @@ -171,6 +172,7 @@ struct Psc
bndp_{grid},
diagnostics_{diagnostics},
inject_particles_{inject_particles},
ext_current_{ext_current},
checkpointing_{params.write_checkpoint_every_step}
{
time_start_ = MPI_Wtime();
Expand Down Expand Up @@ -522,6 +524,9 @@ struct Psc
bnd_.fill_ghosts(mflds_, HX, HX + 3);
#endif

// === external current
this->ext_current_(grid(), mflds_);

bndf_.add_ghosts_J(mflds_);
bnd_.add_ghosts(mflds_, JXI, JXI + 3);
bnd_.fill_ghosts(mflds_, JXI, JXI + 3);
Expand Down Expand Up @@ -724,6 +729,7 @@ protected:
Marder& marder_;
Diagnostics& diagnostics_;
InjectParticles& inject_particles_;
ExtCurrent& ext_current_;

Sort sort_;
PushParticles pushp_;
Expand Down Expand Up @@ -762,21 +768,41 @@ InjectParticlesNone injectParticlesNone;

} // namespace

// ======================================================================
// ExtCurrentNone

class ExtCurrentNone
{
public:
template <typename MfieldsState>
void operator()(const Grid_t& grid, MfieldsState& mflds)
{}
};

namespace
{

ExtCurrentNone extCurrentNone;

} // namespace
// ======================================================================
// makePscIntegrator

template <typename PscConfig, typename MfieldsState, typename Mparticles,
typename Balance, typename Collision, typename Checks,
typename Marder, typename Diagnostics,
typename InjectParticles = InjectParticlesNone>
Psc<PscConfig, Diagnostics, InjectParticles> makePscIntegrator(
typename InjectParticles = InjectParticlesNone,
typename ExtCurrent = ExtCurrentNone>
Psc<PscConfig, Diagnostics, InjectParticles, ExtCurrent> makePscIntegrator(
const PscParams& params, Grid_t& grid, MfieldsState& mflds, Mparticles& mprts,
Balance& balance, Collision& collision, Checks& checks, Marder& marder,
Diagnostics& diagnostics,
InjectParticles& inject_particles = injectParticlesNone)
InjectParticles& inject_particles = injectParticlesNone,
ExtCurrent& ext_current = extCurrentNone)
{
return {params, grid, mflds, mprts, balance,
collision, checks, marder, diagnostics, inject_particles};
return {params, grid, mflds, mprts, balance,
collision, checks, marder, diagnostics, inject_particles,
ext_current};
}

// ======================================================================
Expand Down

0 comments on commit afe118f

Please sign in to comment.