Write_DGModel1D_t Subroutine

public subroutine Write_DGModel1D_t(this, fileName)

Arguments

TypeIntentOptionalAttributesName
class(DGModel1D_t), intent(inout) :: this
character, intent(in), optional :: fileName

Contents

Source Code


Source Code

  subroutine Write_DGModel1D_t(this,fileName)
#undef __FUNC__
#define __FUNC__ "Write_DGModel1D_t"
    implicit none
    class(DGModel1D_t),intent(inout) :: this
    character(*),optional,intent(in) :: fileName
    ! Local
    integer(HID_T) :: fileId
    type(Scalar1D) :: solution
    type(Scalar1D) :: x
    type(Lagrange),target :: interp
    character(LEN=self_FileNameLength) :: pickupFile
    character(13) :: timeStampString

    write(timeStampString,'(I13.13)') this%ioIterate
    if(present(filename)) then
      pickupFile = trim(filename)
    else
      pickupFile = 'solution.'//timeStampString//'.h5'
    endif

    INFO("Writing pickup file : "//trim(pickupFile))
    call this%solution%UpdateHost()

    call Open_HDF5(pickupFile,H5F_ACC_TRUNC_F,fileId)

    ! Write the interpolant to the file
    INFO("Writing interpolant data to file")
    call this%solution%interp%WriteHDF5(fileId)

    ! In this section, we write the solution and geometry on the control (quadrature) grid
    ! which can be used for model pickup runs or post-processing

    ! Write the model state to file
    INFO("Writing control grid solution to file")
    call CreateGroup_HDF5(fileId,'/controlgrid')
    call this%solution%WriteHDF5(fileId,'/controlgrid/solution')

    ! Write the geometry to file
    INFO("Writing control grid  geometry to file")
    call CreateGroup_HDF5(fileId,'/controlgrid/geometry')
    call this%geometry%x%WriteHDF5(fileId,'/controlgrid/geometry/x')
    ! -- END : writing solution on control grid -- !

    ! Interpolate the solution to a grid for plotting results
    ! Create an interpolant for the uniform grid
    call interp%Init(this%solution%interp%M, &
                     this%solution%interp%targetNodeType, &
                     this%solution%interp%N, &
                     this%solution%interp%controlNodeType)

    call solution%Init(interp, &
                       this%solution%nVar,this%solution%nElem)

    call x%Init(interp,1,this%solution%nElem)

    ! Map the mesh positions to the target grid
    call this%geometry%x%GridInterp(x%interior)

    ! Map the solution to the target grid
    call this%solution%GridInterp(solution%interior)

    ! Write the model state to file
    INFO("Writing target grid solution to file")
    call CreateGroup_HDF5(fileId,'/targetgrid')
    call solution%WriteHDF5(fileId,'/targetgrid/solution')

    ! Write the geometry to file
    INFO("Writing target grid geometry to file")
    call CreateGroup_HDF5(fileId,'/targetgrid/geometry')
    call x%WriteHDF5(fileId,'/targetgrid/geometry/x')

    call Close_HDF5(fileId)

    call x%Free()
    call solution%Free()
    call interp%Free()

  endsubroutine Write_DGModel1D_t