Switching to variable particle weight

I have to change the injection of particles. Each edge will receive a
similar number of particles and their weight will change to have a
constant density based on the geometry.

Still testing.
This commit is contained in:
Jorge Gonzalez 2024-07-04 10:56:13 +02:00
commit b972120ed5
3 changed files with 18 additions and 27 deletions

View file

@ -235,6 +235,7 @@ MODULE moduleMesh2DCyl
p1 = (/self%z(1), self%r(1) /)
p2 = (/self%z(2), self%r(2) /)
r(1:2) = (1.D0 - rnd)*p1 + rnd*p2
r(2) = (self%r(2) + self%r(1)) * 0.5D0
r(3) = 0.D0
END FUNCTION randPosEdge
@ -578,9 +579,6 @@ MODULE moduleMesh2DCyl
REAL(8):: detJ
REAL(8):: fPsi(1:4)
REAL(8):: dPsi(1:3, 1:4), pDer(1:3, 1:3)
REAL(8):: nodeR(1:3)
REAL(8), PARAMETER:: correction = 0.81D0 !TODO: No idea why this is needed, this needs more attention. Probably a better
! calculation of the volume is needed.
self%volume = 0.D0
@ -594,26 +592,18 @@ MODULE moduleMesh2DCyl
!Computes total volume of the cell
self%volume = r*detJ*PI8 !4*2*pi
!Computes volume per node
self%n1%v = self%n1%v + fPsi(1)*self%volume
nodeR = self%n1%getCoordinates()
if (nodeR(2) == 0.D0) then
self%n1%v = self%n1%v * correction
end if
self%n2%v = self%n2%v + fPsi(2)*self%volume
nodeR = self%n2%getCoordinates()
if (nodeR(2) == 0.D0) then
self%n2%v = self%n2%v * correction
end if
self%n3%v = self%n3%v + fPsi(3)*self%volume
nodeR = self%n3%getCoordinates()
if (nodeR(2) == 0.D0) then
self%n3%v = self%n3%v * correction
end if
self%n4%v = self%n4%v + fPsi(4)*self%volume
nodeR = self%n4%getCoordinates()
if (nodeR(2) == 0.D0) then
self%n4%v = self%n4%v * correction
end if
Xi = (/-5.D-1, -5.D-1, 0.D0/)
r = self%gatherF(Xi, 4, self%r)
self%n1%v = self%n1%v + fPsi(1)*r*detJ*PI8
Xi = (/ 5.D-1, -5.D-1, 0.D0/)
r = self%gatherF(Xi, 4, self%r)
self%n2%v = self%n2%v + fPsi(2)*r*detJ*PI8
Xi = (/ 5.D-1, 5.D-1, 0.D0/)
r = self%gatherF(Xi, 4, self%r)
self%n3%v = self%n3%v + fPsi(3)*r*detJ*PI8
Xi = (/-5.D-1, 5.D-1, 0.D0/)
r = self%gatherF(Xi, 4, self%r)
self%n4%v = self%n4%v + fPsi(4)*r*detJ*PI8
END SUBROUTINE volumeQuad