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)
use moduleMesh
USE moduleErrors
USE moduleSpecies
use moduleSpecies, only: nSpecies
USE moduleList, ONLY: partSurfaces
USE json_module
IMPLICIT NONE
TYPE(json_file), INTENT(inout):: config
INTEGER:: b
CHARACTER(2):: iString
CHARACTER(:), ALLOCATABLE:: object
integer:: b, s
character(2):: iString
character(:), allocatable:: object
character(len=100), allocatable:: speciesNames(:)
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))
DO b = 1, nBoundary
WRITE(iString, '(i2)') b
object = 'boundary(' // TRIM(iString) // ')'
object = 'boundary.particles.models(' // TRIM(iString) // ')'
call boundaries(i)%init(config, object, b)
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
CALL OMP_INIT_LOCK(partSurfaces%lock)

View file

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

View file

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

View file

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

View file

@ -3,6 +3,7 @@ MODULE moduleMesh
USE moduleList
USE moduleOutput
USE moduleCollisions
use moduleSpecies, only: nSpecies
IMPLICIT NONE
! Declarations for elements
@ -784,9 +785,26 @@ MODULE moduleMesh
end type boundaryPointer
type boundaryParticleLinking
integer:: physicalSurface
integer, allocatable, dimension(:):: speciesIndex
end type boundaryParticleLinking
!Number of boundaries
INTEGER:: nBoundaries = 0
INTEGER:: nBoundaries = 0, nPhysicalSurfaces = 0
!Array for boundaries
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

View file

@ -1,7 +1,7 @@
!moduleMeshBoundary: Boundary functions for the mesh edges
submodule(moduleMesh) boundary
contains
module function boundaryParticleName2Index(boundaryName) result(bp)
module function boundaryParticleName_to_Index(boundaryName) result(bp)
use moduleErrors
implicit none
@ -23,7 +23,7 @@ submodule(moduleMesh) boundary
end if
end function boundaryParticleName2Index
end function boundaryParticleName_to_Index
module subroutine initBoundary(self, config, object, b)
use json_module
@ -483,4 +483,23 @@ submodule(moduleMesh) boundary
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