Average done

Now we can output averages in this format.
This commit is contained in:
Jorge Gonzalez 2026-01-23 14:26:39 +01:00
commit 46b9f263ea

View file

@ -10,13 +10,13 @@ module moduleMeshOutputText
class(meshParticles), INTENT(in):: self
integer, intent(in):: fileID
integer, intent(in):: speciesIndex
type(outputFormat):: output
real(8):: r(1:3)
type(outputFormat):: output
integer:: n
do n = 1, self%numNodes
call calculateOutput(self%nodes(n)%obj%output(speciesIndex), output, self%nodes(n)%obj%v, species(speciesIndex)%obj)
r = self%nodes(n)%obj%getCoordinates()
call calculateOutput(self%nodes(n)%obj%output(speciesIndex), output, self%nodes(n)%obj%v, species(speciesIndex)%obj)
write(fileID, '(5(ES0.6E3,","),ES0.6E3)') r(1)*L_ref, output%density, output%velocity, output%temperature
@ -68,6 +68,41 @@ module moduleMeshOutputText
end subroutine writeEMOutput
subroutine writeAverage(self, fileIDMean, &
fileIDDeviation, &
speciesIndex)
use moduleMesh
use moduleOutput
use moduleAverage
use moduleRefParam, only: L_ref
implicit none
class(meshParticles), intent(in):: self
integer, intent(in):: fileIDMean, fileIDDeviation
INTEGER, intent(in):: speciesIndex
real(8):: r(1:3)
type(outputFormat):: outputMean
type(outputFormat):: outputDeviation
integer:: n
do n = 1, self%numNodes
r = self%nodes(n)%obj%getCoordinates()
call calculateOutput(averageScheme(n)%mean%output(speciesIndex), outputMean, &
self%nodes(n)%obj%v, species(speciesIndex)%obj)
write(fileIDMean, '(5(ES0.6E3,","),ES0.6E3)') r(1)*L_ref, outputMean%density, outputMean%velocity, outputMean%temperature
call calculateOutput(averageScheme(n)%deviation%output(speciesIndex), outputDeviation, &
self%nodes(n)%obj%v, species(speciesIndex)%obj)
write(fileIDDeviation, '(5(ES0.6E3,","),ES0.6E3)') r(1)*L_ref, outputDeviation%density, outputDeviation%velocity, outputDeviation%temperature
end do
end subroutine writeAverage
subroutine printOutputText(self)
use moduleMesh
use moduleSpecies
@ -118,6 +153,8 @@ module moduleMeshOutputText
write(*, "(6X,A15,A)") "Creating file: ", fileName
open (fileID, file = path // folder // '/' // fileName)
close(fileID)
end if
end subroutine printCollText
@ -154,9 +191,43 @@ module moduleMeshOutputText
subroutine printAverageText(self)
use moduleMesh
use moduleSpecies
use moduleMeshInoutCommon
implicit none
class(meshParticles), intent(in):: self
integer:: s
integer:: fileIDMean, fileIDDeviation
character(:), allocatable:: fileNameMean, fileNameDeviation
fileIDMean = 66
fileIDDeviation = 67
do s = 1, nSpecies
fileNameMean = formatFileName('Average_mean', species(s)%obj%name, 'csv', timeStep)
write(*, "(6X,A15,A)") "Creating file: ", fileNameMean
open (fileIDMean, file = path // folder // '/' // fileNameMean)
write(fileIDMean, '(5(A,","),A)') 'Position (m)', &
'Density, mean (m^-3)', &
'Velocity, mean (m s^-1):0', 'Velocity (m s^-1):1', 'Velocity (m s^-1):2', &
'Temperature, mean (K)'
fileNameDeviation = formatFileName('Average_deviation', species(s)%obj%name, 'csv', timeStep)
write(*, "(6X,A15,A)") "Creating file: ", fileNameDeviation
open (fileIDDeviation, file = path // folder // '/' // fileNameDeviation)
write(fileIDDeviation, '(5(A,","),A)') 'Position (m)', &
'Density, deviation (m^-3)', &
'Velocity, deviation (m s^-1):0', 'Velocity (m s^-1):1', 'Velocity (m s^-1):2', &
'Temperature, deviation (K)'
call writeAverage(self, fileIDMean, fileIDDeviation, s)
close(fileIDMean)
close(fileIDDeviation)
end do
end subroutine printAverageText