Almost done with EM, not to modify the EM module itself

This commit is contained in:
Jorge Gonzalez 2026-02-18 15:14:59 +01:00
commit d211ed9a71
13 changed files with 165 additions and 97 deletions

View file

@ -812,15 +812,15 @@ MODULE moduleInput
END DO
! Read linking
CALL config%info('boundaries.particles.linking', found, n_children = nPhysicalSurfaces)
! Link physical surfaces to boundaries
call config%info('boundaries.particles.linking', found, n_children = nPhysicalSurfaces)
allocate(boundaryParticlesLinking(1:nPhysicalSurfaces))
allocate(speciesNames(1:nSpecies))
do b = 1, nPhysicalSurfaces
write(iString, '(i2)') b
object = 'boundary.particles.linking(' // trim(iString) // ')'
call config%get(object // '.physicalSurfaces', boundaryParticlesLinking(b)%physicalSurface, found)
call config%get(object // '.models', speciesNames, found)
call config%get(object // '.physicalSurface', boundaryParticlesLinking(b)%physicalSurface, found)
call config%get(object // '.model', speciesNames, found)
allocate(boundaryParticlesLinking(b)%speciesIndex(1:nSpecies))
do s = 1, nSpecies
boundaryParticlesLinking(b)%speciesIndex(s) = boundaryParticlesName_to_Index(speciesNames(s))
@ -1093,14 +1093,9 @@ MODULE moduleInput
TYPE(json_file), INTENT(inout):: config
CHARACTER(:), ALLOCATABLE:: object
LOGICAL:: found
CHARACTER(:), ALLOCATABLE:: typeEM
REAL(8):: potential
INTEGER:: physicalSurface
CHARACTER(:), ALLOCATABLE:: temporalProfile, temporalProfilePath
INTEGER:: b, s, n, ni
INTEGER:: b
CHARACTER(2):: bString
INTEGER:: info
EXTERNAL:: dgetrf
character(len=100), allocatable:: modelName(:)
CALL config%info('boundaries.EM.models', found, n_children = nBoundariesEM)
@ -1109,14 +1104,27 @@ MODULE moduleInput
END IF
DO b = 1, nBoundaryEM
WRITE(bString, '(I2)') b
do b = 1, nBoundaryEM
write(bString, '(I2)') b
object = 'boundaries.EM.models(' // TRIM(bString) // ')'
call boundariesEM(b)%init(config, object, b)
end do
! Link physical surfaces to boundaries
call config%info('boundaries.EM.linking', found, n_children = nPhysicalSurfaces)
allocate(boundaryEMLinking(1:nPhysicalSurfaces))
allocate(speciesNames(1:nSpecies))
do b = 1, nPhysicalSurfaces
write(iString, '(i2)') b
object = 'boundary.EM.linking(' // trim(iString) // ')'
call config%get(object // '.physicalSurface', boundaryEMLinking(b)%physicalSurface, found)
call config%get(object // '.model', modelName, found)
boundaryEMLinking(b)%model => boundariesEM(boundaryEMName_to_Index(modelName(s)))%obj
end do
! TODO: Move this to the init of species
ALLOCATE(qSpecies(1:nSpecies))
DO s = 1, nSpecies
@ -1131,37 +1139,6 @@ MODULE moduleInput
END DO
! TODO: Do this after the mesh has been read
! Modify K matrix due to 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
mesh%K(ni, :) = 0.D0
mesh%K(ni, ni) = 1.D0
END DO
TYPE IS(boundaryEMDirichletTime)
DO n = 1, boundary%nNodes
ni = boundary%nodes(n)%obj%n
mesh%K(ni, :) = 0.D0
mesh%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(mesh%numNodes, mesh%numNodes, mesh%K, mesh%numNodes, mesh%IPIV, info)
IF (info /= 0) THEN
CALL criticalError('Factorization of K matrix failed', 'readBoundaryEM')
END IF
END SUBROUTINE readBoundaryEM
!Reads the injection of particles from the boundaries