Mallard 0.8.0
Unstructured, GPU accelerated, high-order finite volume CFD solver
Mallard website
Loading...
Searching...
No Matches
solver.h
Go to the documentation of this file.
1
12#ifndef SOLVER_H
13#define SOLVER_H
14
15#include <array>
16#include <fstream>
17#include <functional>
18#include <limits>
19#include <memory>
20#include <string>
21#include <vector>
22
23#include <toml.hpp>
24
25#include "mesh.h"
26#include "boundary.h"
27#include "face_reconstruction.h"
28#include "riemann_solver.h"
29#include "time_integrator.h"
30#include "physics.h"
31#include "les.h"
32#include "pasr.h"
33#include "tfles.h"
34#include "mixture.h"
35#include "cell_chemistry.h"
36#include "radiation.h"
38#include "data_writer.h"
39#include "statistics.h"
40#include "synthetic_inflow.h"
41#include "expression.h"
42#include "comm.h"
43#include "distributed_mesh.h"
44#include "distribution.h"
45#include "halo_exchange.h"
46#include "log.h"
47
49 std::string zone;
50 std::string file;
51 Kokkos::View<uint32_t *> faces;
53 std::shared_ptr<std::ofstream> out;
54};
55
56constexpr int N_FLOW_STATISTICS = 9;
57
60 std::string file;
61 std::shared_ptr<std::ofstream> out;
62 bool budget = false; // also the kinetic-energy budget (Solver::kinetic_energy_budget)
63};
64
72 rtype sgs = 0.0;
73 rtype pressure_work = 0.0; // the convective rate of a scheme without numerical dissipation
74};
75
81 std::vector<uint32_t> faces;
82 std::vector<Expression> W;
83};
84
85class Solver {
86 public:
87 Solver();
88 ~Solver();
89
95 int init(const std::string & input_file_name);
96
102 int init(const toml::value & input);
103
108 int run();
109
115 void take_step();
116
120 void calc_rhs(State solution, State rhs, rtype t);
121
128 rtype calc_dt_cfl1(Kokkos::View<rtype> on_device = {});
129
133 void update_primitives();
134
138 void update_p_max();
139
143 void copy_device_to_host();
144
148 void copy_host_to_device();
149
154 std::array<rtype, 2 * N_DIM> calc_force(const Kokkos::View<uint32_t *> & faces);
155
159 std::array<rtype, N_CONSERVATIVE> integrate_conservatives();
160
165 std::vector<rtype> integrate_species();
166
174 std::array<rtype, N_FLOW_STATISTICS> integrate_flow_statistics();
175
182
185
186 // Public because nvcc rejects device lambdas in non-public member functions
196 void add_mass_flow_force(StateView solution, StateView rhs);
210 void apply_sponges(const State & solution, const State & rhs);
211 void calc_dt();
213 rtype next_target_time() const;
214 void check_fields();
215
216 // A whole step (calc_dt and take_step) as one CUDA graph; see solver_graph.cpp
217 std::string step_graph_unsupported() const;
218 void graph_step();
219 void record_step();
220 void destroy_step_graph();
221 void calc_rhs_mixture(State solution, State rhs, rtype t);
227 void add_geometric_source(StateView rhs, Kokkos::View<rtype *, Kokkos::LayoutStride> mu);
238 void reset_energy();
240 std::array<rtype, 6> mixture_diagnostics();
248 void update_cell_states(const State & solution, bool update_seed);
253 void update_transport();
278 void thicken_transport();
280 void exchange_cell_vectors(const Kokkos::View<rtype *[3]> & v);
281
287 void init_chemistry();
288 void allocate_chemistry();
289 void advance_chemistry(double dt_chem);
295 void take_simpler_step();
297 void subtract_transport_rate(const State & rhs);
302 void check_chemistry(const CellChemistry::Statistics & stats, double start);
305 std::pair<uint64_t, double> chemistry_statistics();
306
315 rtype les_constant() const { return les.C; }
317 double les_dynamic_ratio() const { return dynamic_ratio; }
318
320 bool is_les() const { return les_on; }
321 const LES & get_les() const { return les; }
323 const Kokkos::View<rtype *[3]>::host_mirror_type & get_les_coefficients() const { return h_les_coefficients; }
325 const Kokkos::View<rtype *>::host_mirror_type & get_chem_time_scale() const { return h_chem_time_scale; }
327 const Kokkos::View<rtype *[3]>::host_mirror_type & get_tfles_fields() const { return h_tfles_fields; }
328 const Kokkos::View<rtype *[3]>::host_mirror_type & get_cell_transport() const { return h_cell_transport; }
329
331 bool is_mixture() const { return mixture_model != nullptr; }
333 bool is_viscous() const { return is_mixture() ? mixture.viscous : physics.is_viscous(); }
334 const MixtureModel & get_mixture() const { return *mixture_model; }
335
341 void set_distributed(bool on) { distribute = on; }
342 bool is_distributed() const { return distribute && comm::size() > 1; }
343
345 double chemistry_cells_sent() const { return chem_cells_sent; }
346 const Distribution & get_distribution() const { return distribution; }
347
349 double get_mass_flow_force() const { return mass_flow_force; }
350
351 rtype get_time() const { return t; }
352 const Statistics & get_statistics() const { return statistics; }
353 uint64_t get_step() const { return step; }
354 const Euler & get_physics() const { return physics; }
355 std::shared_ptr<Mesh> get_mesh() const { return mesh; }
356
358 State state() const { return State(conservatives, species); }
359
361 const std::vector<std::string> & get_species_names() const { return species_names; }
362
365 Kokkos::View<rtype *[N_PRIMITIVE]> primitives;
366 StateView::host_mirror_type h_conservatives;
367 SpeciesView::host_mirror_type h_species;
368 Kokkos::View<rtype *[N_PRIMITIVE]>::host_mirror_type h_primitives;
369 Kokkos::View<rtype *> p_max; // largest pressure of each cell so far, if P_MAX is written
370 Kokkos::View<rtype *>::host_mirror_type h_p_max;
371 // Q, then the vorticity (one component in 2D), if any of them is written
372 Kokkos::View<rtype **> vortex_fields;
373 Kokkos::View<rtype **>::host_mirror_type h_vortex_fields;
374
375 protected:
376 void init_mesh();
378 void init_radiation();
379 void add_radiation(StateView rhs, SpeciesView rhoY);
380 void init_physics();
381 void init_numerics();
382 void init_boundaries();
383 void init_run_parameters();
384 void init_output();
385 void init_solution();
390 void init_inlets(const std::vector<toml::value> & input_boundaries,
391 const std::vector<std::pair<size_t, std::vector<uint32_t>>> & inlets);
393 void init_sources();
395 void init_sponges();
397 std::vector<std::vector<double>> composition_at_cells(const toml::value & table, const std::string & where,
398 const std::vector<uint32_t> & cells) const;
399 void allocate_memory();
400 void register_data();
401 std::vector<std::string> restart_variables() const; // Flow block, then RHOY_<species>
402 std::string stop_reason() const; // Empty while no stop condition holds
403 bool state_needed() const; // Whether output, checks or the end of the run read the state now
404 double progress() const; // Fraction of the run done, by the first stop condition to hit
405 void print_setup() const;
406 void print_progress();
407 void print_summary(const std::string & stop) const;
408 template <typename F>
409 void timed_phase(const std::string & name, F && f);
410 void write_data(bool force = false);
411 void write_forces();
412 void write_integrals();
413 void write_probes();
415
416 private:
417 // Step graph (solver_graph.cpp)
418 bool cuda_graphs = true; // [run] cuda_graphs
419 bool use_step_graph = false;
420 void * step_graph_exec = nullptr; // cudaGraphExec_t
421 Kokkos::View<rtype> step_dt_cfl1; // device: local, then global minimum
422 Kokkos::View<rtype *> step_scalars; // device: [t, t_target, dt_scales...]
423 Kokkos::View<rtype *, Kokkos::SharedHostPinnedSpace> step_io; // pinned: [t, t_target, dt]
424
425 bool distribute = true;
426 int halo_layers = 0;
427 std::unique_ptr<DistributedMesh> setup; // during init only
428 std::string partitioner;
429 Distribution distribution;
430 HaloExchange halo;
431
432 int base_halo_layers() const;
433 bool halo_too_shallow();
434 void trim_halo();
435 void describe_partition_surface();
436 void init_rhs_split();
437 void init_axisymmetric_weights();
438 void init_les();
440 void update_upwind_sensor();
442 rtype kinetic_energy_rate() const;
447 rtype pressure_work_rate() const;
448
449 template <typename T_riemann_solver>
450 void launch_flux_functor();
451 template <typename T_riemann_solver>
452 void launch_mixture_flux_functor();
453 template <typename T_riemann_solver>
454 void launch_double_flux_functor();
455 void init_mixture_boundaries(const std::vector<toml::value> & input_boundaries,
456 const std::vector<std::array<uint32_t, 2>> & profiled_faces,
457 std::vector<BoundaryCondition> & bcs);
458
459 Kokkos::View<uint32_t *> rhs_cells; // reconstructed cells, the n_early_cells independent of the halo first
460 uint32_t n_early_cells = 0;
461 Kokkos::View<uint32_t *> rhs_faces; // faces of owned cells, whose fluxes are used; empty if all faces
462 Kokkos::DefaultExecutionSpace overlap_space; // runs the early cells while the halo is exchanged
463 bool halo_current = false; // halo of conservatives filled since its last update
464
465 toml::value input;
466
467 // Run parameters
468 uint64_t n_steps;
469 rtype t_stop;
470 rtype t_wall_stop;
471 bool use_cfl;
472 rtype dt = 0.0;
473 rtype dt_fixed = 0.0;
474 rtype cfl;
475 rtype t;
476 uint64_t step;
477 Kokkos::Timer timer;
478 uint64_t n_cells_global = 0;
479
480 // Run log
481 logging::Items mesh_summary;
482 logging::Items boundary_summary;
483 logging::Items source_summary;
484 std::string initial_state;
485 double t_wall_setup = 0.0;
486 double t_wall_stepping = 0.0;
487 double t_wall_checks = 0.0;
488 double t_wall_output = 0.0;
489 double t_wall_run_start = 0.0;
490 double t_stepping_last_check = 0.0;
491 double progress_run_start = 0.0;
492 uint64_t step_run_start = 0;
493 uint64_t step_last_check = 0;
494 uint64_t n_progress_rows = 0;
495
496 // Numerics and physics
497 std::shared_ptr<Mesh> mesh;
498 Euler physics;
499 std::vector<std::string> species_names;
500 std::shared_ptr<MixtureModel> mixture_model; // null for a single gas
501 Mixture mixture;
502 ScalarReconstruction scalar_reconstruction;
503 std::vector<std::vector<double>> bc_mass_fractions; // per boundary condition, empty unless prescribed
504 std::vector<std::array<double, 2>> bc_surrogates; // [gamma, e0] of prescribed states
505 std::vector<double> bc_temperatures; // T of prescribed states
506 BoundaryData boundary_data;
507 std::vector<DirichletBoundary> dirichlet_boundaries;
508 struct AveragePressureOutlet {
509 int32_t i_bc;
510 Kokkos::View<uint32_t *> faces; // Faces of owned cells
511 std::vector<uint32_t> sum_order; // Order of the gathered faces of all ranks by global key
512 };
513 std::vector<AveragePressureOutlet> average_pressure_outlets;
514 Kokkos::View<rtype *[N_DIM + 2]>::host_mirror_type h_face_state;
515 Kokkos::View<int32_t *>::host_mirror_type h_face_state_index;
516 rtype t_boundary_states;
517 bool boundary_states_steady = false; // evaluated, and no expression depends on t
518 std::unique_ptr<FaceReconstruction> face_reconstruction;
519 RiemannSolverType riemann_solver_type;
520 rtype low_mach_cutoff = 0.1_r;
521 bool hybrid_flux = false; // [numerics] convective_flux = "hybrid" (docs/design/les.md, section 4.3)
522 rtype hybrid_threshold = 0.65_r;
523 rtype hybrid_floor = 0.0;
524 Kokkos::View<rtype *> cell_upwind; // hybrid flux: upwind fraction of each cell, else empty
525 std::unique_ptr<TimeIntegrator> time_integrator;
526
527 // Axisymmetric runs (see docs/design/axisymmetric.md)
528 bool axisymmetric = false;
529 Kokkos::View<rtype *> geometric_source; // (cell): int (p - tau_thetatheta) dA, the radial momentum source
530 Kokkos::View<rtype *> cell_mu; // (cell): viscosity, viscous single gases
531
532 // Weights of the convective flux points, (face, q): 3D faces, and 2D Gauss
533 // weights times the radius in axisymmetric runs; empty for planar 2D runs
534 Kokkos::View<rtype **> flux_weights;
535
536 // Work arrays
537 Kokkos::View<rtype *[N_CONSERVATIVE]> W_cells;
538 Kokkos::View<rtype **[2][N_CONSERVATIVE]> face_solution;
539 Kokkos::View<rtype *[N_CONSERVATIVE]> face_flux;
540 Kokkos::View<rtype *[N_CONSERVATIVE][N_DIM]> viscous_gradients;
541 LSQVertexGradientFunctor viscous_gradient; // Fills viscous_gradients from W_cells
542 Kokkos::View<rtype *> cfl_local;
543 Kokkos::View<rtype *>::host_mirror_type h_cfl_local;
544 Kokkos::View<rtype *>::host_mirror_type h_teno_sigma;
545 std::vector<State> solution_vec;
546 std::vector<State> rhs_vec;
547 RHSFunction rhs_func;
548
549 // Large-eddy simulation (docs/design/les.md)
550 bool les_on = false;
551 LES les;
552 Kokkos::View<rtype *> les_delta; // (cell): filter width V^(1/d)
553 Kokkos::View<rtype *> les_width; // (cell): the eddy viscosity's width (les_delta or Scotti's)
554 Kokkos::View<rtype *[3]> les_coefficients; // (cell, [mu_t, lambda_t, mu_t / (Sc_t W)]), empty without LES
555 Kokkos::View<rtype *[3]>::host_mirror_type h_les_coefficients;
556 bool budget_pass = false; // calc_rhs evaluates kinetic_energy_budget
557 bool tfles_on = false; // [les.combustion]: thickened flame
558 ThickenedFlame thickened_flame;
559 Kokkos::View<rtype *[3]> tfles_fields; // (cell, [F, E, Omega])
560 Kokkos::View<rtype *[3]>::host_mirror_type h_tfles_fields;
561 Kokkos::View<rtype *> chem_time_scale; // (cell): E / F or kappa, the chemistry's rate multiplier
562 Kokkos::View<rtype *>::host_mirror_type h_chem_time_scale;
563 bool pasr_on = false; // [les.combustion]: partially stirred reactor
565 Kokkos::View<rtype *[3]> tfles_vorticity;
566 Kokkos::View<rtype *[3][N_DIM]> tfles_gradients;
567 State tfles_halo; // [F, E, Omega] as species, for the halo exchange
568 State dynamic_halo; // [rho, u] as flow, d u_i / d x_j as species, owners' values
569 Kokkos::View<double *[2]> dynamic_terms; // (owned cell, [L:M, M:M] V)
570 Kokkos::View<double *[6]> dynamic_stresses; // (cell, rho Delta^2 D(g) S^d)
571 double dynamic_ratio = 0.0;
572 KineticEnergyBudget budget;
573
574 // Gas mixtures
575 ScalarView cell_scalars; // (cell, [Y_1 .. Y_Ns, gamma, e0])
576 Kokkos::View<rtype *> cell_molar_mass; // TENO: troubled-cell indicator
577 bool double_flux = false;
578 bool cells_frozen = false; // within a double-flux step
579 Kokkos::View<rtype *[2]> frozen_thermo; // (cell, [gamma, e0]) of the step
580 Kokkos::View<rtype *> face_energy_1; // double flux: energy flux of side 1
581 Kokkos::View<rtype *> T_seed; // Newton seed of each cell's temperature
582 Kokkos::View<rtype *>::host_mirror_type h_T_seed;
583 Kokkos::View<rtype **[2][2]> face_thermo; // (face, q, side, [gamma, e0])
584 Kokkos::View<rtype **> face_mdot; // (face, q)
585 Kokkos::View<rtype ***, Kokkos::LayoutRight> species_slots; // (face, side, k)
586 Kokkos::View<rtype *[3]> cell_transport; // viscous: (cell, [mu, lambda, nu_eff])
587 Kokkos::View<rtype *[3]>::host_mirror_type h_cell_transport;
588 Kokkos::View<double **, Kokkos::LayoutRight> cell_diffusion; // (cell, k): rho D_k W_k / W, then D^T_k (Soret)
589 Kokkos::View<rtype **, Kokkos::LayoutRight> transport_values; // (cell, [u, T, X_1 .. X_Ns])
590 Kokkos::View<rtype ***, Kokkos::LayoutRight> transport_gradients; // (cell, variable, dimension)
591 Kokkos::View<rtype **, Kokkos::LayoutRight> bc_transport_values; // (condition, [T, X]) of UPT
592 Kokkos::View<rtype **, Kokkos::LayoutRight, Kokkos::HostSpace> h_D; // output: D_k, then D^T_k (Soret)
593 Kokkos::View<rtype **, Kokkos::LayoutRight, Kokkos::HostSpace> h_Y, h_X; // output
594
595 // Chemistry (Strang splitting around each flow step)
596 bool reacting = false;
597 chemistry::ReactorOptions chemistry_options;
598 double T_frozen = 0.0;
600 Kokkos::View<rtype *> chem_h; // last chemistry sub-step of each cell (restart: CHEM_H)
601 Kokkos::View<rtype *>::host_mirror_type h_chem_h;
602 Kokkos::View<rtype *> chem_cost; // chemistry sub-steps of each cell in the last step
603 Kokkos::View<rtype *>::host_mirror_type h_chem_cost;
604 Kokkos::View<rtype *> hrr; // heat release rate, for output
605 Kokkos::View<rtype *>::host_mirror_type h_hrr;
606 Kokkos::View<rtype **, Kokkos::LayoutRight> production; // W_k omega_k, for output
607 Kokkos::View<rtype **, Kokkos::LayoutRight>::host_mirror_type h_production;
608 uint32_t chemistry_lanes = 0; // vector lanes per cell, 0: automatic
609 CellChemistry cell_chemistry;
610 uint64_t chem_active_cells = 0; // owned cells advanced in the last chemistry call
611 double t_wall_chemistry = 0.0;
612 double t_chemistry_slowest = 0.0; // sums over chemistry calls of the slowest rank's time
613 double t_chemistry_mean = 0.0; // and of the mean of the ranks' times
614 double chem_cells_integrated = 0.0, chem_cells_sent = 0.0; // over calls and ranks; sent: load balancing
615 bool chemistry_load_balance = false;
616 bool fuse_chemistry = false; // run(): fuse consecutive half steps
617 bool simpler = false; // SIMPLER balanced splitting instead of Strang
618 State transport_rate; // SIMPLER: -c = T(U^n), the transport tendency at the step's start
619 bool defer_chemistry = false; // take_step leaves its last half step pending
620 double chemistry_pending = 0.0; // chemistry time not yet applied to the state
621
622 // Optically thin radiation ([radiation])
623 bool radiating = false;
625 Kokkos::View<rtype *, Kokkos::HostSpace> h_qrad; // output: radiative loss [W/m^3]
626
627 // Source terms
628 bool has_gravity = false;
629 rtype gravity[N_DIM] = {};
630 std::vector<Expression> source_expressions; // Per conservative variable, empty if none
631 bool source_time_dependent = false;
632 StateView source_field;
633 StateView::host_mirror_type h_source_field;
634 rtype t_source = -1.0;
635 bool hold_mass_flow = false;
636 double mass_flow_target = 0.0; // volume average of rho u along the direction
637 rtype mass_flow_direction[N_DIM] = {};
638 double domain_volume = 0.0;
639 double mass_flow_force = 0.0;
640
641 // Sponge layers: owned cells of positive total strength sum_i sigma_i,
642 // and sum_i sigma_i U_ref,i of the conservatives, then the partial densities
643 Kokkos::View<uint32_t *> sponge_cells;
644 Kokkos::View<rtype *> sponge_strength;
645 Kokkos::View<rtype **, Kokkos::LayoutRight> sponge_target;
646 rtype sponge_dt_max = std::numeric_limits<rtype>::infinity(); // 1 / max strength
647
648 bool characteristic_transverse = false; // Some characteristic boundary has transverse terms
649 rtype t_characteristic = -1.0; // Time the incoming waves were last advanced from
650 bool characteristic_state_set = false; // char_state holds the faces' state (from a step or a restart)
651 // Synthetic turbulence of inlets, and the time of the targets in char_target
652 std::vector<std::unique_ptr<SyntheticInflow>> inflows;
653 rtype t_inflow = -1.0;
654
655 // Checks
656 uint32_t check_interval;
657 bool check_nan;
658
659 // Outputs
660 std::vector<Data> data;
661 std::vector<std::unique_ptr<DataWriter>> data_writers;
662 std::vector<ForceMonitor> force_monitors;
663 IntegralMonitor integral_monitor;
664 Statistics statistics;
665 Probes probes;
666};
667
668#endif // SOLVER_H
Boundary conditions.
Finite-rate chemistry of the cells of a mesh: each cell that needs it is an adiabatic constant-volume...
Work memory and kernels that advance the cells of a state as adiabatic constant-volume reactors at fi...
Definition cell_chemistry.h:99
Point-to-point exchange of per-cell state following a Distribution's plan. Buffers are packed on the ...
Definition halo_exchange.h:30
Host side of the mixture gas model: the mechanism, a host copy of the thermodynamics for setup,...
Definition mixture.h:83
Point and line probes: the values of the cells holding a set of points, written every interval steps ...
Definition statistics.h:128
Reconstructs a mixture's cell scalars (mass fractions and the thermodynamic surrogates gamma,...
Definition scalar_reconstruction.h:103
Definition solver.h:85
bool is_viscous() const
Whether the flow is viscous (Navier-Stokes), for a single gas or a mixture.
Definition solver.h:333
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|.
Definition solver_mixture.cpp:352
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...
Definition solver_rhs.cpp:226
void write_data(bool force=false)
Definition solver.cpp:1563
void init_temperature_seed()
Definition solver_mixture.cpp:386
const std::vector< std::string > & get_species_names() const
Names of the transported species, empty for a single gas.
Definition solver.h:361
void reset_energy()
Definition solver_mixture.cpp:382
void init_numerics()
Definition solver.cpp:771
void graph_step()
Definition solver_graph.cpp:108
std::vector< std::string > restart_variables() const
Definition solver.cpp:1221
void init_mesh()
Definition solver.cpp:198
void init_radiation()
Mixtures: read [radiation]; subtract the optically thin radiative loss from the energy RHS.
Definition solver_radiation.cpp:49
const Statistics & get_statistics() const
Definition solver.h:352
void thicken_transport()
Thickened flame: multiply the transport of every cell (after update_eddy_viscosity).
Definition solver_les.cpp:645
void record_step()
Definition solver_graph.cpp:67
CellSampler cell_sampler() const
Definition solver.h:414
rtype les_constant() const
LES: the model constant in use (the dynamic procedure's latest with les.dynamic).
Definition solver.h:315
void update_partially_stirred_reactor()
PaSR: the reacting fraction kappa of every owned cell (chem_time_scale), once per step in calc_dt.
Definition solver_les.cpp:573
void update_transport()
Viscous mixtures, after update_cell_states: transport coefficients of every cell and the gradients of...
Definition solver_mixture.cpp:368
int init(const std::string &input_file_name)
Initialize the solver from an input file.
Definition solver.cpp:47
const LES & get_les() const
Definition solver.h:321
void subtract_transport_rate(const State &rhs)
SIMPLER: rhs -= T(U^n) on the owned cells.
Definition solver_chemistry.cpp:163
void write_forces()
Definition solver.cpp:1879
KineticEnergyBudget kinetic_energy_budget()
Rates of change of the resolved kinetic energy by the convective, viscous and SGS fluxes of the curre...
Definition solver_les.cpp:765
void copy_host_to_device()
Copy the host mirrors to the device solution.
Definition solver.cpp:1073
void register_data()
Definition solver.cpp:1150
void update_vortex_fields()
Q = (|Omega|^2 - |S|^2) / 2 and the vorticity of each owned cell, into vortex_fields.
Definition solver.cpp:1995
const Euler & get_physics() const
Definition solver.h:354
rtype get_time() const
Definition solver.h:351
void update_characteristic_boundaries(rtype t_stage)
At the first stage of each step: the transverse terms of the characteristic boundaries and their inco...
Definition solver_sponge.cpp:133
void add_radiation(StateView rhs, SpeciesView rhoY)
Definition solver_radiation.cpp:93
Kokkos::View< rtype ** > vortex_fields
Definition solver.h:372
Kokkos::View< rtype *[N_PRIMITIVE]>::host_mirror_type h_primitives
Definition solver.h:368
void update_velocity_gradients()
W = [rho, u, p] in W_cells and its gradients in viscous_gradients on the owned cells: from the recons...
Definition solver.cpp:1964
StateView conservatives
Definition solver.h:363
std::string stop_reason() const
Definition solver.cpp:1332
const Kokkos::View< rtype * >::host_mirror_type & get_chem_time_scale() const
PaSR: the reacting fraction kappa per cell, after copy_device_to_host.
Definition solver.h:325
void check_fields()
Definition solver.cpp:1533
void set_distributed(bool on)
Whether a run on several ranks splits the mesh between them (default). Call before init(); tests turn...
Definition solver.h:341
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).
Definition solver_les.cpp:722
StateView::host_mirror_type h_conservatives
Definition solver.h:366
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.
Definition solver.h:323
Kokkos::View< rtype * > p_max
Definition solver.h:369
bool state_needed() const
Definition solver.cpp:1341
void update_inflow(rtype t_eval)
Definition solver_inflow.cpp:50
void update_source_field(rtype t_eval)
Definition solver.cpp:708
uint64_t get_step() const
Definition solver.h:353
RestartFaces characteristic_restart_faces() const
The [p, u_n] of the characteristic faces of owned cells, once they hold a state.
Definition solver_sponge.cpp:163
double les_dynamic_ratio() const
LES: <L:M> / <M:M> of the latest dynamic procedure, before clipping at zero.
Definition solver.h:317
void init_physics()
Definition solver.cpp:401
SpeciesView species
Definition solver.h:364
void update_heat_release_rate()
Definition solver_chemistry.cpp:128
void allocate_memory()
Definition solver.cpp:991
void copy_device_to_host()
Copy the device solution to the host mirrors.
Definition solver.cpp:1082
void init_solution()
Definition solver_initialize.cpp:48
void allocate_chemistry()
Definition solver_chemistry.cpp:76
void update_dynamic_constant()
Global dynamic procedure: les.C from the Germano identity of the current state, summed over the domai...
Definition solver_les.cpp:594
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 it...
Definition solver.cpp:673
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 ...
Definition solver_chemistry.cpp:173
void timed_phase(const std::string &name, F &&f)
Definition solver.cpp:52
int run()
Run until a stop condition is reached.
Definition solver.cpp:1263
void calc_rhs_mixture(State solution, State rhs, rtype t)
Definition solver_mixture.cpp:390
bool is_les() const
Whether the run is a large-eddy simulation ([les]).
Definition solver.h:320
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 gradien...
Definition solver_les.cpp:710
void print_progress()
Definition solver.cpp:1361
bool is_distributed() const
Definition solver.h:342
void calc_dt()
Definition solver.cpp:1657
std::vector< std::vector< double > > composition_at_cells(const toml::value &table, const std::string &where, const std::vector< uint32_t > &cells) const
Mass fractions of a composition table (numbers or expressions) at the centroids of cells.
Definition solver_mixture.cpp:626
const MixtureModel & get_mixture() const
Definition solver.h:334
std::shared_ptr< Mesh > get_mesh() const
Definition solver.h:355
void update_primitives()
Recompute primitives from conservatives on the device.
Definition solver.cpp:1623
void freeze_thermodynamics()
Double flux: freeze each cell's [gamma, e0] from the true equation of state at the start of a step,...
Definition solver_mixture.cpp:377
Kokkos::View< rtype * >::host_mirror_type h_p_max
Definition solver.h:370
void init_sponges()
Definition solver_sponge.cpp:34
const Kokkos::View< rtype *[3]>::host_mirror_type & get_tfles_fields() const
Thickened flame: [F, E, Omega] per cell, after copy_device_to_host.
Definition solver.h:327
uint64_t restart_face_key(uint32_t i_face) const
Rank-count independent key of a boundary face in restart files.
Definition solver_sponge.cpp:156
const Kokkos::View< rtype *[3]>::host_mirror_type & get_cell_transport() const
Definition solver.h:328
void take_step()
Advance the solution by one time step. With chemistry, the half step that ends it may be deferred (se...
Definition solver.cpp:1586
rtype calc_dt_cfl1(Kokkos::View< rtype > on_device={})
Compute the stable time step for the current solution.
Definition solver.cpp:1753
Solver()
Definition solver.cpp:38
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 (di...
Definition solver.cpp:1984
std::string step_graph_unsupported() const
Definition solver_graph.cpp:46
void update_average_pressure_outlets(StateView solution)
Definition solver.cpp:720
void update_thickened_flame()
Thickened flame: [F, E, Omega] and the chemistry time scale E / F of every cell from the current stat...
Definition solver_les.cpp:554
void advance_chemistry(double dt_chem)
Definition solver_chemistry.cpp:97
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,...
Definition solver.cpp:1853
~Solver()
Definition solver.cpp:42
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 imbala...
Definition solver_chemistry.cpp:106
void restore_characteristic_state(const RestartData &restart)
Takes the characteristic faces' [p, u_n] from a restart file that has every face.
Definition solver_sponge.cpp:176
double chemistry_cells_sent() const
Cell integrations done by another rank than the owner so far (chemistry load balancing).
Definition solver.h:345
void calc_rhs(State solution, State rhs, rtype t)
Compute dU/dt for the given conservative state at time t.
Definition solver_rhs.cpp:90
std::vector< rtype > integrate_species()
Partial density of each species integrated over the domain (empty for a single gas).
Definition solver_mixture.cpp:613
void exchange_cell_vectors(const Kokkos::View< rtype *[3]> &v)
Overwrite the halo cells of a 3-vector cell field with their owners' values.
Definition solver_les.cpp:633
SpeciesView::host_mirror_type h_species
Definition solver.h:367
Kokkos::View< rtype *[N_PRIMITIVE]> primitives
Definition solver.h:365
void init_chemistry()
Reacting mixtures: read [chemistry]; advance every owned cell that needs it as an adiabatic constant-...
Definition solver_chemistry.cpp:38
Kokkos::View< rtype ** >::host_mirror_type h_vortex_fields
Definition solver.h:373
double progress() const
Definition solver.cpp:1353
void write_probes()
Definition solver.cpp:1580
rtype next_target_time() const
The time the next step must not pass: t_stop or the next time-based output.
Definition solver.cpp:1649
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 foun...
Definition solver_mixture.cpp:361
void init_solution_restart()
Definition solver_initialize.cpp:69
void update_boundary_states(rtype t_eval)
Definition solver.cpp:751
State state() const
The solution: flow block and species partial densities.
Definition solver.h:358
const Distribution & get_distribution() const
Definition solver.h:346
void print_summary(const std::string &stop) const
Definition solver.cpp:1487
bool is_mixture() const
Whether the gas is a mixture (a mechanism is given).
Definition solver.h:331
void destroy_step_graph()
Definition solver_graph.cpp:164
void print_setup() const
Definition solver.cpp:1420
rtype calc_dt_cfl1_mixture()
Definition solver_mixture.cpp:578
void update_primitives_mixture()
Definition solver_mixture.cpp:608
void update_p_max()
Raise P_MAX to the current pressure (updates the primitives).
Definition solver.cpp:1640
void apply_sponges(const State &solution, const State &rhs)
Adds the sponge-layer sources to the RHS per unit volume (owned cells).
Definition solver_sponge.cpp:117
void init_inlets(const std::vector< toml::value > &input_boundaries, const std::vector< std::pair< size_t, std::vector< uint32_t > > > &inlets)
Definition solver_inflow.cpp:16
void init_solution_analytical()
Definition solver_initialize.cpp:416
void init_solution_constant()
Definition solver_initialize.cpp:137
void take_simpler_step()
SIMPLER balanced splitting (Wu, Ma & Ihme 2019): with c = -T(U^n), the reaction substep dU/dt = R(U) ...
Definition solver_chemistry.cpp:140
void init_output()
Definition solver.cpp:900
double get_mass_flow_force() const
Body force per unit volume, along the mass flow direction, of the last RHS ([source] mass_flow).
Definition solver.h:349
void write_integrals()
Definition solver.cpp:2024
std::array< rtype, N_CONSERVATIVE > integrate_conservatives()
Sum of each conservative variable integrated over the domain.
Definition solver.cpp:1891
void init_run_parameters()
Definition solver.cpp:876
void init_boundaries()
Definition solver.cpp:420
void init_sources()
Definition solver.cpp:609
Running time averages per owned cell: means of fields and covariances <a'b'> of pairs of them,...
Definition statistics.h:70
Process-level communication: MPI when built with Mallard_ENABLE_MPI, otherwise a single-rank stub wit...
KOKKOS_INLINE_FUNCTION rtype dot(const rtype *a, const rtype *b)
Compute the dot product of two arrays.
Definition common_math.h:32
float rtype
Definition common_typedef.h:39
#define N_DIM
Definition common_typedef.h:28
Data writer class declaration.
Scalable setup of a distributed mesh: no rank ever holds the whole mesh.
A rank's share of a distributed mesh: owned cells, halo layers and the halo exchange plan.
Host-side analytical expressions of (x, y, z, t) from input files.
Face reconstruction class declaration.
Fills halo cells with their owners' values.
Subgrid-scale eddy-viscosity models of large-eddy simulation.
Console output: rank-0 info lines, aligned sections and tables, warnings and errors on stderr,...
Mesh class declaration.
Thermally perfect gas mixture: the gas model of runs with a mechanism.
int size()
Number of processes in the world communicator.
Definition comm.cpp:182
std::vector< std::pair< std::string, std::string > > Items
Key-value lines of a setup section, in display order.
Definition log.h:27
Partially stirred reactor (PaSR) closure of the filtered reaction rates (docs/design/les....
Physics model declaration.
Planck-mean absorption coefficients of the optically thin radiation model of the TNF workshop (RADCAL...
Approximate Riemann solvers.
RiemannSolverType
Definition riemann_solver.h:24
Reconstruction of a gas mixture's cell scalars to faces.
Kokkos::View< rtype **, Kokkos::LayoutRight > ScalarView
Cell scalars of a mixture: (cell, j) = Y_1 .. Y_Ns, gamma, e0.
Definition scalar_reconstruction.h:26
constexpr int N_FLOW_STATISTICS
Definition solver.h:56
Kokkos::View< rtype *[N_CONSERVATIVE]> StateView
Flow block [rho, rho u, rho E] per cell.
Definition state.h:23
Kokkos::View< rtype **, SpeciesLayout > SpeciesView
Partial densities rho Y_k per (cell, species).
Definition state.h:37
In-situ running time averages and probes.
Device-side lookup from faces to boundary conditions.
Definition boundary.h:229
Definition cell_chemistry.h:108
Cell values that statistics and probes sample, by code: 0 is RHO, 1 + i the primitive PRIMITIVE_NAMES...
Definition statistics.h:37
Faces with a Dirichlet condition and the expressions of x, y, z, t for their exterior state W = [rho,...
Definition solver.h:80
std::vector< Expression > W
Definition solver.h:82
std::vector< uint32_t > faces
Definition solver.h:81
Local numbering: owned cells first (in global order), then halo layer 1, 2, ... Every local cell keep...
Definition distribution.h:26
Calorically perfect gas, inviscid (Euler) or viscous and heat conducting (Navier-Stokes,...
Definition physics.h:54
KOKKOS_INLINE_FUNCTION bool is_viscous() const
Definition physics.h:85
Definition solver.h:48
std::shared_ptr< std::ofstream > out
Definition solver.h:53
std::string zone
Definition solver.h:49
uint64_t interval
Definition solver.h:52
std::string file
Definition solver.h:50
Kokkos::View< uint32_t * > faces
Definition solver.h:51
Definition solver.h:58
std::shared_ptr< std::ofstream > out
Definition solver.h:61
uint64_t interval
Definition solver.h:59
std::string file
Definition solver.h:60
bool budget
Definition solver.h:62
Rates of change of the resolved kinetic energy sum_c V rho |u|^2 / 2 caused by the convective,...
Definition solver.h:69
rtype sgs
Definition solver.h:72
rtype viscous
Definition solver.h:71
rtype convective
Definition solver.h:70
rtype pressure_work
Definition solver.h:73
Eddy viscosity nu_t = C^2 Delta^2 D(g) (Vreman: c Delta^2 D(g)) of the resolved velocity gradient g[i...
Definition les.h:40
rtype C
Definition les.h:42
Gradient over all vertex neighbors plus the boundary ghost states of the cell's own boundary faces,...
Definition gradient.h:233
Device side of the mixture gas model, captured by value in kernels.
Definition mixture.h:45
bool viscous
Definition mixture.h:49
Each cell's rates are those of its filtered state times the reacting fraction kappa = tau_c / (tau_c ...
Definition pasr.h:32
Contents of a restart file.
Definition data_writer.h:67
Face records of a restart file (version 4): the [p, u_n] of the characteristic boundary faces (docs/d...
Definition data_writer.h:58
Conservative state of every cell: the flow block and the partial densities of a mixture's species....
Definition state.h:56
Thickening F, efficiency E and flame sensor Omega of a cell. The flame is thickened by F where Omega ...
Definition tfles.h:31
Reactions of a mechanism as flat device tables (compressed rows per reaction), in MemorySpace....
Definition kinetics.h:70
Optically thin radiative loss q = 4 sigma sum_i p_i a_i(T) (T^4 - T_amb^4), p_i the partial pressures...
Definition radiation.h:53
Definition reactor.h:27
Mean velocity of characteristic inlets, and synthetic turbulence (digital filter) superposed on it.
Kokkos::View< uint32_t *, Space > cells
Definition teno_setup.cpp:682
Dynamically thickened flame model (TFLES) of turbulence-chemistry interaction (docs/design/les....
Time integrator class declarations.
std::function< void(State solution, State rhs, rtype t)> RHSFunction
Definition time_integrator.h:43