Skip to content

Commit

Permalink
Merge branch 'add_electron_energy_equation_to_hybrid_solver' of githu…
Browse files Browse the repository at this point in the history
…b.com:marcoacc95/WarpX into add_electron_energy_equation_to_hybrid_solver
  • Loading branch information
marcoacc95 committed Mar 5, 2025
2 parents efbe5b6 + 25718e0 commit 2b019be
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
14 changes: 7 additions & 7 deletions Source/FieldSolver/WarpXPushFieldsHybridPIC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ void WarpX::HybridPICEvolveFields ()
// Calculate Ke using rho^{n} in rho_fp_temp
if(m_hybrid_pic_model->m_solve_electron_energy_equation)
{

// copy rho_fp_temp to hybrid_electron_fl->name_mf_N
m_fields.get(hybrid_electron_fl->name_mf_N, finest_level)->setVal(0);
MultiFab::Copy( *m_fields.get(hybrid_electron_fl->name_mf_N, finest_level),
*m_fields.get(FieldType::hybrid_rho_fp_temp, finest_level),
0, 0, 1, m_fields.get(hybrid_electron_fl->name_mf_N, finest_level)->nGrowVect());
// Calculate Ke
hybrid_electron_fl->HybridInitializeKe(m_fields, m_hybrid_pic_model->m_gamma, m_hybrid_pic_model->m_n_floor, finest_level);

}


Expand Down Expand Up @@ -202,7 +202,7 @@ void WarpX::HybridPICEvolveFields ()

if(m_hybrid_pic_model->m_solve_electron_energy_equation)
{

// Calculate plasma current at n+1/2 using Ampere's law
// using B field at t=n+1/2
m_hybrid_pic_model->CalculatePlasmaCurrent(
Expand All @@ -214,7 +214,7 @@ void WarpX::HybridPICEvolveFields ()
m_fields.get_alldirs(FieldType::current_fp, finest_level),
m_hybrid_pic_model.get(),
finest_level);

}


Expand Down Expand Up @@ -265,7 +265,7 @@ void WarpX::HybridPICEvolveFields ()
// all the qdsmc solver functions should be in a ElectronEnergyEquationSolver class as well as other solvers like Layer method
if(m_hybrid_pic_model->m_solve_electron_energy_equation){


// Reset qdsmc particles positions to x0,y0,z0 and rest of attributes to 0 and redistribute
m_hybrid_pic_model->qdsmc_hybrid_electron_pc->ResetParticles(finest_level);

Expand Down Expand Up @@ -318,8 +318,8 @@ void WarpX::HybridPICEvolveFields ()
// This term should also apply MCC to ions particle container (Qie)
// Implement for 1 ion species and then extend to multiple species using mypc
// COMPLETE ...



}

Expand Down
38 changes: 19 additions & 19 deletions Source/Fluids/QdsmcParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ void QdsmcParticleContainer::InitParticles (int lev)
amrex::Gpu::synchronize(); // added for debugging
amrex::AllPrint() << "Rank " << ParallelDescriptor::MyProc()
<< "Before first ParallelFor(commented now) (but with extra synchronize)" << "\n";
<< "Before first ParallelFor(commented now) (but with extra synchronize)" << "\n";
//
//amrex::ParallelFor(tile_box, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
//{
Expand All @@ -296,18 +296,18 @@ void QdsmcParticleContainer::InitParticles (int lev)
});
//
amrex::Gpu::synchronize();
amrex::AllPrint() << "Rank " << ParallelDescriptor::MyProc()
<< "After first ParallelFor(commented now)" << "\n";
<< "After first ParallelFor(commented now)" << "\n";
const amrex::Long max_new_particles = Scan::ExclusiveSum(counts.size(), counts.data(), offset.data());
amrex::Gpu::synchronize(); // Added for debugging
amrex::AllPrint() << "Rank " << ParallelDescriptor::MyProc()
<< "After Scan::ExclusiveSum" << "\n";
<< "After Scan::ExclusiveSum" << "\n";
// Update NextID to include particles created in this function
amrex::Long pid;
Expand Down Expand Up @@ -348,19 +348,19 @@ void QdsmcParticleContainer::InitParticles (int lev)
if(tile_box.contains(iv))
{
const auto index = tile_box.index(iv);
// Skip if this cell did not count as a valid cell.
if ( pcounts[index] == 0 ) { return; }
const amrex::Long ip = poffset[index];
// check that ip is in [0, max_new_particles)
if (ip < 0 || ip >= max_new_particles) { return; }
const amrex::Real x = problo[0] + (iv[0] + 0.5_rt) * dx[0];
const amrex::Real y = problo[1] + (iv[1] + 0.5_rt) * dx[1];
const amrex::Real z = problo[2] + (iv[2] + 0.5_rt) * dx[2];
pa_idcpu[ip] = amrex::SetParticleIDandCPU(pid + ip, cpuid);
pa[QdsmcPIdx::x][ip] = x;
Expand All @@ -377,26 +377,26 @@ void QdsmcParticleContainer::InitParticles (int lev)
pa[QdsmcPIdx::entropy][ip] = 0._rt;
pa[QdsmcPIdx::np_real][ip] = 0._rt;
}
});
amrex::Gpu::synchronize();
amrex::AllPrint() << "Rank " << ParallelDescriptor::MyProc()
<< "After second ParallelFor" << "\n";
<< "After second ParallelFor" << "\n";
if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers)
{
wt = static_cast<amrex::Real>(amrex::second()) - wt;
amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt);
}
}
}
amrex::Gpu::synchronize();
amrex::AllPrint() << "Rank " << ParallelDescriptor::MyProc()
<< "post_MFIter" << "\n";
<< "post_MFIter" << "\n";
Redistribute();
}
Expand Down Expand Up @@ -522,13 +522,13 @@ void QdsmcParticleContainer::InitParticles_2(int lev){
});
amrex::Gpu::synchronize();
if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers)
{
wt = static_cast<amrex::Real>(amrex::second()) - wt;
amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt);
}
}
}
amrex::Gpu::synchronize();
Redistribute();
Expand Down Expand Up @@ -660,7 +660,7 @@ void QdsmcParticleContainer::InitParticles(int lev){
const auto index = tile_box.index(iv);

//if (index >= 0 && index < tile_box.numPts()) {

long ip = poffset[index];

//if (ip >= 0 && ip < max_new_particles) {
Expand Down Expand Up @@ -690,13 +690,13 @@ void QdsmcParticleContainer::InitParticles(int lev){
});

amrex::Gpu::synchronize();

if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers)
{
wt = static_cast<amrex::Real>(amrex::second()) - wt;
amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt);
}
}
}

amrex::Gpu::synchronize();
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Initialization/WarpXInitData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ WarpX::InitData ()

if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::HybridPIC) {
m_hybrid_pic_model->InitData();

// old version
//if(m_hybrid_pic_model->m_solve_electron_energy_equation){
// qdsmc_hybrid_electron_pc->AllocData();
Expand All @@ -606,7 +606,7 @@ WarpX::InitData ()
if (m_hybrid_pic_model->m_solve_electron_energy_equation) {
m_hybrid_pic_model->InitQdsmcParticleContainer();
}

}

if (ParallelDescriptor::IOProcessor()) {
Expand Down

0 comments on commit 2b019be

Please sign in to comment.