Minor improvements in performance and code clarity.

Still no solution for the reset subroutine. It is really time
consumming.
This commit is contained in:
Jorge Gonzalez 2020-10-13 18:16:18 +02:00
commit ffb03e634b
12 changed files with 233 additions and 117 deletions

View file

@ -62,17 +62,18 @@ MODULE moduleMeshCyl
REAL(8):: arNodes(1:4) = 0.D0
CONTAINS
PROCEDURE, PASS:: init => initVolQuadCyl
PROCEDURE, PASS:: locKe => localKeQuad
PROCEDURE, PASS:: detJac => detJQuad
PROCEDURE, PASS:: invJ => invJQuad
PROCEDURE, PASS:: area => areaQuad
PROCEDURE, NOPASS:: weight => weightQuad
PROCEDURE, NOPASS:: inside => insideQuad
PROCEDURE, PASS:: dVal => dValQuad
PROCEDURE, PASS:: scatter => scatterQuad
PROCEDURE, PASS:: phy2log => phy2logQuad
PROCEDURE, PASS:: findCell => findCellCylQuad
PROCEDURE, PASS:: init => initVolQuadCyl
PROCEDURE, PASS:: locKe => localKeQuad
PROCEDURE, PASS:: detJac => detJQuad
PROCEDURE, PASS:: invJ => invJQuad
PROCEDURE, PASS:: area => areaQuad
PROCEDURE, NOPASS:: weight => weightQuad
PROCEDURE, NOPASS:: inside => insideQuad
PROCEDURE, PASS:: dVal => dValQuad
PROCEDURE, PASS:: scatter => scatterQuad
PROCEDURE, PASS:: phy2log => phy2logQuad
PROCEDURE, PASS:: findCell => findCellCylQuad
PROCEDURE, PASS:: resetOutput => resetOutputQuad
END TYPE meshVolCylQuad
@ -430,7 +431,7 @@ MODULE moduleMeshCyl
USE moduleSpecies
IMPLICIT NONE
CLASS(meshVolCylQuad), INTENT(in):: self
CLASS(meshVolCylQuad), INTENT(inout):: self
CLASS(meshVol), OPTIONAL, INTENT(in):: oldCell
CLASS(particle), INTENT(inout):: part
REAL(8):: xLog(1:2)
@ -482,6 +483,36 @@ MODULE moduleMeshCyl
END SUBROUTINE findCellCylQuad
PURE SUBROUTINE resetOutputQuad(self)
USE moduleSpecies
USE moduleOutput
IMPLICIT NONE
CLASS(meshVolCylQuad), INTENT(inout):: self
INTEGER:: k
DO k = 1, nSpecies
self%n1%output(k)%den = 0.D0
self%n1%output(k)%mom = 0.D0
self%n1%output(k)%tensorS = 0.D0
self%n2%output(k)%den = 0.D0
self%n2%output(k)%mom = 0.D0
self%n2%output(k)%tensorS = 0.D0
self%n3%output(k)%den = 0.D0
self%n3%output(k)%mom = 0.D0
self%n3%output(k)%tensorS = 0.D0
self%n4%output(k)%den = 0.D0
self%n4%output(k)%mom = 0.D0
self%n4%output(k)%tensorS = 0.D0
END DO
END SUBROUTINE resetOutputQuad
SUBROUTINE collision2DCyl(self)
USE moduleRefParam
USE moduleConstParam
@ -492,45 +523,41 @@ MODULE moduleMeshCyl
CLASS(meshVolCyl), INTENT(inout):: self
INTEGER:: Npart !Number of particles inside the cell
INTEGER:: Ncoll !Maximum number of collisions
REAL(8):: Fn !Specific weight
REAL(8):: Pmax !Maximum probability of collision
INTEGER:: i,j !random particles index
INTEGER:: rnd !random index
TYPE(particle), POINTER:: part_i, part_j
INTEGER:: n !collision
INTEGER:: ij, k
REAL(8):: sigmaVrel
REAL(8):: sigmaVrelMaxNew
Fn = species(1)%obj%weight!Check how to do this for multiple species
Fn = species(1)%obj%weight!TODO: Check how to do this for multiple species
Npart = self%listPart_in%amount
Pmax = Fn*self%sigmaVrelMax*tau/self%volume
Ncoll = INT(REAL(Npart*(Npart-1))*Pmax*0.5D0)
self%nColl = Ncoll
self%nColl = INT(REAL(Npart*(Npart-1))*Pmax*0.5D0)
DO n = 1, NColl
DO n = 1, self%NColl
!Select random numbers
rnd = 1 + FLOOR(Npart*RAND())
i = self%listPart_in%get(rnd)
part_i => part_old(i)
part_i => self%listPart_in%get(rnd)
rnd = 1 + FLOOR(Npart*RAND())
j = self%listPart_in%get(rnd)
part_j => part_old(j)
part_j => self%listPart_in%get(rnd)
ij = interactionIndex(part_i%pt, part_j%pt)
sigmaVrelMaxNew = 0.D0
DO k = 1, interactionMatrix(ij)%amount
CALL interactionMatrix(ij)%collisions(k)%obj%collide(self%sigmaVrelMax, sigmaVrel, part_i, part_j)
sigmaVrelMaxNew = sigmaVrel + SigmaVrelMaxNew
CALL interactionMatrix(ij)%collisions(k)%obj%collide(self%sigmaVrelMax, sigmaVrelMaxNew, part_i, part_j)
END DO
!Update maximum cross section times vrelative per each collision
IF (sigmaVrelMaxNew > self%sigmaVrelMax) self%sigmaVrelMax = sigmaVrelMaxNew
END DO
!Reset output in nodes
CALL self%resetOutput()
!Erase the list of particles inside the cell
CALL self%listPart_in%erase()
END SUBROUTINE collision2DCyl