Trying to organise output better

This commit is contained in:
Jorge Gonzalez 2026-03-11 19:15:58 +01:00
commit 0109dc2f06
11 changed files with 196 additions and 192 deletions

View file

@ -6,7 +6,6 @@ OBJECTS = $(OBJDIR)/moduleMesh.o $(OBJDIR)/moduleMeshCommon.o $(OBJDIR)/moduleCo
$(OBJDIR)/moduleCollisions.o $(OBJDIR)/moduleTable.o $(OBJDIR)/moduleParallel.o \ $(OBJDIR)/moduleCollisions.o $(OBJDIR)/moduleTable.o $(OBJDIR)/moduleParallel.o \
$(OBJDIR)/moduleEM.o $(OBJDIR)/moduleRandom.o $(OBJDIR)/moduleMath.o \ $(OBJDIR)/moduleEM.o $(OBJDIR)/moduleRandom.o $(OBJDIR)/moduleMath.o \
$(OBJDIR)/moduleProbe.o $(OBJDIR)/moduleAverage.o $(OBJDIR)/moduleCoulomb.o \ $(OBJDIR)/moduleProbe.o $(OBJDIR)/moduleAverage.o $(OBJDIR)/moduleCoulomb.o \
$(OBJDIR)/moduleMeshInoutCommon.o \
$(OBJDIR)/moduleMeshInputVTU.o $(OBJDIR)/moduleMeshOutputVTU.o \ $(OBJDIR)/moduleMeshInputVTU.o $(OBJDIR)/moduleMeshOutputVTU.o \
$(OBJDIR)/moduleMeshInputGmsh2.o $(OBJDIR)/moduleMeshOutputGmsh2.o \ $(OBJDIR)/moduleMeshInputGmsh2.o $(OBJDIR)/moduleMeshOutputGmsh2.o \
$(OBJDIR)/moduleMeshInput0D.o $(OBJDIR)/moduleMeshOutput0D.o \ $(OBJDIR)/moduleMeshInput0D.o $(OBJDIR)/moduleMeshOutput0D.o \

View file

@ -15,19 +15,21 @@ MODULE moduleMeshOutput0D
CHARACTER(:), ALLOCATABLE:: fileName CHARACTER(:), ALLOCATABLE:: fileName
DO i = 1, nSpecies DO i = 1, nSpecies
fileName='OUTPUT_' // species(i)%obj%name // '.dat' fileName = formatFileName('Output', species(i)%obj%name, 'csv')
IF (timeStep == 0) THEN IF (timeStep == 0) THEN
OPEN(20, file = path // folder // '/' // fileName, action = 'write') OPEN(20, file = generateFilePath(fileName), action = 'write')
WRITE(20, "(A1, 14X, A5, A20, 40X, A20, 2(A20))") "#","t (s)","density (m^-3)", "velocity (m/s)", & WRITE(20, "(*("//fmtColStr//"))")'"t (s)"','"density (m^-3)"', &
"pressure (Pa)", "temperature (K)" '"velocity (m/s):0"', '"velocity (m/s):1"', '"velocity (m/s):2"', &
WRITE(*, "(6X,A15,A)") "Creating file: ", fileName '"pressure (Pa)"', &
'"temperature (K)"'
call informFileCreation(fileName)
CLOSE(20) CLOSE(20)
END IF END IF
OPEN(20, file = path // folder // '/' // fileName, position = 'append', action = 'write') OPEN(20, file = generateFilePath(fileName), position = 'append', action = 'write')
CALL calculateOutput(self%nodes(1)%obj%output(i), output, self%nodes(1)%obj%v, species(i)%obj) CALL calculateOutput(self%nodes(1)%obj%output(i), output, self%nodes(1)%obj%v, species(i)%obj)
WRITE(20, "(7(ES20.6E3))") REAL(timeStep)*tauMin*ti_ref, output%density, & WRITE(20, "(*("//fmtColReal//"))") REAL(timeStep)*tauMin*ti_ref, output%density, &
output%velocity, & output%velocity, &
output%pressure, & output%pressure, &
output%temperature output%temperature
@ -51,15 +53,15 @@ MODULE moduleMeshOutput0D
fileName='OUTPUT_Collisions.dat' fileName='OUTPUT_Collisions.dat'
IF (timeStep == tInitial) THEN IF (timeStep == tInitial) THEN
OPEN(20, file = path // folder // '/' // fileName, action = 'write') OPEN(20, file = generateFilePath(fileName), action = 'write')
WRITE(20, "(A1, 14X, A5, A20)") "#","t (s)","collisions" WRITE(20, "(A1, 14X, A5, A20)") "#","t (s)","collisions"
WRITE(*, "(6X,A15,A)") "Creating file: ", fileName call informFileCreation(fileName)
CLOSE(20) CLOSE(20)
END IF END IF
OPEN(20, file = path // folder // '/' // fileName, position = 'append', action = 'write') OPEN(20, file = generateFilePath(fileName), position = 'append', action = 'write')
WRITE(20, "(ES20.6E3, 10I20)") REAL(timeStep)*tauMin*ti_ref, (self%cells(1)%obj%tallyColl(k)%tally, k=1,nCollPairs) WRITE(20, "("//fmtReal//", 10I20)") REAL(timeStep)*tauMin*ti_ref, (self%cells(1)%obj%tallyColl(k)%tally, k=1,nCollPairs)
CLOSE(20) CLOSE(20)
END SUBROUTINE printColl0D END SUBROUTINE printColl0D

View file

@ -16,6 +16,7 @@ MODULE moduleMeshOutputGmsh2
!Node data subroutines !Node data subroutines
!Header !Header
SUBROUTINE writeGmsh2HeaderNodeData(fileID, title, iteration, time, dimensions, nNodes) SUBROUTINE writeGmsh2HeaderNodeData(fileID, title, iteration, time, dimensions, nNodes)
use moduleOutput
IMPLICIT NONE IMPLICIT NONE
INTEGER, INTENT(in):: fileID INTEGER, INTENT(in):: fileID
@ -25,14 +26,14 @@ MODULE moduleMeshOutputGmsh2
WRITE(fileID, "(A)") '$NodeData' WRITE(fileID, "(A)") '$NodeData'
WRITE(fileID, "(I10)") 1 WRITE(fileID, "("//fmtInt//")") 1
WRITE(fileID, "(A1, A, A1)") '"' , title , '"' WRITE(fileID, "(A1, A, A1)") '"' , title , '"'
WRITE(fileID, "(I10)") 1 WRITE(fileID, "("//fmtInt//")") 1
WRITE(fileID, "(ES20.6E3)") time WRITE(fileID, "("//fmtReal//")") time
WRITE(fileID, "(I10)") 3 WRITE(fileID, "("//fmtInt//")") 3
WRITE(fileID, "(I10)") iteration WRITE(fileID, "("//fmtInt//")") iteration
WRITE(fileID, "(I10)") dimensions WRITE(fileID, "("//fmtInt//")") dimensions
WRITE(fileID, "(I10)") nNodes WRITE(fileID, "("//fmtInt//")") nNodes
END SUBROUTINE writeGmsh2HeaderNodeData END SUBROUTINE writeGmsh2HeaderNodeData
@ -49,6 +50,7 @@ MODULE moduleMeshOutputGmsh2
!Element data subroutines !Element data subroutines
!Header !Header
SUBROUTINE writeGmsh2HeaderElementData(fileID, title, iteration, time, dimensions, nVols) SUBROUTINE writeGmsh2HeaderElementData(fileID, title, iteration, time, dimensions, nVols)
use moduleOutput
IMPLICIT NONE IMPLICIT NONE
INTEGER, INTENT(in):: fileID INTEGER, INTENT(in):: fileID
@ -58,14 +60,14 @@ MODULE moduleMeshOutputGmsh2
WRITE(fileID, "(A)") '$ElementData' WRITE(fileID, "(A)") '$ElementData'
WRITE(fileID, "(I10)") 1 WRITE(fileID, "("//fmtInt//")") 1
WRITE(fileID, "(A1, A, A1)") '"' , title , '"' WRITE(fileID, "(A1, A, A1)") '"' , title , '"'
WRITE(fileID, "(I10)") 1 WRITE(fileID, "("//fmtInt//")") 1
WRITE(fileID, "(ES20.6E3)") time WRITE(fileID, "("//fmtReal//")") time
WRITE(fileID, "(I10)") 3 WRITE(fileID, "("//fmtInt//")") 3
WRITE(fileID, "(I10)") iteration WRITE(fileID, "("//fmtInt//")") iteration
WRITE(fileID, "(I10)") dimensions WRITE(fileID, "("//fmtInt//")") dimensions
WRITE(fileID, "(I10)") nVols WRITE(fileID, "("//fmtInt//")") nVols
END SUBROUTINE writeGmsh2HeaderElementData END SUBROUTINE writeGmsh2HeaderElementData
@ -85,7 +87,6 @@ MODULE moduleMeshOutputGmsh2
USE moduleRefParam USE moduleRefParam
USE moduleSpecies USE moduleSpecies
USE moduleOutput USE moduleOutput
USE moduleMeshInoutCommon
USE moduleCaseParam, ONLY: timeStep USE moduleCaseParam, ONLY: timeStep
IMPLICIT NONE IMPLICIT NONE
@ -99,33 +100,33 @@ MODULE moduleMeshOutputGmsh2
DO i = 1, nSpecies DO i = 1, nSpecies
fileName = formatFileName(prefix, species(i)%obj%name, 'msh', timeStep) fileName = formatFileName(prefix, species(i)%obj%name, 'msh', timeStep)
WRITE(*, "(6X,A15,A)") "Creating file: ", fileName call informFileCreation(fileName)
OPEN (60, file = path // folder // '/' // fileName) OPEN (60, file = generateFilePath(fileName))
CALL writeGmsh2HeaderMesh(60) CALL writeGmsh2HeaderMesh(60)
CALL writeGmsh2HeaderNodeData(60, species(i)%obj%name // ' density (m^-3)', timeStep, time, 1, self%numNodes) CALL writeGmsh2HeaderNodeData(60, species(i)%obj%name // ' density (m^-3)', timeStep, time, 1, self%numNodes)
DO n=1, self%numNodes DO n=1, self%numNodes
CALL calculateOutput(self%nodes(n)%obj%output(i), output(n), self%nodes(n)%obj%v, species(i)%obj) CALL calculateOutput(self%nodes(n)%obj%output(i), output(n), self%nodes(n)%obj%v, species(i)%obj)
WRITE(60, "(I6,ES20.6E3)") n, output(n)%density WRITE(60, "(I6,"//fmtReal//")") n, output(n)%density
END DO END DO
CALL writeGmsh2FooterNodeData(60) CALL writeGmsh2FooterNodeData(60)
CALL writeGmsh2HeaderNodeData(60, species(i)%obj%name // ' velocity (m s^-1)', timeStep, time, 3, self%numNodes) CALL writeGmsh2HeaderNodeData(60, species(i)%obj%name // ' velocity (m s^-1)', timeStep, time, 3, self%numNodes)
DO n=1, self%numNodes DO n=1, self%numNodes
WRITE(60, "(I6,3(ES20.6E3))") n, output(n)%velocity WRITE(60, "(I6,3("//fmtReal//"))") n, output(n)%velocity
END DO END DO
CALL writeGmsh2FooterNodeData(60) CALL writeGmsh2FooterNodeData(60)
CALL writeGmsh2HeaderNodeData(60, species(i)%obj%name // ' Pressure (Pa)', timeStep, time, 1, self%numNodes) CALL writeGmsh2HeaderNodeData(60, species(i)%obj%name // ' Pressure (Pa)', timeStep, time, 1, self%numNodes)
DO n=1, self%numNodes DO n=1, self%numNodes
WRITE(60, "(I6,3(ES20.6E3))") n, output(n)%pressure WRITE(60, "(I6,3("//fmtReal//"))") n, output(n)%pressure
END DO END DO
CALL writeGmsh2FooterNodeData(60) CALL writeGmsh2FooterNodeData(60)
CALL writeGmsh2HeaderNodeData(60, species(i)%obj%name // ' Temperature (K)', timeStep, time, 1, self%numNodes) CALL writeGmsh2HeaderNodeData(60, species(i)%obj%name // ' Temperature (K)', timeStep, time, 1, self%numNodes)
DO n=1, self%numNodes DO n=1, self%numNodes
WRITE(60, "(I6,3(ES20.6E3))") n, output(n)%temperature WRITE(60, "(I6,3("//fmtReal//"))") n, output(n)%temperature
END DO END DO
CALL writeGmsh2FooterNodeData(60) CALL writeGmsh2FooterNodeData(60)
CLOSE (60) CLOSE (60)
@ -141,7 +142,6 @@ MODULE moduleMeshOutputGmsh2
USE moduleCaseParam USE moduleCaseParam
USE moduleCollisions USE moduleCollisions
USE moduleOutput USE moduleOutput
USE moduleMeshInoutCommon
IMPLICIT NONE IMPLICIT NONE
CLASS(meshGeneric), INTENT(in):: self CLASS(meshGeneric), INTENT(in):: self
@ -169,8 +169,8 @@ MODULE moduleMeshOutputGmsh2
time = DBLE(timeStep)*tauMin*ti_ref time = DBLE(timeStep)*tauMin*ti_ref
fileName = formatFileName(prefix, 'Collisions', 'msh', timeStep) fileName = formatFileName(prefix, 'Collisions', 'msh', timeStep)
WRITE(*, "(6X,A15,A)") "Creating file: ", fileName call informFileCreation(fileName)
OPEN (60, file = path // folder // '/' // fileName) OPEN (60, file = generateFilePath(fileName))
CALL writeGmsh2HeaderMesh(60) CALL writeGmsh2HeaderMesh(60)
@ -180,7 +180,7 @@ MODULE moduleMeshOutputGmsh2
title = '"Pair ' // interactionMatrix(k)%sp_i%name // '-' // interactionMatrix(k)%sp_j%name // ' collision ' // cString title = '"Pair ' // interactionMatrix(k)%sp_i%name // '-' // interactionMatrix(k)%sp_j%name // ' collision ' // cString
CALL writeGmsh2HeaderElementData(60, title, timeStep, time, 1, self%numCells) CALL writeGmsh2HeaderElementData(60, title, timeStep, time, 1, self%numCells)
DO n=1, self%numCells DO n=1, self%numCells
WRITE(60, "(I6,I10)") n + numEdges, self%cells(n)%obj%tallyColl(k)%tally(c) WRITE(60, "(I6,"//fmtInt//")") n + numEdges, self%cells(n)%obj%tallyColl(k)%tally(c)
END DO END DO
CALL writeGmsh2FooterElementData(60) CALL writeGmsh2FooterElementData(60)
@ -200,7 +200,6 @@ MODULE moduleMeshOutputGmsh2
USE moduleRefParam USE moduleRefParam
USE moduleCaseParam USE moduleCaseParam
USE moduleOutput USE moduleOutput
USE moduleMeshInoutCommon
IMPLICIT NONE IMPLICIT NONE
CLASS(meshParticles), INTENT(in):: self CLASS(meshParticles), INTENT(in):: self
@ -215,8 +214,8 @@ MODULE moduleMeshOutputGmsh2
time = DBLE(timeStep)*tauMin*ti_ref time = DBLE(timeStep)*tauMin*ti_ref
fileName = formatFileName(prefix, 'EMField', 'msh', timeStep) fileName = formatFileName(prefix, 'EMField', 'msh', timeStep)
WRITE(*, "(6X,A15,A)") "Creating file: ", fileName call informFileCreation(fileName)
OPEN (20, file = path // folder // '/' // fileName) OPEN (20, file = generateFilePath(fileName))
CALL writeGmsh2HeaderMesh(20) CALL writeGmsh2HeaderMesh(20)
@ -251,7 +250,6 @@ MODULE moduleMeshOutputGmsh2
USE moduleSpecies USE moduleSpecies
USE moduleOutput USE moduleOutput
USE moduleAverage USE moduleAverage
USE moduleMeshInoutCommon
IMPLICIT NONE IMPLICIT NONE
CLASS(meshParticles), INTENT(in):: self CLASS(meshParticles), INTENT(in):: self
@ -262,12 +260,12 @@ MODULE moduleMeshOutputGmsh2
DO i = 1, nSpecies DO i = 1, nSpecies
fileName = formatFileName('Average_mean', species(i)%obj%name, 'msh') fileName = formatFileName('Average_mean', species(i)%obj%name, 'msh')
WRITE(*, "(6X,A15,A)") "Creating file: ", fileName call informFileCreation(fileName)
OPEN (fileMean, file = path // folder // '/' // fileName) OPEN (fileMean, file = generateFilePath(fileName))
fileName = formatFileName('Average_deviation', species(i)%obj%name, 'msh') fileName = formatFileName('Average_deviation', species(i)%obj%name, 'msh')
WRITE(*, "(6X,A15,A)") "Creating file: ", fileName call informFileCreation(fileName)
OPEN (filedeviation, file = path // folder // '/' // fileName) OPEN (filedeviation, file = generateFilePath(fileName))
CALL writeGmsh2HeaderMesh(fileMean) CALL writeGmsh2HeaderMesh(fileMean)
CALL writeGmsh2HeaderMesh(fileDeviation) CALL writeGmsh2HeaderMesh(fileDeviation)
@ -276,9 +274,9 @@ MODULE moduleMeshOutputGmsh2
CALL writeGmsh2HeaderNodeData(fileDeviation, species(i)%obj%name // ' density, sd (m^-3)', 0, 0.D0, 1, self%numNodes) CALL writeGmsh2HeaderNodeData(fileDeviation, species(i)%obj%name // ' density, sd (m^-3)', 0, 0.D0, 1, self%numNodes)
DO n=1, self%numNodes DO n=1, self%numNodes
CALL calculateOutput(averageScheme(n)%mean%output(i), outputMean(n), self%nodes(n)%obj%v, species(i)%obj) CALL calculateOutput(averageScheme(n)%mean%output(i), outputMean(n), self%nodes(n)%obj%v, species(i)%obj)
WRITE(fileMean, "(I6,ES20.6E3)") n, outputMean(n)%density WRITE(fileMean, "(I6,"//fmtReal//")") n, outputMean(n)%density
CALL calculateOutput(averageScheme(n)%deviation%output(i), outputDeviation(n), self%nodes(n)%obj%v, species(i)%obj) CALL calculateOutput(averageScheme(n)%deviation%output(i), outputDeviation(n), self%nodes(n)%obj%v, species(i)%obj)
WRITE(fileDeviation, "(I6,ES20.6E3)") n, outputDeviation(n)%density WRITE(fileDeviation, "(I6,"//fmtReal//")") n, outputDeviation(n)%density
END DO END DO
CALL writeGmsh2FooterNodeData(fileMean) CALL writeGmsh2FooterNodeData(fileMean)
CALL writeGmsh2FooterNodeData(fileDeviation) CALL writeGmsh2FooterNodeData(fileDeviation)
@ -286,8 +284,8 @@ MODULE moduleMeshOutputGmsh2
CALL writeGmsh2HeaderNodeData(fileMean, species(i)%obj%name // ' velocity, mean (m s^-1)', 0, 0.D0, 3, self%numNodes) CALL writeGmsh2HeaderNodeData(fileMean, species(i)%obj%name // ' velocity, mean (m s^-1)', 0, 0.D0, 3, self%numNodes)
CALL writeGmsh2HeaderNodeData(fileDeviation, species(i)%obj%name // ' velocity, sd (m s^-1)', 0, 0.D0, 3, self%numNodes) CALL writeGmsh2HeaderNodeData(fileDeviation, species(i)%obj%name // ' velocity, sd (m s^-1)', 0, 0.D0, 3, self%numNodes)
DO n=1, self%numNodes DO n=1, self%numNodes
WRITE(fileMean, "(I6,3(ES20.6E3))") n, outputMean(n)%velocity WRITE(fileMean, "(I6,3("//fmtReal//"))") n, outputMean(n)%velocity
WRITE(fileDeviation, "(I6,3(ES20.6E3))") n, outputDeviation(n)%velocity WRITE(fileDeviation, "(I6,3("//fmtReal//"))") n, outputDeviation(n)%velocity
END DO END DO
CALL writeGmsh2FooterNodeData(fileMean) CALL writeGmsh2FooterNodeData(fileMean)
CALL writeGmsh2FooterNodeData(fileDeviation) CALL writeGmsh2FooterNodeData(fileDeviation)
@ -295,8 +293,8 @@ MODULE moduleMeshOutputGmsh2
CALL writeGmsh2HeaderNodeData(fileMean, species(i)%obj%name // ' Pressure, mean (Pa)', 0, 0.D0, 1, self%numNodes) CALL writeGmsh2HeaderNodeData(fileMean, species(i)%obj%name // ' Pressure, mean (Pa)', 0, 0.D0, 1, self%numNodes)
CALL writeGmsh2HeaderNodeData(fileDeviation, species(i)%obj%name // ' Pressure, sd (Pa)', 0, 0.D0, 1, self%numNodes) CALL writeGmsh2HeaderNodeData(fileDeviation, species(i)%obj%name // ' Pressure, sd (Pa)', 0, 0.D0, 1, self%numNodes)
DO n=1, self%numNodes DO n=1, self%numNodes
WRITE(fileMean, "(I6,3(ES20.6E3))") n, outputMean(n)%pressure WRITE(fileMean, "(I6,3("//fmtReal//"))") n, outputMean(n)%pressure
WRITE(fileDeviation, "(I6,3(ES20.6E3))") n, outputDeviation(n)%pressure WRITE(fileDeviation, "(I6,3("//fmtReal//"))") n, outputDeviation(n)%pressure
END DO END DO
CALL writeGmsh2FooterNodeData(fileMean) CALL writeGmsh2FooterNodeData(fileMean)
CALL writeGmsh2FooterNodeData(fileDeviation) CALL writeGmsh2FooterNodeData(fileDeviation)
@ -304,8 +302,8 @@ MODULE moduleMeshOutputGmsh2
CALL writeGmsh2HeaderNodeData(fileMean, species(i)%obj%name // ' Temperature, mean (K)', 0, 0.D0, 1, self%numNodes) CALL writeGmsh2HeaderNodeData(fileMean, species(i)%obj%name // ' Temperature, mean (K)', 0, 0.D0, 1, self%numNodes)
CALL writeGmsh2HeaderNodeData(fileDeviation, species(i)%obj%name // ' Temperature, sd (K)', 0, 0.D0, 1, self%numNodes) CALL writeGmsh2HeaderNodeData(fileDeviation, species(i)%obj%name // ' Temperature, sd (K)', 0, 0.D0, 1, self%numNodes)
DO n=1, self%numNodes DO n=1, self%numNodes
WRITE(fileMean, "(I6,3(ES20.6E3))") n, outputMean(n)%temperature WRITE(fileMean, "(I6,3("//fmtReal//"))") n, outputMean(n)%temperature
WRITE(fileDeviation, "(I6,3(ES20.6E3))") n, outputDeviation(n)%temperature WRITE(fileDeviation, "(I6,3("//fmtReal//"))") n, outputDeviation(n)%temperature
END DO END DO
CALL writeGmsh2FooterNodeData(fileMean) CALL writeGmsh2FooterNodeData(fileMean)
CALL writeGmsh2FooterNodeData(fileDeviation) CALL writeGmsh2FooterNodeData(fileDeviation)

View file

@ -1,6 +1,6 @@
all: vtu.o gmsh2.o 0D.o text.o all: vtu.o gmsh2.o 0D.o text.o
vtu.o: moduleMeshInoutCommon.o vtu.o:
$(MAKE) -C vtu all $(MAKE) -C vtu all
gmsh2.o: gmsh2.o:

View file

@ -1,74 +0,0 @@
MODULE moduleMeshInoutCommon
CHARACTER(LEN=4):: prefix = 'Step'
integer, parameter, private:: fileID_boundaryParticle = 30
integer, parameter, private:: fileID_boundaryEM = 31
CONTAINS
PURE FUNCTION formatFileName(pref, suff, extension, timeStep) RESULT(fileName)
USE moduleOutput
IMPLICIT NONE
CHARACTER(*), INTENT(in):: pref, suff, extension
INTEGER, INTENT(in), OPTIONAL:: timeStep
CHARACTER (LEN=iterationDigits):: tString
CHARACTER(:), ALLOCATABLE:: fileName
IF (PRESENT(timeStep)) THEN
WRITE(tString, iterationFormat) timeStep
fileName = pref // '_' // tString // '_' // suff // '.' // extension
ELSE
fileName = pref // '_' // suff // '.' // extension
END IF
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

View file

@ -121,7 +121,6 @@ module moduleMeshOutputText
subroutine printOutputText(self) subroutine printOutputText(self)
use moduleMesh use moduleMesh
use moduleSpecies use moduleSpecies
use moduleMeshInoutCommon
use moduleCaseParam, ONLY: timeStep use moduleCaseParam, ONLY: timeStep
implicit none implicit none
@ -134,7 +133,7 @@ module moduleMeshOutputText
do s = 1, nSpecies do s = 1, nSpecies
fileName = formatFileName(prefix, species(s)%obj%name, 'csv', timeStep) fileName = formatFileName(prefix, species(s)%obj%name, 'csv', timeStep)
write(*, "(6X,A15,A)") "Creating file: ", fileName call informFileCreation(fileName)
open (fileID, file = path // folder // '/' // fileName) open (fileID, file = path // folder // '/' // fileName)
write(fileID, '(5(A,","),A)') '"Position (m)"', & write(fileID, '(5(A,","),A)') '"Position (m)"', &
@ -153,7 +152,6 @@ module moduleMeshOutputText
subroutine printCollText(self) subroutine printCollText(self)
use moduleMesh use moduleMesh
use moduleOutput use moduleOutput
use moduleMeshInoutCommon
use moduleCaseParam, only: timeStep use moduleCaseParam, only: timeStep
implicit none implicit none
@ -167,7 +165,7 @@ module moduleMeshOutputText
if (collOutput) then if (collOutput) then
fileName = formatFileName(prefix, 'Collisions', 'csv', timeStep) fileName = formatFileName(prefix, 'Collisions', 'csv', timeStep)
write(*, "(6X,A15,A)") "Creating file: ", fileName call informFileCreation(fileName)
open (fileID, file = path // folder // '/' // fileName) open (fileID, file = path // folder // '/' // fileName)
write(fileID, '(A)', advance='no') "Cell" write(fileID, '(A)', advance='no') "Cell"
@ -191,7 +189,6 @@ module moduleMeshOutputText
subroutine printEMText(self) subroutine printEMText(self)
use moduleMesh use moduleMesh
use moduleMeshInoutCommon
use moduleCaseParam, only: timeStep use moduleCaseParam, only: timeStep
implicit none implicit none
@ -203,7 +200,7 @@ module moduleMeshOutputText
if (emOutput) then if (emOutput) then
fileName = formatFileName(prefix, 'EMField', 'csv', timeStep) fileName = formatFileName(prefix, 'EMField', 'csv', timeStep)
write(*, "(6X,A15,A)") "Creating file: ", fileName call informFileCreation(fileName)
open (fileID, file = path // folder // '/' // fileName) open (fileID, file = path // folder // '/' // fileName)
write(fileID, '(8(A,","),A)') '"Position (m)"', & write(fileID, '(8(A,","),A)') '"Position (m)"', &
@ -222,7 +219,6 @@ module moduleMeshOutputText
subroutine printAverageText(self) subroutine printAverageText(self)
use moduleMesh use moduleMesh
use moduleSpecies use moduleSpecies
use moduleMeshInoutCommon
implicit none implicit none
class(meshParticles), intent(in):: self class(meshParticles), intent(in):: self
@ -235,7 +231,7 @@ module moduleMeshOutputText
do s = 1, nSpecies do s = 1, nSpecies
fileNameMean = formatFileName('Average_mean', species(s)%obj%name, 'csv') fileNameMean = formatFileName('Average_mean', species(s)%obj%name, 'csv')
write(*, "(6X,A15,A)") "Creating file: ", fileNameMean call informFileCreation(fileNameMean)
open (fileIDMean, file = path // folder // '/' // fileNameMean) open (fileIDMean, file = path // folder // '/' // fileNameMean)
write(fileIDMean, '(5(A,","),A)') '"Position (m)"', & write(fileIDMean, '(5(A,","),A)') '"Position (m)"', &
@ -244,7 +240,7 @@ module moduleMeshOutputText
'"Temperature, mean (K)"' '"Temperature, mean (K)"'
fileNameDeviation = formatFileName('Average_deviation', species(s)%obj%name, 'csv') fileNameDeviation = formatFileName('Average_deviation', species(s)%obj%name, 'csv')
write(*, "(6X,A15,A)") "Creating file: ", fileNameDeviation call informFileCreation(fileNameDeviation)
open (fileIDDeviation, file = path // folder // '/' // fileNameDeviation) open (fileIDDeviation, file = path // folder // '/' // fileNameDeviation)
write(fileIDDeviation, '(5(A,","),A)') '"Position (m)"', & write(fileIDDeviation, '(5(A,","),A)') '"Position (m)"', &

View file

@ -12,7 +12,7 @@ MODULE moduleMeshOutputVTU
WRITE(fileID,"(A)") '<?xml version="1.0"?>' WRITE(fileID,"(A)") '<?xml version="1.0"?>'
WRITE(fileID,"(2X, A)") '<VTKFile type="UnstructuredGrid">' WRITE(fileID,"(2X, A)") '<VTKFile type="UnstructuredGrid">'
WRITE(fileID,"(4X, A)") '<UnstructuredGrid>' WRITE(fileID,"(4X, A)") '<UnstructuredGrid>'
WRITE(fileID,"(6X, A, I10, A, I10, A)") '<Piece NumberOfPoints="', nNodes, '" NumberOfCells="', nCells, '">' WRITE(fileID,"(6X, A, "//fmtInt//", A, "//fmtInt//", A)") '<Piece NumberOfPoints="', nNodes, '" NumberOfCells="', nCells, '">'
END SUBROUTINE writeHeader END SUBROUTINE writeHeader
@ -87,14 +87,14 @@ MODULE moduleMeshOutputVTU
!Write nodes coordinates !Write nodes coordinates
WRITE(fileID, "(8X, A)") '<Points>' WRITE(fileID, "(8X, A)") '<Points>'
WRITE(fileID, "(10X,A)") '<DataArray type="Float32" NumberOfComponents="3" format="ascii">' WRITE(fileID, "(10X,A)") '<DataArray type="Float32" NumberOfComponents="3" format="ascii">'
WRITE(fileID, "(6(ES20.6E3))") (self%nodes(e)%obj%getCoordinates()*L_ref, e = 1, self%numNodes) WRITE(fileID, "(6("//fmtReal//"))") (self%nodes(e)%obj%getCoordinates()*L_ref, e = 1, self%numNodes)
WRITE(fileID, "(10X, A)") '</DataArray>' WRITE(fileID, "(10X, A)") '</DataArray>'
WRITE(fileID, "(8X, A)") '</Points>' WRITE(fileID, "(8X, A)") '</Points>'
WRITE(fileID, "(8X, A)") '<Cells>' WRITE(fileID, "(8X, A)") '<Cells>'
!Write nodes connectivity of each cell !Write nodes connectivity of each cell
WRITE(fileID, "(10X,A)") '<DataArray type="Int32" Name="connectivity" format="ascii">' WRITE(fileID, "(10X,A)") '<DataArray type="Int32" Name="connectivity" format="ascii">'
WRITE(fileID, "(6(I10))") (self%cells(e)%obj%getNodes(self%cells(e)%obj%nNodes) - 1, e = 1, self%numCells) !Array starts on 0 WRITE(fileID, "(6("//fmtInt//"))") (self%cells(e)%obj%getNodes(self%cells(e)%obj%nNodes) - 1, e = 1, self%numCells) !Array starts on 0
WRITE(fileID, "(10X, A)") '</DataArray>' WRITE(fileID, "(10X, A)") '</DataArray>'
!Write offset of each cell !Write offset of each cell
offset(1) = self%cells(1)%obj%nNodes offset(1) = self%cells(1)%obj%nNodes
@ -103,7 +103,7 @@ MODULE moduleMeshOutputVTU
offset(e) = offset(e - 1) + self%cells(e)%obj%nNodes offset(e) = offset(e - 1) + self%cells(e)%obj%nNodes
END DO END DO
WRITE(fileID, "(6(I10))") offset WRITE(fileID, "(6("//fmtInt//"))") offset
WRITE(fileID, "(10X, A)") '</DataArray>' WRITE(fileID, "(10X, A)") '</DataArray>'
!Write type of each cell !Write type of each cell
WRITE(fileID, "(10X,A)") '<DataArray type="Int32" Name="types" format="ascii">' WRITE(fileID, "(10X,A)") '<DataArray type="Int32" Name="types" format="ascii">'
@ -111,7 +111,7 @@ MODULE moduleMeshOutputVTU
types(e) = getCellType(self%cells(e)%obj) types(e) = getCellType(self%cells(e)%obj)
END DO END DO
WRITE(fileID, "(6(I10))") types WRITE(fileID, "(6("//fmtInt//"))") types
WRITE(fileID, "(10X, A)") '</DataArray>' WRITE(fileID, "(10X, A)") '</DataArray>'
WRITE(fileID, "(8X, A)") '</Cells>' WRITE(fileID, "(8X, A)") '</Cells>'
@ -137,19 +137,19 @@ MODULE moduleMeshOutputVTU
WRITE(fileID,"(8X,A)") '<PointData>' WRITE(fileID,"(8X,A)") '<PointData>'
!Write density !Write density
WRITE(fileID,"(10X,A)") '<DataArray type="Float64" Name="Density (m^-3)" NumberOfComponents="1">' WRITE(fileID,"(10X,A)") '<DataArray type="Float64" Name="Density (m^-3)" NumberOfComponents="1">'
WRITE(fileID,"(6(ES20.6E3))") (output(n)%density, n = 1, self%numNodes) WRITE(fileID,"(6("//fmtReal//"))") (output(n)%density, n = 1, self%numNodes)
WRITE(fileID,"(10X,A)") '</DataArray>' WRITE(fileID,"(10X,A)") '</DataArray>'
!Write velocity !Write velocity
WRITE(fileID,"(10X,A)") '<DataArray type="Float64" Name="Velocity (m s^-1)" NumberOfComponents="3">' WRITE(fileID,"(10X,A)") '<DataArray type="Float64" Name="Velocity (m s^-1)" NumberOfComponents="3">'
WRITE(fileID,"(6(ES20.6E3))") (output(n)%velocity, n = 1, self%numNodes) WRITE(fileID,"(6("//fmtReal//"))") (output(n)%velocity, n = 1, self%numNodes)
WRITE(fileID,"(10X,A)") '</DataArray>' WRITE(fileID,"(10X,A)") '</DataArray>'
!Write pressure !Write pressure
WRITE(fileID,"(10X,A)") '<DataArray type="Float64" Name="Pressure (Pa)" NumberOfComponents="1">' WRITE(fileID,"(10X,A)") '<DataArray type="Float64" Name="Pressure (Pa)" NumberOfComponents="1">'
WRITE(fileID,"(6(ES20.6E3))") (output(n)%pressure, n = 1, self%numNodes) WRITE(fileID,"(6("//fmtReal//"))") (output(n)%pressure, n = 1, self%numNodes)
WRITE(fileID,"(10X,A)") '</DataArray>' WRITE(fileID,"(10X,A)") '</DataArray>'
!Write temperature !Write temperature
WRITE(fileID,"(10X,A)") '<DataArray type="Float64" Name="Temperature (K)" NumberOfComponents="1">' WRITE(fileID,"(10X,A)") '<DataArray type="Float64" Name="Temperature (K)" NumberOfComponents="1">'
WRITE(fileID,"(6(ES20.6E3))") (output(n)%temperature, n = 1, self%numNodes) WRITE(fileID,"(6("//fmtReal//"))") (output(n)%temperature, n = 1, self%numNodes)
WRITE(fileID,"(10X,A)") '</DataArray>' WRITE(fileID,"(10X,A)") '</DataArray>'
!End node data !End node data
WRITE(fileID,"(8X,A)") '</PointData>' WRITE(fileID,"(8X,A)") '</PointData>'
@ -173,7 +173,7 @@ MODULE moduleMeshOutputVTU
WRITE(cString, "(I2)") c WRITE(cString, "(I2)") c
title = 'Pair ' // interactionMatrix(k)%sp_i%name // '-' // interactionMatrix(k)%sp_j%name // ' collision ' // cString title = 'Pair ' // interactionMatrix(k)%sp_i%name // '-' // interactionMatrix(k)%sp_j%name // ' collision ' // cString
WRITE(fileID,"(10X,A, A, A)") '<DataArray type="Float64" Name="',title, '" NumberOfComponents="1">' WRITE(fileID,"(10X,A, A, A)") '<DataArray type="Float64" Name="',title, '" NumberOfComponents="1">'
WRITE(fileID, "(6(I10))") (self%cells(n)%obj%tallyColl(k)%tally(c), n = 1, self%numCells) WRITE(fileID, "(6("//fmtInt//"))") (self%cells(n)%obj%tallyColl(k)%tally(c), n = 1, self%numCells)
WRITE(fileID, "(10X, A)") '</DataArray>' WRITE(fileID, "(10X, A)") '</DataArray>'
END DO END DO
@ -196,11 +196,11 @@ MODULE moduleMeshOutputVTU
WRITE(fileID,"(8X,A)") '<PointData>' WRITE(fileID,"(8X,A)") '<PointData>'
!Electric potential !Electric potential
WRITE(fileID,"(10X,A)") '<DataArray type="Float64" Name="Potential (V)" NumberOfComponents="1">' WRITE(fileID,"(10X,A)") '<DataArray type="Float64" Name="Potential (V)" NumberOfComponents="1">'
WRITE(fileID,"(6(ES20.6E3))") (self%nodes(n)%obj%emData%phi*Volt_ref, n = 1, self%numNodes) WRITE(fileID,"(6("//fmtReal//"))") (self%nodes(n)%obj%emData%phi*Volt_ref, n = 1, self%numNodes)
WRITE(fileID,"(10X,A)") '</DataArray>' WRITE(fileID,"(10X,A)") '</DataArray>'
!Magnetic Field !Magnetic Field
WRITE(fileID,"(10X,A)") '<DataArray type="Float64" Name="Magnetic Field (T)" NumberOfComponents="3">' WRITE(fileID,"(10X,A)") '<DataArray type="Float64" Name="Magnetic Field (T)" NumberOfComponents="3">'
WRITE(fileID,"(6(ES20.6E3))") (self%nodes(n)%obj%emData%B*B_ref, n = 1, self%numNodes) WRITE(fileID,"(6("//fmtReal//"))") (self%nodes(n)%obj%emData%B*B_ref, n = 1, self%numNodes)
WRITE(fileID,"(10X,A)") '</DataArray>' WRITE(fileID,"(10X,A)") '</DataArray>'
WRITE(fileID,"(8X,A)") '</PointData>' WRITE(fileID,"(8X,A)") '</PointData>'
@ -209,7 +209,7 @@ MODULE moduleMeshOutputVTU
WRITE(fileID,"(8X,A)") '<CellData>' WRITE(fileID,"(8X,A)") '<CellData>'
!Electric field !Electric field
WRITE(fileID,"(10X,A, A, A)") '<DataArray type="Float64" Name="Electric Field (V m^-1)" NumberOfComponents="3">' WRITE(fileID,"(10X,A, A, A)") '<DataArray type="Float64" Name="Electric Field (V m^-1)" NumberOfComponents="3">'
WRITE(fileID,"(6(ES20.6E3))") (self%cells(n)%obj%gatherElectricField(Xi)*EF_ref, n = 1, self%numCells) WRITE(fileID,"(6("//fmtReal//"))") (self%cells(n)%obj%gatherElectricField(Xi)*EF_ref, n = 1, self%numCells)
WRITE(fileID,"(10X,A)") '</DataArray>' WRITE(fileID,"(10X,A)") '</DataArray>'
WRITE(fileID,"(8X,A)") '</CellData>' WRITE(fileID,"(8X,A)") '</CellData>'
@ -221,30 +221,32 @@ MODULE moduleMeshOutputVTU
USE moduleRefParam USE moduleRefParam
IMPLICIT NONE IMPLICIT NONE
INTEGER:: fileID INTEGER, intent(in):: fileID
CHARACTER(*):: fileNameStep, fileNameCollection CHARACTER(*), intent(in):: fileNameStep, fileNameCollection
IF (timeStep == tInitial) THEN IF (timeStep == tInitial) THEN
!Create collection file !Create collection file
WRITE(*, "(6X,A15,A)") "Creating file: ", fileNameCollection call informFileCreation(fileNameCollection)
OPEN (fileID + 1, file = path // folder // '/' // fileNameCollection) OPEN (fileID + 1, file = generateFilePath(fileNameCollection))
WRITE (fileID + 1, "(A)") '<VTKFile type="Collection">' WRITE (fileID + 1, "(A)") '<VTKFile type="Collection">'
WRITE (fileID + 1, "(2X, A)") '<Collection>' WRITE (fileID + 1, "(2X, A)") '<Collection>'
CLOSE(fileID + 1) CLOSE(fileID + 1)
else
! Append removing the last two lines that close the <tags>
rewind(fileID)
rewind(fileID)
END IF END IF
!Write iteration file in collection !Write iteration file in collection
OPEN (fileID + 1, file = path // folder // '/' // fileNameCollection, ACCESS='APPEND') OPEN (fileID + 1, file = generateFilePath(fileNameCollection), ACCESS='APPEND')
WRITE(fileID + 1, "(4X, A, ES20.6E3, A, A, A)") & WRITE(fileID + 1, "(4X, A, "//fmtReal//", A, A, A)") &
'<DataSet timestep="', DBLE(timeStep)*tauMin*ti_ref,'" file="', fileNameStep,'"/>' '<DataSet timestep="', DBLE(timeStep)*tauMin*ti_ref,'" file="', fileNameStep,'"/>'
!Close collection file
IF (timeStep == tFinal) THEN
WRITE (fileID + 1, "(2X, A)") '</Collection>' WRITE (fileID + 1, "(2X, A)") '</Collection>'
WRITE (fileID + 1, "(A)") '</VTKFile>' WRITE (fileID + 1, "(A)") '</VTKFile>'
END IF
CLOSE(fileID + 1) CLOSE(fileID + 1)
END SUBROUTINE writeCollection END SUBROUTINE writeCollection
@ -276,29 +278,29 @@ MODULE moduleMeshOutputVTU
!Write density !Write density
WRITE(fileIDMean, "(10X,A)") '<DataArray type="Float64" Name="Density, mean (m^-3)" NumberOfComponents="1">' WRITE(fileIDMean, "(10X,A)") '<DataArray type="Float64" Name="Density, mean (m^-3)" NumberOfComponents="1">'
WRITE(fileIDDeviation,"(10X,A)") '<DataArray type="Float64" Name="Density, deviation (m^-3)" NumberOfComponents="1">' WRITE(fileIDDeviation,"(10X,A)") '<DataArray type="Float64" Name="Density, deviation (m^-3)" NumberOfComponents="1">'
WRITE(fileIDMean, "(6(ES20.6E3))") (outputMean(n)%density, n = 1, self%numNodes) WRITE(fileIDMean, "(6("//fmtReal//"))") (outputMean(n)%density, n = 1, self%numNodes)
WRITE(fileIDDeviation,"(6(ES20.6E3))") (outputDeviation(n)%density, n = 1, self%numNodes) WRITE(fileIDDeviation,"(6("//fmtReal//"))") (outputDeviation(n)%density, n = 1, self%numNodes)
WRITE(fileIDMean,"(10X,A)") '</DataArray>' WRITE(fileIDMean,"(10X,A)") '</DataArray>'
WRITE(fileIDDeviation,"(10X,A)") '</DataArray>' WRITE(fileIDDeviation,"(10X,A)") '</DataArray>'
!Write velocity !Write velocity
WRITE(fileIDMean, "(10X,A)") '<DataArray type="Float64" Name="Velocity, mean (m s^-1)" NumberOfComponents="3">' WRITE(fileIDMean, "(10X,A)") '<DataArray type="Float64" Name="Velocity, mean (m s^-1)" NumberOfComponents="3">'
WRITE(fileIDDeviation,"(10X,A)") '<DataArray type="Float64" Name="Velocity, deviation (m s^-1)" NumberOfComponents="3">' WRITE(fileIDDeviation,"(10X,A)") '<DataArray type="Float64" Name="Velocity, deviation (m s^-1)" NumberOfComponents="3">'
WRITE(fileIDMean, "(6(ES20.6E3))") (outputMean(n)%velocity, n = 1, self%numNodes) WRITE(fileIDMean, "(6("//fmtReal//"))") (outputMean(n)%velocity, n = 1, self%numNodes)
WRITE(fileIDDeviation,"(6(ES20.6E3))") (outputDeviation(n)%velocity, n = 1, self%numNodes) WRITE(fileIDDeviation,"(6("//fmtReal//"))") (outputDeviation(n)%velocity, n = 1, self%numNodes)
WRITE(fileIDMean, "(10X,A)") '</DataArray>' WRITE(fileIDMean, "(10X,A)") '</DataArray>'
WRITE(fileIDDeviation,"(10X,A)") '</DataArray>' WRITE(fileIDDeviation,"(10X,A)") '</DataArray>'
!Write pressure !Write pressure
WRITE(fileIDMean, "(10X,A)") '<DataArray type="Float64" Name="Pressure, mean (Pa)" NumberOfComponents="1">' WRITE(fileIDMean, "(10X,A)") '<DataArray type="Float64" Name="Pressure, mean (Pa)" NumberOfComponents="1">'
WRITE(fileIDDeviation,"(10X,A)") '<DataArray type="Float64" Name="Pressure, deviation (Pa)" NumberOfComponents="1">' WRITE(fileIDDeviation,"(10X,A)") '<DataArray type="Float64" Name="Pressure, deviation (Pa)" NumberOfComponents="1">'
WRITE(fileIDMean, "(6(ES20.6E3))") (outputMean(n)%pressure, n = 1, self%numNodes) WRITE(fileIDMean, "(6("//fmtReal//"))") (outputMean(n)%pressure, n = 1, self%numNodes)
WRITE(fileIDDeviation,"(6(ES20.6E3))") (outputDeviation(n)%pressure, n = 1, self%numNodes) WRITE(fileIDDeviation,"(6("//fmtReal//"))") (outputDeviation(n)%pressure, n = 1, self%numNodes)
WRITE(fileIDMean, "(10X,A)") '</DataArray>' WRITE(fileIDMean, "(10X,A)") '</DataArray>'
WRITE(fileIDDeviation,"(10X,A)") '</DataArray>' WRITE(fileIDDeviation,"(10X,A)") '</DataArray>'
!Write temperature !Write temperature
WRITE(fileIDMean, "(10X,A)") '<DataArray type="Float64" Name="Temperature, mean (K)" NumberOfComponents="1">' WRITE(fileIDMean, "(10X,A)") '<DataArray type="Float64" Name="Temperature, mean (K)" NumberOfComponents="1">'
WRITE(fileIDDeviation,"(10X,A)") '<DataArray type="Float64" Name="Temperature, deviation (K)" NumberOfComponents="1">' WRITE(fileIDDeviation,"(10X,A)") '<DataArray type="Float64" Name="Temperature, deviation (K)" NumberOfComponents="1">'
WRITE(fileIDMean, "(6(ES20.6E3))") (outputMean(n)%temperature, n = 1, self%numNodes) WRITE(fileIDMean, "(6("//fmtReal//"))") (outputMean(n)%temperature, n = 1, self%numNodes)
WRITE(fileIDDeviation,"(6(ES20.6E3))") (outputDeviation(n)%temperature, n = 1, self%numNodes) WRITE(fileIDDeviation,"(6("//fmtReal//"))") (outputDeviation(n)%temperature, n = 1, self%numNodes)
WRITE(fileIDMean, "(10X,A)") '</DataArray>' WRITE(fileIDMean, "(10X,A)") '</DataArray>'
WRITE(fileIDDeviation,"(10X,A)") '</DataArray>' WRITE(fileIDDeviation,"(10X,A)") '</DataArray>'
!End node data !End node data
@ -310,7 +312,6 @@ MODULE moduleMeshOutputVTU
SUBROUTINE printOutputVTU(self) SUBROUTINE printOutputVTU(self)
USE moduleMesh USE moduleMesh
USE moduleSpecies USE moduleSpecies
USE moduleMeshInoutCommon
USE moduleCaseParam, ONLY: timeStep USE moduleCaseParam, ONLY: timeStep
IMPLICIT NONE IMPLICIT NONE
@ -322,8 +323,8 @@ MODULE moduleMeshOutputVTU
DO i = 1, nSpecies DO i = 1, nSpecies
fileName = formatFileName(prefix, species(i)%obj%name, 'vtu', timeStep) fileName = formatFileName(prefix, species(i)%obj%name, 'vtu', timeStep)
WRITE(*, "(6X,A15,A)") "Creating file: ", fileName call informFileCreation(fileName)
OPEN (fileID, file = path // folder // '/' // fileName) OPEN (fileID, file = generateFilePath(fileName))
CALL writeHeader(self%numNodes, self%numCells, fileID) CALL writeHeader(self%numNodes, self%numCells, fileID)
@ -346,7 +347,6 @@ MODULE moduleMeshOutputVTU
SUBROUTINE printCollVTU(self) SUBROUTINE printCollVTU(self)
USE moduleMesh USE moduleMesh
USE moduleOutput USE moduleOutput
USE moduleMeshInoutCommon
USE moduleCaseParam, ONLY: timeStep USE moduleCaseParam, ONLY: timeStep
IMPLICIT NONE IMPLICIT NONE
@ -358,8 +358,8 @@ MODULE moduleMeshOutputVTU
IF (collOutput) THEN IF (collOutput) THEN
fileName = formatFileName(prefix, 'Collisions', 'vtu', timeStep) fileName = formatFileName(prefix, 'Collisions', 'vtu', timeStep)
WRITE(*, "(6X,A15,A)") "Creating file: ", fileName call informFileCreation(fileName)
OPEN (fileID, file = path // folder // '/' // fileName) OPEN (fileID, file = generateFilePath(fileName))
CALL writeHeader(self%numNodes, self%numCells, fileID) CALL writeHeader(self%numNodes, self%numCells, fileID)
@ -381,7 +381,6 @@ MODULE moduleMeshOutputVTU
SUBROUTINE printEMVTU(self) SUBROUTINE printEMVTU(self)
USE moduleMesh USE moduleMesh
USE moduleMeshInoutCommon
USE moduleCaseParam, ONLY: timeStep USE moduleCaseParam, ONLY: timeStep
IMPLICIT NONE IMPLICIT NONE
@ -393,8 +392,8 @@ MODULE moduleMeshOutputVTU
IF (emOutput) THEN IF (emOutput) THEN
fileName = formatFileName(prefix, 'EMField', 'vtu', timeStep) fileName = formatFileName(prefix, 'EMField', 'vtu', timeStep)
WRITE(*, "(6X,A15,A)") "Creating file: ", fileName call informFileCreation(fileName)
OPEN (fileID, file = path // folder // '/' // fileName) OPEN (fileID, file = generateFilePath(fileName))
CALL writeHeader(self%numNodes, self%numCells, fileID) CALL writeHeader(self%numNodes, self%numCells, fileID)
@ -416,8 +415,8 @@ MODULE moduleMeshOutputVTU
SUBROUTINE printAverageVTU(self) SUBROUTINE printAverageVTU(self)
USE moduleMesh USE moduleMesh
use moduleOutput
USE moduleSpecies USE moduleSpecies
USE moduleMeshInoutCommon
IMPLICIT NONE IMPLICIT NONE
CLASS(meshParticles), INTENT(in):: self CLASS(meshParticles), INTENT(in):: self
@ -429,12 +428,12 @@ MODULE moduleMeshOutputVTU
DO i = 1, nSpecies DO i = 1, nSpecies
fileNameMean = formatFileName('Average_mean', species(i)%obj%name, 'vtu') fileNameMean = formatFileName('Average_mean', species(i)%obj%name, 'vtu')
WRITE(*, "(6X,A15,A)") "Creating file: ", fileNameMean call informFileCreation(fileNameMean)
OPEN (fileIDMean, file = path // folder // '/' // fileNameMean) OPEN (fileIDMean, file = generateFilePath(fileNameMean))
fileNameDeviation = formatFileName('Average_deviation', species(i)%obj%name, 'vtu') fileNameDeviation = formatFileName('Average_deviation', species(i)%obj%name, 'vtu')
WRITE(*, "(6X,A15,A)") "Creating file: ", fileNameDeviation call informFileCreation(fileNameDeviation)
OPEN (fileIDDeviation, file = path // folder // '/' // fileNameDeviation) OPEN (fileIDDeviation, file = generateFilePath(fileNameDeviation))
CALL writeHeader(self%numNodes, self%numCells, fileIDMean) CALL writeHeader(self%numNodes, self%numCells, fileIDMean)
CALL writeHeader(self%numNodes, self%numCells, fileIDDeviation) CALL writeHeader(self%numNodes, self%numCells, fileIDDeviation)

View file

@ -887,12 +887,16 @@ MODULE moduleMesh
!Array for boundaries !Array for boundaries
type(boundaryParticleCont), allocatable, target:: boundariesParticle(:) type(boundaryParticleCont), allocatable, target:: boundariesParticle(:)
! Update the particle boundary models
interface interface
! Update the particle boundary models
module subroutine boundariesParticle_update() module subroutine boundariesParticle_update()
end subroutine boundariesParticle_update end subroutine boundariesParticle_update
! Write data about particle boundaries
module subroutine boundariesParticle_write()
end subroutine boundariesParticle_write
end interface end interface
! BOUNDARY ELECTROMAGNETIC DEFINITIONS ! BOUNDARY ELECTROMAGNETIC DEFINITIONS

View file

@ -414,9 +414,9 @@ submodule(moduleMesh) boundaryParticle
write(fileID, '(A)') self%name write(fileID, '(A)') self%name
select type(self) select type(self)
type is(boundaryQuasiNeutrality) type is(boundaryQuasiNeutrality)
write(fileID, '(A,",",A)'), '"Edge id"', '"alpha"' write(fileID, '(A,",",A)') '"Edge id"', '"alpha"'
do e = 1, size(self%edges) do e = 1, size(self%edges)
write(fileID, '(I0,",",ES0.6E3)'), self%edges(e)%obj%n, self%alpha(self%edges(e)%obj%n) write(fileID, '(I0,",",ES0.6E3)') self%edges(e)%obj%n, self%alpha(self%edges(e)%obj%n)
end do end do
@ -477,4 +477,28 @@ submodule(moduleMesh) boundaryParticle
end subroutine boundariesParticle_update end subroutine boundariesParticle_update
module subroutine boundariesParticle_write()
use moduleCaseparam, only: timeStep
use moduleOutput, only:fileID_boundaryParticle, formatFileName, informFileCreation
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_write
end submodule boundaryParticle end submodule boundaryParticle

View file

@ -43,6 +43,25 @@ MODULE moduleOutput
LOGICAL:: collOutput = .FALSE. LOGICAL:: collOutput = .FALSE.
LOGICAL:: emOutput = .FALSE. LOGICAL:: emOutput = .FALSE.
! Prefix for iteration files
character(len=*), parameter:: prefix = 'Step'
! Column separator
character(len=*), parameter:: colSep = '","'
! General format for file outputs
character(len=*), parameter:: fmtColReal = 'ES0.6E3,:,'//colSep ! Column with real
character(len=*), parameter:: fmtColInt = 'I0,:,'//colSep ! Column with integer
character(len=*), parameter:: fmtColStr = 'A,:,'//colSep ! Column with text
character(len=*), parameter:: fmtReal = 'ES14.6E3' ! Fixed size real
character(len=*), parameter:: fmtInt = 'I14' ! Fixed size real
! File IDs for different input/output
integer, parameter:: fileID_mesh = 10 ! Base id for mesh files
integer, parameter:: fileID_output = 20 ! Base id for species/collisions/EM output
integer, parameter:: fileID_boundaryParticle = 30 ! Particle boundaries
integer, parameter:: fileID_boundaryEM = 31 ! EM boundaries
CONTAINS CONTAINS
PURE SUBROUTINE outputNode_equal_outputNode(self, from) PURE SUBROUTINE outputNode_equal_outputNode(self, from)
IMPLICIT NONE IMPLICIT NONE
@ -177,7 +196,7 @@ MODULE moduleOutput
WRITE(20, "(A1, 8X, A1, 9X, A1, 7(A20))") "#","t","n","total (s)","push (s)","reset (s)", & WRITE(20, "(A1, 8X, A1, 9X, A1, 7(A20))") "#","t","n","total (s)","push (s)","reset (s)", &
"collision (s)","coulomb (s)", & "collision (s)","coulomb (s)", &
"weighting (s)","EMField (s)" "weighting (s)","EMField (s)"
WRITE(*, "(6X,A15,A)") "Creating file: ", fileName call informFileCreation(fileName)
CLOSE(20) CLOSE(20)
END IF END IF
@ -194,5 +213,43 @@ MODULE moduleOutput
END SUBROUTINE printTime END SUBROUTINE printTime
PURE FUNCTION formatFileName(pref, suff, extension, timeStep) RESULT(fileName)
IMPLICIT NONE
CHARACTER(*), INTENT(in):: pref, suff, extension
INTEGER, INTENT(in), OPTIONAL:: timeStep
CHARACTER (LEN=iterationDigits):: tString
CHARACTER(:), ALLOCATABLE:: fileName
IF (PRESENT(timeStep)) THEN
WRITE(tString, iterationFormat) timeStep
fileName = pref // '_' // tString // '_' // suff // '.' // extension
ELSE
fileName = pref // '_' // suff // '.' // extension
END IF
END FUNCTION formatFileName
pure function generateFilePath(filename) result(completePath)
implicit none
character(*), intent(in):: fileName
character(:), allocatable:: completePath
completePath = path // folder // '/' // fileName
end function generateFilePath
subroutine informFileCreation(filename)
implicit none
character(*), intent(in):: fileName
write(*, "(6X,A15,A)") "Creating file: ", fileName
end subroutine informFileCreation
END MODULE moduleOutput END MODULE moduleOutput

View file

@ -521,7 +521,6 @@ 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
CALL outputProbes() CALL outputProbes()
@ -538,7 +537,7 @@ MODULE moduleSolver
CALL mesh%printEM() CALL mesh%printEM()
! Output of boundaries. TODO: Add an if ! Output of boundaries. TODO: Add an if
call boundariesParticle_print() call boundariesParticle_write()
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