Proper output file for particle boundaries. Missing input toggle

This commit is contained in:
Jorge Gonzalez 2026-03-11 16:32:17 +01:00
commit c01f0bd381
4 changed files with 70 additions and 26 deletions

View file

@ -2,26 +2,73 @@ MODULE moduleMeshInoutCommon
CHARACTER(LEN=4):: prefix = 'Step' CHARACTER(LEN=4):: prefix = 'Step'
integer, parameter, private:: fileID_boundaryParticle = 30
integer, parameter, private:: fileID_boundaryEM = 31
CONTAINS CONTAINS
PURE FUNCTION formatFileName(prefix, suffix, extension, timeStep) RESULT(fileName) PURE FUNCTION formatFileName(pref, suff, extension, timeStep) RESULT(fileName)
USE moduleOutput USE moduleOutput
IMPLICIT NONE IMPLICIT NONE
CHARACTER(*), INTENT(in):: prefix, suffix, extension CHARACTER(*), INTENT(in):: pref, suff, extension
INTEGER, INTENT(in), OPTIONAL:: timeStep INTEGER, INTENT(in), OPTIONAL:: timeStep
CHARACTER (LEN=iterationDigits):: tString CHARACTER (LEN=iterationDigits):: tString
CHARACTER(:), ALLOCATABLE:: fileName CHARACTER(:), ALLOCATABLE:: fileName
IF (PRESENT(timeStep)) THEN IF (PRESENT(timeStep)) THEN
WRITE(tString, iterationFormat) timeStep WRITE(tString, iterationFormat) timeStep
fileName = prefix // '_' // tString // '_' // suffix // '.' // extension fileName = pref // '_' // tString // '_' // suff // '.' // extension
ELSE ELSE
fileName = prefix // '_' // suffix // '.' // extension fileName = pref // '_' // suff // '.' // extension
END IF END IF
END FUNCTION formatFileName END FUNCTION formatFileName
pure function returnFilePath(filename) result(completePath)
use moduleOutput, only: path, folder
implicit none
character(:), allocatable, intent(in):: fileName
character(:), allocatable:: completePath
completePath = path // folder // '/' // fileName
end function returnFilePath
subroutine informFileCreation(filename)
implicit none
character(:), allocatable, intent(in):: fileName
write(*, "(6X,A15,A)") "Creating file: ", fileName
end subroutine informFileCreation
module subroutine boundariesParticle_print()
use moduleCaseparam, only: timeStep
use moduleOutput, only: path, folder
use moduleMesh, only: nBoundariesParticle, boundariesParticle
implicit none
integer:: b
character(:), allocatable:: fileName
fileName = formatFileName(prefix, 'boundariesParticle', 'csv', timeStep)
call informFileCreation(fileName)
open(fileID_boundaryParticle, file = path // folder // '/' // fileName)
do b = 1, nBoundariesParticle
if (associated(boundariesParticle(b)%obj%print)) then
call boundariesParticle(b)%obj%print(fileID_boundaryParticle)
end if
end do
close(fileID_boundaryParticle)
end subroutine boundariesParticle_print
END MODULE moduleMeshInoutCommon END MODULE moduleMeshInoutCommon

View file

@ -4,7 +4,6 @@ MODULE moduleMesh
USE moduleOutput USE moduleOutput
USE moduleCollisions USE moduleCollisions
use moduleSpecies, only: nSpecies use moduleSpecies, only: nSpecies
IMPLICIT NONE
! MESH ELEMENTS ! MESH ELEMENTS
!Generic mesh element !Generic mesh element
@ -710,10 +709,11 @@ MODULE moduleMesh
end subroutine updateParticle_interface end subroutine updateParticle_interface
! Update the values of the particle boundary model ! Update the values of the particle boundary model
subroutine printParticle_interface(self) subroutine printParticle_interface(self, fileID)
import boundaryParticleGeneric import boundaryParticleGeneric
class(boundaryParticleGeneric), intent(inout):: self class(boundaryParticleGeneric), intent(in):: self
integer, intent(in):: fileID
end subroutine printParticle_interface end subroutine printParticle_interface

View file

@ -404,16 +404,21 @@ submodule(moduleMesh) boundaryParticle
end subroutine quasiNeutrality_update end subroutine quasiNeutrality_update
subroutine quasiNeutrality_print(self) subroutine quasiNeutrality_print(self, fileID)
implicit none implicit none
class(boundaryParticleGeneric), intent(inout):: self class(boundaryParticleGeneric), intent(in):: self
integer, intent(in):: fileID
print *, 'test' integer:: e
write(fileID, '(A)') self%name
select type(self) select type(self)
type is(boundaryQuasiNeutrality) type is(boundaryQuasiNeutrality)
print*, self%alpha write(fileID, '(A,",",A)'), '"Edge id"', '"alpha"'
do e = 1, size(self%edges)
write(fileID, '(I0,",",ES0.6E3)'), self%edges(e)%obj%n, self%alpha(self%edges(e)%obj%n)
end do
end select end select
@ -470,6 +475,6 @@ submodule(moduleMesh) boundaryParticle
end do end do
end subroutine boundariesParticle_update end subroutine boundariesParticle_update
end submodule boundaryParticle end submodule boundaryParticle

View file

@ -521,10 +521,9 @@ MODULE moduleSolver
USE moduleCompTime USE moduleCompTime
USE moduleProbe USE moduleProbe
USE moduleCaseParam, ONLY: timeStep USE moduleCaseParam, ONLY: timeStep
use moduleMeshInoutCommon, only: boundariesParticle_print
IMPLICIT NONE IMPLICIT NONE
integer:: b ! TEMPORARY
CALL outputProbes() CALL outputProbes()
counterOutput = counterOutput + 1 counterOutput = counterOutput + 1
@ -537,6 +536,10 @@ MODULE moduleSolver
CALL mesh%printOutput() CALL mesh%printOutput()
IF (ASSOCIATED(meshForMCC)) CALL meshForMCC%printColl() IF (ASSOCIATED(meshForMCC)) CALL meshForMCC%printColl()
CALL mesh%printEM() CALL mesh%printEM()
! Output of boundaries. TODO: Add an if
call boundariesParticle_print()
WRITE(*, "(5X,A21,I10,A1,I10)") "t/tFinal: ", timeStep, "/", tFinal WRITE(*, "(5X,A21,I10,A1,I10)") "t/tFinal: ", timeStep, "/", tFinal
WRITE(*, "(5X,A21,I10)") "Particles: ", nPartOld WRITE(*, "(5X,A21,I10)") "Particles: ", nPartOld
IF (timeStep == 0) THEN IF (timeStep == 0) THEN
@ -553,17 +556,6 @@ MODULE moduleSolver
END IF END IF
WRITE(*,*) WRITE(*,*)
! TEMPORARY
! Output of boundaries. TODO: Move this to mesh module
do b = 1, nBoundariesParticle
if (associated(boundariesParticle(b)%obj%print)) then
print *, b
call boundariesParticle(b)%obj%print()
end if
end do
END IF END IF
counterCPUTime = counterCPUTime + 1 counterCPUTime = counterCPUTime + 1