From 7b470b7f584e98c3f7928c2bd9b9b47806e814c1 Mon Sep 17 00:00:00 2001 From: Jorge Gonzalez Date: Sun, 5 Feb 2023 18:32:38 +0100 Subject: [PATCH] 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. --- .../mesh/inout/vtu/moduleMeshInputVTU.f90 | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/modules/mesh/inout/vtu/moduleMeshInputVTU.f90 b/src/modules/mesh/inout/vtu/moduleMeshInputVTU.f90 index 505f10d..b283d67 100644 --- a/src/modules/mesh/inout/vtu/moduleMeshInputVTU.f90 +++ b/src/modules/mesh/inout/vtu/moduleMeshInputVTU.f90 @@ -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)