From a0d45503f7386ca9827bb2eff734f749f6ce5355 Mon Sep 17 00:00:00 2001 From: JGonzalez Date: Thu, 19 Feb 2026 20:42:28 +0100 Subject: [PATCH] Working on init for new physical surfaces --- src/modules/init/moduleInput.f90 | 5 ++ src/modules/mesh/3DCart/moduleMesh3DCart.f90 | 18 ++---- .../mesh/inout/vtu/moduleMeshInputVTU.f90 | 6 +- src/modules/mesh/moduleMesh.f90 | 18 ++++++ src/modules/mesh/moduleMesh@boundaryEM.f90 | 36 ----------- src/modules/mesh/moduleMesh@surfaces.f90 | 64 +++++++++++++++++++ 6 files changed, 93 insertions(+), 54 deletions(-) diff --git a/src/modules/init/moduleInput.f90 b/src/modules/init/moduleInput.f90 index 42f6ea5..f332c19 100644 --- a/src/modules/init/moduleInput.f90 +++ b/src/modules/init/moduleInput.f90 @@ -49,6 +49,9 @@ MODULE moduleInput CALL checkStatus(config, "readBoundaryEM") ! Read Physical Surfaces + call verboseError('Reading Physical Surfaces...') + call readPhysicalSurfaces(config) + call checkStatus(config, 'readPhysicalSurfaces') !Read Geometry CALL verboseError('Reading Geometry...') @@ -895,6 +898,8 @@ MODULE moduleInput write(ps, '(I2)') ps object = 'physicalSurfaces(' // TRIM(bString) // ')' + allocate(physicalSurfaces(ps)%nodes(0)) + allocate(physicalSurfaces(ps)%edges(0)) call config%get(object // '.index', physicalSurfaces(ps)%index, found) if (.not. found) then call criticalError('Physical surface index not found', 'readPhysicalSurfaces') diff --git a/src/modules/mesh/3DCart/moduleMesh3DCart.f90 b/src/modules/mesh/3DCart/moduleMesh3DCart.f90 index 78f19c7..d891ec7 100644 --- a/src/modules/mesh/3DCart/moduleMesh3DCart.f90 +++ b/src/modules/mesh/3DCart/moduleMesh3DCart.f90 @@ -104,7 +104,7 @@ MODULE moduleMesh3DCart !EDGE FUNCTIONS !Init surface element - SUBROUTINE initEdge3DCartTria(self, n, p, btPart, btEM) + SUBROUTINE initEdge3DCartTria(self, n, p, ps) USE moduleSpecies, only: nSpecies USE moduleErrors USE moduleMath @@ -114,8 +114,8 @@ MODULE moduleMesh3DCart CLASS(meshEdge3DCartTria), INTENT(out):: self INTEGER, INTENT(in):: n INTEGER, INTENT(in):: p(:) - INTEGER, INTENT(in):: btPart(1:nSpecies) - integer, intent(in):: btEM + INTEGER, INTENT(in):: ps + integer:: ps_index REAL(8), DIMENSION(1:3):: r1, r2, r3 REAL(8), DIMENSION(1:3):: vec1, vec2 INTEGER:: s @@ -144,16 +144,8 @@ MODULE moduleMesh3DCart self%surface = 1.D0/L_ref**2 !TODO: FIX THIS WHEN MOVING TO 3D - !Boundary particle linking - 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)) + ps_index = physicalSurface_to_index(ps) + END SUBROUTINE initEdge3DCartTria diff --git a/src/modules/mesh/inout/vtu/moduleMeshInputVTU.f90 b/src/modules/mesh/inout/vtu/moduleMeshInputVTU.f90 index 4b7542d..508f453 100644 --- a/src/modules/mesh/inout/vtu/moduleMeshInputVTU.f90 +++ b/src/modules/mesh/inout/vtu/moduleMeshInputVTU.f90 @@ -364,12 +364,8 @@ MODULE moduleMeshInputVTU END SELECT - !Associate boundary condition procedure. - btPart = physicalSurface_to_id(boundariesParticleLinking, entitiesID(n)) - btEM = physicalSurface_to_id(boundariesEMLinking, entitiesID(n)) - !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) diff --git a/src/modules/mesh/moduleMesh.f90 b/src/modules/mesh/moduleMesh.f90 index f4d4770..9132f39 100644 --- a/src/modules/mesh/moduleMesh.f90 +++ b/src/modules/mesh/moduleMesh.f90 @@ -937,9 +937,27 @@ MODULE moduleMesh class(meshEdgePointer), allocatable:: edges(:) class(boundaryParticlePointer), allocatable:: particles(:) class(boundaryEMGeneric), pointer:: EM => null() + contains + procedure, pass:: addNode + procedure, pass:: addEdge 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 type(physicalSurface), allocatable:: physicalSurfaces(:) diff --git a/src/modules/mesh/moduleMesh@boundaryEM.f90 b/src/modules/mesh/moduleMesh@boundaryEM.f90 index b5798a4..d3d20fd 100644 --- a/src/modules/mesh/moduleMesh@boundaryEM.f90 +++ b/src/modules/mesh/moduleMesh@boundaryEM.f90 @@ -24,42 +24,6 @@ submodule(moduleMesh) boundaryEM 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) use json_module use moduleErrors diff --git a/src/modules/mesh/moduleMesh@surfaces.f90 b/src/modules/mesh/moduleMesh@surfaces.f90 index ec91f41..e3d95dc 100644 --- a/src/modules/mesh/moduleMesh@surfaces.f90 +++ b/src/modules/mesh/moduleMesh@surfaces.f90 @@ -19,4 +19,68 @@ submodule(moduleMesh) surfaces 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