Implementing input subroutines
This commit is contained in:
parent
9f9bacca7c
commit
7d4f4b98c3
2 changed files with 88 additions and 10 deletions
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue