Skip to content

Commit

Permalink
add CC inj ring mf for computing total cells in inj ring
Browse files Browse the repository at this point in the history
  • Loading branch information
RevathiJambunathan committed Oct 10, 2023
1 parent 0009494 commit 813ba90
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions Source/Parallelization/WarpXRegrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi
RemakeMultiFab(m_pulsar->m_injected_cell[lev], dm, true);
RemakeMultiFab(m_pulsar->m_pcount[lev], dm, true);
RemakeMultiFab(m_pulsar->m_injection_ring[lev], dm, true);
RemakeMultiFab(m_pulsar->m_injection_ringCC[lev], dm, true);
RemakeMultiFab(m_pulsar->m_sigma_inj_ring[lev], dm, true);
RemakeMultiFab(m_pulsar->m_sigma_threshold[lev], dm, true);
RemakeMultiFab(m_pulsar->m_PC_flag[lev], dm, false);
Expand Down
1 change: 1 addition & 0 deletions Source/Particles/PulsarParameters.H
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ public:
/** Number of particles to be injected per cell per species */
amrex::Vector<std::unique_ptr<amrex::MultiFab> > m_pcount;
amrex::Vector<std::unique_ptr<amrex::MultiFab> > m_injection_ring;
amrex::Vector<std::unique_ptr<amrex::MultiFab> > m_injection_ringCC;
amrex::Vector<std::unique_ptr<amrex::MultiFab> > m_sigma_inj_ring;
amrex::Vector<std::unique_ptr<amrex::MultiFab> > m_sigma_threshold;
amrex::Vector<std::unique_ptr<amrex::MultiFab> > m_PC_flag;
Expand Down
13 changes: 12 additions & 1 deletion Source/Particles/PulsarParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ Pulsar::InitDataAtRestart ()
m_sigma_reldiff.resize(nlevs_max);
m_pcount.resize(nlevs_max);
m_injection_ring.resize(nlevs_max);
m_injection_ringCC.resize(nlevs_max);
m_sigma_inj_ring.resize(nlevs_max);
m_sigma_threshold.resize(nlevs_max);
amrex::ParmParse pp_particles("particles");
Expand Down Expand Up @@ -429,6 +430,8 @@ Pulsar::InitDataAtRestart ()
ba, dm, 1, ng_EB_alloc);
m_injection_ring[lev] = std::make_unique<amrex::MultiFab>(
amrex::convert(ba,amrex::IntVect::TheNodeVector()), dm, 1, ng_EB_alloc);
m_injection_ringCC[lev] = std::make_unique<amrex::MultiFab>(
ba, dm, 1, ng_EB_alloc);
m_sigma_inj_ring[lev] = std::make_unique<amrex::MultiFab>(
ba, dm, 1, ng_EB_alloc);
m_sigma_threshold[lev] = std::make_unique<amrex::MultiFab>(
Expand All @@ -444,6 +447,7 @@ Pulsar::InitDataAtRestart ()
m_sigma_reldiff[lev]->setVal(0._rt);
m_pcount[lev]->setVal(0._rt);
m_injection_ring[lev]->setVal(0._rt);
m_injection_ringCC[lev]->setVal(0._rt);
m_sigma_inj_ring[lev]->setVal(0._rt);
m_sigma_threshold[lev]->setVal(0._rt);

Expand Down Expand Up @@ -495,6 +499,7 @@ Pulsar::InitData ()
m_injected_cell.resize(nlevs_max);
m_pcount.resize(nlevs_max);
m_injection_ring.resize(nlevs_max);
m_injection_ringCC.resize(nlevs_max);
m_sigma_inj_ring.resize(nlevs_max);
m_sigma_threshold.resize(nlevs_max);
amrex::ParmParse pp_particles("particles");
Expand Down Expand Up @@ -524,6 +529,8 @@ Pulsar::InitData ()
ba, dm, 1, ng_EB_alloc);
m_injection_ring[lev] = std::make_unique<amrex::MultiFab>(
amrex::convert(ba,amrex::IntVect::TheNodeVector() ), dm, 1, ng_EB_alloc);
m_injection_ringCC[lev] = std::make_unique<amrex::MultiFab>(
ba, dm, 1, ng_EB_alloc);
m_sigma_inj_ring[lev] = std::make_unique<amrex::MultiFab>(
ba, dm, 1, ng_EB_alloc);
m_sigma_threshold[lev] = std::make_unique<amrex::MultiFab>(
Expand All @@ -538,6 +545,7 @@ Pulsar::InitData ()
m_sigma_reldiff[lev]->setVal(0._rt);
m_pcount[lev]->setVal(0._rt);
m_injection_ring[lev]->setVal(0._rt);
m_injection_ringCC[lev]->setVal(0._rt);
m_sigma_inj_ring[lev]->setVal(0._rt);
m_sigma_threshold[lev]->setVal(0._rt);

Expand Down Expand Up @@ -2080,10 +2088,10 @@ Pulsar::FlagCellsForInjectionWithPcounts ()
int ParticlesToBeInjected = TotalParticlesToBeInjected(scale_factor);
amrex::Print() << " particles to be injected " << ParticlesToBeInjected <<"\n";

m_totalcells_injectionring = m_injection_ring[lev]->sum();
m_injection_flag[lev]->setVal(0);
m_injected_cell[lev]->setVal(0);
m_sigma_inj_ring[lev]->setVal(0);
m_injection_ringCC[lev]->setVal(0._rt);
m_pcount[lev]->setVal(0);
int use_FixedSigmaInput = m_use_FixedSigmaInput;
for (amrex::MFIter mfi(*m_injection_flag[lev], amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
Expand All @@ -2094,6 +2102,7 @@ Pulsar::FlagCellsForInjectionWithPcounts ()
amrex::Array4<amrex::Real> const& injected_cell = m_injected_cell[lev]->array(mfi);
amrex::Array4<amrex::Real> const& sigma = m_magnetization[lev]->array(mfi);
amrex::Array4<amrex::Real> const& inj_ring = m_injection_ring[lev]->array(mfi);
amrex::Array4<amrex::Real> const& inj_ringCC = m_injection_ringCC[lev]->array(mfi);
amrex::Array4<amrex::Real> const& sigma_inj_ring = m_sigma_inj_ring[lev]->array(mfi);
amrex::Array4<amrex::Real> const& sigma_threshold_loc = m_sigma_threshold[lev]->array(mfi);
amrex::Array4<amrex::Real> const& PCflag = m_PC_flag[lev]->array(mfi);
Expand Down Expand Up @@ -2128,6 +2137,7 @@ Pulsar::FlagCellsForInjectionWithPcounts ()
amrex::Real rad = std::sqrt( (x-xc[0]) * (x-xc[0])
+ (y-xc[1]) * (y-xc[1])
+ (z-xc[2]) * (z-xc[2]));
inj_ringCC(i,j,k) = 1;
if (use_FixedSigmaInput == 1) {
if (sigma(i,j,k) > Sigma0_threshold) {
//if (modify_Sigma0_threshold == 1) {
Expand All @@ -2153,6 +2163,7 @@ Pulsar::FlagCellsForInjectionWithPcounts ()
}

// Total injection cells
m_totalcells_injectionring = m_injection_ringCC[lev]->sum();
amrex::Real TotalInjectionCells = SumInjectionFlag();
amrex::Print() << " total inj cells : " << TotalInjectionCells << "\n";
m_sum_inj_magnetization = 1;
Expand Down

0 comments on commit 813ba90

Please sign in to comment.