initial_conditions Module

Provides a single public entry point apply_initial_condition that fills the conserved-state array state%ub (interior + halo) for the chosen problem. For boundary conditions that use early-return in apply_bcs (dirichlet / inflow / supersonic_inlet), this routine also pre-fills the halo cells with the prescribed boundary state.

Supported problems: 'sod' — Sod shock tube 'shu_osher' — Shu-Osher shock/entropy-wave interaction 'smooth_wave' — Smooth advecting density wave (periodic) 'linear_advection' — Sinusoidal density on uniform background flow (periodic) 'woodward_colella' — Woodward-Colella interacting blast waves 'lax' — Lax shock tube 'from_file' — Read primitives (x, rho, u, p) from an external data file 'udf' — Call a user-defined Fortran subroutine compiled at runtime 'acoustic_pulse' — Gaussian acoustic pulse (quiescent background; NRBC benchmark)



Variables

Type Visibility Attributes Name Initial
integer(kind=c_int), private, parameter :: host_platform_windows = 1_c_int
integer(kind=c_int), private, parameter :: host_platform_macos = 2_c_int
integer(kind=c_int), private, parameter :: host_platform_linux = 3_c_int

Interfaces

interface

  • private function cfd_solver_host_platform() bind(C, name="cfd_solver_host_platform")

    Arguments

    None

    Return Value integer(kind=c_int)

interface

  • private function cfd_solver_call_udf(libpath, n, x, rho, rho_u, e_arr) bind(C, name="cfd_solver_call_udf")

    Arguments

    Type IntentOptional Attributes Name
    character(kind=c_char, len=1), intent(in) :: libpath(*)
    integer(kind=c_int), intent(in), value :: n
    real(kind=c_double), intent(in) :: x(n)
    real(kind=c_double), intent(out) :: rho(n)
    real(kind=c_double), intent(out) :: rho_u(n)
    real(kind=c_double), intent(out) :: e_arr(n)

    Return Value integer(kind=c_int)

interface

  • private function cfd_solver_get_pid() bind(C, name="cfd_solver_get_pid")

    Arguments

    None

    Return Value integer(kind=c_int)


Functions

private function get_host_platform() result(platform)

Return the host platform detected by the C portability shim.

Arguments

None

Return Value integer(kind=c_int)

private function get_windows_temp_dir() result(temp_dir)

Return the preferred runtime-UDF output directory on Windows.

Arguments

None

Return Value character(len=512)

private function join_path(dirpath, leafname, separator) result(full_path)

Join a directory and leaf name with a platform-appropriate separator.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: dirpath
character(len=*), intent(in) :: leafname
character(len=1), intent(in) :: separator

Return Value character(len=len_trim)

public function quote_shell_arg(raw_path) result(quoted_path)

Wrap a filesystem path for the shell used by execute_command_line.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: raw_path

Return Value character(len=len_trim)


Subroutines

public subroutine apply_initial_condition(state, cfg)

Fill state%ub (interior + halo) with the initial condition selected by cfg%problem_type. Boundary halo cells are also pre-populated for Dirichlet-style BCs (dirichlet/inflow/supersonic_inlet) which use early return in apply_bcs.

Arguments

Type IntentOptional Attributes Name
type(solver_state_t), intent(inout), target :: state

Solver state (must have ub allocated, schemes bound)

type(config_t), intent(in) :: cfg

Runtime configuration

private pure subroutine left_right_states_from_namelist(cfg, gam, q_l, q_r)

Convert namelist primitives (rho_left, u_left, p_left / rho_right, ...) to conserved state vectors.

Arguments

Type IntentOptional Attributes Name
type(config_t), intent(in) :: cfg
real(kind=wp), intent(in) :: gam
real(kind=wp), intent(out) :: q_l(neq)
real(kind=wp), intent(out) :: q_r(neq)

private subroutine seed_dirichlet_halos(state, q_l, q_r)

Fill the boundary halo cells with the prescribed Dirichlet states.

Read more…

Arguments

Type IntentOptional Attributes Name
type(solver_state_t), intent(inout) :: state
real(kind=wp), intent(in) :: q_l(neq)
real(kind=wp), intent(in) :: q_r(neq)

private subroutine ic_from_file(state, cfg)

Load the initial condition from a data file containing columns: x rho u p.

Read more…

Arguments

Type IntentOptional Attributes Name
type(solver_state_t), intent(inout) :: state

Solver state (must have ub allocated, schemes bound)

type(config_t), intent(in) :: cfg

Runtime configuration (uses cfg%ic_file, cfg%ic_interp, cfg%gam)

private subroutine ic_udf(state, cfg)

Compile a user-defined Fortran source file to a shared library at runtime and call its ic_udf subroutine to fill the initial state.

Read more…

Arguments

Type IntentOptional Attributes Name
type(solver_state_t), intent(inout) :: state

Solver state (must have ub allocated, schemes bound)

type(config_t), intent(in) :: cfg

Runtime configuration (uses cfg%ic_udf_src)