|
Mallard 0.8.0
Unstructured, GPU accelerated, high-order finite volume CFD solver
Mallard website |
#include <solver.h>
Public Member Functions | |
| Solver () | |
| ~Solver () | |
| int | init (const std::string &input_file_name) |
| Initialize the solver from an input file. | |
| int | init (const toml::value &input) |
| Initialize the solver from a parsed TOML input. | |
| int | run () |
| Run until a stop condition is reached. | |
| void | take_step () |
| Advance the solution by one time step. With chemistry, the half step that ends it may be deferred (see run) and fused with the next step's first half (Strang splitting). | |
| void | calc_rhs (State solution, State rhs, rtype t) |
| Compute dU/dt for the given conservative state at time t. | |
| rtype | calc_dt_cfl1 (Kokkos::View< rtype > on_device={}) |
| Compute the stable time step for the current solution. | |
| void | update_primitives () |
| Recompute primitives from conservatives on the device. | |
| void | update_p_max () |
| Raise P_MAX to the current pressure (updates the primitives). | |
| void | copy_device_to_host () |
| Copy the device solution to the host mirrors. | |
| void | copy_host_to_device () |
| Copy the host mirrors to the device solution. | |
| std::array< rtype, 2 *N_DIM > | calc_force (const Kokkos::View< uint32_t * > &faces) |
| Force exerted by the fluid on a boundary zone: pressure part [Fx, Fy] and viscous part [Fx, Fy]. | |
| std::array< rtype, N_CONSERVATIVE > | integrate_conservatives () |
| Sum of each conservative variable integrated over the domain. | |
| std::vector< rtype > | integrate_species () |
| Partial density of each species integrated over the domain (empty for a single gas). | |
| std::array< rtype, N_FLOW_STATISTICS > | integrate_flow_statistics () |
| Domain integrals of kinetic energy rho |u|^2 / 2, enstrophy rho |omega|^2 / 2, squared dilatation (div u)^2, pressure dilatation p div u, |u|^2, |omega|^2, rho^2, T and T^2, with the reconstruction's velocity gradients (TENO polynomials) or else least-squares ones. | |
| void | update_velocity_gradients () |
| W = [rho, u, p] in W_cells and its gradients in viscous_gradients on the owned cells: from the reconstruction polynomials (TENO), else least squares. | |
| void | update_vortex_fields () |
| Q = (|Omega|^2 - |S|^2) / 2 and the vorticity of each owned cell, into vortex_fields. | |
| void | update_average_pressure_outlets (StateView solution) |
| void | add_mass_flow_force (StateView solution, StateView rhs) |
| Add the uniform body force along the mass flow direction that holds the volume average of rho u at its target: it cancels the rate of change of that average from all other terms of the RHS (integrated over the cells, before division by volume), plus the remaining gap divided by the time step. The energy gains the force's work. | |
| void | update_characteristic_boundaries (rtype t_stage) |
| At the first stage of each step: the transverse terms of the characteristic boundaries and their incoming waves, advanced over the step. | |
| RestartFaces | characteristic_restart_faces () const |
| The [p, u_n] of the characteristic faces of owned cells, once they hold a state. | |
| void | restore_characteristic_state (const RestartData &restart) |
| Takes the characteristic faces' [p, u_n] from a restart file that has every face. | |
| uint64_t | restart_face_key (uint32_t i_face) const |
| Rank-count independent key of a boundary face in restart files. | |
| void | apply_sponges (const State &solution, const State &rhs) |
| Adds the sponge-layer sources to the RHS per unit volume (owned cells). | |
| void | calc_dt () |
| rtype | next_target_time () const |
| The time the next step must not pass: t_stop or the next time-based output. | |
| void | check_fields () |
| std::string | step_graph_unsupported () const |
| void | graph_step () |
| void | record_step () |
| void | destroy_step_graph () |
| void | calc_rhs_mixture (State solution, State rhs, rtype t) |
| void | add_geometric_source (StateView rhs, Kokkos::View< rtype *, Kokkos::LayoutStride > mu) |
| Axisymmetric runs: add geometric_source, made high order by the reconstruction where it can (mu: cell viscosities, empty if inviscid), to the radial momentum of owned cells. | |
| void | update_primitives_mixture () |
| void | init_temperature_seed () |
| rtype | calc_dt_cfl1_mixture () |
| void | freeze_thermodynamics () |
| Double flux: freeze each cell's [gamma, e0] from the true equation of state at the start of a step, and after the step reset rho E to the true equation of state at the pressure the frozen one gives. | |
| void | reset_energy () |
| std::array< rtype, 6 > | mixture_diagnostics () |
| Over owned cells and all ranks: min rho, min p, -max Ma, min T, -max T, -max |sum Y - 1|. | |
| void | update_cell_states (const State &solution, bool update_seed) |
| Gas mixtures: W = [rho, u, p] and the scalars [Y, gamma, e0] of every cell, with the temperature found by Newton from the cached seed; update_seed stores the new temperature as the seed. Only the RHS updates the seed, so that its history, and the last bits of T, do not depend on output or diagnostics. | |
| void | update_transport () |
| Viscous mixtures, after update_cell_states: transport coefficients of every cell and the gradients of [u, T, X]. | |
| void | update_eddy_viscosity (uint32_t n) |
| LES: the SGS coefficients [mu_t, lambda_t, mu_t / (Sc_t W)] of cells [0, n) from the velocity gradients of the current RHS (viscous_gradients, or transport_gradients for mixtures, whose time-step diffusivity NU_EFF also grows). | |
| void | eddy_viscosity_of_state (uint32_t n) |
| LES: the eddy viscosity of the current state for the time step (owned cells) or output (all). | |
| void | update_thickened_flame () |
| Thickened flame: [F, E, Omega] and the chemistry time scale E / F of every cell from the current state (owned cells, exchanged to the halo), once per step in calc_dt. | |
| void | update_partially_stirred_reactor () |
| PaSR: the reacting fraction kappa of every owned cell (chem_time_scale), once per step in calc_dt. | |
| void | update_dynamic_constant () |
| Global dynamic procedure: les.C from the Germano identity of the current state, summed over the domain exactly (fixed point), so the constant is independent of the rank count. The velocity gradients of the state must be up to date on owned cells. | |
| void | thicken_transport () |
| Thickened flame: multiply the transport of every cell (after update_eddy_viscosity). | |
| void | exchange_cell_vectors (const Kokkos::View< rtype *[3]> &v) |
| Overwrite the halo cells of a 3-vector cell field with their owners' values. | |
| void | init_chemistry () |
| Reacting mixtures: read [chemistry]; advance every owned cell that needs it as an adiabatic constant-volume reactor over dt_chem; heat release rate of every cell for output. | |
| void | allocate_chemistry () |
| void | advance_chemistry (double dt_chem) |
| void | take_simpler_step () |
| SIMPLER balanced splitting (Wu, Ma & Ihme 2019): with c = -T(U^n), the reaction substep dU/dt = R(U) - c over dt, then the transport substep dU/dt = T(U) + c over dt / 2. | |
| void | subtract_transport_rate (const State &rhs) |
| SIMPLER: rhs -= T(U^n) on the owned cells. | |
| void | check_chemistry (const CellChemistry::Statistics &stats, double start) |
Counts the active cells of a chemistry call begun at start (timer), adds its rank times to the imbalance sums; throws if any cell failed on any rank. | |
| void | update_heat_release_rate () |
| std::pair< uint64_t, double > | chemistry_statistics () |
| Over all ranks: owned cells advanced in the last chemistry call, max sub-steps of a cell in the last step. | |
| KineticEnergyBudget | kinetic_energy_budget () |
| Rates of change of the resolved kinetic energy by the convective, viscous and SGS fluxes of the current state, from an RHS evaluation that leaves the solver's state as it was (docs/design/les.md, section 4.2). Planar runs only. | |
| rtype | les_constant () const |
| LES: the model constant in use (the dynamic procedure's latest with les.dynamic). | |
| double | les_dynamic_ratio () const |
| LES: <L:M> / <M:M> of the latest dynamic procedure, before clipping at zero. | |
| bool | is_les () const |
| Whether the run is a large-eddy simulation ([les]). | |
| const LES & | get_les () const |
| const Kokkos::View< rtype *[3]>::host_mirror_type & | get_les_coefficients () const |
| LES: [mu_t, lambda_t, mu_t / (Sc_t W)] of each cell as of the last copy_device_to_host. | |
| const Kokkos::View< rtype * >::host_mirror_type & | get_chem_time_scale () const |
| PaSR: the reacting fraction kappa per cell, after copy_device_to_host. | |
| const Kokkos::View< rtype *[3]>::host_mirror_type & | get_tfles_fields () const |
| Thickened flame: [F, E, Omega] per cell, after copy_device_to_host. | |
| const Kokkos::View< rtype *[3]>::host_mirror_type & | get_cell_transport () const |
| bool | is_mixture () const |
| Whether the gas is a mixture (a mechanism is given). | |
| bool | is_viscous () const |
| Whether the flow is viscous (Navier-Stokes), for a single gas or a mixture. | |
| const MixtureModel & | get_mixture () const |
| void | set_distributed (bool on) |
| Whether a run on several ranks splits the mesh between them (default). Call before init(); tests turn it off to get a serial reference on every rank. | |
| bool | is_distributed () const |
| double | chemistry_cells_sent () const |
| Cell integrations done by another rank than the owner so far (chemistry load balancing). | |
| const Distribution & | get_distribution () const |
| double | get_mass_flow_force () const |
| Body force per unit volume, along the mass flow direction, of the last RHS ([source] mass_flow). | |
| rtype | get_time () const |
| const Statistics & | get_statistics () const |
| uint64_t | get_step () const |
| const Euler & | get_physics () const |
| std::shared_ptr< Mesh > | get_mesh () const |
| State | state () const |
| The solution: flow block and species partial densities. | |
| const std::vector< std::string > & | get_species_names () const |
| Names of the transported species, empty for a single gas. | |
Public Attributes | |
| StateView | conservatives |
| SpeciesView | species |
| Kokkos::View< rtype *[N_PRIMITIVE]> | primitives |
| StateView::host_mirror_type | h_conservatives |
| SpeciesView::host_mirror_type | h_species |
| Kokkos::View< rtype *[N_PRIMITIVE]>::host_mirror_type | h_primitives |
| Kokkos::View< rtype * > | p_max |
| Kokkos::View< rtype * >::host_mirror_type | h_p_max |
| Kokkos::View< rtype ** > | vortex_fields |
| Kokkos::View< rtype ** >::host_mirror_type | h_vortex_fields |
| Solver::Solver | ( | ) |
| Solver::~Solver | ( | ) |
| void Solver::add_geometric_source | ( | StateView | rhs, |
| Kokkos::View< rtype *, Kokkos::LayoutStride > | mu | ||
| ) |
Axisymmetric runs: add geometric_source, made high order by the reconstruction where it can (mu: cell viscosities, empty if inviscid), to the radial momentum of owned cells.
Add the uniform body force along the mass flow direction that holds the volume average of rho u at its target: it cancels the rate of change of that average from all other terms of the RHS (integrated over the cells, before division by volume), plus the remaining gap divided by the time step. The energy gains the force's work.
|
protected |
| void Solver::allocate_chemistry | ( | ) |
|
protected |
Adds the sponge-layer sources to the RHS per unit volume (owned cells).
| void Solver::calc_dt | ( | ) |
Compute the stable time step for the current solution.
| on_device | If given (single gas), the local minimum is left there instead, without a host synchronization, and 0 returned. |
| rtype Solver::calc_dt_cfl1_mixture | ( | ) |
Force exerted by the fluid on a boundary zone: pressure part [Fx, Fy] and viscous part [Fx, Fy].
Compute dU/dt for the given conservative state at time t.
|
inlineprotected |
| RestartFaces Solver::characteristic_restart_faces | ( | ) | const |
The [p, u_n] of the characteristic faces of owned cells, once they hold a state.
| void Solver::check_chemistry | ( | const CellChemistry::Statistics & | stats, |
| double | start | ||
| ) |
Counts the active cells of a chemistry call begun at start (timer), adds its rank times to the imbalance sums; throws if any cell failed on any rank.
| void Solver::check_fields | ( | ) |
|
inline |
Cell integrations done by another rank than the owner so far (chemistry load balancing).
Over all ranks: owned cells advanced in the last chemistry call, max sub-steps of a cell in the last step.
|
protected |
Mass fractions of a composition table (numbers or expressions) at the centroids of cells.
| void Solver::copy_device_to_host | ( | ) |
Copy the device solution to the host mirrors.
| void Solver::copy_host_to_device | ( | ) |
Copy the host mirrors to the device solution.
| void Solver::destroy_step_graph | ( | ) |
LES: the eddy viscosity of the current state for the time step (owned cells) or output (all).
Overwrite the halo cells of a 3-vector cell field with their owners' values.
| void Solver::freeze_thermodynamics | ( | ) |
Double flux: freeze each cell's [gamma, e0] from the true equation of state at the start of a step, and after the step reset rho E to the true equation of state at the pressure the frozen one gives.
|
inline |
|
inline |
PaSR: the reacting fraction kappa per cell, after copy_device_to_host.
|
inline |
|
inline |
LES: [mu_t, lambda_t, mu_t / (Sc_t W)] of each cell as of the last copy_device_to_host.
|
inline |
Body force per unit volume, along the mass flow direction, of the last RHS ([source] mass_flow).
|
inline |
|
inline |
|
inline |
Names of the transported species, empty for a single gas.
|
inline |
|
inline |
|
inline |
Thickened flame: [F, E, Omega] per cell, after copy_device_to_host.
|
inline |
| void Solver::graph_step | ( | ) |
Initialize the solver from an input file.
| input_file_name | Path to the TOML input file. |
Initialize the solver from a parsed TOML input.
| input | Parsed TOML input. |
|
protected |
| void Solver::init_chemistry | ( | ) |
Reacting mixtures: read [chemistry]; advance every owned cell that needs it as an adiabatic constant-volume reactor over dt_chem; heat release rate of every cell for output.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Mixtures: read [radiation]; subtract the optically thin radiative loss from the energy RHS.
|
protected |
|
protected |
|
protected |
Cell averages of the conservative variables are computed by splitting each cell into simplices and applying a composite rule on each: in 2D, a fan of triangles, each subdivided into n_sub^2 sub-triangles with a degree-5 Dunavant rule; in 3D, the tetrahedra of Mesh::h_cell_tetrahedra, each subdivided into n_sub^3 sub-tetrahedra with a 14-point degree-5 rule. This resolves discontinuous initial data that do not align with the mesh and is high-order accurate for smooth data. Curved cells use their own rule (curved::Geometry::cell_rule). Cells are averaged in parallel on the host, each thread with its own compiled expressions; every cell's sum runs in the same order as on one thread, so the result does not depend on the thread count.
|
protected |
|
protected |
|
protected |
|
protected |
| void Solver::init_temperature_seed | ( | ) |
| std::array< rtype, N_CONSERVATIVE > Solver::integrate_conservatives | ( | ) |
Sum of each conservative variable integrated over the domain.
| std::array< rtype, N_FLOW_STATISTICS > Solver::integrate_flow_statistics | ( | ) |
Domain integrals of kinetic energy rho |u|^2 / 2, enstrophy rho |omega|^2 / 2, squared dilatation (div u)^2, pressure dilatation p div u, |u|^2, |omega|^2, rho^2, T and T^2, with the reconstruction's velocity gradients (TENO polynomials) or else least-squares ones.
| std::vector< rtype > Solver::integrate_species | ( | ) |
Partial density of each species integrated over the domain (empty for a single gas).
|
inline |
|
inline |
Whether the run is a large-eddy simulation ([les]).
|
inline |
Whether the gas is a mixture (a mechanism is given).
|
inline |
Whether the flow is viscous (Navier-Stokes), for a single gas or a mixture.
| KineticEnergyBudget Solver::kinetic_energy_budget | ( | ) |
Rates of change of the resolved kinetic energy by the convective, viscous and SGS fluxes of the current state, from an RHS evaluation that leaves the solver's state as it was (docs/design/les.md, section 4.2). Planar runs only.
|
inline |
LES: the model constant in use (the dynamic procedure's latest with les.dynamic).
|
inline |
LES: <L:M> / <M:M> of the latest dynamic procedure, before clipping at zero.
| std::array< rtype, 6 > Solver::mixture_diagnostics | ( | ) |
Over owned cells and all ranks: min rho, min p, -max Ma, min T, -max T, -max |sum Y - 1|.
| rtype Solver::next_target_time | ( | ) | const |
The time the next step must not pass: t_stop or the next time-based output.
|
protected |
|
protected |
|
protected |
| void Solver::record_step | ( | ) |
|
protected |
| void Solver::reset_energy | ( | ) |
Rank-count independent key of a boundary face in restart files.
|
protected |
| void Solver::restore_characteristic_state | ( | const RestartData & | restart | ) |
Takes the characteristic faces' [p, u_n] from a restart file that has every face.
| int Solver::run | ( | ) |
Run until a stop condition is reached.
Whether a run on several ranks splits the mesh between them (default). Call before init(); tests turn it off to get a serial reference on every rank.
|
inline |
The solution: flow block and species partial densities.
|
protected |
| std::string Solver::step_graph_unsupported | ( | ) | const |
|
protected |
SIMPLER: rhs -= T(U^n) on the owned cells.
| void Solver::take_simpler_step | ( | ) |
SIMPLER balanced splitting (Wu, Ma & Ihme 2019): with c = -T(U^n), the reaction substep dU/dt = R(U) - c over dt, then the transport substep dU/dt = T(U) + c over dt / 2.
| void Solver::take_step | ( | ) |
Advance the solution by one time step. With chemistry, the half step that ends it may be deferred (see run) and fused with the next step's first half (Strang splitting).
| void Solver::thicken_transport | ( | ) |
Thickened flame: multiply the transport of every cell (after update_eddy_viscosity).
Gas mixtures: W = [rho, u, p] and the scalars [Y, gamma, e0] of every cell, with the temperature found by Newton from the cached seed; update_seed stores the new temperature as the seed. Only the RHS updates the seed, so that its history, and the last bits of T, do not depend on output or diagnostics.
At the first stage of each step: the transverse terms of the characteristic boundaries and their incoming waves, advanced over the step.
| void Solver::update_dynamic_constant | ( | ) |
Global dynamic procedure: les.C from the Germano identity of the current state, summed over the domain exactly (fixed point), so the constant is independent of the rank count. The velocity gradients of the state must be up to date on owned cells.
LES: the SGS coefficients [mu_t, lambda_t, mu_t / (Sc_t W)] of cells [0, n) from the velocity gradients of the current RHS (viscous_gradients, or transport_gradients for mixtures, whose time-step diffusivity NU_EFF also grows).
| void Solver::update_heat_release_rate | ( | ) |
| void Solver::update_p_max | ( | ) |
Raise P_MAX to the current pressure (updates the primitives).
| void Solver::update_partially_stirred_reactor | ( | ) |
PaSR: the reacting fraction kappa of every owned cell (chem_time_scale), once per step in calc_dt.
| void Solver::update_primitives | ( | ) |
Recompute primitives from conservatives on the device.
| void Solver::update_primitives_mixture | ( | ) |
| void Solver::update_thickened_flame | ( | ) |
Thickened flame: [F, E, Omega] and the chemistry time scale E / F of every cell from the current state (owned cells, exchanged to the halo), once per step in calc_dt.
| void Solver::update_transport | ( | ) |
Viscous mixtures, after update_cell_states: transport coefficients of every cell and the gradients of [u, T, X].
| void Solver::update_velocity_gradients | ( | ) |
W = [rho, u, p] in W_cells and its gradients in viscous_gradients on the owned cells: from the reconstruction polynomials (TENO), else least squares.
| void Solver::update_vortex_fields | ( | ) |
Q = (|Omega|^2 - |S|^2) / 2 and the vorticity of each owned cell, into vortex_fields.
|
protected |
|
protected |
|
protected |
| StateView Solver::conservatives |
| StateView::host_mirror_type Solver::h_conservatives |
| Kokkos::View<rtype*>::host_mirror_type Solver::h_p_max |
| Kokkos::View<rtype*[N_PRIMITIVE]>::host_mirror_type Solver::h_primitives |
| SpeciesView::host_mirror_type Solver::h_species |
| Kokkos::View<rtype**>::host_mirror_type Solver::h_vortex_fields |
| Kokkos::View<rtype *> Solver::p_max |
| Kokkos::View<rtype *[N_PRIMITIVE]> Solver::primitives |
| SpeciesView Solver::species |
| Kokkos::View<rtype **> Solver::vortex_fields |