mod_output Module

Output management for VTK visualization and solver diagnostics.

This module handles the generation of simulation results in modern XML-based VTK format (.vtu) and CSV-based global diagnostics. It manages the creation of the output directory, writing mesh summaries, and generating PVD collection files for time-series visualization in ParaView. Most arrays are globally allocated, but VTU piece files write owned cells only. Variable-density projection validation should use divu_minus_S_projection diagnostics, not raw divergence.



Variables

Type Visibility Attributes Name Initial
integer, private, save :: n_pvd_entries = 0
integer, private, allocatable, save :: pvd_steps(:)
real(kind=rk), private, allocatable, save :: pvd_times(:)

Functions

private function energy_reconciliation_value(energy, transport, c, name) result(value)

Arguments

Type IntentOptional Attributes Name
type(energy_fields_t), intent(in) :: energy
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: c
character(len=*), intent(in) :: name

Return Value real(kind=rk)

private function lowmach_cell_div_mass_flux(mesh, fields, c) result(value)

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_fields_t), intent(in) :: fields
integer, intent(in) :: c

Return Value real(kind=rk)

private function lowmach_cell_divu(mesh, fields, c) result(value)

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_fields_t), intent(in) :: fields
integer, intent(in) :: c

Return Value real(kind=rk)

private function lowmach_cell_rho_current(transport, c) result(value)

Arguments

Type IntentOptional Attributes Name
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: c

Return Value real(kind=rk)

private function lowmach_cell_rho_projection(fields, transport, c) result(value)

Arguments

Type IntentOptional Attributes Name
type(flow_fields_t), intent(in) :: fields
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: c

Return Value real(kind=rk)

private function lowmach_cell_source_current(fields, c) result(value)

Arguments

Type IntentOptional Attributes Name
type(flow_fields_t), intent(in) :: fields
integer, intent(in) :: c

Return Value real(kind=rk)

private function lowmach_cell_source_projection(fields, c) result(value)

Arguments

Type IntentOptional Attributes Name
type(flow_fields_t), intent(in) :: fields
integer, intent(in) :: c

Return Value real(kind=rk)

private function lowmach_cell_u_dot_grad_rho(mesh, fields, transport, c) result(value)

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_fields_t), intent(in) :: fields
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: c

Return Value real(kind=rk)

private function lowmach_debug_value(mesh, fields, transport, c, name) result(value)

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_fields_t), intent(in) :: fields
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: c
character(len=*), intent(in) :: name

Return Value real(kind=rk)


Subroutines

public subroutine load_existing_pvd(params, flow, start_step)

Checks if an existing flow.pvd file exists and reads its entries to populate our steps/times.

Arguments

Type IntentOptional Attributes Name
type(case_params_t), intent(in) :: params
type(flow_mpi_t), intent(in) :: flow
integer, intent(in), optional :: start_step

public subroutine prepare_output(params, flow)

Creates the output directory specified in the case parameters.

Arguments

Type IntentOptional Attributes Name
type(case_params_t), intent(in) :: params
type(flow_mpi_t), intent(in) :: flow

public subroutine update_pvd_collection(params, flow, step, time)

Dynamically adds a new step and actual physical time entry to flow.pvd.

Arguments

Type IntentOptional Attributes Name
type(case_params_t), intent(in) :: params
type(flow_mpi_t), intent(in) :: flow
integer, intent(in) :: step
real(kind=rk), intent(in) :: time

public subroutine write_boundary_mass_balance_diagnostics(mesh, flow, params, fields, transport, step, time)

Write per-patch boundary mass-balance diagnostics.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(case_params_t), intent(in) :: params
type(flow_fields_t), intent(in) :: fields
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: step
real(kind=rk), intent(in) :: time

public subroutine write_diagnostics_header(params, flow)

Writes the CSV header for global simulation diagnostics.

Arguments

Type IntentOptional Attributes Name
type(case_params_t), intent(in) :: params
type(flow_mpi_t), intent(in) :: flow

public subroutine write_diagnostics_row(params, flow, step, time, stats)

Appends a new row of diagnostic data to the CSV file.

Arguments

Type IntentOptional Attributes Name
type(case_params_t), intent(in) :: params
type(flow_mpi_t), intent(in) :: flow
integer, intent(in) :: step
real(kind=rk), intent(in) :: time
type(solver_stats_t), intent(in) :: stats

public subroutine write_enthalpy_energy_budget_diagnostics(mesh, flow, params, fields, energy, transport, step, time)

Write dedicated enthalpy/energy budget diagnostics.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(case_params_t), intent(in) :: params
type(flow_fields_t), intent(in) :: fields
type(energy_fields_t), intent(in) :: energy
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: step
real(kind=rk), intent(in) :: time

public subroutine write_mesh_summary(params, flow, mesh)

Writes a human-readable summary of the mesh connectivity and patches.

Arguments

Type IntentOptional Attributes Name
type(case_params_t), intent(in) :: params
type(flow_mpi_t), intent(in) :: flow
type(mesh_t), intent(in) :: mesh

public subroutine write_pvd_collection(params, flow, nsteps, output_interval, dt)

Writes a PVD collection file to allow ParaView to load time-series data (legacy wrapper).

Arguments

Type IntentOptional Attributes Name
type(case_params_t), intent(in) :: params
type(flow_mpi_t), intent(in) :: flow
integer, intent(in) :: nsteps
integer, intent(in) :: output_interval
real(kind=rk), intent(in) :: dt

public subroutine write_species_energy_conservation_diagnostics(mesh, flow, params, fields, species, energy, transport, step, time)

Write aggregate species and enthalpy conservation trend diagnostics.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(case_params_t), intent(in) :: params
type(flow_fields_t), intent(in) :: fields
type(species_fields_t), intent(in) :: species
type(energy_fields_t), intent(in) :: energy
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: step
real(kind=rk), intent(in) :: time

public subroutine write_variable_density_diagnostics(mesh, flow, params, fields, energy, transport, step, time)

Performs sanity checks on hex connectivity before writing output. Write variable-density low-Mach diagnostics to dedicated CSV files.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(case_params_t), intent(in) :: params
type(flow_fields_t), intent(in) :: fields
type(energy_fields_t), intent(in) :: energy
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: step
real(kind=rk), intent(in) :: time

public subroutine write_vtu_unstructured(params, flow, mesh, fields, species, energy, transport, step, time)

Main dispatcher that routes to either ASCII or high-performance Binary VTU formats.

Arguments

Type IntentOptional Attributes Name
type(case_params_t), intent(in) :: params
type(flow_mpi_t), intent(inout) :: flow
type(mesh_t), intent(in) :: mesh
type(flow_fields_t), intent(in) :: fields
type(species_fields_t), intent(in) :: species
type(energy_fields_t), intent(in) :: energy
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: step
real(kind=rk), intent(in) :: time

private subroutine compute_projection_audit_cell_balance(mesh, fields, c, div_c, mdot_div_c, boundary_face_count, physical_boundary_face_count)

Compute recomputed divergence and mass-flux divergence for one cell.

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_fields_t), intent(in) :: fields
integer, intent(in) :: c
real(kind=rk), intent(out) :: div_c
real(kind=rk), intent(out) :: mdot_div_c
integer, intent(out) :: boundary_face_count
integer, intent(out) :: physical_boundary_face_count

private subroutine reduce_sum(local_value, global_value, flow)

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: local_value
real(kind=rk), intent(out) :: global_value
type(flow_mpi_t), intent(in) :: flow

private subroutine write_csv_header(unit_id, text)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit_id
character(len=*), intent(in) :: text

private subroutine write_csv_value_i(unit_id, value)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit_id
integer, intent(in) :: value

private subroutine write_csv_value_r(unit_id, value)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit_id
real(kind=rk), intent(in) :: value

private subroutine write_energy_reconciliation_scalar(unit_id, mesh, flow, energy, transport, name)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit_id
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(energy_fields_t), intent(in) :: energy
type(transport_properties_t), intent(in) :: transport
character(len=*), intent(in) :: name

private subroutine write_energy_reconciliation_vtu_arrays(unit_id, mesh, flow, energy, transport)

Append local rho*h density-reconciliation fields to VTU CellData.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit_id
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(energy_fields_t), intent(in) :: energy
type(transport_properties_t), intent(in) :: transport

private subroutine write_lowmach_debug_scalar(unit_id, mesh, flow, fields, transport, name)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit_id
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(flow_fields_t), intent(in) :: fields
type(transport_properties_t), intent(in) :: transport
character(len=*), intent(in) :: name

private subroutine write_lowmach_debug_vtu_arrays(unit_id, mesh, flow, params, fields, transport)

Append variable-density low-Mach debug fields to the VTU CellData block.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit_id
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(case_params_t), intent(in) :: params
type(flow_fields_t), intent(in) :: fields
type(transport_properties_t), intent(in) :: transport

private subroutine write_projection_audit_one_cell(mesh, flow, fields, energy, transport, step, time, c, audit_label, unit_cells, unit_faces)

Write one audited cell and all its faces.

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(flow_fields_t), intent(in) :: fields
type(energy_fields_t), intent(in) :: energy
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: step
real(kind=rk), intent(in) :: time
integer, intent(in) :: c
character(len=*), intent(in) :: audit_label
integer, intent(in) :: unit_cells
integer, intent(in) :: unit_faces

private subroutine write_pvtu_master(params, flow, step)

Writes the master Parallel VTK file (.pvtu) that links the rank pieces.

Arguments

Type IntentOptional Attributes Name
type(case_params_t), intent(in) :: params
type(flow_mpi_t), intent(in) :: flow
integer, intent(in) :: step

private subroutine write_variable_density_boundary_residual_scan(mesh, flow, params, fields, energy, transport, step, time)

Scan all owned boundary-adjacent cells for low-Mach projection residuals.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(case_params_t), intent(in) :: params
type(flow_fields_t), intent(in) :: fields
type(energy_fields_t), intent(in) :: energy
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: step
real(kind=rk), intent(in) :: time

private subroutine write_variable_density_compatibility_diagnostics(mesh, flow, params, fields, step, time)

Write low-Mach compatibility and source-time-level diagnostics.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(case_params_t), intent(in) :: params
type(flow_fields_t), intent(in) :: fields
integer, intent(in) :: step
real(kind=rk), intent(in) :: time

private subroutine write_variable_density_continuity_residual_diagnostics(mesh, flow, params, fields, transport, step, time)

Write conservative continuity residual diagnostics for variable-density mode.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(case_params_t), intent(in) :: params
type(flow_fields_t), intent(in) :: fields
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: step
real(kind=rk), intent(in) :: time

private subroutine write_variable_density_projection_audit(mesh, flow, params, fields, energy, transport, step, time)

Targeted projection audit for variable-density low-Mach residuals.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(case_params_t), intent(in) :: params
type(flow_fields_t), intent(in) :: fields
type(energy_fields_t), intent(in) :: energy
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: step
real(kind=rk), intent(in) :: time

private subroutine write_variable_density_transport_conservation_diagnostics(mesh, flow, params, fields, energy, transport, step, time)

Write variable-density transport/conservation diagnostics.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(flow_mpi_t), intent(in) :: flow
type(case_params_t), intent(in) :: params
type(flow_fields_t), intent(in) :: fields
type(energy_fields_t), intent(in) :: energy
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: step
real(kind=rk), intent(in) :: time

private subroutine write_vtu_ascii(params, flow, mesh, fields, species, energy, transport, step, time)

Writes the full flow field to an XML Unstructured Grid file (.vtu).

Read more…

Arguments

Type IntentOptional Attributes Name
type(case_params_t), intent(in) :: params
type(flow_mpi_t), intent(inout) :: flow
type(mesh_t), intent(in) :: mesh
type(flow_fields_t), intent(in) :: fields
type(species_fields_t), intent(in) :: species
type(energy_fields_t), intent(in) :: energy
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: step
real(kind=rk), intent(in) :: time

private subroutine write_vtu_binary(params, flow, mesh, fields, species, energy, transport, step, time)

Arguments

Type IntentOptional Attributes Name
type(case_params_t), intent(in) :: params
type(flow_mpi_t), intent(inout) :: flow
type(mesh_t), intent(in) :: mesh
type(flow_fields_t), intent(in) :: fields
type(species_fields_t), intent(in) :: species
type(energy_fields_t), intent(in) :: energy
type(transport_properties_t), intent(in) :: transport
integer, intent(in) :: step
real(kind=rk), intent(in) :: time