Almost done with EM, not to modify the EM module itself
This commit is contained in:
parent
0379ea42c2
commit
d211ed9a71
13 changed files with 165 additions and 97 deletions
|
|
@ -1,7 +1,7 @@
|
|||
submodule(moduleMesh) elements
|
||||
CONTAINS
|
||||
!Reset the output of node
|
||||
PURE module SUBROUTINE resetOutput(self)
|
||||
PURE SUBROUTINE resetOutput(self)
|
||||
USE moduleSpecies
|
||||
USE moduleOutput
|
||||
IMPLICIT NONE
|
||||
|
|
@ -40,40 +40,73 @@ submodule(moduleMesh) elements
|
|||
end function meshNodePointer_equal_type_int
|
||||
|
||||
!Constructs the global K matrix
|
||||
PURE module SUBROUTINE constructGlobalK(self)
|
||||
SUBROUTINE constructGlobalK(self)
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(meshParticles), INTENT(inout):: self
|
||||
INTEGER:: c
|
||||
INTEGER, ALLOCATABLE:: n(:)
|
||||
INTEGER, ALLOCATABLE:: nodes(:)
|
||||
REAL(8), ALLOCATABLE:: localK(:,:)
|
||||
INTEGER:: i, j
|
||||
integer:: n, b, ni
|
||||
INTEGER:: info
|
||||
EXTERNAL:: dgetrf
|
||||
|
||||
DO c = 1, self%numCells
|
||||
associate(nNodes => self%cells(c)%obj%nNodes)
|
||||
ALLOCATE(n(1:nNodes))
|
||||
ALLOCATE(nodes(1:nNodes))
|
||||
ALLOCATE(localK(1:nNodes, 1:nNodes))
|
||||
n = self%cells(c)%obj%getNodes(nNodes)
|
||||
nodes = self%cells(c)%obj%getNodes(nNodes)
|
||||
localK = self%cells(c)%obj%elemK(nNodes)
|
||||
|
||||
DO i = 1, nNodes
|
||||
DO j = 1, nNodes
|
||||
self%K(n(i), n(j)) = self%K(n(i), n(j)) + localK(i, j)
|
||||
self%K(nodes(i), nodes(j)) = self%K(nodes(i), nodes(j)) + localK(i, j)
|
||||
|
||||
END DO
|
||||
|
||||
END DO
|
||||
|
||||
DEALLOCATE(n, localK)
|
||||
DEALLOCATE(nodes, localK)
|
||||
|
||||
end associate
|
||||
|
||||
END DO
|
||||
|
||||
! Modify K matrix due to EM boundary conditions
|
||||
DO b = 1, nBoundariesEM
|
||||
SELECT TYPE(boundary => boundariesEM(b)%obj)
|
||||
TYPE IS(boundaryEMDirichlet)
|
||||
DO n = 1, boundary%nNodes
|
||||
ni = boundary%nodes(n)%obj%n
|
||||
self%K(ni, :) = 0.D0
|
||||
self%K(ni, ni) = 1.D0
|
||||
|
||||
END DO
|
||||
|
||||
TYPE IS(boundaryEMDirichletTime)
|
||||
DO n = 1, boundary%nNodes
|
||||
ni = boundary%nodes(n)%obj%n
|
||||
self%K(ni, :) = 0.D0
|
||||
self%K(ni, ni) = 1.D0
|
||||
|
||||
END DO
|
||||
|
||||
END SELECT
|
||||
|
||||
END DO
|
||||
|
||||
!Compute the PLU factorization of K once boundary conditions have been read
|
||||
CALL dgetrf(self%numNodes, self%numNodes, self%K, self%numNodes, self%IPIV, info)
|
||||
IF (info /= 0) THEN
|
||||
CALL criticalError('Factorization of K matrix failed', 'readBoundaryEM')
|
||||
|
||||
END IF
|
||||
|
||||
END SUBROUTINE constructGlobalK
|
||||
|
||||
! Gather the value of valNodes at position Xi of an edge
|
||||
pure module function gatherF_edge_scalar(self, Xi, nNodes, valNodes) RESULT(f)
|
||||
pure function gatherF_edge_scalar(self, Xi, nNodes, valNodes) RESULT(f)
|
||||
implicit none
|
||||
|
||||
class(meshEdge), intent(in):: self
|
||||
|
|
@ -89,7 +122,7 @@ submodule(moduleMesh) elements
|
|||
end function gatherF_edge_scalar
|
||||
|
||||
!Gather the value of valNodes (scalar) at position Xi
|
||||
PURE module FUNCTION gatherF_cell_scalar(self, Xi, nNodes, valNodes) RESULT(f)
|
||||
PURE FUNCTION gatherF_cell_scalar(self, Xi, nNodes, valNodes) RESULT(f)
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(meshCell), INTENT(in):: self
|
||||
|
|
@ -105,7 +138,7 @@ submodule(moduleMesh) elements
|
|||
END FUNCTION gatherF_cell_scalar
|
||||
|
||||
!Gather the value of valNodes (array) at position Xi
|
||||
PURE module FUNCTION gatherF_cell_array(self, Xi, nNodes, valNodes) RESULT(f)
|
||||
PURE FUNCTION gatherF_cell_array(self, Xi, nNodes, valNodes) RESULT(f)
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(meshCell), INTENT(in):: self
|
||||
|
|
@ -121,7 +154,7 @@ submodule(moduleMesh) elements
|
|||
END FUNCTION gatherF_cell_array
|
||||
|
||||
!Gather the spatial derivative of valNodes (scalar) at position Xi
|
||||
PURE module FUNCTION gatherDF_cell_scalar(self, Xi, nNodes, valNodes) RESULT(df)
|
||||
PURE FUNCTION gatherDF_cell_scalar(self, Xi, nNodes, valNodes) RESULT(df)
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(meshCell), INTENT(in):: self
|
||||
|
|
@ -146,7 +179,7 @@ submodule(moduleMesh) elements
|
|||
END FUNCTION gatherDF_cell_scalar
|
||||
|
||||
!Scatters particle properties into cell nodes
|
||||
module SUBROUTINE scatter(self, nNodes, part)
|
||||
SUBROUTINE scatter(self, nNodes, part)
|
||||
USE moduleMath
|
||||
USE moduleSpecies
|
||||
USE OMP_LIB
|
||||
|
|
@ -184,7 +217,7 @@ submodule(moduleMesh) elements
|
|||
END SUBROUTINE scatter
|
||||
|
||||
!Find next cell for particle
|
||||
RECURSIVE module SUBROUTINE findCell(self, part, oldCell)
|
||||
RECURSIVE SUBROUTINE findCell(self, part, oldCell)
|
||||
USE moduleSpecies
|
||||
USE moduleErrors
|
||||
USE OMP_LIB
|
||||
|
|
@ -248,7 +281,7 @@ submodule(moduleMesh) elements
|
|||
END SUBROUTINE findCell
|
||||
|
||||
!If Coll and Particle are the same, simply copy the part%cell into part%cellColl
|
||||
module SUBROUTINE findCellSameMesh(part)
|
||||
SUBROUTINE findCellSameMesh(part)
|
||||
USE moduleSpecies
|
||||
IMPLICIT NONE
|
||||
|
||||
|
|
@ -261,7 +294,7 @@ submodule(moduleMesh) elements
|
|||
!TODO: try to combine this with the findCell for a regular mesh
|
||||
!Find the volume in which particle reside in the mesh for collisions
|
||||
!No boundary interaction taken into account
|
||||
module SUBROUTINE findCellCollMesh(part)
|
||||
SUBROUTINE findCellCollMesh(part)
|
||||
USE moduleSpecies
|
||||
IMPLICIT NONE
|
||||
|
||||
|
|
@ -311,7 +344,7 @@ submodule(moduleMesh) elements
|
|||
!Returns index of volume associated to a position (if any)
|
||||
!If no voulme is found, returns 0
|
||||
!WARNING: This function is slow and should only be used in initialization phase
|
||||
module FUNCTION findCellBrute(self, r) RESULT(nVol)
|
||||
FUNCTION findCellBrute(self, r) RESULT(nVol)
|
||||
USE moduleSpecies
|
||||
IMPLICIT NONE
|
||||
|
||||
|
|
@ -337,7 +370,7 @@ submodule(moduleMesh) elements
|
|||
END FUNCTION findCellBrute
|
||||
|
||||
!Computes collisions in element
|
||||
module SUBROUTINE doCollisions(self)
|
||||
SUBROUTINE doCollisions(self)
|
||||
USE moduleCollisions
|
||||
USE moduleSpecies
|
||||
USE moduleList
|
||||
|
|
@ -501,7 +534,7 @@ submodule(moduleMesh) elements
|
|||
|
||||
END SUBROUTINE doCollisions
|
||||
|
||||
module SUBROUTINE doCoulomb(self)
|
||||
SUBROUTINE doCoulomb(self)
|
||||
USE moduleCoulomb
|
||||
USE moduleRandom
|
||||
USE moduleOutput
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue