Skip to content

Commit

Permalink
add plasma, fix doc
Browse files Browse the repository at this point in the history
  • Loading branch information
SeverinDiederichs committed Jun 23, 2023
1 parent 88bb89d commit 657cf39
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/Hipace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ Hipace::Evolve ()
}

m_multi_beam.InSituWriteToFile(step, m_physical_time, m_3D_geom[0], m_max_step, m_max_time);
m_multi_plasma.InSituWriteToFile(step, m_physical_time, m_3D_geom[0]);
m_multi_plasma.InSituWriteToFile(step, m_physical_time, m_3D_geom[0], m_max_step, m_max_time);

// printing and resetting predictor corrector loop diagnostics
if (m_verbose>=2 && !m_explicit) amrex::AllPrint() << "Rank " << rank <<
Expand Down Expand Up @@ -501,7 +501,7 @@ Hipace::SolveOneSlice (int islice, const int islice_local, int step)

m_multi_beam.InSituComputeDiags(step, islice, islice_local, m_max_step,
m_physical_time, m_max_time);
m_multi_plasma.InSituComputeDiags(step, islice);
m_multi_plasma.InSituComputeDiags(step, islice, m_max_step, m_physical_time, m_max_time);

// Get this laser slice from the 3D array
m_multi_laser.Copy(islice, false);
Expand Down
10 changes: 10 additions & 0 deletions src/particles/beam/MultiBeam.H
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,20 @@ public:
* \param[in] step time step of simulation
* \param[in] islice current slice, on which diags are computed.
* \param[in] islice_local local index of the slice
* \param[in] max_step maximum time step of simulation
* \param[in] physical_time physical time at the given step
* \param[in] max_time maximum time of simulation
*/
void InSituComputeDiags (int step, int islice, int islice_local,
int max_step, amrex::Real physical_time,
amrex::Real max_time);
/** Write reduced beam diagnostics to file
* \param[in] step time step of simulation
* \param[in] time physical time at the given step
* \param[in] geom Simulation geometry
* \param[in] max_step maximum time step of simulation
* \param[in] max_time maximum time of simulation
*/
void InSituWriteToFile (int step, amrex::Real time, const amrex::Geometry& geom,
int max_step, amrex::Real max_time);
/** Loop over species and init them
Expand Down
6 changes: 3 additions & 3 deletions src/particles/beam/MultiBeam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ MultiBeam::InSituComputeDiags (int step, int islice, int islice_local,
int max_step, amrex::Real physical_time,
amrex::Real max_time)
{
for (int i = 0; i < m_nbeams; ++i) {
if (utils::doOutput(m_all_beams[i].m_insitu_period, step,
for (auto& beam : m_all_beams) {
if (utils::doOutput(beam.m_insitu_period, step,
max_step, physical_time, max_time)) {
m_all_beams[i].InSituComputeDiags(islice, islice_local);
beam.InSituComputeDiags(islice, islice_local);
}
}
}
Expand Down
16 changes: 14 additions & 2 deletions src/particles/plasma/MultiPlasma.H
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,21 @@ public:
/** Compute reduced plasma diagnostics of current slice, store in member variable.
* \param[in] step time step of simulation
* \param[in] islice current slice, on which diags are computed.
* \param[in] max_step maximum time step of simulation
* \param[in] physical_time physical time at the given step
* \param[in] max_time maximum time of simulation
*/
void InSituComputeDiags (int step, int islice);
void InSituWriteToFile (int step, amrex::Real time, const amrex::Geometry& geom);
void InSituComputeDiags (int step, int islice, int max_step,
amrex::Real physical_time, amrex::Real max_time);
/** Write reduced beam diagnostics to file
* \param[in] step time step of simulation
* \param[in] time physical time at the given step
* \param[in] geom Simulation geometry
* \param[in] max_step maximum time step of simulation
* \param[in] max_time maximum time of simulation
*/
void InSituWriteToFile (int step, amrex::Real time, const amrex::Geometry& geom,
int max_step, amrex::Real max_time);

int m_sort_bin_size {32}; /**< Tile size to sort plasma particles */

Expand Down
13 changes: 9 additions & 4 deletions src/particles/plasma/MultiPlasma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "particles/sorting/TileSort.H"
#include "utils/HipaceProfilerWrapper.H"
#include "utils/DeprecatedInput.H"
#include "utils/IOUtil.H"
#include "Hipace.H"

MultiPlasma::MultiPlasma ()
Expand Down Expand Up @@ -203,20 +204,24 @@ MultiPlasma::TagByLevel (const int current_N_level, amrex::Vector<amrex::Geometr
}

void
MultiPlasma::InSituComputeDiags (int step, int islice)
MultiPlasma::InSituComputeDiags (int step, int islice, int max_step,
amrex::Real physical_time, amrex::Real max_time)
{
for (auto& plasma : m_all_plasmas) {
if (plasma.doInSitu(step)) {
if (utils::doOutput(plasma.m_insitu_period, step,
max_step, physical_time, max_time)) {
plasma.InSituComputeDiags(islice);
}
}
}

void
MultiPlasma::InSituWriteToFile (int step, amrex::Real time, const amrex::Geometry& geom)
MultiPlasma::InSituWriteToFile (int step, amrex::Real time, const amrex::Geometry& geom,
int max_step, amrex::Real max_time)
{
for (auto& plasma : m_all_plasmas) {
if (plasma.doInSitu(step)) {
if (utils::doOutput(plasma.m_insitu_period, step,
max_step, time, max_time)) {
plasma.InSituWriteToFile(step, time, geom);
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/particles/plasma/PlasmaParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public:
* \param[in] geom Geometry object for the whole domain
*/
void InSituWriteToFile (int step, amrex::Real time, const amrex::Geometry& geom);
bool doInSitu (int step);

amrex::Parser m_parser; /**< owns data for m_density_func */
amrex::ParserExecutor<3> m_density_func; /**< Density function for the plasma */
Expand Down Expand Up @@ -186,7 +185,9 @@ public:
int m_reorder_period = 0;
/** 2D reordering index type. 0: cell, 1: node, 2: both */
amrex::IntVect m_reorder_idx_type = {0, 0, 0};

/** How often the insitu plasma diagnostics should be computed and written
* Default is 0, meaning no output */
int m_insitu_period {0};
private:
std::string m_name; /**< name of the species */
int m_nslices; /**< number of z slices of the domain */
Expand Down Expand Up @@ -215,9 +216,6 @@ private:
amrex::Vector<int> m_insitu_sum_idata;
/** Prefix/path for the output files */
std::string m_insitu_file_prefix = "diags/plasma_insitu";
/** How often the insitu plasma diagnostics should be computed and written
* Default is 0, meaning no output */
int m_insitu_period {0};
};

/** \brief Iterator over boxes in a particle container */
Expand Down
6 changes: 0 additions & 6 deletions src/particles/plasma/PlasmaParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,6 @@ IonizationModule (const int lev,
}
}

bool
PlasmaParticleContainer::doInSitu (int step)
{
return (m_insitu_period > 0 && step % m_insitu_period == 0);
}

void
PlasmaParticleContainer::InSituComputeDiags (int islice)
{
Expand Down

0 comments on commit 657cf39

Please sign in to comment.