Cholla 3.0.1-dev
Cholla - Massively parallel hydro on GPUs
Loading...
Searching...
No Matches
pcm_cuda.h
Go to the documentation of this file.
1
4#ifndef PCM_CUDA_H
5#define PCM_CUDA_H
6
7#include "../utils/basic_structs.h"
8#include "../utils/hydro_utilities.h"
9
10__global__ void PCM_Reconstruction_1D(Real *dev_conserved, Real *dev_bounds_L, Real *dev_bounds_R, int n_cells,
11 int n_ghost, Real gamma, int n_fields);
12
13__global__ void PCM_Reconstruction_2D(Real *dev_conserved, Real *dev_bounds_Lx, Real *dev_bounds_Rx,
14 Real *dev_bounds_Ly, Real *dev_bounds_Ry, int nx, int ny, int n_ghost, Real gamma,
15 int n_fields);
16
17__global__ void PCM_Reconstruction_3D(Real *dev_conserved, Real *dev_bounds_Lx, Real *dev_bounds_Rx,
18 Real *dev_bounds_Ly, Real *dev_bounds_Ry, Real *dev_bounds_Lz,
19 Real *dev_bounds_Rz, int nx, int ny, int nz, int n_ghost, Real gamma,
20 int n_fields);
21
23{
38template <uint direction>
39reconstruction::InterfaceState __device__ __host__ inline PCM_Reconstruction(Real const *dev_conserved,
40 size_t const xid, size_t const yid,
41 size_t const zid, size_t const nx,
42 size_t const ny, size_t const n_cells,
43 Real const gamma)
44{
45 // Load cell conserved
46 hydro_utilities::Conserved conserved_data =
47 hydro_utilities::Load_Cell_Conserved<direction>(dev_conserved, xid, yid, zid, nx, ny, n_cells);
48
49 // Convert cell to primitives
50 hydro_utilities::Primitive primitive_data = hydro_utilities::Conserved_2_Primitive(conserved_data, gamma);
51
52 // Integrate cell values into an InterfaceState
53 reconstruction::InterfaceState interface_state;
54
55 interface_state.density = conserved_data.density;
56 interface_state.velocity = primitive_data.velocity;
57 interface_state.momentum = conserved_data.momentum;
58 interface_state.pressure = primitive_data.pressure;
59 interface_state.energy = conserved_data.energy;
60
61#ifdef MHD
62 interface_state.total_pressure = mhd::utils::computeTotalPressure(primitive_data.pressure, conserved_data.magnetic);
63 interface_state.magnetic = conserved_data.magnetic;
64#endif // MHD
65#ifdef DE
66 interface_state.gas_energy = primitive_data.gas_energy;
67#endif // DE
68#ifdef SCALAR
69 for (size_t i = 0; i < grid_enum::nscalars; i++) {
70 interface_state.scalar[i] = primitive_data.scalar[i];
71 }
72#endif // SCALAR
73
74 return interface_state;
75}
76} // namespace reconstruction
77#endif // PCM_CUDA_H
__host__ __device__ Primitive Conserved_2_Primitive(Conserved const &conserved_in, Real const gamma)
Convert Conserved cell centered variables to primitive variables.
Definition hydro_utilities.h:294
Namespace to contain various utilities for the interface reconstruction kernels.
Definition pcm_cuda.h:23
reconstruction::InterfaceState __device__ __host__ PCM_Reconstruction(Real const *dev_conserved, size_t const xid, size_t const yid, size_t const zid, size_t const nx, size_t const ny, size_t const n_cells, Real const gamma)
Perform PCM reconstruction for a given cell.
Definition pcm_cuda.h:39
A data only struct for the conserved variables.
Definition basic_structs.h:83
A data only struct for the primitive variables.
Definition basic_structs.h:124
Definition basic_structs.h:165
Real pressure
Note that pressure here is the gas pressure not the total pressure which would include the magnetic c...
Definition basic_structs.h:169