Skip to content

Commit

Permalink
Merge branch 'improvement.tracking2D.SideIsSymSide' into 'master.dev'
Browse files Browse the repository at this point in the history
Added cycle for symmetry BC sides in triatracking in case of 2D simulations

See merge request piclas/piclas!811
  • Loading branch information
scopplestone committed Jun 12, 2023
2 parents fe37889 + 8c45d21 commit ae216e6
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ BPO-Species = (/1/) ! electrons
! =============================================================================== !
Part-Species1-MassIC = 9.11E-31
Part-Species1-ChargeIC = -1.60217653E-19
Part-Species1-MacroParticleFactor = 2E4
Part-Species1-MacroParticleFactor = 1E4

Part-Species1-nSurfaceFluxBCs=1
Part-Species1-Surfaceflux1-BC=2
Expand Down
11 changes: 11 additions & 0 deletions src/particles/boundary/particle_boundary_init.f90
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ SUBROUTINE InitializeVariablesPartBoundary()
PartBound%TargetBoundCond = -1
ALLOCATE(PartBound%MomentumACC( 1:nPartBound))
PartBound%MomentumACC = -1
ALLOCATE(PartBound%OnlySpecular( 1:nPartBound))
PartBound%OnlySpecular = .FALSE.
ALLOCATE(PartBound%OnlyDiffuse( 1:nPartBound))
PartBound%OnlyDiffuse = .FALSE.
ALLOCATE(PartBound%WallTemp( 1:nPartBound))
PartBound%WallTemp = -1.
ALLOCATE(PartBound%WallTemp2( 1:nPartBound))
Expand Down Expand Up @@ -299,6 +303,11 @@ SUBROUTINE InitializeVariablesPartBoundary()
#endif
PartBound%TargetBoundCond(iPartBound) = PartBound%ReflectiveBC
PartBound%MomentumACC(iPartBound) = GETREAL('Part-Boundary'//TRIM(hilf)//'-MomentumACC')
IF(PartBound%MomentumACC(iPartBound).EQ.0.0) THEN
PartBound%OnlySpecular(iPartBound) = .TRUE.
ELSE IF(PartBound%MomentumACC(iPartBound).EQ.1.0) THEN
PartBound%OnlyDiffuse(iPartBound) = .TRUE.
END IF
PartBound%WallTemp(iPartBound) = GETREAL('Part-Boundary'//TRIM(hilf)//'-WallTemp')
PartBound%TransACC(iPartBound) = GETREAL('Part-Boundary'//TRIM(hilf)//'-TransACC')
PartBound%VibACC(iPartBound) = GETREAL('Part-Boundary'//TRIM(hilf)//'-VibACC')
Expand Down Expand Up @@ -1122,6 +1131,8 @@ SUBROUTINE FinalizeParticleBoundary()
SDEALLOCATE(PartBound%SourceBoundName)
SDEALLOCATE(PartBound%TargetBoundCond)
SDEALLOCATE(PartBound%MomentumACC)
SDEALLOCATE(PartBound%OnlySpecular)
SDEALLOCATE(PartBound%OnlyDiffuse)
SDEALLOCATE(PartBound%WallTemp)
SDEALLOCATE(PartBound%WallTemp2)
SDEALLOCATE(PartBound%WallTempDelta)
Expand Down
2 changes: 2 additions & 0 deletions src/particles/boundary/particle_boundary_vars.f90
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ MODULE MOD_Particle_Boundary_Vars
INTEGER , ALLOCATABLE :: MapToFieldBC(:) ! Map from Particle BC (NOT TO TYPE!) to PICLas BCindex
!!INTEGER , ALLOCATABLE :: SideBCType(:) ! list with boundary condition for each side
REAL , ALLOCATABLE :: MomentumACC(:)
LOGICAL , ALLOCATABLE :: OnlySpecular(:)
LOGICAL , ALLOCATABLE :: OnlyDiffuse(:)
REAL , ALLOCATABLE :: WallTemp(:), WallTemp2(:), WallTempDelta(:)
REAL , ALLOCATABLE :: TempGradStart(:,:), TempGradEnd(:,:), TempGradVec(:,:)
REAL , ALLOCATABLE :: TransACC(:)
Expand Down
29 changes: 22 additions & 7 deletions src/particles/dsmc/dsmc_symmetry.f90
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,16 @@ SUBROUTINE DSMC_2D_InitVolumes()
USE MOD_Particle_Mesh_Vars ,ONLY: GEO,LocalVolume,MeshVolume
USE MOD_DSMC_Vars ,ONLY: SymmetrySide
USE MOD_Particle_Mesh_Vars ,ONLY: ElemVolume_Shared,ElemCharLength_Shared
USE MOD_Particle_Mesh_Vars ,ONLY: NodeCoords_Shared,ElemSideNodeID_Shared, SideInfo_Shared
USE MOD_Particle_Mesh_Vars ,ONLY: NodeCoords_Shared,ElemSideNodeID_Shared, SideInfo_Shared, SideIsSymSide_Shared
USE MOD_Mesh_Tools ,ONLY: GetCNElemID
USE MOD_Particle_Mesh_Vars ,ONLY: nNonUniqueGlobalSides
USE MOD_Particle_Mesh_Tools ,ONLY: GetGlobalNonUniqueSideID
USE MOD_Particle_Surfaces ,ONLY: CalcNormAndTangTriangle
#if USE_MPI
USE MOD_MPI_Shared ,ONLY: BARRIER_AND_SYNC
USE MOD_MPI_Shared
USE MOD_MPI_Shared_Vars ,ONLY: MPI_COMM_SHARED
USE MOD_Particle_Mesh_Vars ,ONLY: offsetComputeNodeElem
USE MOD_Particle_Mesh_Vars ,ONLY: ElemVolume_Shared_Win,ElemCharLength_Shared_Win
USE MOD_Particle_Mesh_Vars ,ONLY: ElemVolume_Shared_Win,ElemCharLength_Shared_Win,SideIsSymSide_Shared_Win
USE MOD_MPI_Shared_Vars ,ONLY: myComputeNodeRank,MPI_COMM_LEADERS_SHARED
#endif /*USE_MPI*/
! IMPLICIT VARIABLE HANDLING
Expand All @@ -113,13 +114,14 @@ SUBROUTINE DSMC_2D_InitVolumes()
!===================================================================================================================================

#if USE_MPI
FirstElem = offsetElem - offsetComputeNodeElem + 1
LastElem = offsetElem - offsetComputeNodeElem + nElems
CALL Allocate_Shared((/nNonUniqueGlobalSides/),SideIsSymSide_Shared_Win,SideIsSymSide_Shared)
CALL MPI_WIN_LOCK_ALL(0,SideIsSymSide_Shared_Win,IERROR)
#else
firstElem = 1
lastElem = nElems
ALLOCATE(SideIsSymSide_Shared(nNonUniqueGlobalSides))
#endif /*USE_MPI*/

SideIsSymSide_Shared = .FALSE.

SymmetryBCExists = .FALSE.
ALLOCATE(SymmetrySide(1:nElems,1:2)) ! 1: GlobalSide, 2: LocalSide
SymmetrySide = -1
Expand All @@ -137,6 +139,8 @@ SUBROUTINE DSMC_2D_InitVolumes()
iLocSide = SideToElem(S2E_LOC_SIDE_ID,BCSideID)
SideID=GetGlobalNonUniqueSideID(offsetElem+locElemID,iLocSide)
IF (PartBound%TargetBoundCond(PartBound%MapToPartBC(SideInfo_Shared(SIDE_BCID,SideID))).EQ.PartBound%SymmetryBC) THEN
! Mark side to skip in tracking
SideIsSymSide_Shared(SideID) = .TRUE.
CNElemID = GetCNElemID(SideInfo_Shared(SIDE_ELEMID,SideID))
iLocSide = SideInfo_Shared(SIDE_LOCALID,SideID)
! Exclude the symmetry axis (y=0)
Expand Down Expand Up @@ -177,14 +181,25 @@ SUBROUTINE DSMC_2D_InitVolumes()
END IF
END DO


IF(.NOT.SymmetryBCExists) THEN
CALL abort(__STAMP__&
,'At least one symmetric BC (in the xy-plane) has to be defined for 2D simulations')
END IF

! LocalVolume & MeshVolume: Recalculate the volume of the mesh of a single process and the total mesh volume
#if USE_MPI
FirstElem = offsetElem - offsetComputeNodeElem + 1
LastElem = offsetElem - offsetComputeNodeElem + nElems
#else
firstElem = 1
lastElem = nElems
#endif /*USE_MPI*/

LocalVolume = SUM(ElemVolume_Shared(FirstElem:LastElem))

#if USE_MPI
CALL BARRIER_AND_SYNC(SideIsSymSide_Shared_Win ,MPI_COMM_SHARED)
CALL BARRIER_AND_SYNC(ElemVolume_Shared_Win ,MPI_COMM_SHARED)
CALL BARRIER_AND_SYNC(ElemCharLength_Shared_Win,MPI_COMM_SHARED)
! Compute-node mesh volume
Expand Down
1 change: 1 addition & 0 deletions src/particles/particle_mesh/particle_mesh_readin.f90
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ SUBROUTINE FinalizeMeshReadin()
#endif /*USE_MPI*/

! Then, free the pointers or arrays
ADEALLOCATE(SideIsSymSide_Shared)
ADEALLOCATE(ElemVolume_Shared)
ADEALLOCATE(ElemCharLength_Shared)

Expand Down
2 changes: 2 additions & 0 deletions src/particles/particle_mesh/particle_mesh_vars.f90
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@ MODULE MOD_Particle_Mesh_Vars
REAL,ALLOCPOINT :: ElemCharLengthX_Shared(:)
REAL,ALLOCPOINT :: ElemCharLengthY_Shared(:)
REAL,ALLOCPOINT :: ElemCharLengthZ_Shared(:)
LOGICAL,ALLOCPOINT :: SideIsSymSide_Shared(:)

#if USE_MPI
INTEGER :: SideIsSymSide_Shared_Win
! integers to hold shared memory windows
INTEGER :: NodeToElemMapping_Shared_Win
INTEGER :: NodeToElemInfo_Shared_Win
Expand Down
10 changes: 5 additions & 5 deletions src/particles/surfacemodel/surfacemodel_main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -287,18 +287,18 @@ SUBROUTINE MaxwellScattering(PartID,SideID,n_loc,SpecularReflectionOnly_opt)
ACC = PartBound%MomentumACC(iBC)

! Check if optional parameter was supplied
ASSOCIATE( SpecularReflectionOnly => MERGE(SpecularReflectionOnly_opt, .FALSE., PRESENT(SpecularReflectionOnly_opt)) )
IF (SpecularReflectionOnly.OR.ACC.EQ.0.0) THEN
ASSOCIATE( SpecularReflectionOnly => MERGE(SpecularReflectionOnly_opt,PartBound%OnlySpecular(iBC),PRESENT(SpecularReflectionOnly_opt)))
IF (SpecularReflectionOnly) THEN
CALL PerfectReflection(PartID,SideID,n_loc)
ELSE IF(ACC.LT.1.0) THEN
ELSE IF(PartBound%OnlyDiffuse(iBC)) THEN
CALL DiffuseReflection(PartID,SideID,n_loc)
ELSE
CALL RANDOM_NUMBER(RanNum)
IF(RanNum.GE.ACC) THEN
CALL PerfectReflection(PartID,SideID,n_loc)
ELSE
CALL DiffuseReflection(PartID,SideID,n_loc)
END IF
ELSE
CALL DiffuseReflection(PartID,SideID,n_loc)
END IF
END ASSOCIATE

Expand Down
5 changes: 5 additions & 0 deletions src/particles/tracking/particle_triatracking.f90
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ SUBROUTINE ParticleTriaTracking()
USE MOD_Mesh_Tools ,ONLY: GetCNElemID
USE MOD_Particle_Vars ,ONLY: PEM,PDM,PartSpecies
USE MOD_Particle_Vars ,ONLY: PartState,LastPartPos
USE MOD_Particle_Vars ,ONLY: Symmetry
USE MOD_Particle_Mesh_Tools ,ONLY: ParticleInsideQuad3D
USE MOD_Particle_Mesh_Vars
USE MOD_Particle_Tracking_vars ,ONLY: ntracks,MeasureTrackTime,CountNbrOfLostParts, NbrOfLostParticles, TrackInfo
Expand Down Expand Up @@ -154,6 +155,10 @@ SUBROUTINE ParticleTriaTracking()
nlocSides = ElemInfo_Shared(ELEM_LASTSIDEIND,ElemID) - ElemInfo_Shared(ELEM_FIRSTSIDEIND,ElemID)
DO iLocSide=1,nlocSides
TempSideID = ElemInfo_Shared(ELEM_FIRSTSIDEIND,ElemID) + iLocSide
! Skip symmetry side
IF(Symmetry%Order.EQ.2) THEN
IF(SideIsSymSide_Shared(TempSideID)) CYCLE
END IF
localSideID = SideInfo_Shared(SIDE_LOCALID,TempSideID)

! Side is not one of the 6 local sides
Expand Down

0 comments on commit ae216e6

Please sign in to comment.