Skip to content

Commit b7eee37

Browse files
committed
Merge branch 'dev' into update_perftests
2 parents fb35234 + 1a0a254 commit b7eee37

File tree

11 files changed

+635
-501
lines changed

11 files changed

+635
-501
lines changed

Source/ParticleContainer.cpp

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -340,36 +340,39 @@ ::GetLabFrameData(const std::string& snapshot_name,
340340
WarpXParticleContainer* pc = allcontainers[i].get();
341341
WarpXParticleContainer::DiagnosticParticles diagnostic_particles;
342342
pc->GetParticleSlice(direction, z_old, z_new, t_boost, t_lab, dt, diagnostic_particles);
343-
344-
for (auto it = diagnostic_particles.begin(); it != diagnostic_particles.end(); ++it)
345-
{
346-
parts[i].GetRealData(DiagIdx::w).insert( parts[i].GetRealData(DiagIdx::w ).end(),
347-
it->second.GetRealData(DiagIdx::w ).begin(),
348-
it->second.GetRealData(DiagIdx::w ).end());
349-
350-
parts[i].GetRealData(DiagIdx::x).insert( parts[i].GetRealData(DiagIdx::x ).end(),
351-
it->second.GetRealData(DiagIdx::x ).begin(),
352-
it->second.GetRealData(DiagIdx::x ).end());
353-
354-
parts[i].GetRealData(DiagIdx::y).insert( parts[i].GetRealData(DiagIdx::y ).end(),
355-
it->second.GetRealData(DiagIdx::y ).begin(),
356-
it->second.GetRealData(DiagIdx::y ).end());
357-
358-
parts[i].GetRealData(DiagIdx::z).insert( parts[i].GetRealData(DiagIdx::z ).end(),
359-
it->second.GetRealData(DiagIdx::z ).begin(),
360-
it->second.GetRealData(DiagIdx::z ).end());
361343

362-
parts[i].GetRealData(DiagIdx::ux).insert( parts[i].GetRealData(DiagIdx::ux).end(),
363-
it->second.GetRealData(DiagIdx::ux).begin(),
364-
it->second.GetRealData(DiagIdx::ux).end());
365-
366-
parts[i].GetRealData(DiagIdx::uy).insert( parts[i].GetRealData(DiagIdx::uy).end(),
367-
it->second.GetRealData(DiagIdx::uy).begin(),
368-
it->second.GetRealData(DiagIdx::uy).end());
369-
370-
parts[i].GetRealData(DiagIdx::uz).insert( parts[i].GetRealData(DiagIdx::uz).end(),
371-
it->second.GetRealData(DiagIdx::uz).begin(),
372-
it->second.GetRealData(DiagIdx::uz).end());
344+
for (int lev = 0; lev <= pc->finestLevel(); ++lev)
345+
{
346+
for (auto it = diagnostic_particles[lev].begin(); it != diagnostic_particles[lev].end(); ++it)
347+
{
348+
parts[i].GetRealData(DiagIdx::w).insert( parts[i].GetRealData(DiagIdx::w ).end(),
349+
it->second.GetRealData(DiagIdx::w ).begin(),
350+
it->second.GetRealData(DiagIdx::w ).end());
351+
352+
parts[i].GetRealData(DiagIdx::x).insert( parts[i].GetRealData(DiagIdx::x ).end(),
353+
it->second.GetRealData(DiagIdx::x ).begin(),
354+
it->second.GetRealData(DiagIdx::x ).end());
355+
356+
parts[i].GetRealData(DiagIdx::y).insert( parts[i].GetRealData(DiagIdx::y ).end(),
357+
it->second.GetRealData(DiagIdx::y ).begin(),
358+
it->second.GetRealData(DiagIdx::y ).end());
359+
360+
parts[i].GetRealData(DiagIdx::z).insert( parts[i].GetRealData(DiagIdx::z ).end(),
361+
it->second.GetRealData(DiagIdx::z ).begin(),
362+
it->second.GetRealData(DiagIdx::z ).end());
363+
364+
parts[i].GetRealData(DiagIdx::ux).insert( parts[i].GetRealData(DiagIdx::ux).end(),
365+
it->second.GetRealData(DiagIdx::ux).begin(),
366+
it->second.GetRealData(DiagIdx::ux).end());
367+
368+
parts[i].GetRealData(DiagIdx::uy).insert( parts[i].GetRealData(DiagIdx::uy).end(),
369+
it->second.GetRealData(DiagIdx::uy).begin(),
370+
it->second.GetRealData(DiagIdx::uy).end());
371+
372+
parts[i].GetRealData(DiagIdx::uz).insert( parts[i].GetRealData(DiagIdx::uz).end(),
373+
it->second.GetRealData(DiagIdx::uz).begin(),
374+
it->second.GetRealData(DiagIdx::uz).end());
375+
}
373376
}
374377
}
375378
}

Source/PhysicalParticleContainer.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,8 @@ void PhysicalParticleContainer::GetParticleSlice(const int direction, const Real
14641464
slice_box.setLo(direction, z_min);
14651465
slice_box.setHi(direction, z_max);
14661466

1467+
diagnostic_particles.resize(finestLevel()+1);
1468+
14671469
for (int lev = 0; lev < nlevs; ++lev) {
14681470

14691471
const Real* dx = Geom(lev).CellSize();
@@ -1473,7 +1475,7 @@ void PhysicalParticleContainer::GetParticleSlice(const int direction, const Real
14731475
for (WarpXParIter pti(*this, lev); pti.isValid(); ++pti)
14741476
{
14751477
auto index = std::make_pair(pti.index(), pti.LocalTileIndex());
1476-
diagnostic_particles[index];
1478+
diagnostic_particles[lev][index];
14771479
}
14781480

14791481
#ifdef _OPENMP
@@ -1544,15 +1546,15 @@ void PhysicalParticleContainer::GetParticleSlice(const int direction, const Real
15441546
Real uyp = uyp_old[i]*weight_old + uyp_new[i]*weight_new;
15451547
Real uzp = uz_old_p *weight_old + uz_new_p *weight_new;
15461548

1547-
diagnostic_particles[index].GetRealData(DiagIdx::w).push_back(wp[i]);
1548-
1549-
diagnostic_particles[index].GetRealData(DiagIdx::x).push_back(xp);
1550-
diagnostic_particles[index].GetRealData(DiagIdx::y).push_back(yp);
1551-
diagnostic_particles[index].GetRealData(DiagIdx::z).push_back(zp);
1549+
diagnostic_particles[lev][index].GetRealData(DiagIdx::w).push_back(wp[i]);
1550+
1551+
diagnostic_particles[lev][index].GetRealData(DiagIdx::x).push_back(xp);
1552+
diagnostic_particles[lev][index].GetRealData(DiagIdx::y).push_back(yp);
1553+
diagnostic_particles[lev][index].GetRealData(DiagIdx::z).push_back(zp);
15521554

1553-
diagnostic_particles[index].GetRealData(DiagIdx::ux).push_back(uxp);
1554-
diagnostic_particles[index].GetRealData(DiagIdx::uy).push_back(uyp);
1555-
diagnostic_particles[index].GetRealData(DiagIdx::uz).push_back(uzp);
1555+
diagnostic_particles[lev][index].GetRealData(DiagIdx::ux).push_back(uxp);
1556+
diagnostic_particles[lev][index].GetRealData(DiagIdx::uy).push_back(uyp);
1557+
diagnostic_particles[lev][index].GetRealData(DiagIdx::uz).push_back(uzp);
15561558
}
15571559
}
15581560
}

Source/WarpX.H

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ enum struct DtType : int
3434
SecondHalf
3535
};
3636

37+
enum struct PatchType : int
38+
{
39+
fine,
40+
coarse
41+
};
42+
3743
class WarpX
3844
: public amrex::AmrCore
3945
{
@@ -230,6 +236,15 @@ private:
230236
/// Advance the simulation by numsteps steps, electromagnetic case.
231237
///
232238
void EvolveEM(int numsteps);
239+
240+
void FillBoundaryB (int lev, PatchType patch_type);
241+
void FillBoundaryE (int lev, PatchType patch_type);
242+
void FillBoundaryF (int lev, PatchType patch_type);
243+
244+
void EvolveB (int lev, PatchType patch_type, amrex::Real dt);
245+
void EvolveE (int lev, PatchType patch_type, amrex::Real dt);
246+
void EvolveF (int lev, PatchType patch_type, amrex::Real dt, DtType dt_type);
247+
void DampPML (int lev, PatchType patch_type);
233248

234249
#ifdef WARPX_DO_ELECTROSTATIC
235250
///

Source/WarpX.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -257,33 +257,33 @@ WarpX::ReadParameters ()
257257
const std::string msg = "Unknown moving_window_dir: "+s;
258258
amrex::Abort(msg.c_str());
259259
}
260-
260+
261261
moving_window_x = geom[0].ProbLo(moving_window_dir);
262-
262+
263263
pp.get("moving_window_v", moving_window_v);
264264
moving_window_v *= PhysConst::c;
265265
}
266-
266+
267267
pp.query("do_plasma_injection", do_plasma_injection);
268268
if (do_plasma_injection) {
269-
pp.get("num_injected_species", num_injected_species);
270-
injected_plasma_species.resize(num_injected_species);
271-
pp.getarr("injected_plasma_species", injected_plasma_species,
272-
0, num_injected_species);
273-
if (moving_window_v >= 0){
274-
// Inject particles continuously from the right end of the box
275-
current_injection_position = geom[0].ProbHi(moving_window_dir);
276-
} else {
277-
// Inject particles continuously from the left end of the box
278-
current_injection_position = geom[0].ProbLo(moving_window_dir);
279-
}
269+
pp.get("num_injected_species", num_injected_species);
270+
injected_plasma_species.resize(num_injected_species);
271+
pp.getarr("injected_plasma_species", injected_plasma_species,
272+
0, num_injected_species);
273+
if (moving_window_v >= 0){
274+
// Inject particles continuously from the right end of the box
275+
current_injection_position = geom[0].ProbHi(moving_window_dir);
276+
} else {
277+
// Inject particles continuously from the left end of the box
278+
current_injection_position = geom[0].ProbLo(moving_window_dir);
279+
}
280280
}
281-
281+
282282
pp.query("do_boosted_frame_diagnostic", do_boosted_frame_diagnostic);
283283
if (do_boosted_frame_diagnostic) {
284-
284+
285285
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(gamma_boost > 1.0,
286-
"gamma_boost must be > 1 to use the boosted frame diagnostic.");
286+
"gamma_boost must be > 1 to use the boosted frame diagnostic.");
287287

288288
std::string s;
289289
pp.get("boost_direction", s);

Source/WarpXBoostedFrameDiagnostic.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ BoostedFrameDiagnostic::
221221
writeParticleData(const WarpXParticleContainer::DiagnosticParticleData& pdata, const std::string& name,
222222
const int i_lab)
223223
{
224-
225224
BL_PROFILE("BoostedFrameDiagnostic::writeParticleData");
226225

227226
std::string field_name;

Source/WarpXComm.cpp

Lines changed: 85 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -238,43 +238,82 @@ WarpX::FillBoundaryF ()
238238
void
239239
WarpX::FillBoundaryE(int lev)
240240
{
241-
const auto& period = Geom(lev).periodicity();
242-
243-
if (do_pml && pml[lev]->ok()) {
244-
ExchangeWithPmlE(lev);
245-
pml[lev]->FillBoundaryE();
246-
}
241+
FillBoundaryE(lev, PatchType::fine);
242+
if (lev > 0) FillBoundaryE(lev, PatchType::coarse);
243+
}
247244

248-
(*Efield_fp[lev][0]).FillBoundary( period );
249-
(*Efield_fp[lev][1]).FillBoundary( period );
250-
(*Efield_fp[lev][2]).FillBoundary( period );
245+
void
246+
WarpX::FillBoundaryE (int lev, PatchType patch_type)
247+
{
248+
if (patch_type == PatchType::fine)
249+
{
250+
if (do_pml && pml[lev]->ok())
251+
{
252+
pml[lev]->ExchangeE(patch_type,
253+
{ Efield_fp[lev][0].get(),
254+
Efield_fp[lev][1].get(),
255+
Efield_fp[lev][2].get() });
256+
pml[lev]->FillBoundaryE(patch_type);
257+
}
251258

252-
if (lev > 0)
259+
const auto& period = Geom(lev).periodicity();
260+
(*Efield_fp[lev][0]).FillBoundary(period);
261+
(*Efield_fp[lev][1]).FillBoundary(period);
262+
(*Efield_fp[lev][2]).FillBoundary(period);
263+
}
264+
else if (patch_type == PatchType::coarse)
253265
{
266+
if (do_pml && pml[lev]->ok())
267+
{
268+
pml[lev]->ExchangeE(patch_type,
269+
{ Efield_cp[lev][0].get(),
270+
Efield_cp[lev][1].get(),
271+
Efield_cp[lev][2].get() });
272+
pml[lev]->FillBoundaryE(patch_type);
273+
}
274+
254275
const auto& cperiod = Geom(lev-1).periodicity();
255276
(*Efield_cp[lev][0]).FillBoundary(cperiod);
256277
(*Efield_cp[lev][1]).FillBoundary(cperiod);
257278
(*Efield_cp[lev][2]).FillBoundary(cperiod);
258-
}
279+
}
259280
}
260281

261282
void
262-
WarpX::FillBoundaryB(int lev)
283+
WarpX::FillBoundaryB (int lev)
263284
{
264-
const auto& period = Geom(lev).periodicity();
285+
FillBoundaryB(lev, PatchType::fine);
286+
if (lev > 0) FillBoundaryB(lev, PatchType::coarse);
287+
}
265288

266-
if (do_pml && pml[lev]->ok())
289+
void
290+
WarpX::FillBoundaryB (int lev, PatchType patch_type)
291+
{
292+
if (patch_type == PatchType::fine)
267293
{
268-
ExchangeWithPmlB(lev);
269-
pml[lev]->FillBoundaryB();
294+
if (do_pml && pml[lev]->ok())
295+
{
296+
pml[lev]->ExchangeB(patch_type,
297+
{ Bfield_fp[lev][0].get(),
298+
Bfield_fp[lev][1].get(),
299+
Bfield_fp[lev][2].get() });
300+
pml[lev]->FillBoundaryB(patch_type);
301+
}
302+
const auto& period = Geom(lev).periodicity();
303+
(*Bfield_fp[lev][0]).FillBoundary(period);
304+
(*Bfield_fp[lev][1]).FillBoundary(period);
305+
(*Bfield_fp[lev][2]).FillBoundary(period);
270306
}
271-
272-
(*Bfield_fp[lev][0]).FillBoundary(period);
273-
(*Bfield_fp[lev][1]).FillBoundary(period);
274-
(*Bfield_fp[lev][2]).FillBoundary(period);
275-
276-
if (lev > 0)
307+
else if (patch_type == PatchType::coarse)
277308
{
309+
if (do_pml && pml[lev]->ok())
310+
{
311+
pml[lev]->ExchangeB(patch_type,
312+
{ Bfield_cp[lev][0].get(),
313+
Bfield_cp[lev][1].get(),
314+
Bfield_cp[lev][2].get() });
315+
pml[lev]->FillBoundaryB(patch_type);
316+
}
278317
const auto& cperiod = Geom(lev-1).periodicity();
279318
(*Bfield_cp[lev][0]).FillBoundary(cperiod);
280319
(*Bfield_cp[lev][1]).FillBoundary(cperiod);
@@ -283,22 +322,36 @@ WarpX::FillBoundaryB(int lev)
283322
}
284323

285324
void
286-
WarpX::FillBoundaryF(int lev)
325+
WarpX::FillBoundaryF (int lev)
287326
{
288-
const auto& period = Geom(lev).periodicity();
327+
FillBoundaryF(lev, PatchType::fine);
328+
if (lev > 0) FillBoundaryF(lev, PatchType::coarse);
329+
}
289330

290-
if (do_pml && pml[lev]->ok())
331+
void
332+
WarpX::FillBoundaryF (int lev, PatchType patch_type)
333+
{
334+
if (patch_type == PatchType::fine && F_fp[lev])
291335
{
292-
ExchangeWithPmlF(lev);
293-
pml[lev]->FillBoundaryF();
294-
}
295-
296-
if (F_fp[lev]) F_fp[lev]->FillBoundary(period);
336+
if (do_pml && pml[lev]->ok())
337+
{
338+
pml[lev]->ExchangeF(patch_type, F_fp[lev].get());
339+
pml[lev]->FillBoundaryF(patch_type);
340+
}
297341

298-
if (lev > 0)
342+
const auto& period = Geom(lev).periodicity();
343+
F_fp[lev]->FillBoundary(period);
344+
}
345+
else if (patch_type == PatchType::coarse && F_cp[lev])
299346
{
347+
if (do_pml && pml[lev]->ok())
348+
{
349+
pml[lev]->ExchangeF(patch_type, F_cp[lev].get());
350+
pml[lev]->FillBoundaryF(patch_type);
351+
}
352+
300353
const auto& cperiod = Geom(lev-1).periodicity();
301-
if (F_cp[lev]) F_cp[lev]->FillBoundary(cperiod);
354+
F_cp[lev]->FillBoundary(cperiod);
302355
}
303356
}
304357

0 commit comments

Comments
 (0)