feature/meshText #57

Merged
JGonzalez merged 10 commits from feature/meshText into development 2026-01-23 15:27:27 +01:00
2 changed files with 88 additions and 10 deletions
Showing only changes of commit 7d4f4b98c3 - Show all commits

Implementing input subroutines

Jorge Gonzalez 2026-01-19 15:37:31 +01:00

View file

@ -41,19 +41,25 @@ module moduleMeshInputText
class(meshGeneric), intent(inout):: self class(meshGeneric), intent(inout):: self
character(:), allocatable, intent(in):: filename !Dummy file, not used character(:), allocatable, intent(in):: filename !Dummy file, not used
integer:: fileID, reason integer:: fileID, reason
CHARACTER(LEN=256):: line character(len=256):: line
real(8):: r !dummy 1D coordinate integer:: nNodes
real(8):: r(1:3) !dummy 3D coordinate
integer:: physicalID integer:: physicalID
integer:: n, c
integer, allocatable:: p(:)
integer:: bt
fileID = 10 fileID = 10
open(fileID, file=trim(filename)) open(fileID, file=trim(filename))
!Skip header !Skip header
read(fileID) read(fileID, *)
!Get number of nodes
nNodes = 0
do do
read(fileID, *, iostat=reason) r, physicalID read(fileID, *, iostat=reason) line
if (reason > 0) then if (reason > 0) then
call criticalError('Error reading mesh file', 'readText') call criticalError('Error reading mesh file', 'readText')
@ -61,10 +67,82 @@ module moduleMeshInputText
else if (reason < 0) then else if (reason < 0) then
exit exit
else if (len(line) > 0) then
nNodes = nNodes + 1
end if end if
write(*, *) r, physicalID end do
if (nNodes == 0) then
call criticalError('No nodes read in mesh file', 'readText')
end if
self%numNodes = nNodes
self%numCells = nNodes - 1
allocate(self%nodes(1:self%numNodes))
allocate(self%cells(1:self%numCells))
select type(self)
type is (meshParticles)
self%numEdges = 2
allocate(self%edges(1:self%numEdges))
end select
!Read the mesh now
rewind(fileID)
!Skip header
read(fileID, *)
!Allocate nodes and edges
do n = 1, self%numNodes
r = 0.D0
read(fileID, *) r(1), physicalID
select case(self%geometry)
case("Cart")
allocate(meshNode1DCart:: self%nodes(n)%obj)
case("Rad")
allocate(meshNode1DRad:: self%nodes(n)%obj)
end select
!Init nodes
call self%nodes(n)%obj%init(n, r)
!Allocate edges if required)
select type(self)
type is (meshParticles)
if ((physicalID == 1) .or. (physicalID == 2)) then
select case(self%geometry)
case("Cart")
allocate(meshEdge1DCart:: self%edges(physicalID)%obj)
case("Rad")
allocate(meshEdge1DRad:: self%edges(physicalID)%obj)
end select
allocate(p(1))
p(1) = n
bt = getBoundaryId(physicalID)
call self%edges(physicalID)%obj%init(physicalID, p, physicalID, physicalID)
deallocate(p)
end if
end select
end do
!Allocate cells
do c = 1, self%numCells
end do end do

View file

@ -344,10 +344,10 @@ MODULE moduleMesh
!Array of cell elements !Array of cell elements
TYPE(meshCellCont), ALLOCATABLE:: cells(:) TYPE(meshCellCont), ALLOCATABLE:: cells(:)
!PROCEDURES SPECIFIC OF FILE TYPE !PROCEDURES SPECIFIC OF FILE TYPE
PROCEDURE(readMesh_interface), POINTER, PASS:: readMesh => NULL() PROCEDURE(readMesh_interface), POINTER, PASS:: readMesh => NULL()
PROCEDURE(readInitial_interface), POINTER, NOPASS:: readInitial => NULL() PROCEDURE(readInitial_interface), POINTER, NOPASS:: readInitial => NULL()
PROCEDURE(connectMesh_interface), POINTER, PASS:: connectMesh => NULL() PROCEDURE(connectMesh_interface), POINTER, PASS:: connectMesh => NULL()
PROCEDURE(printColl_interface), POINTER, PASS:: printColl => NULL() PROCEDURE(printColl_interface), POINTER, PASS:: printColl => NULL()
CONTAINS CONTAINS
!GENERIC PROCEDURES !GENERIC PROCEDURES
PROCEDURE, PASS:: doCollisions PROCEDURE, PASS:: doCollisions