diff --git a/src/makefile b/src/makefile index 247c7d2..83cf8db 100644 --- a/src/makefile +++ b/src/makefile @@ -9,6 +9,7 @@ OBJECTS = $(OBJDIR)/moduleMesh.o $(OBJDIR)/moduleMeshBoundary.o $(OBJDIR)/module $(OBJDIR)/moduleMeshInputVTU.o $(OBJDIR)/moduleMeshOutputVTU.o \ $(OBJDIR)/moduleMeshInputGmsh2.o $(OBJDIR)/moduleMeshOutputGmsh2.o \ $(OBJDIR)/moduleMeshInput0D.o $(OBJDIR)/moduleMeshOutput0D.o \ + $(OBJDIR)/moduleMeshInputText.o $(OBJDIR)/moduleMeshOutputText.o \ $(OBJDIR)/moduleMesh3DCart.o \ $(OBJDIR)/moduleMesh2DCyl.o \ $(OBJDIR)/moduleMesh2DCart.o \ diff --git a/src/modules/init/moduleInput.f90 b/src/modules/init/moduleInput.f90 index 9a8ace6..74da279 100644 --- a/src/modules/init/moduleInput.f90 +++ b/src/modules/init/moduleInput.f90 @@ -910,6 +910,7 @@ MODULE moduleInput USE moduleMeshInputGmsh2, ONLY: initGmsh2 USE moduleMeshInputVTU, ONLY: initVTU USE moduleMeshInput0D, ONLY: init0D + USE moduleMeshInputText, ONLY: initText USE moduleMesh3DCart USE moduleMesh2DCyl USE moduleMesh2DCart @@ -1058,6 +1059,20 @@ MODULE moduleInput 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 CALL criticalError('Mesh format ' // meshFormat // ' not defined.', 'readGeometry') diff --git a/src/modules/mesh/inout/makefile b/src/modules/mesh/inout/makefile index a93161d..1b8883d 100644 --- a/src/modules/mesh/inout/makefile +++ b/src/modules/mesh/inout/makefile @@ -1,4 +1,4 @@ -all: vtu.o gmsh2.o 0D.o +all: vtu.o gmsh2.o 0D.o text.o vtu.o: moduleMeshInoutCommon.o $(MAKE) -C vtu all @@ -9,5 +9,8 @@ gmsh2.o: 0D.o: $(MAKE) -C 0D all +text.o: + $(MAKE) -C text all + %.o: %.f90 $(FC) $(FCFLAGS) -c $< -o $(OBJDIR)/$@ diff --git a/src/modules/mesh/inout/text/makefile b/src/modules/mesh/inout/text/makefile new file mode 100644 index 0000000..26d0f10 --- /dev/null +++ b/src/modules/mesh/inout/text/makefile @@ -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)/$@ diff --git a/src/modules/mesh/inout/text/moduleMeshInputText.f90 b/src/modules/mesh/inout/text/moduleMeshInputText.f90 new file mode 100644 index 0000000..4e29d03 --- /dev/null +++ b/src/modules/mesh/inout/text/moduleMeshInputText.f90 @@ -0,0 +1,85 @@ +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 + real(8):: r !dummy 1D coordinate + integer:: physicalID + + fileID = 10 + + open(fileID, file=trim(filename)) + + !Skip header + read(fileID) + + do + read(fileID, *, iostat=reason) r, physicalID + + if (reason > 0) then + call criticalError('Error reading mesh file', 'readText') + + else if (reason < 0) then + exit + + end if + + write(*, *) r, physicalID + + + 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 diff --git a/src/modules/mesh/inout/text/moduleMeshOutputText.f90 b/src/modules/mesh/inout/text/moduleMeshOutputText.f90 new file mode 100644 index 0000000..c1b288d --- /dev/null +++ b/src/modules/mesh/inout/text/moduleMeshOutputText.f90 @@ -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