First version of vtu file format

After some testing and making things a bit better and more general, I am
quite happy with the implementation of vtu and it seems that it is
working (at least as good as Gmsh2).

There are some procedures that might be useful for other XML-like
formats that might be moved in the future to the common module (I am
    thinking right now in the implementation of a general format like
    XDMF3).
This commit is contained in:
Jorge Gonzalez 2023-02-07 16:02:36 +01:00
commit 2c55913501
7 changed files with 51 additions and 39 deletions

View file

@ -1,29 +1,7 @@
MODULE moduleMeshOutputVTU
CHARACTER(LEN=6):: prefix = 'OUTPUT'
CONTAINS
PURE FUNCTION formatFileName(prefix, suffix, extension, t) RESULT(fileName)
USE moduleOutput
IMPLICIT NONE
CHARACTER(*), INTENT(in):: prefix, suffix, extension
INTEGER, INTENT(in), OPTIONAL:: t
CHARACTER (LEN=iterationDigits):: tString
CHARACTER(:), ALLOCATABLE:: fileName
IF (PRESENT(t)) THEN
WRITE(tString, iterationFormat) t
fileName = prefix // '_' // tString // '_' // suffix // '.' // extension
ELSE
fileName = prefix // '_' // suffix // '.' // extension
END IF
END FUNCTION formatFileName
SUBROUTINE writeHeader(nNodes, nCells, fileID)
USE moduleMesh
IMPLICIT NONE
@ -332,6 +310,7 @@ MODULE moduleMeshOutputVTU
SUBROUTINE printOutputVTU(self,t)
USE moduleMesh
USE moduleSpecies
USE moduleMeshInoutCommon
IMPLICIT NONE
CLASS(meshParticles), INTENT(in):: self
@ -358,7 +337,7 @@ MODULE moduleMeshOutputVTU
CLOSE(fileID)
!Write collection file for time plotting
fileNameCollection = formatFileName(prefix, 'Collection_' // species(i)%obj%name, 'pvd')
fileNameCollection = formatFileName('Collection', species(i)%obj%name, 'pvd')
CALL writeCollection(fileID, t, fileName, filenameCollection)
END DO
@ -368,6 +347,7 @@ MODULE moduleMeshOutputVTU
SUBROUTINE printCollVTU(self,t)
USE moduleMesh
USE moduleOutput
USE moduleMeshInoutCommon
IMPLICIT NONE
CLASS(meshGeneric), INTENT(in):: self
@ -395,7 +375,7 @@ MODULE moduleMeshOutputVTU
CLOSE(fileID)
!Write collection file for time plotting
fileNameCollection = formatFileName(prefix, 'Collection_Collisions', 'pvd')
fileNameCollection = formatFileName('Collection', 'Collisions', 'pvd')
CALL writeCollection(fileID, t, fileName, filenameCollection)
END IF
@ -404,6 +384,7 @@ MODULE moduleMeshOutputVTU
SUBROUTINE printEMVTU(self, t)
USE moduleMesh
USE moduleMeshInoutCommon
IMPLICIT NONE
CLASS(meshParticles), INTENT(in):: self
@ -429,7 +410,7 @@ MODULE moduleMeshOutputVTU
CLOSE(fileID)
!Write collection file for time plotting
fileNameCollection = formatFileName(prefix, 'Collection_EMField', 'pvd')
fileNameCollection = formatFileName('Collection', 'EMField', 'pvd')
CALL writeCollection(fileID, t, fileName, filenameCollection)
END IF
@ -439,6 +420,7 @@ MODULE moduleMeshOutputVTU
SUBROUTINE printAverageVTU(self)
USE moduleMesh
USE moduleSpecies
USE moduleMeshInoutCommon
IMPLICIT NONE
CLASS(meshParticles), INTENT(in):: self