Mallard 0.8.0
Unstructured, GPU accelerated, high-order finite volume CFD solver
Mallard website
Loading...
Searching...
No Matches
chemistry_balance.h
Go to the documentation of this file.
1
14#ifndef CHEMISTRY_BALANCE_H
15#define CHEMISTRY_BALANCE_H
16
17#include <cstdint>
18#include <functional>
19#include <vector>
20
21#include <Kokkos_Core.hpp>
22
23#include "cell_chemistry.h"
24#include "comm.h"
25
45 public:
46 using Integrate = std::function<uint32_t(const ChemistryCells &, const Kokkos::View<uint32_t *> &,
47 const Kokkos::View<float *> &, uint32_t)>;
48
49 ChemistryBalance(uint32_t n_species, double threshold);
50
56 uint32_t send(const ChemistryCells & cells, const Kokkos::View<uint32_t *> & queue, uint32_t n_queued);
57
64 uint32_t receive(const ChemistryCells & cells, const Kokkos::View<uint32_t *> & queue, const Integrate & integrate);
65
66 private:
67 struct Transfer {
68 int rank;
69 uint32_t first, count; // cells: queue slots (sent) or guest slots (received)
70 };
71
72 void reserve_guests(uint32_t n);
73
74 uint32_t n_species;
75 double threshold;
76 uint32_t state_stride = 0, result_stride; // rtype values per cell in the messages
77 uint32_t kept = 0, n_sent = 0, n_guests = 0;
78 std::vector<Transfer> sends, receives;
79 Kokkos::View<rtype *> send_buffer, guest_buffer; // states, then results in place
80 Kokkos::View<rtype *>::host_mirror_type h_send_buffer, h_guest_buffer;
81 ChemistryCells guests;
82 Kokkos::View<uint32_t *> guest_queue;
83 Kokkos::View<float *> guest_cost;
84 bool scaled = false; // the cells carry a multiplier of dt
85 bool forced = false; // and a forcing
86#ifdef Mallard_HAS_MPI
87 std::vector<MPI_Request> requests;
88#endif
89};
90
91#endif // CHEMISTRY_BALANCE_H
Finite-rate chemistry of the cells of a mesh: each cell that needs it is an adiabatic constant-volume...
Moves the integration of queued cells from ranks with more chemistry work than the mean to ranks with...
Definition chemistry_balance.h:44
uint32_t receive(const ChemistryCells &cells, const Kokkos::View< uint32_t * > &queue, const Integrate &integrate)
Receives the cells sent to this rank, integrates them with integrate (guest cells,...
Definition chemistry_balance.cpp:192
uint32_t send(const ChemistryCells &cells, const Kokkos::View< uint32_t * > &queue, uint32_t n_queued)
Plans the call (collective) and sends the states of the cells this rank gives away,...
Definition chemistry_balance.cpp:86
std::function< uint32_t(const ChemistryCells &, const Kokkos::View< uint32_t * > &, const Kokkos::View< float * > &, uint32_t)> Integrate
Definition chemistry_balance.h:47
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
The per-cell views a chemistry call reads and writes: the state, the temperature seed,...
Definition cell_chemistry.h:68
Kokkos::View< uint32_t *, Space > cells
Definition teno_setup.cpp:682