Skip to content

Commit a6a466b

Browse files
Bug fix : Coarse patch dx for external field init (#3674)
* fix coarse patch dx for external field init * rename var * Update Source/Initialization/WarpXInitData.cpp Co-authored-by: Axel Huebl <[email protected]> * reset benchmark for PEC_mr test case --------- Co-authored-by: Axel Huebl <[email protected]>
1 parent 9411576 commit a6a466b

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

Regression/Checksum/benchmarks_json/PEC_field_mr.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Ey": 1052208601.720587
55
},
66
"lev=1": {
7-
"Bx": 0.3187370090421958,
8-
"Ey": 98224588.87142882
7+
"Bx": 0.038732896603981076,
8+
"Ey": 9503300.083366634
99
}
1010
}

Source/Initialization/WarpXInitData.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ WarpX::InitLevelData (int lev, Real /*time*/)
756756
m_edge_lengths[lev],
757757
m_face_areas[lev],
758758
'B',
759-
lev);
759+
lev, PatchType::fine);
760760
if (lev > 0) {
761761
InitializeExternalFieldsOnGridUsingParser(Bfield_aux[lev][0].get(),
762762
Bfield_aux[lev][1].get(),
@@ -767,7 +767,7 @@ WarpX::InitLevelData (int lev, Real /*time*/)
767767
m_edge_lengths[lev],
768768
m_face_areas[lev],
769769
'B',
770-
lev);
770+
lev, PatchType::fine);
771771

772772
InitializeExternalFieldsOnGridUsingParser(Bfield_cp[lev][0].get(),
773773
Bfield_cp[lev][1].get(),
@@ -778,7 +778,7 @@ WarpX::InitLevelData (int lev, Real /*time*/)
778778
m_edge_lengths[lev],
779779
m_face_areas[lev],
780780
'B',
781-
lev);
781+
lev, PatchType::coarse);
782782
}
783783
}
784784

@@ -815,7 +815,7 @@ WarpX::InitLevelData (int lev, Real /*time*/)
815815
m_edge_lengths[lev],
816816
m_face_areas[lev],
817817
'E',
818-
lev);
818+
lev, PatchType::fine);
819819

820820
#ifdef AMREX_USE_EB
821821
// We initialize ECTRhofield consistently with the Efield
@@ -836,7 +836,7 @@ WarpX::InitLevelData (int lev, Real /*time*/)
836836
m_edge_lengths[lev],
837837
m_face_areas[lev],
838838
'E',
839-
lev);
839+
lev, PatchType::fine);
840840

841841
InitializeExternalFieldsOnGridUsingParser(Efield_cp[lev][0].get(),
842842
Efield_cp[lev][1].get(),
@@ -847,7 +847,7 @@ WarpX::InitLevelData (int lev, Real /*time*/)
847847
m_edge_lengths[lev],
848848
m_face_areas[lev],
849849
'E',
850-
lev);
850+
lev, PatchType::coarse);
851851
#ifdef AMREX_USE_EB
852852
if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::ECT) {
853853
// We initialize ECTRhofield consistently with the Efield
@@ -876,10 +876,16 @@ WarpX::InitializeExternalFieldsOnGridUsingParser (
876876
std::array< std::unique_ptr<amrex::MultiFab>, 3 > const& edge_lengths,
877877
std::array< std::unique_ptr<amrex::MultiFab>, 3 > const& face_areas,
878878
const char field,
879-
const int lev)
879+
const int lev, PatchType patch_type)
880880
{
881881

882-
const auto dx_lev = geom[lev].CellSizeArray();
882+
auto dx_lev = geom[lev].CellSizeArray();
883+
amrex::IntVect refratio = (lev > 0 ) ? WarpX::RefRatio(lev-1) : amrex::IntVect(1);
884+
if (patch_type == PatchType::coarse) {
885+
for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
886+
dx_lev[idim] = dx_lev[idim] * refratio[idim];
887+
}
888+
}
883889
const RealBox& real_box = geom[lev].ProbDomain();
884890
amrex::IntVect x_nodal_flag = mfx->ixType().toIntVect();
885891
amrex::IntVect y_nodal_flag = mfy->ixType().toIntVect();

Source/WarpX.H

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,7 @@ public:
924924
* \param[in] face_areas face areas information
925925
* \param[in] field flag indicating which field is being initialized ('E' for electric, 'B' for magnetic)
926926
* \param[in] lev level of the Multifabs that is initialized
927+
* \param[in] patch_type PatchType on which the field is initialized (fine or coarse)
927928
*/
928929
void InitializeExternalFieldsOnGridUsingParser (
929930
amrex::MultiFab *mfx, amrex::MultiFab *mfy, amrex::MultiFab *mfz,
@@ -933,7 +934,7 @@ public:
933934
std::array< std::unique_ptr<amrex::MultiFab>, 3 > const& edge_lengths,
934935
std::array< std::unique_ptr<amrex::MultiFab>, 3 > const& face_areas,
935936
const char field,
936-
const int lev);
937+
const int lev, PatchType patch_type);
937938

938939
/**
939940
* \brief

0 commit comments

Comments
 (0)