Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harris sheetin x with lev0 init #136

Open
wants to merge 4 commits into
base: HarrisSheetinX
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 71 additions & 62 deletions Source/Initialization/WarpXInitData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,8 @@ WarpX::InitLevelData (int lev, Real /*time*/)
Bzfield_parser = std::make_unique<amrex::Parser>(
utils::parser::makeParser(str_Bz_ext_grid_function,{"x","y","z"}));

// Initialize Bfield_fp with external function
// Initialize Bfield_fp with external function only on level 0 -- HACK
if (lev == 0) {
InitializeExternalFieldsOnGridUsingParser(Bfield_fp[lev][0].get(),
Bfield_fp[lev][1].get(),
Bfield_fp[lev][2].get(),
Expand All @@ -761,56 +762,64 @@ WarpX::InitLevelData (int lev, Real /*time*/)
m_face_areas[lev],
'B',
lev, PatchType::fine);
if (lev > 0) {
InitializeExternalFieldsOnGridUsingParser(Bfield_aux[lev][0].get(),
Bfield_aux[lev][1].get(),
Bfield_aux[lev][2].get(),
Bxfield_parser->compile<3>(),
Byfield_parser->compile<3>(),
Bzfield_parser->compile<3>(),
m_edge_lengths[lev],
m_face_areas[lev],
'B',
lev, PatchType::fine);

InitializeExternalFieldsOnGridUsingParser(Bfield_cp[lev][0].get(),
Bfield_cp[lev][1].get(),
Bfield_cp[lev][2].get(),
Bxfield_parser->compile<3>(),
Byfield_parser->compile<3>(),
Bzfield_parser->compile<3>(),
m_edge_lengths[lev],
m_face_areas[lev],
'B',
lev, PatchType::coarse);
}
} else {
for (int i = 0; i < 3; ++i) {
Bfield_aux[lev][i]->setVal(0.);
Bfield_cp[lev][i]->setVal(0.);
Bfield_fp[lev][i]->setVal(0.);
}
}
// if (lev > 0) {
// InitializeExternalFieldsOnGridUsingParser(Bfield_aux[lev][0].get(),
// Bfield_aux[lev][1].get(),
// Bfield_aux[lev][2].get(),
// Bxfield_parser->compile<3>(),
// Byfield_parser->compile<3>(),
// Bzfield_parser->compile<3>(),
// m_edge_lengths[lev],
// m_face_areas[lev],
// 'B',
// lev, PatchType::fine);
//
// InitializeExternalFieldsOnGridUsingParser(Bfield_cp[lev][0].get(),
// Bfield_cp[lev][1].get(),
// Bfield_cp[lev][2].get(),
// Bxfield_parser->compile<3>(),
// Byfield_parser->compile<3>(),
// Bzfield_parser->compile<3>(),
// m_edge_lengths[lev],
// m_face_areas[lev],
// 'B',
// lev, PatchType::coarse);
// }
}
int IncludeBfieldPerturbation = 0;
pp_warpx.query("IncludeBfieldPerturbation",IncludeBfieldPerturbation);
if (IncludeBfieldPerturbation == 1) {
#ifndef WARPX_DIM_RZ
if (lev == 0) { // HACK to debug MR
Reconnection_Perturbation::AddBfieldPerturbation (Bfield_fp[lev][0].get(),
Bfield_fp[lev][1].get(),
Bfield_fp[lev][2].get(),
Bxfield_parser->compile<3>(),
Byfield_parser->compile<3>(),
Bzfield_parser->compile<3>(), lev, PatchType::fine);

if (lev > 0) {
Reconnection_Perturbation::AddBfieldPerturbation (Bfield_aux[lev][0].get(),
Bfield_aux[lev][1].get(),
Bfield_aux[lev][2].get(),
Bxfield_parser->compile<3>(),
Byfield_parser->compile<3>(),
Bzfield_parser->compile<3>(), lev, PatchType::fine);

Reconnection_Perturbation::AddBfieldPerturbation (Bfield_cp[lev][0].get(),
Bfield_cp[lev][1].get(),
Bfield_cp[lev][2].get(),
Bxfield_parser->compile<3>(),
Byfield_parser->compile<3>(),
Bzfield_parser->compile<3>(), lev, PatchType::coarse);
}
// if (lev > 0) {
// Reconnection_Perturbation::AddBfieldPerturbation (Bfield_aux[lev][0].get(),
// Bfield_aux[lev][1].get(),
// Bfield_aux[lev][2].get(),
// Bxfield_parser->compile<3>(),
// Byfield_parser->compile<3>(),
// Bzfield_parser->compile<3>(), lev, PatchType::fine);
//
// Reconnection_Perturbation::AddBfieldPerturbation (Bfield_cp[lev][0].get(),
// Bfield_cp[lev][1].get(),
// Bfield_cp[lev][2].get(),
// Bxfield_parser->compile<3>(),
// Byfield_parser->compile<3>(),
// Bzfield_parser->compile<3>(), lev, PatchType::coarse);
// }

#endif
}
Expand Down Expand Up @@ -859,28 +868,28 @@ WarpX::InitLevelData (int lev, Real /*time*/)
}
#endif

if (lev > 0) {
InitializeExternalFieldsOnGridUsingParser(Efield_aux[lev][0].get(),
Efield_aux[lev][1].get(),
Efield_aux[lev][2].get(),
Exfield_parser->compile<3>(),
Eyfield_parser->compile<3>(),
Ezfield_parser->compile<3>(),
m_edge_lengths[lev],
m_face_areas[lev],
'E',
lev, PatchType::fine);

InitializeExternalFieldsOnGridUsingParser(Efield_cp[lev][0].get(),
Efield_cp[lev][1].get(),
Efield_cp[lev][2].get(),
Exfield_parser->compile<3>(),
Eyfield_parser->compile<3>(),
Ezfield_parser->compile<3>(),
m_edge_lengths[lev],
m_face_areas[lev],
'E',
lev, PatchType::coarse);
// if (lev > 0) {
// InitializeExternalFieldsOnGridUsingParser(Efield_aux[lev][0].get(),
// Efield_aux[lev][1].get(),
// Efield_aux[lev][2].get(),
// Exfield_parser->compile<3>(),
// Eyfield_parser->compile<3>(),
// Ezfield_parser->compile<3>(),
// m_edge_lengths[lev],
// m_face_areas[lev],
// 'E',
// lev, PatchType::fine);
//
// InitializeExternalFieldsOnGridUsingParser(Efield_cp[lev][0].get(),
// Efield_cp[lev][1].get(),
// Efield_cp[lev][2].get(),
// Exfield_parser->compile<3>(),
// Eyfield_parser->compile<3>(),
// Ezfield_parser->compile<3>(),
// m_edge_lengths[lev],
// m_face_areas[lev],
// 'E',
// lev, PatchType::coarse);
#ifdef AMREX_USE_EB
if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::ECT) {
// We initialize ECTRhofield consistently with the Efield
Expand All @@ -889,7 +898,7 @@ WarpX::InitLevelData (int lev, Real /*time*/)

}
#endif
}
// }
}

if (costs[lev]) {
Expand Down