Working on init for new physical surfaces

This commit is contained in:
Jorge Gonzalez 2026-02-19 20:42:28 +01:00
commit a0d45503f7
6 changed files with 93 additions and 54 deletions

View file

@ -49,6 +49,9 @@ MODULE moduleInput
CALL checkStatus(config, "readBoundaryEM") CALL checkStatus(config, "readBoundaryEM")
! Read Physical Surfaces ! Read Physical Surfaces
call verboseError('Reading Physical Surfaces...')
call readPhysicalSurfaces(config)
call checkStatus(config, 'readPhysicalSurfaces')
!Read Geometry !Read Geometry
CALL verboseError('Reading Geometry...') CALL verboseError('Reading Geometry...')
@ -895,6 +898,8 @@ MODULE moduleInput
write(ps, '(I2)') ps write(ps, '(I2)') ps
object = 'physicalSurfaces(' // TRIM(bString) // ')' object = 'physicalSurfaces(' // TRIM(bString) // ')'
allocate(physicalSurfaces(ps)%nodes(0))
allocate(physicalSurfaces(ps)%edges(0))
call config%get(object // '.index', physicalSurfaces(ps)%index, found) call config%get(object // '.index', physicalSurfaces(ps)%index, found)
if (.not. found) then if (.not. found) then
call criticalError('Physical surface index not found', 'readPhysicalSurfaces') call criticalError('Physical surface index not found', 'readPhysicalSurfaces')

View file

@ -104,7 +104,7 @@ MODULE moduleMesh3DCart
!EDGE FUNCTIONS !EDGE FUNCTIONS
!Init surface element !Init surface element
SUBROUTINE initEdge3DCartTria(self, n, p, btPart, btEM) SUBROUTINE initEdge3DCartTria(self, n, p, ps)
USE moduleSpecies, only: nSpecies USE moduleSpecies, only: nSpecies
USE moduleErrors USE moduleErrors
USE moduleMath USE moduleMath
@ -114,8 +114,8 @@ MODULE moduleMesh3DCart
CLASS(meshEdge3DCartTria), INTENT(out):: self CLASS(meshEdge3DCartTria), INTENT(out):: self
INTEGER, INTENT(in):: n INTEGER, INTENT(in):: n
INTEGER, INTENT(in):: p(:) INTEGER, INTENT(in):: p(:)
INTEGER, INTENT(in):: btPart(1:nSpecies) INTEGER, INTENT(in):: ps
integer, intent(in):: btEM integer:: ps_index
REAL(8), DIMENSION(1:3):: r1, r2, r3 REAL(8), DIMENSION(1:3):: r1, r2, r3
REAL(8), DIMENSION(1:3):: vec1, vec2 REAL(8), DIMENSION(1:3):: vec1, vec2
INTEGER:: s INTEGER:: s
@ -144,16 +144,8 @@ MODULE moduleMesh3DCart
self%surface = 1.D0/L_ref**2 !TODO: FIX THIS WHEN MOVING TO 3D self%surface = 1.D0/L_ref**2 !TODO: FIX THIS WHEN MOVING TO 3D
!Boundary particle linking ps_index = physicalSurface_to_index(ps)
allocate(self%boundariesParticle(1:nSpecies))
!Assign functions to particle boundary
do s = 1, nSpecies
self%boundariesParticle(s)%obj => boundariesParticle(btPart(s))%obj
end do
! Add nodes to EM boundary
call boundariesEMLinking(btEM)%model%addNodes(self%getNodes(self%nNodes))
END SUBROUTINE initEdge3DCartTria END SUBROUTINE initEdge3DCartTria

View file

@ -364,12 +364,8 @@ MODULE moduleMeshInputVTU
END SELECT END SELECT
!Associate boundary condition procedure.
btPart = physicalSurface_to_id(boundariesParticleLinking, entitiesID(n))
btEM = physicalSurface_to_id(boundariesEMLinking, entitiesID(n))
!Init edge !Init edge
CALL self%edges(e)%obj%init(n, p, boundariesParticleLinking(btPart)%speciesIndex, btEM) CALL self%edges(e)%obj%init(n, p, entitiesID(n))
DEALLOCATE(p) DEALLOCATE(p)

View file

@ -937,9 +937,27 @@ MODULE moduleMesh
class(meshEdgePointer), allocatable:: edges(:) class(meshEdgePointer), allocatable:: edges(:)
class(boundaryParticlePointer), allocatable:: particles(:) class(boundaryParticlePointer), allocatable:: particles(:)
class(boundaryEMGeneric), pointer:: EM => null() class(boundaryEMGeneric), pointer:: EM => null()
contains
procedure, pass:: addNode
procedure, pass:: addEdge
end type end type
interface
module subroutine addNode(self, node)
class(physicalSurface), intent(inout):: self
integer, intent(in):: node
end subroutine addNode
module subroutine addEdge(self, edge)
class(physicalSurface), intent(inout):: self
integer, intent(in):: edge
end subroutine addEdge
end interface
integer:: nPhysicalSurfaces integer:: nPhysicalSurfaces
type(physicalSurface), allocatable:: physicalSurfaces(:) type(physicalSurface), allocatable:: physicalSurfaces(:)

View file

@ -24,42 +24,6 @@ submodule(moduleMesh) boundaryEM
end function boundaryEMName_to_Index end function boundaryEMName_to_Index
subroutine addNodes(self, nodes)
implicit none
class(boundaryEMGeneric), intent(inout):: self
integer, intent(in):: nodes(:)
integer:: n, nn, nNodes
logical:: inArray
type(meshNodePointer):: nodeToAdd
nNodes = size(nodes)
! Collect all nodes that are not already in the boundary
DO n = 1, nNodes
nodeToAdd%obj => mesh%nodes(nodes(n))%obj
inArray = .false.
! I cannot use the procedure 'any' for this
do nn = 1 , size(self%nodes)
IF (self%nodes(nn) == nodeToAdd) THEN
! Node already in array
inArray = .true.
exit
end if
end do
if (.not. inArray) then
! If not, add element to array of nodes
self%nodes = [self%nodes, nodeToAdd]
end if
end do
end subroutine addNodes
module subroutine initBoundaryEM(self, config, object, b) module subroutine initBoundaryEM(self, config, object, b)
use json_module use json_module
use moduleErrors use moduleErrors

View file

@ -19,4 +19,68 @@ submodule(moduleMesh) surfaces
end function physicalSurface_to_index end function physicalSurface_to_index
subroutine addNode(self, node)
implicit none
class(physicalSurface), intent(inout):: self
integer, intent(in):: node
integer:: n, nn
logical:: inArray
associate(nodeToAdd => mesh%nodes(node)%obj)
inArray = .false.
! I cannot use the procedure 'any' for this
do nn = 1 , size(self%nodes)
IF (self%nodes(nn)%obj == nodeToAdd) THEN
! Node already in array
inArray = .true.
exit
end if
end do
if (.not. inArray) then
! If not, add element to array of nodes
self%nodes = [self%nodes, nodeToAdd]
end if
end associate
end subroutine addNode
subroutine addEdge(self, edge)
implicit none
class(physicalSurface), intent(inout):: self
integer, intent(in):: edge
integer:: n, nn
logical:: inArray
associate(edgeToAdd => mesh%edges(edge)%obj)
inArray = .false.
! I cannot use the procedure 'any' for this
do nn = 1 , size(self%edges)
IF (self%edges(nn) == edgeToAdd) THEN
! Node already in array
inArray = .true.
exit
end if
end do
if (.not. inArray) then
! If not, add element to array of nodes
self%edges = [self%edges, edgeToAdd]
end if
end associate
end subroutine addEdge
end submodule surfaces end submodule surfaces