Skip to content

NASTO — Common

Backend-independent physics, configuration, and I/O layer for all NASTO solvers.

The common/ directory provides the objects shared by every NASTO backend (CPU, NVF, FNL, GMP). It covers the full simulation lifecycle — configuration parsing, equation of state, initial and boundary conditions, time-step control, and I/O — without containing any backend-specific compute kernels.

Module overview

Source fileModuleTypeRole
adam_nasto_parameters.F90adam_nasto_parametersGlobal parameter placeholder
adam_nasto_common_object.F90adam_nasto_common_objectnasto_common_objectCentral orchestrator; extended by every backend
adam_nasto_physics_object.F90adam_nasto_physics_objectnasto_physics_objectSpecies count and variable-index management
adam_nasto_eos_object.F90adam_nasto_eos_objectnasto_eos_objectIdeal-gas equation of state per species
adam_nasto_bc_object.F90adam_nasto_bc_objectnasto_bc_objectBoundary condition types and inflow data
adam_nasto_ic_object.F90adam_nasto_ic_objectnasto_ic_objectInitial condition setup (uniform, vortex, Riemann)
adam_nasto_io_object.F90adam_nasto_io_objectnasto_io_objectOutput frequency, restart, residual monitoring
adam_nasto_time_object.F90adam_nasto_time_objectnasto_time_objectCFL time-step control and termination criteria
adam_nasto_common_library.F90adam_nasto_common_libraryBarrel re-export of all modules above

Object hierarchy


nasto_common_object

The top-level base class. Every backend object (nasto_cpu_object, nasto_nvf_object, etc.) extends this type, inheriting all handlers and grid/field references without duplicating configuration logic.

Data members

ADAM SDK objects (aggregated, not inherited):

MemberTypePurpose
mpihmpih_objectMPI communication handler
adamadam_objectTop-level ADAM framework
fieldfield_object*5D field array container
gridgrid_object*Block-structured grid geometry
amramr_objectAMR marker and refinement handler
ibib_objectImmersed boundary method
slicesslices_objectIn-situ slice output
rkrk_objectRunge-Kutta temporal integrator
wenoweno_objectWENO reconstruction

NASTO handlers:

MemberTypePurpose
ionasto_io_objectOutput and restart control
physicsnasto_physics_objectSpecies and thermodynamics
icnasto_ic_objectInitial condition setup
bcnasto_bc_objectBoundary conditions
timenasto_time_objectTime-step and termination

Field arrays (allocated with ghost cells):

fortran
real(R8P), allocatable :: q    (nv,     1-ngc:ni+ngc, 1-ngc:nj+ngc, 1-ngc:nk+ngc, nb)
real(R8P), allocatable :: q_aux(nv_aux, 1-ngc:ni+ngc, 1-ngc:nj+ngc, 1-ngc:nk+ngc, nb)

q holds conservative variables; q_aux holds primitive/auxiliary variables (density, velocity components, pressure, temperature, etc.).

Methods

ProcedurePurpose
allocate_common()Allocates q and q_aux with correct ghost-cell bounds
initialize_common()Full startup sequence: MPI → IO → physics → grid → AMR → fields → IC → BC → time → WENO → IB

nasto_physics_object

Manages the number of fluid species and the mapping between species and conservative-variable indices.

Data members

MemberTypeDefaultDescription
nsI4P1Number of fluid species
nvI4P5Conservative variables = ns + 4 (momentum + energy)
nv_auxI4P9Auxiliary variables = ns + 8
npI4P51D primitive variables = ns + 4
eos(:)nasto_eos_objectEOS model for each species [1:ns]

Variable index offsets (module-level, computed after initialize()):

IndexMeaning
IR = ns + 1Bulk density in q_aux
IU = ns + 2x-velocity
IV = ns + 3y-velocity
IW = ns + 4z-velocity
IG = ns + 5Heat capacity ratio γ
IP = ns + 6Pressure

Methods

ProcedureNotes
initialize()Reads ns from INI; allocates eos(1:ns); updates index offsets
conservative2primitive()Pure: (ρs, ρu, ρv, ρw, ρE) → (s, u, v, w, ρ, p, γ)
primitive2conservative()Pure: inverse conversion
description()Formatted summary string

INI configuration

ini
[physics]
  ns = 1          ! number of fluid species

nasto_eos_object

Ideal-gas equation of state for a single fluid species. Stores primary thermodynamic properties and pre-computes derived combinations for efficiency.

Data members

MemberTypeDescription
cpR8PSpecific heat at constant pressure (J/kg·K)
cvR8PSpecific heat at constant volume (J/kg·K)
gR8PHeat capacity ratio γ = cp/cv
RR8PGas constant = cp − cv (J/kg·K)
muR8PDynamic viscosity (Pa·s)
kdR8PThermal diffusivity (W/m·K)
dhaR8PEnthalpy of formation (J/kg)
gm1R8Pγ − 1 (pre-computed)
gp1R8Pγ + 1 (pre-computed)
deltaR8P(γ − 1)/2
etaR8P2γ/(γ − 1)

Methods

Elemental state functions (vectorise over arrays):

ProcedureReturns
pressure(ρ, e)p=(γ1)ρe
density(p, c)ρ=γp/c2
speed_of_sound(ρ, p)c=γp/ρ
temperature(ρ, p)T=p/(ρR)
internal_energy(ρ, p)e=p/[(γ1)ρ]
total_energy(ρ, u, v, w, p)E=e+12(u2+v2+w2)
total_entalpy(ρ, u, v, w, p)H=E+p/ρ

Other methods:

ProcedurePurpose
compute_derivate()Derives gm1, gp1, delta, eta from cp/cv
conservative2primitive()Single-species conversion
load_from_file()Reads properties from INI
save_into_file()Writes properties back to INI
destroy()Resets to default state

INI configuration

Section name: physics_specie_N where N is the species index (1-based).

ini
[physics_specie_1]
  cp  = 1004.5      ! J/kg·K
  cv  = 717.5       ! J/kg·K
  mu  = 1.8e-5      ! Pa·s
  kd  = 0.026       ! W/m·K
  dha = 0.0         ! J/kg  (enthalpy of formation)

nasto_bc_object

Stores the boundary condition type for each of the six domain faces and the prescribed primitive-variable state for inflow boundaries.

Boundary condition types

ConstantValueDescription
BC_EXTRAPOLATION1Zero-gradient extrapolation (outflow)
BC_INFLOW2Supersonic inflow with prescribed (ρ, u, v, w, p)
BC_WALL_INVISCID3Slip wall — normal velocity set to zero

Face ordering in bc_type(6): x_min, x_max, y_min, y_max, z_min, z_max.

INI configuration

ini
[bc_x_min]
  type = inflow
  r = 1.225       ! density (kg/m³)
  u = 340.0       ! x-velocity (m/s)
  v = 0.0
  w = 0.0
  p = 101325.0    ! pressure (Pa)
  s = 1           ! species index

[bc_x_max]
  type = extrapolation

[bc_y_min]
  type = wall-inviscid

[bc_y_max]
  type = extrapolation

[bc_z_min]
  type = periodic

[bc_z_max]
  type = periodic

nasto_ic_object

Sets the initial field q across all AMR blocks. Supports three analytical configurations and a flexible multi-region domain decomposition.

Initial condition types

Type stringDescription
uniformUniform state everywhere; optional random velocity perturbation
isentropic-vortexLamb-Oseen isentropic vortex superposed on a background flow
riemann-problemPiecewise-constant regions defined by axis-aligned bounding boxes

Data members

MemberDescription
ic_typeSelected IC type string
regions_numberNumber of spatial regions
q(6, regions_number)Primitive state per region: (ρ, u, v, w, p, species)
emin(3, regions_number)Min corner (x, y, z) of each region bounding box
emax(3, regions_number)Max corner (x, y, z) of each region bounding box
amr_iterationsAMR refinement passes applied after IC setup

INI configuration

ini
[initial_conditions]
  type            = riemann-problem
  regions_number  = 2
  amr_iterations  = 3

[initial_conditions_region_1]
  r = 1.0   u = 0.0   v = 0.0   w = 0.0   p = 1.0   s = 1
  emin_x = 0.0   emin_y = 0.0   emin_z = 0.0
  emax_x = 10.0  emax_y = 20.0  emax_z = 20.0

[initial_conditions_region_2]
  r = 0.125   u = 0.0   v = 0.0   w = 0.0   p = 0.1   s = 1
  emin_x = 10.0  emin_y = 0.0   emin_z = 0.0
  emax_x = 20.0  emax_y = 20.0  emax_z = 20.0

nasto_io_object

Controls output scheduling, restart checkpointing, and residual monitoring.

Data members

MemberTypeDefaultDescription
output_basenamecharacterBase filename for HDF5 snapshots
it_saveI4P100Output frequency (iterations)
restartlogical.false.Enable restart from checkpoint
restart_basenamecharacterBase filename for restart files
restart_saveI4P100Restart checkpoint frequency
residuals_saveI4P10Residuals file write frequency
save_memory_statuslogical.false.Log memory usage during allocation

Methods

ProcedurePurpose
initialize()Creates FiNeR parser; loads all IO parameters
open_file_residuals()Opens residuals file; writes column header
save_residuals()Appends iteration, time, block count, and field norms
close_file_residuals()Closes residuals file unit
description()Pure: formatted configuration summary

INI configuration

ini
[IO]
  output_basename    = nasto_out
  it_save            = 100
  restart            = .false.
  restart_basename   = nasto_rst
  restart_save       = 500
  residuals_save     = 10
  save_memory_status = .false.

nasto_time_object

Governs temporal integration: CFL-based time-step selection, iteration counting, and simulation termination.

Data members

MemberTypeDefaultDescription
it_maxI4P−1Max iterations; ≤ 0 means use time_max instead
time_maxR8P1.0Max physical time (s)
CFLR8P0.3Courant–Friedrichs–Lewy number
itI4P0Current iteration counter
timeR8P0.0Current physical time
dtR8P0.0001Current time step (updated each iteration)

Termination logic

it_maxStopping criterion
≤ 0time ≥ time_max
> 0it ≥ it_max

Output is also forced at the final iteration regardless of it_save spacing.

Methods

ProcedurePurpose
initialize()Loads time parameters from INI
is_to_save() → logicalReturns .true. when output should be written
print_progress()Prints iteration, time, dt, and % completion
description()Pure: formatted configuration summary

INI configuration

ini
[time]
  it_max   = -1       ! use time_max as stopping criterion
  time_max = 10.0     ! seconds
  CFL      = 0.8

adam_nasto_common_library

A barrel re-export module: use adam_nasto_common_library brings every module listed in the overview table into scope with a single statement. Backend objects use this as their sole import from common/.


Copyrights

NASTO is part of the ADAM framework, released under the GNU Lesser General Public License v3.0 (LGPLv3).

Copyright (C) Andrea Di Mascio, Federico Negro, Giacomo Rossi, Francesco Salvadore, Stefano Zaghi.