From 865c5cce0508cbccc5f0ec06b56daf5a3b163809 Mon Sep 17 00:00:00 2001 From: Stephen Copplestone Date: Sun, 6 Mar 2022 18:45:10 +0100 Subject: [PATCH 1/2] Added BGField contribution when fallback algorithm "CVWM save" is activated when elements are strongly deformed and TriaTracking yields a different host element than RefMapping (the latter is used for deposition within the reference element). --- REGGIE.md | 2 +- .../command_line.ini | 1 + .../parameter.ini | 17 +++++++++++++ .../readme.md | 1 + .../pic/interpolation/init_BGField.f90 | 3 +++ .../pic/interpolation/pic_interpolation.f90 | 7 ++---- .../interpolation/pic_interpolation_tools.f90 | 25 ++++++++++++++++--- 7 files changed, 47 insertions(+), 9 deletions(-) diff --git a/REGGIE.md b/REGGIE.md index bc08b52ae..63713d367 100644 --- a/REGGIE.md +++ b/REGGIE.md @@ -92,7 +92,7 @@ Overview of the test cases performed during the nightly regression testing. | 4 | feature_TWT_recordpoints | maxwell,RK4 | RPs, ExactFlux | nProcs=1,4, RPs, interior TE-Inflow | RP_State, RP_Daata | | | 5 | NIG_PIC_poisson_plasma_wave | poisson,RK4,CN | Poisson-PIC,Shape-Function-1D for normal, charge conserving and adaptive SF, auto initial LB | nProcs=1,(2), (Imex for CN) | W_el LineIntegration over 2Per | | | 6 | NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean | maxwell,RK3 | Maxwell-PIC,CVWM deposition | nProcs=1,5,10 | Particle_ref.csv | [Link](regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean/readme.md) | -| 7 | NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM | maxwell,RK3 | Maxwell-PIC,CVWM deposition + fallback algorithm | nProcs=1,5,10 | Particle_ref.csv | [Link](regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM/readme.md) | +| 7 | NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM | maxwell,RK3 | Maxwell-PIC, CVWM deposition + fallback algorithm + BGField (superB) | nProcs=1,5,10 | Particle_ref.csv | [Link](regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM/readme.md) | | 8 | NIG_PIC_Deposition/Plasma_Ball_Shape-function-xDir | maxwell,RK3 | Maxwell-PIC,deposition shape_function, shape_function_cc, shape_function_adaptive | nProcs=1,5,10 | PartAnalyze.csv vs. reference | [Link](regressioncheck/NIG_PIC_Deposition/Plasma_Ball_Shape-function-xDir/readme.md) | | 9 | NIG_PIC_Deposition/Plasma_Ball_Shape-function-yDir | maxwell,RK3 | Maxwell-PIC,deposition shape_function, shape_function_cc, shape_function_adaptive | nProcs=1,5,10 | PartAnalyze.csv vs. reference | [Link](regressioncheck/NIG_PIC_Deposition/Plasma_Ball_Shape-function-yDir/readme.md) | | 10 | NIG_PIC_Deposition/Plasma_Ball_Shape-function-zDir | maxwell,RK3 | Maxwell-PIC,deposition shape_function, shape_function_cc, shape_function_adaptive | nProcs=1,5,10 | PartAnalyze.csv vs. reference | [Link](regressioncheck/NIG_PIC_Deposition/Plasma_Ball_Shape-function-zDir/readme.md) | diff --git a/regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM/command_line.ini b/regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM/command_line.ini index 9e8805f79..6feeb3fe4 100644 --- a/regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM/command_line.ini +++ b/regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM/command_line.ini @@ -1 +1,2 @@ +! Only 2 elements, therefore max. 2 cores MPI = 1,2 diff --git a/regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM/parameter.ini b/regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM/parameter.ini index 81a614f33..3ea8db2f4 100644 --- a/regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM/parameter.ini +++ b/regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM/parameter.ini @@ -136,3 +136,20 @@ PIC-OutputSource = T CalcHaloInfo = T CalcMeshInfo = T + +! =============================================================================== ! +! SuperB +! =============================================================================== ! +PIC-BG-Field = T + +PIC-CalcBField-OutputVTK = T + +NumOfCoils = 1 +Coil1-Type = circle +Coil1-BasePoint = (/0.0,0.0,-0.5/) +Coil1-LengthVector = (/0.,0.,1.0/) +Coil1-Current = 1.e-6 +Coil1-Radius = 1.9 +Coil1-LoopNum = 10 +Coil1-PointsPerLoop = 20 +Coil1-AxisVec1 = (/0.,0.,1.0/) diff --git a/regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM/readme.md b/regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM/readme.md index 06a143759..9029ab155 100644 --- a/regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM/readme.md +++ b/regressioncheck/NIG_PIC_Deposition/Plasma_Ball_cell_volweight_mean_save_CVWM/readme.md @@ -9,3 +9,4 @@ because one element interface is strongly deformed - this feature is useful if the Jacobians are determined good enough with N and the integration error is then reduced using a much higher NAnalyze (in this case the Jacobians are bad from the beginning, which is why the calculation of the error does not improve much) +- also considers superB magnetic field to test functionality of CVWM fallback in combination with B-field diff --git a/src/particles/pic/interpolation/init_BGField.f90 b/src/particles/pic/interpolation/init_BGField.f90 index 2658f89a9..81e25a5b2 100644 --- a/src/particles/pic/interpolation/init_BGField.f90 +++ b/src/particles/pic/interpolation/init_BGField.f90 @@ -187,14 +187,17 @@ SUBROUTINE InitializeBackgroundField IF(nVar_BField.EQ.3) THEN BGDataSize=3 IF(TRIM(VarNames(1)).EQ.'BG-ElectricFieldX') THEN + ! Ex, Ey, Ez BGType=1 ELSE IF(TRIM(VarNames(1)).EQ.'BG-MagneticFieldX') THEN + ! Bx, By, Bz BGType=2 ELSE CALL abort(__STAMP__,'ERROR Background Field: Variable names do not seem to be correct!') END IF ELSE BGDataSize=6 + ! Ex,Ey,Ez,Bx,By,Bz BGType=3 END IF diff --git a/src/particles/pic/interpolation/pic_interpolation.f90 b/src/particles/pic/interpolation/pic_interpolation.f90 index d2e2a5356..376034193 100644 --- a/src/particles/pic/interpolation/pic_interpolation.f90 +++ b/src/particles/pic/interpolation/pic_interpolation.f90 @@ -333,8 +333,7 @@ SUBROUTINE InterpolateFieldToSingleParticle(PartID,FieldAtParticle) !2. Calculate fields at particle #if USE_MPI IF(PEM%LocalElemID(PartID).GT.PP_nElems)THEN! RETURN - CALL abort(& - __STAMP__& + CALL abort(__STAMP__& ,'ERROR: This check used to "RETURN" here but is now set to "ABORT". PEM%LocalElemID(PartID).GT.PP_nElems should not happen here.') END IF #endif @@ -343,9 +342,7 @@ SUBROUTINE InterpolateFieldToSingleParticle(PartID,FieldAtParticle) ! Add the interpolated electro-(magnetic) field FieldAtParticle(:) = FieldAtParticle(:) + GetInterpolatedFieldPartPos(PEM%GlobalElemID(PartID),PartID) CASE DEFAULT - CALL abort(& - __STAMP__& - , 'ERROR: Unknown InterpolationType!') + CALL abort(__STAMP__, 'ERROR: Unknown InterpolationType!') END SELECT END SUBROUTINE InterpolateFieldToSingleParticle diff --git a/src/particles/pic/interpolation/pic_interpolation_tools.f90 b/src/particles/pic/interpolation/pic_interpolation_tools.f90 index 4d888effe..73b00b7a2 100644 --- a/src/particles/pic/interpolation/pic_interpolation_tools.f90 +++ b/src/particles/pic/interpolation/pic_interpolation_tools.f90 @@ -276,13 +276,14 @@ PPURE FUNCTION GetEMField(ElemID,PartPosRef_loc) END FUNCTION GetEMField -FUNCTION GetEMFieldDW(ElemID, PartPos_loc) +PPURE FUNCTION GetEMFieldDW(ElemID, PartPos_loc) !=================================================================================================================================== ! Evaluate the electro-(magnetic) field using the reference position and return the field !=================================================================================================================================== ! MODULES USE MOD_Mesh_Vars ,ONLY: Elem_xGP USE MOD_PICInterpolation_Vars ,ONLY: useBGField +USE MOD_Interpolation_Vars ,ONLY: BGField,BGType USE MOD_Globals USE MOD_PreProc #if ! (USE_HDG) @@ -313,7 +314,7 @@ FUNCTION GetEMFieldDW(ElemID, PartPos_loc) ! LOCAL VARIABLES REAL :: HelperU(1:6,0:PP_N,0:PP_N,0:PP_N) REAL :: PartDistDepo(0:PP_N,0:PP_N,0:PP_N), DistSum -INTEGER :: k,l,m +INTEGER :: k,l,m,ind1,ind2 REAL :: norm !=================================================================================================================================== GetEMFieldDW(1:6)=0. @@ -367,7 +368,25 @@ FUNCTION GetEMFieldDW(ElemID, PartPos_loc) GetEMFieldDW(1:6) = GetEMFieldDW(1:6) + PartDistDepo(k,l,m)/DistSum*HelperU(1:6,k,l,m) END DO; END DO; END DO -IF(useBGField) CALL abort(__STAMP__,' ERROR BG Field not implemented for GetEMFieldDW!') +! Check whether magnetic background field is activated (superB) +IF(useBGField)THEN + ! Check BG type and set dimensions + SELECT CASE(BGType) + CASE(1) ! Ex,Ey,Ez + ind1 = 1 + ind2 = 3 + CASE(2) ! Bx,By,Bz + ind1 = 4 + ind2 = 6 + CASE(3) ! Ex,Ey,Ez,Bx,By,Bz + ind1 = 1 + ind2 = 6 + END SELECT + ! Add contribution of the magnetic field + DO k = 0, PP_N; DO l=0, PP_N; DO m=0, PP_N + GetEMFieldDW(ind1:ind2) = GetEMFieldDW(ind1:ind2) + PartDistDepo(k,l,m)/DistSum*BGField(ind1:ind2,k,l,m,ElemID) + END DO; END DO; END DO +END IF ! useBGField END FUNCTION GetEMFieldDW From 3c911f0efc23dd284121dd352d63cbf1d2188f41 Mon Sep 17 00:00:00 2001 From: Stephen Copplestone Date: Mon, 7 Mar 2022 16:15:39 +0100 Subject: [PATCH 2/2] Use correct size for BGField that is allocated with size 1:BGDataSize --- src/particles/pic/interpolation/pic_interpolation_tools.f90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/particles/pic/interpolation/pic_interpolation_tools.f90 b/src/particles/pic/interpolation/pic_interpolation_tools.f90 index 73b00b7a2..6a3f165b5 100644 --- a/src/particles/pic/interpolation/pic_interpolation_tools.f90 +++ b/src/particles/pic/interpolation/pic_interpolation_tools.f90 @@ -281,9 +281,9 @@ PPURE FUNCTION GetEMFieldDW(ElemID, PartPos_loc) ! Evaluate the electro-(magnetic) field using the reference position and return the field !=================================================================================================================================== ! MODULES -USE MOD_Mesh_Vars ,ONLY: Elem_xGP +USE MOD_Mesh_Vars ,ONLY: Elem_xGP USE MOD_PICInterpolation_Vars ,ONLY: useBGField -USE MOD_Interpolation_Vars ,ONLY: BGField,BGType +USE MOD_Interpolation_Vars ,ONLY: BGField,BGType,BGDataSize USE MOD_Globals USE MOD_PreProc #if ! (USE_HDG) @@ -384,7 +384,7 @@ PPURE FUNCTION GetEMFieldDW(ElemID, PartPos_loc) END SELECT ! Add contribution of the magnetic field DO k = 0, PP_N; DO l=0, PP_N; DO m=0, PP_N - GetEMFieldDW(ind1:ind2) = GetEMFieldDW(ind1:ind2) + PartDistDepo(k,l,m)/DistSum*BGField(ind1:ind2,k,l,m,ElemID) + GetEMFieldDW(ind1:ind2) = GetEMFieldDW(ind1:ind2) + PartDistDepo(k,l,m)/DistSum*BGField(1:BGDataSize,k,l,m,ElemID) END DO; END DO; END DO END IF ! useBGField