Skeleton of boundaries for EM with new structure for mesh
This commit is contained in:
parent
4872bcc194
commit
6a7c92f62f
5 changed files with 269 additions and 224 deletions
141
src/modules/mesh/moduleMesh@boundaryEM.f90
Normal file
141
src/modules/mesh/moduleMesh@boundaryEM.f90
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
submodule(moduleMesh) boundaryEM
|
||||
CONTAINS
|
||||
SUBROUTINE findNodes(self, physicalSurface)
|
||||
USE moduleMesh
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(boundaryEMGeneric), INTENT(inout):: self
|
||||
INTEGER, INTENT(in):: physicalSurface
|
||||
CLASS(meshEdge), POINTER:: edge
|
||||
INTEGER, ALLOCATABLE:: nodes(:), nodesEdge(:)
|
||||
INTEGER:: nNodes, nodesNew
|
||||
INTEGER:: e, n
|
||||
|
||||
!Temporal array to hold nodes
|
||||
ALLOCATE(nodes(0))
|
||||
|
||||
! Loop thorugh the edges and identify those that are part of the boundary
|
||||
DO e = 1, mesh%numEdges
|
||||
edge => mesh%edges(e)%obj
|
||||
IF (edge%physicalSurface == physicalSurface) THEN
|
||||
! Edge is of the right boundary index
|
||||
! Get nodes in the edge
|
||||
nNodes = edge%nNodes
|
||||
nodesEdge = edge%getNodes(nNodes)
|
||||
! Collect all nodes that are not already in the temporal array
|
||||
DO n = 1, nNodes
|
||||
IF (ANY(nodes == nodesEdge(n))) THEN
|
||||
! Node already in array, skip
|
||||
CYCLE
|
||||
|
||||
ELSE
|
||||
! If not, add element to array of nodes
|
||||
nodes = [nodes, nodesEdge(n)]
|
||||
|
||||
END IF
|
||||
|
||||
END DO
|
||||
|
||||
END IF
|
||||
|
||||
END DO
|
||||
|
||||
! Point boundary to nodes
|
||||
nNodes = SIZE(nodes)
|
||||
ALLOCATE(self%nodes(nNodes))
|
||||
self%nNodes = nNodes
|
||||
DO n = 1, nNodes
|
||||
self%nodes(n)%obj => mesh%nodes(nodes(n))%obj
|
||||
|
||||
END DO
|
||||
|
||||
END SUBROUTINE findNodes
|
||||
|
||||
! Initialize Dirichlet boundary condition
|
||||
SUBROUTINE initDirichlet(self, physicalSurface, potential)
|
||||
USE moduleRefParam, ONLY: Volt_ref
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(boundaryEMGeneric), ALLOCATABLE, INTENT(out):: self
|
||||
INTEGER, INTENT(in):: physicalSurface
|
||||
REAL(8), INTENT(in):: potential
|
||||
|
||||
! Allocate boundary edge
|
||||
ALLOCATE(boundaryEMDirichlet:: self)
|
||||
|
||||
SELECT TYPE(self)
|
||||
TYPE IS(boundaryEMDirichlet)
|
||||
self%potential = potential / Volt_ref
|
||||
|
||||
CALL findNodes(self, physicalSurface)
|
||||
|
||||
END SELECT
|
||||
|
||||
END SUBROUTINE initDirichlet
|
||||
|
||||
! Initialize Dirichlet boundary condition
|
||||
SUBROUTINE initDirichletTime(self, physicalSurface, potential, temporalProfile)
|
||||
USE moduleRefParam, ONLY: Volt_ref, ti_ref
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(boundaryEMGeneric), ALLOCATABLE, INTENT(out):: self
|
||||
INTEGER, INTENT(in):: physicalSurface
|
||||
REAL(8), INTENT(in):: potential
|
||||
CHARACTER(:), ALLOCATABLE, INTENT(in):: temporalProfile
|
||||
|
||||
! Allocate boundary edge
|
||||
ALLOCATE(boundaryEMDirichletTime:: self)
|
||||
|
||||
SELECT TYPE(self)
|
||||
TYPE IS(boundaryEMDirichletTime)
|
||||
self%potential = potential / Volt_ref
|
||||
|
||||
CALL findNodes(self, physicalSurface)
|
||||
|
||||
CALL self%temporalProfile%init(temporalProfile)
|
||||
|
||||
CALL self%temporalProfile%convert(1.D0/ti_ref, 1.D0)
|
||||
|
||||
END SELECT
|
||||
|
||||
END SUBROUTINE initDirichletTime
|
||||
|
||||
!Apply Dirichlet boundary condition to the poisson equation
|
||||
SUBROUTINE applyDirichlet(self, vectorF)
|
||||
USE moduleMesh
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(boundaryEMDirichlet), INTENT(in):: self
|
||||
REAL(8), INTENT(inout):: vectorF(:)
|
||||
INTEGER:: n, ni
|
||||
|
||||
DO n = 1, self%nNodes
|
||||
self%nodes(n)%obj%emData%phi = self%potential
|
||||
vectorF(self%nodes(n)%obj%n) = self%nodes(n)%obj%emData%phi
|
||||
|
||||
END DO
|
||||
|
||||
END SUBROUTINE applyDirichlet
|
||||
|
||||
!Apply Dirichlet boundary condition with time temporal profile
|
||||
SUBROUTINE applyDirichletTime(self, vectorF)
|
||||
USE moduleMesh
|
||||
USE moduleCaseParam, ONLY: timeStep, tauMin
|
||||
IMPLICIT NONE
|
||||
|
||||
CLASS(boundaryEMDirichletTime), INTENT(in):: self
|
||||
REAL(8), INTENT(inout):: vectorF(:)
|
||||
REAL(8):: timeFactor
|
||||
INTEGER:: n, ni
|
||||
|
||||
timeFactor = self%temporalProfile%get(DBLE(timeStep)*tauMin)
|
||||
|
||||
DO n = 1, self%nNodes
|
||||
self%nodes(n)%obj%emData%phi = self%potential * timeFactor
|
||||
vectorF(self%nodes(n)%obj%n) = self%nodes(n)%obj%emData%phi
|
||||
|
||||
END DO
|
||||
|
||||
END SUBROUTINE applyDirichletTime
|
||||
|
||||
end submodule boundaryEM
|
||||
Loading…
Add table
Add a link
Reference in a new issue