Skip to content

Commit 67223cd

Browse files
committed
bugfix when using non-zero sigma away from the PEC mask; need to compute the PEC mask first and then zero out sigma so it can be parsed *after*
1 parent 8eb71b6 commit 67223cd

1 file changed

Lines changed: 22 additions & 18 deletions

File tree

Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,28 @@ MacroscopicProperties::InitData ()
259259
// mu is cell-centered MultiFab
260260
m_mu_mf = std::make_unique<amrex::MultiFab>(ba, dmap, 1, ng_EB_alloc);
261261

262+
////////////////////////
263+
// PEC mask
264+
265+
// call this before setting sigma in the rest of the domain since this zeros sigma once the PEC mask is defined
266+
if (warpx.use_PEC_mask) {
267+
// get pointer to PEC mask in WarpX class
268+
amrex::MultiFab * PECx = warpx.get_pointer_PEC_fp(lev,0);
269+
amrex::MultiFab * PECy = warpx.get_pointer_PEC_fp(lev,1);
270+
amrex::MultiFab * PECz = warpx.get_pointer_PEC_fp(lev,2);
271+
272+
PECx->setVal(1.);
273+
PECy->setVal(1.);
274+
PECz->setVal(1.);
275+
276+
InitializePECFromSigma(m_sigma_mf.get(), PECx, PECy, m_npy_k_index);
277+
if (!m_sigma_npy_filename2.empty()) {
278+
InitializePECFromSigma(m_sigma_mf.get(), PECx, PECy, m_npy_k_index2);
279+
}
280+
// zero sigma
281+
m_sigma_mf->setVal(0.);
282+
}
283+
262284
////////////////////////
263285
// Initialize sigma
264286
if (m_sigma_s == "constant") {
@@ -279,24 +301,6 @@ MacroscopicProperties::InitData ()
279301
}
280302
}
281303

282-
if (warpx.use_PEC_mask) {
283-
// get pointer to PEC mask in WarpX class
284-
amrex::MultiFab * PECx = warpx.get_pointer_PEC_fp(lev,0);
285-
amrex::MultiFab * PECy = warpx.get_pointer_PEC_fp(lev,1);
286-
amrex::MultiFab * PECz = warpx.get_pointer_PEC_fp(lev,2);
287-
288-
PECx->setVal(1.);
289-
PECy->setVal(1.);
290-
PECz->setVal(1.);
291-
292-
InitializePECFromSigma(m_sigma_mf.get(), PECx, PECy, m_npy_k_index);
293-
if (!m_sigma_npy_filename2.empty()) {
294-
InitializePECFromSigma(m_sigma_mf.get(), PECx, PECy, m_npy_k_index2);
295-
}
296-
// no need for sigma anymore
297-
m_sigma_mf->setVal(0.);
298-
}
299-
300304
////////////////////////
301305
// Initialize epsilon
302306
if (m_epsilon_s == "constant") {

0 commit comments

Comments
 (0)