Init for boundaries particles

This commit is contained in:
Jorge Gonzalez 2026-02-16 20:05:23 +01:00
commit 6f8656bc21
6 changed files with 80 additions and 40 deletions

View file

@ -794,27 +794,46 @@ MODULE moduleInput
SUBROUTINE readBoundary(config) SUBROUTINE readBoundary(config)
use moduleMesh use moduleMesh
USE moduleErrors USE moduleErrors
USE moduleSpecies use moduleSpecies, only: nSpecies
USE moduleList, ONLY: partSurfaces USE moduleList, ONLY: partSurfaces
USE json_module USE json_module
IMPLICIT NONE IMPLICIT NONE
TYPE(json_file), INTENT(inout):: config TYPE(json_file), INTENT(inout):: config
INTEGER:: b integer:: b, s
CHARACTER(2):: iString character(2):: iString
CHARACTER(:), ALLOCATABLE:: object character(:), allocatable:: object
character(len=100), allocatable:: speciesNames(:)
LOGICAL:: found LOGICAL:: found
CALL config%info('boundary', found, n_children = nBoundary) ! Read models of particles
CALL config%info('boundaries.particles.models', found, n_children = nBoundary)
ALLOCATE(boundaries(1:nBoundary)) ALLOCATE(boundaries(1:nBoundary))
DO b = 1, nBoundary DO b = 1, nBoundary
WRITE(iString, '(i2)') b WRITE(iString, '(i2)') b
object = 'boundary(' // TRIM(iString) // ')' object = 'boundary.particles.models(' // TRIM(iString) // ')'
call boundaries(i)%init(config, object, b) call boundaries(i)%init(config, object, b)
END DO END DO
! Read linking
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)
allocate(boundaryParticlesLinking(b)%speciesIndex(1:nSpecies))
do s = 1, nSpecies
boundaryParticlesLinking(b)%speciesIndex(s) = boundaryParticlesName_to_Index(speciesNames(s))
end do
end do
!Init the list of particles from surfaces !Init the list of particles from surfaces
CALL OMP_INIT_LOCK(partSurfaces%lock) CALL OMP_INIT_LOCK(partSurfaces%lock)

View file

@ -160,9 +160,6 @@ MODULE moduleMeshInputGmsh2
READ(10, *) n, elemType, eTemp, boundaryType READ(10, *) n, elemType, eTemp, boundaryType
BACKSPACE(10) BACKSPACE(10)
!Associate boundary condition procedure.
bt = getBoundaryID(boundaryType)
SELECT CASE(elemType) SELECT CASE(elemType)
CASE(2) CASE(2)
!Triangular surface !Triangular surface
@ -177,8 +174,6 @@ MODULE moduleMeshInputGmsh2
CASE (2) CASE (2)
ALLOCATE(p(1:2)) ALLOCATE(p(1:2))
READ(10,*) n, elemType, eTemp, boundaryType, eTemp, p(1:2) READ(10,*) n, elemType, eTemp, boundaryType, eTemp, p(1:2)
!Associate boundary condition procedure.
bt = getBoundaryId(boundaryType)
SELECT CASE(self%geometry) SELECT CASE(self%geometry)
CASE("Cyl") CASE("Cyl")
@ -192,8 +187,6 @@ MODULE moduleMeshInputGmsh2
CASE(1) CASE(1)
ALLOCATE(p(1:1)) ALLOCATE(p(1:1))
READ(10, *) n, elemType, eTemp, boundaryType, eTemp, p(1) READ(10, *) n, elemType, eTemp, boundaryType, eTemp, p(1)
!Associate boundary condition
bt = getBoundaryId(boundaryType)
SELECT CASE(self%geometry) SELECT CASE(self%geometry)
CASE("Rad") CASE("Rad")
ALLOCATE(meshEdge1DRad:: self%edges(e)%obj) ALLOCATE(meshEdge1DRad:: self%edges(e)%obj)
@ -205,7 +198,10 @@ MODULE moduleMeshInputGmsh2
END SELECT END SELECT
CALL self%edges(e)%obj%init(n, p, bt, boundaryType) !Associate boundary condition procedure.
bt = physicalSurface_to_id(boundaryType)
CALL self%edges(e)%obj%init(n, p, boundariesParticleLinking(bt)%speciesIndex)
DEALLOCATE(p) DEALLOCATE(p)
END DO END DO

View file

@ -141,8 +141,10 @@ module moduleMeshInputText
allocate(p(1)) allocate(p(1))
p(1) = n p(1) = n
bt = getBoundaryId(physicalID) !Associate boundary condition procedure.
call self%edges(physicalID)%obj%init(physicalID, p, physicalID, physicalID) bt = physicalSurface_to_id(physicalID)
call self%edges(physicalID)%obj%init(physicalID, p, boundariesParticleLinking(bt)%speciesIndex)
deallocate(p) deallocate(p)
end if end if

View file

@ -320,16 +320,9 @@ MODULE moduleMeshInputVTU
p(2) = connectivity(offsets(n) - 1) p(2) = connectivity(offsets(n) - 1)
p(3) = connectivity(offsets(n)) p(3) = connectivity(offsets(n))
!Associate boundary condition procedure.
bt = getBoundaryId(entitiesID(n))
!Allocate edge !Allocate edge
ALLOCATE(meshEdge3DCartTria:: self%edges(e)%obj) ALLOCATE(meshEdge3DCartTria:: self%edges(e)%obj)
!Init edge
CALL self%edges(e)%obj%init(n, p, bt, entitiesID(n))
DEALLOCATE(p)
END IF END IF
CASE(2) CASE(2)
@ -339,9 +332,6 @@ MODULE moduleMeshInputVTU
p(1) = connectivity(offsets(n) - 1) p(1) = connectivity(offsets(n) - 1)
p(2) = connectivity(offsets(n)) p(2) = connectivity(offsets(n))
!Associate boundary condition procedure.
bt = getBoundaryId(entitiesID(n))
!Allocate edge !Allocate edge
SELECT CASE(self%geometry) SELECT CASE(self%geometry)
CASE("Cyl") CASE("Cyl")
@ -352,10 +342,6 @@ MODULE moduleMeshInputVTU
END SELECT END SELECT
!Init edge
CALL self%edges(e)%obj%init(n, p, bt, entitiesID(n))
DEALLOCATE(p)
END IF END IF
CASE(1) CASE(1)
@ -364,9 +350,6 @@ MODULE moduleMeshInputVTU
ALLOCATE(p(1:1)) ALLOCATE(p(1:1))
p(1) = connectivity(offsets(n)) p(1) = connectivity(offsets(n))
!Associate boundary condition procedure.
bt = getBoundaryId(entitiesID(n))
!Allocate edge !Allocate edge
SELECT CASE(self%geometry) SELECT CASE(self%geometry)
CASE("Rad") CASE("Rad")
@ -377,14 +360,17 @@ MODULE moduleMeshInputVTU
END SELECT END SELECT
!Init edge
CALL self%edges(e)%obj%init(n, p, bt, entitiesID(n))
DEALLOCATE(p)
END IF END IF
END SELECT END SELECT
!Associate boundary condition procedure.
bt = physicalSurface_to_id(entitiesID(n))
!Init edge
CALL self%edges(e)%obj%init(n, p, boundariesParticleLinking(bt)%speciesIndex)
DEALLOCATE(p)
END DO END DO
END SELECT END SELECT

View file

@ -3,6 +3,7 @@ MODULE moduleMesh
USE moduleList USE moduleList
USE moduleOutput USE moduleOutput
USE moduleCollisions USE moduleCollisions
use moduleSpecies, only: nSpecies
IMPLICIT NONE IMPLICIT NONE
! Declarations for elements ! Declarations for elements
@ -784,9 +785,26 @@ MODULE moduleMesh
end type boundaryPointer end type boundaryPointer
type boundaryParticleLinking
integer:: physicalSurface
integer, allocatable, dimension(:):: speciesIndex
end type boundaryParticleLinking
!Number of boundaries !Number of boundaries
INTEGER:: nBoundaries = 0 INTEGER:: nBoundaries = 0, nPhysicalSurfaces = 0
!Array for boundaries !Array for boundaries
TYPE(boundaryCont), ALLOCATABLE, TARGET:: boundariesParticle(:) TYPE(boundaryCont), ALLOCATABLE, TARGET:: boundariesParticle(:)
!Array for linking boundaries
type(boundaryParticleLinking), allocatable, dimension(:):: boundariesParticleLinking
interface
module function physicalSurface_to_id(physicalSurface) result(b)
integer:: physicalSurface
integer:: b
end function physicalSurface_to_id
end interface
END MODULE moduleMesh END MODULE moduleMesh

View file

@ -1,7 +1,7 @@
!moduleMeshBoundary: Boundary functions for the mesh edges !moduleMeshBoundary: Boundary functions for the mesh edges
submodule(moduleMesh) boundary submodule(moduleMesh) boundary
contains contains
module function boundaryParticleName2Index(boundaryName) result(bp) module function boundaryParticleName_to_Index(boundaryName) result(bp)
use moduleErrors use moduleErrors
implicit none implicit none
@ -23,7 +23,7 @@ submodule(moduleMesh) boundary
end if end if
end function boundaryParticleName2Index end function boundaryParticleName_to_Index
module subroutine initBoundary(self, config, object, b) module subroutine initBoundary(self, config, object, b)
use json_module use json_module
@ -483,4 +483,23 @@ submodule(moduleMesh) boundary
end subroutine genericTransparent end subroutine genericTransparent
function physicalSurface_to_id(physicalSurface) result(b)
implicit none
integer:: physicalSurface
integer:: b
integer:: bt
do bt=1, nPhysicalSurfaces
if (boundariesParticleLinking(bt)%physicalSurface == physicalSurface) then
b = bt
exit
end if
end do
end function physicalSurface_to_id
end submodule boundary end submodule boundary