Merge branch 'feature/collisionPairs' into feature/electromagnetic

Merging branches and fixing a number of important issues:

- Initial particles were not being assigned to the list of particles.

- List of particles was being erased every iteration, even if species
  was not pushed.

These caused issues with the calculation of collisions when a species
was frozen.

Now, things should work properly. All particles are properly added to
the volume list and the list is erased ONLY if the species has been
updated.

I hope that collisions are now properly accounted for per species pair.
This commit is contained in:
Jorge Gonzalez 2022-04-23 20:48:34 +02:00
commit cbb5fe0bf2
12 changed files with 179 additions and 81 deletions

View file

@ -457,6 +457,7 @@ MODULE moduleSolver
INTEGER, SAVE:: nPartNew
INTEGER, SAVE:: nInjIn, nOldIn, nWScheme, nCollisions, nSurfaces
TYPE(particle), ALLOCATABLE, SAVE:: partTemp(:)
INTEGER:: s
!$OMP SECTIONS
!$OMP SECTION
@ -540,18 +541,30 @@ MODULE moduleSolver
END DO
!$OMP SECTION
!Erase the list of particles inside the cell
DO e = 1, mesh%numVols
mesh%vols(e)%obj%totalWeight = 0.D0
CALL mesh%vols(e)%obj%listPart_in%erase()
!Erase the list of particles inside the cell if particles have been pushed
DO s = 1, nSpecies
DO e = 1, mesh%numVols
IF (solver%pusher(s)%pushSpecies) THEN
CALL mesh%vols(e)%obj%listPart_in(s)%erase()
mesh%vols(e)%obj%totalWeight(s) = 0.D0
END IF
END DO
END DO
!$OMP SECTION
!Erase the list of particles inside the cell in coll mesh
DO e = 1, meshColl%numVols
meshColl%vols(e)%obj%totalWeight = 0.D0
CALL meshColl%vols(e)%obj%listPart_in%erase()
DO s = 1, nSpecies
DO e = 1, meshColl%numVols
IF (solver%pusher(s)%pushSpecies) THEN
CALL meshColl%vols(e)%obj%listPart_in(s)%erase()
meshColl%vols(e)%obj%totalWeight(s) = 0.D0
END IF
END DO
END DO
@ -685,6 +698,7 @@ MODULE moduleSolver
REAL(8):: newWeight
TYPE(particle), POINTER:: newPart
INTEGER:: p
INTEGER:: sp
newWeight = part%weight / nSplit
@ -697,12 +711,14 @@ MODULE moduleSolver
ALLOCATE(newPart)
!Copy data from original particle
newPart = part
!Add particle to list of new particles from weighting scheme
CALL OMP_SET_LOCK(lockWScheme)
CALL partWScheme%add(newPart)
CALL OMP_UNSET_LOCK(lockWScheme)
!Add particle to cell list
CALL OMP_SET_lock(vol%lock)
CALL vol%listPart_in%add(newPart)
sp = part%species%n
CALL vol%listPart_in(sp)%add(newPart)
CALL OMP_UNSET_lock(vol%lock)
END DO