Reduction in pushing
Reduction in 10-20% of time spend in pushing in 2DCyl thanks to rewriting fPsi and dPsi.
This commit is contained in:
parent
0db76083ec
commit
2486ef6316
18 changed files with 1289 additions and 1280 deletions
|
|
@ -46,40 +46,6 @@ MODULE moduleEM
|
|||
|
||||
END SUBROUTINE
|
||||
|
||||
PURE FUNCTION gatherElecField(part) RESULT(elField)
|
||||
USE moduleSpecies
|
||||
USE moduleMesh
|
||||
IMPLICIT NONE
|
||||
|
||||
TYPE(particle), INTENT(in):: part
|
||||
REAl(8):: xi(1:3) !Logical coordinates of particle in element
|
||||
REAL(8):: elField(1:3)
|
||||
|
||||
elField = 0.D0
|
||||
|
||||
xi = part%xi
|
||||
|
||||
elField = mesh%vols(part%vol)%obj%gatherEF(xi)
|
||||
|
||||
END FUNCTION gatherElecField
|
||||
|
||||
PURE FUNCTION gatherMagnField(part) RESULT(BField)
|
||||
USE moduleSpecies
|
||||
USE moduleMesh
|
||||
IMPLICIT NONE
|
||||
|
||||
TYPE(particle), INTENT(in):: part
|
||||
REAl(8):: xi(1:3) !Logical coordinates of particle in element
|
||||
REAL(8):: BField(1:3)
|
||||
|
||||
BField = 0.D0
|
||||
|
||||
xi = part%xi
|
||||
|
||||
BField = mesh%vols(part%vol)%obj%gatherMF(xi)
|
||||
|
||||
END FUNCTION gatherMagnField
|
||||
|
||||
!Assemble the source vector based on the charge density to solve Poisson's equation
|
||||
SUBROUTINE assembleSourceVector(vectorF)
|
||||
USE moduleMesh
|
||||
|
|
@ -99,8 +65,8 @@ MODULE moduleEM
|
|||
!$OMP END SINGLE
|
||||
|
||||
!$OMP DO REDUCTION(+:vectorF)
|
||||
DO e = 1, mesh%numVols
|
||||
nodes = mesh%vols(e)%obj%getNodes()
|
||||
DO e = 1, mesh%numCells
|
||||
nodes = mesh%cells(e)%obj%getNodes()
|
||||
nNodes = SIZE(nodes)
|
||||
!Calculates charge density (rho) in element nodes
|
||||
ALLOCATE(rho(1:nNodes))
|
||||
|
|
@ -113,7 +79,7 @@ MODULE moduleEM
|
|||
END DO
|
||||
|
||||
!Calculates local F vector
|
||||
localF = mesh%vols(e)%obj%elemF(rho)
|
||||
localF = mesh%cells(e)%obj%elemF(rho)
|
||||
|
||||
!Assign local F to global F
|
||||
DO i = 1, nNodes
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ MODULE moduleSolver
|
|||
IMPLICIT NONE
|
||||
|
||||
TYPE(particle), INTENT(inout):: part
|
||||
CLASS(meshVol), POINTER, INTENT(in):: volOld
|
||||
CLASS(meshVol), POINTER, INTENT(inout):: volNew
|
||||
CLASS(meshCell), POINTER, INTENT(in):: volOld
|
||||
CLASS(meshCell), POINTER, INTENT(inout):: volNew
|
||||
|
||||
END SUBROUTINE weightingScheme_interface
|
||||
|
||||
|
|
@ -314,10 +314,10 @@ MODULE moduleSolver
|
|||
!$OMP SECTION
|
||||
!Erase the list of particles inside the cell if particles have been pushed
|
||||
DO s = 1, nSpecies
|
||||
DO e = 1, mesh%numVols
|
||||
DO e = 1, mesh%numCells
|
||||
IF (solver%pusher(s)%pushSpecies) THEN
|
||||
CALL mesh%vols(e)%obj%listPart_in(s)%erase()
|
||||
mesh%vols(e)%obj%totalWeight(s) = 0.D0
|
||||
CALL mesh%cells(e)%obj%listPart_in(s)%erase()
|
||||
mesh%cells(e)%obj%totalWeight(s) = 0.D0
|
||||
|
||||
END IF
|
||||
|
||||
|
|
@ -328,10 +328,10 @@ MODULE moduleSolver
|
|||
!$OMP SECTION
|
||||
!Erase the list of particles inside the cell in coll mesh
|
||||
DO s = 1, nSpecies
|
||||
DO e = 1, meshColl%numVols
|
||||
DO e = 1, meshColl%numCells
|
||||
IF (solver%pusher(s)%pushSpecies) THEN
|
||||
CALL meshColl%vols(e)%obj%listPart_in(s)%erase()
|
||||
meshColl%vols(e)%obj%totalWeight(s) = 0.D0
|
||||
CALL meshColl%cells(e)%obj%listPart_in(s)%erase()
|
||||
meshColl%cells(e)%obj%totalWeight(s) = 0.D0
|
||||
|
||||
END IF
|
||||
|
||||
|
|
@ -358,7 +358,7 @@ MODULE moduleSolver
|
|||
!Loops over the particles to scatter them
|
||||
!$OMP DO
|
||||
DO n = 1, nPartOld
|
||||
CALL mesh%vols(partOld(n)%vol)%obj%scatter(partOld(n))
|
||||
CALL mesh%cells(partOld(n)%vol)%obj%scatter(partOld(n))
|
||||
|
||||
END DO
|
||||
!$OMP END DO
|
||||
|
|
@ -383,8 +383,8 @@ MODULE moduleSolver
|
|||
IMPLICIT NONE
|
||||
|
||||
TYPE(particle), INTENT(inout):: part
|
||||
CLASS(meshVol), POINTER, INTENT(in):: volOld
|
||||
CLASS(meshVol), POINTER, INTENT(inout):: volNew
|
||||
CLASS(meshCell), POINTER, INTENT(in):: volOld
|
||||
CLASS(meshCell), POINTER, INTENT(inout):: volNew
|
||||
REAL(8):: fractionVolume, pSplit
|
||||
|
||||
!If particle changes volume to smaller cell
|
||||
|
|
@ -416,7 +416,7 @@ MODULE moduleSolver
|
|||
|
||||
TYPE(particle), INTENT(inout):: part
|
||||
INTEGER, INTENT(in):: nSplit
|
||||
CLASS(meshVol), INTENT(inout):: vol
|
||||
CLASS(meshCell), INTENT(inout):: vol
|
||||
REAL(8):: newWeight
|
||||
TYPE(particle), POINTER:: newPart
|
||||
INTEGER:: p
|
||||
|
|
@ -454,15 +454,15 @@ MODULE moduleSolver
|
|||
|
||||
CLASS(solverGeneric), INTENT(in):: self
|
||||
TYPE(particle), INTENT(inout):: part
|
||||
CLASS(meshVol), POINTER:: volOld, volNew
|
||||
CLASS(meshCell), POINTER:: volOld, volNew
|
||||
|
||||
!Assume that particle is outside the domain
|
||||
part%n_in = .FALSE.
|
||||
|
||||
volOld => mesh%vols(part%vol)%obj
|
||||
volOld => mesh%cells(part%vol)%obj
|
||||
CALL volOld%findCell(part)
|
||||
CALL findCellColl(part)
|
||||
volNew => mesh%vols(part%vol)%obj
|
||||
volNew => mesh%cells(part%vol)%obj
|
||||
!Call the NA shcme
|
||||
IF (ASSOCIATED(self%weightingScheme)) THEN
|
||||
CALL self%weightingScheme(part, volOld, volNew)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ MODULE modulePusher
|
|||
|
||||
PURE SUBROUTINE pushCartElectrostatic(part, tauIn)
|
||||
USE moduleSPecies
|
||||
USE moduleEM
|
||||
USE moduleMesh
|
||||
IMPLICIT NONE
|
||||
|
||||
TYPE(particle), INTENT(inout):: part
|
||||
|
|
@ -23,7 +23,8 @@ MODULE modulePusher
|
|||
REAL(8):: qmEFt(1:3)
|
||||
|
||||
!Get the electric field at particle position
|
||||
qmEFt = part%species%qm*gatherElecField(part)*tauIn
|
||||
qmEFT = mesh%cells(part%vol)%obj%gatherElectricField(part%Xi)
|
||||
qmEFt = qmEFt*part%species%qm*tauMin
|
||||
|
||||
!Update velocity
|
||||
part%v = part%v + qmEFt
|
||||
|
|
@ -34,8 +35,8 @@ MODULE modulePusher
|
|||
END SUBROUTINE pushCartElectrostatic
|
||||
|
||||
PURE SUBROUTINE pushCartElectromagnetic(part, tauIn)
|
||||
USE moduleSPecies
|
||||
USE moduleEM
|
||||
USE moduleSpecies
|
||||
USE moduleMesh
|
||||
USE moduleMath
|
||||
IMPLICIT NONE
|
||||
|
||||
|
|
@ -49,13 +50,14 @@ MODULE modulePusher
|
|||
|
||||
tauInHalf = tauIn *0.5D0
|
||||
!Half of the force o f the electric field
|
||||
qmEFt = part%species%qm*gatherElecField(part)*tauInHalf
|
||||
qmEFT = mesh%cells(part%vol)%obj%gatherElectricField(part%Xi)
|
||||
qmEFt = qmEFt*part%species%qm*tauInHalf
|
||||
|
||||
!Half step for electrostatic
|
||||
v_minus = part%v + qmEFt
|
||||
|
||||
!Full step rotation
|
||||
B = gatherMagnField(part)
|
||||
B = mesh%cells(part%vol)%obj%gatherMagneticField(part%Xi)
|
||||
BNorm = NORM2(B)
|
||||
IF (BNorm > 0.D0) THEN
|
||||
fn = DTAN(part%species%qm * tauInHalf*BNorm) / BNorm
|
||||
|
|
@ -112,7 +114,7 @@ MODULE modulePusher
|
|||
!Push one particle. Boris pusher for 2D Cyl Electrostatic particle
|
||||
PURE SUBROUTINE push2DCylElectrostatic(part, tauIn)
|
||||
USE moduleSpecies
|
||||
USE moduleEM
|
||||
USE moduleMesh
|
||||
IMPLICIT NONE
|
||||
|
||||
TYPE(particle), INTENT(inout):: part
|
||||
|
|
@ -124,7 +126,8 @@ MODULE modulePusher
|
|||
|
||||
part_temp = part
|
||||
!Get electric field at particle position
|
||||
qmEFt = part_temp%species%qm*gatherElecField(part_temp)*tauIn
|
||||
qmEFT = mesh%cells(part_temp%vol)%obj%gatherElectricField(part_temp%Xi)
|
||||
qmEFt = qmEFt*part_temp%species%qm*tauMin
|
||||
!z
|
||||
part_temp%v(1) = part%v(1) + qmEFt(1)
|
||||
part_temp%r(1) = part%r(1) + part_temp%v(1)*tauIn
|
||||
|
|
@ -153,7 +156,6 @@ MODULE modulePusher
|
|||
!Push one particle. Boris pusher for 1D Radial Neutral particle
|
||||
PURE SUBROUTINE push1DRadNeutral(part, tauIn)
|
||||
USE moduleSpecies
|
||||
USE moduleEM
|
||||
IMPLICIT NONE
|
||||
|
||||
TYPE(particle), INTENT(inout):: part
|
||||
|
|
@ -188,7 +190,7 @@ MODULE modulePusher
|
|||
!Push one particle. Boris pusher for 1D Radial Electrostatic particle
|
||||
PURE SUBROUTINE push1DRadElectrostatic(part, tauIn)
|
||||
USE moduleSpecies
|
||||
USE moduleEM
|
||||
USE moduleMesh
|
||||
IMPLICIT NONE
|
||||
|
||||
TYPE(particle), INTENT(inout):: part
|
||||
|
|
@ -200,7 +202,8 @@ MODULE modulePusher
|
|||
|
||||
part_temp = part
|
||||
!Get electric field at particle position
|
||||
qmEFt = part_temp%species%qm*gatherElecField(part_temp)*tauMin
|
||||
qmEFT = mesh%cells(part_temp%vol)%obj%gatherElectricField(part_temp%Xi)
|
||||
qmEFt = qmEFt*part_temp%species%qm*tauMin
|
||||
!r,theta
|
||||
v_p_oh_star(1) = part%v(1) + qmEFt(1)
|
||||
x_new = part%r(1) + v_p_oh_star(1)*tauIn
|
||||
|
|
@ -226,7 +229,6 @@ MODULE modulePusher
|
|||
!Dummy pusher for 0D geometry
|
||||
PURE SUBROUTINE push0D(part, tauIn)
|
||||
USE moduleSpecies
|
||||
USE moduleEM
|
||||
IMPLICIT NONE
|
||||
|
||||
TYPE(particle), INTENT(inout):: part
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue