Compare commits

...

2 commits

7 changed files with 261 additions and 5 deletions

View file

@ -9,6 +9,7 @@ OBJECTS = $(OBJDIR)/moduleMesh.o $(OBJDIR)/moduleMeshBoundary.o $(OBJDIR)/module
$(OBJDIR)/moduleMeshInputVTU.o $(OBJDIR)/moduleMeshOutputVTU.o \ $(OBJDIR)/moduleMeshInputVTU.o $(OBJDIR)/moduleMeshOutputVTU.o \
$(OBJDIR)/moduleMeshInputGmsh2.o $(OBJDIR)/moduleMeshOutputGmsh2.o \ $(OBJDIR)/moduleMeshInputGmsh2.o $(OBJDIR)/moduleMeshOutputGmsh2.o \
$(OBJDIR)/moduleMeshInput0D.o $(OBJDIR)/moduleMeshOutput0D.o \ $(OBJDIR)/moduleMeshInput0D.o $(OBJDIR)/moduleMeshOutput0D.o \
$(OBJDIR)/moduleMeshInputText.o $(OBJDIR)/moduleMeshOutputText.o \
$(OBJDIR)/moduleMesh3DCart.o \ $(OBJDIR)/moduleMesh3DCart.o \
$(OBJDIR)/moduleMesh2DCyl.o \ $(OBJDIR)/moduleMesh2DCyl.o \
$(OBJDIR)/moduleMesh2DCart.o \ $(OBJDIR)/moduleMesh2DCart.o \

View file

@ -910,6 +910,7 @@ MODULE moduleInput
USE moduleMeshInputGmsh2, ONLY: initGmsh2 USE moduleMeshInputGmsh2, ONLY: initGmsh2
USE moduleMeshInputVTU, ONLY: initVTU USE moduleMeshInputVTU, ONLY: initVTU
USE moduleMeshInput0D, ONLY: init0D USE moduleMeshInput0D, ONLY: init0D
USE moduleMeshInputText, ONLY: initText
USE moduleMesh3DCart USE moduleMesh3DCart
USE moduleMesh2DCyl USE moduleMesh2DCyl
USE moduleMesh2DCart USE moduleMesh2DCart
@ -1058,6 +1059,20 @@ MODULE moduleInput
END IF END IF
case ("text")
!Check if the geometry is right.
if (mesh%dimen /= 1) then
call criticalError("Text mesh is only allowed for 1D geometries", 'readGeometry')
end if
!Read the mesh
call initText(mesh)
if (doubleMesh) then
call initText(meshColl)
end if
CASE DEFAULT CASE DEFAULT
CALL criticalError('Mesh format ' // meshFormat // ' not defined.', 'readGeometry') CALL criticalError('Mesh format ' // meshFormat // ' not defined.', 'readGeometry')

View file

@ -1,4 +1,4 @@
all: vtu.o gmsh2.o 0D.o all: vtu.o gmsh2.o 0D.o text.o
vtu.o: moduleMeshInoutCommon.o vtu.o: moduleMeshInoutCommon.o
$(MAKE) -C vtu all $(MAKE) -C vtu all
@ -9,5 +9,8 @@ gmsh2.o:
0D.o: 0D.o:
$(MAKE) -C 0D all $(MAKE) -C 0D all
text.o:
$(MAKE) -C text all
%.o: %.f90 %.o: %.f90
$(FC) $(FCFLAGS) -c $< -o $(OBJDIR)/$@ $(FC) $(FCFLAGS) -c $< -o $(OBJDIR)/$@

View file

@ -0,0 +1,7 @@
all: moduleMeshInputText.o moduleMeshOutputText.o
moduleMeshInputText.o: moduleMeshOutputText.o moduleMeshInputText.f90
$(FC) $(FCFLAGS) -c $(subst .o,.f90,$@) -o $(OBJDIR)/$@
%.o: %.f90
$(FC) $(FCFLAGS) -c $< -o $(OBJDIR)/$@

View file

@ -0,0 +1,163 @@
module moduleMeshInputText
!The mesh is stored as a column-wise text file.
!Aimed for simple geometries in 1D
contains
!Inits the text mesh
subroutine initText(self)
use moduleMesh
use moduleMeshOutputText
implicit none
class(meshGeneric), intent(inout), target:: self
if (associated(meshForMCC,self)) then
self%printColl => printCollText
end if
select type(self)
type is (meshParticles)
self%printOutput => printOutputText
self%printEM => printEMText
self%printAverage => printAverageText
self%readInitial => readInitialText
end select
self%readMesh => readText
end subroutine initText
!Reads the text mesh
subroutine readText(self, filename)
use moduleMesh
use moduleMesh1DCart
use moduleMesh1DRad
use moduleErrors
implicit none
class(meshGeneric), intent(inout):: self
character(:), allocatable, intent(in):: filename !Dummy file, not used
integer:: fileID, reason
character(len=256):: line
integer:: nNodes
real(8):: r(1:3) !dummy 3D coordinate
integer:: physicalID
integer:: n, c
integer, allocatable:: p(:)
integer:: bt
fileID = 10
open(fileID, file=trim(filename))
!Skip header
read(fileID, *)
!Get number of nodes
nNodes = 0
do
read(fileID, *, iostat=reason) line
if (reason > 0) then
call criticalError('Error reading mesh file', 'readText')
else if (reason < 0) then
exit
else if (len(line) > 0) then
nNodes = nNodes + 1
end if
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
close(fileID)
end subroutine readText
subroutine readInitialText(filename, density, velocity, temperature)
implicit none
character(:), allocatable, intent(in):: filename
real(8), allocatable, intent(out), dimension(:):: density
real(8), allocatable, intent(out), dimension(:,:):: velocity
real(8), allocatable, intent(out), dimension(:):: temperature
end subroutine readInitialText
end module moduleMeshInputText

View file

@ -0,0 +1,67 @@
module moduleMeshOutputText
contains
subroutine writeSpeciesOutput(self, fileID, speciesIndex)
use moduleMesh
use moduleOutput
implicit none
class(meshParticles), INTENT(in):: self
integer, intent(in):: fileID
integer, intent(in):: speciesIndex
end subroutine writeSpeciesOutput
subroutine writeCollOutput(self, fileID)
use moduleMesh
use moduleCollisions
implicit none
class(meshGeneric), intent(in):: self
integer, intent(in):: fileID
end subroutine writeCollOutput
subroutine writeEMOutput(self, fileID)
use moduleMesh
use moduleRefParam
implicit none
class(meshParticles), intent(in):: self
integer, intent(in):: fileID
end subroutine writeEMOutput
subroutine printOutputText(self)
use moduleMesh
implicit none
class(meshParticles), intent(in):: self
end subroutine printOutputText
subroutine printCollText(self)
use moduleMesh
implicit none
class(meshGeneric), intent(in):: self
end subroutine printCollText
subroutine printEMText(self)
use moduleMesh
implicit none
class(meshParticles), intent(in):: self
end subroutine printEMText
subroutine printAverageText(self)
use moduleMesh
implicit none
class(meshParticles), intent(in):: self
end subroutine printAverageText
end module moduleMeshOutputText

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