Subroutines to read .vtu information

All subroutines to read .vtu information is ready.

Now it is time to create the input and generate a mesh for fpakc.
This commit is contained in:
Jorge Gonzalez 2023-02-05 18:32:38 +01:00
commit 7b470b7f58

View file

@ -6,6 +6,11 @@ MODULE moduleMeshInputVTU
END INTERFACE
INTERFACE readDataBlock
MODULE PROCEDURE readIntegerBlock, readRealBlock
END INTERFACE
CONTAINS
FUNCTION findLine(fileID, text) RESULT(line)
USE moduleErrors
@ -93,7 +98,6 @@ MODULE moduleMeshInputVTU
DO WHILE (iStart < nData)
iStart = iStart + 1
iEnd = iStart - 1 + block
PRINT *, iStart, iEnd
IF (iEnd > nData) THEN
iEnd = nData
@ -167,7 +171,8 @@ MODULE moduleMeshInputVTU
INTEGER:: fileID, error, found
CHARACTER(LEN=256):: line
INTEGER:: numNodes, numElements
INTEGER, ALLOCATABLE, DIMENSION(:):: entitiesID, offsets
INTEGER, ALLOCATABLE, DIMENSION(:):: entitiesID, offsets, connectivity, types
REAL(8), ALLOCATABLE, DIMENSION(:):: coordinates
fileID = 10
@ -182,17 +187,37 @@ MODULE moduleMeshInputVTU
!Get the IDs of the cells to identify physical surfaces
line = findLine(fileID, 'Name="CellEntityIds"')
ALLOCATE(entitiesID(1:numElements))
CALL readIntegerBlock(fileID, numElements, entitiesID)
CALL readDataBlock(fileID, numElements, entitiesID)
REWIND(fileID)
!Get the offsets to read connectivity
line = findLine(fileID, 'Name="offsets"')
ALLOCATE(offsets(1:numElements))
CALL readIntegerBlock(fileID, numElements, offsets)
CALL readDataBlock(fileID, numElements, offsets)
REWIND(fileID)
!Get the connectivity of elements to nodes
line = findline(fileID, 'Name="connectivity"')
ALLOCATE(connectivity(1:MAXVAL(offsets)))
CALL readDataBlock(fileID, MAXVAL(offsets), connectivity)
REWIND(fileID)
!Get the type of elements
line = findline(fileID, 'Name="types"')
ALLOCATE(types(1:numElements))
CALL readDataBlock(fileID, numElements, types)
REWIND(fileID)
!Get nodes coordinates
line = findline(fileID, 'Name="Points"')
ALLOCATE(coordinates(1:3*numNodes))
CALL readDataBlock(fileID, 3*numNodes, coordinates)
REWIND(fileID)
CLOSE(fileID)
!All relevant information from the .vtu file has been read. Time to build the mesh.
END SUBROUTINE readVTU
SUBROUTINE readInitialVTU(filename, density, velocity, temperature)