Theseus
Compressible flow solver
Loading...
Searching...
No Matches
dgsem_cache.hpp
Go to the documentation of this file.
1// Copyright (c) 2025-2026 Board of Trustees of the University of Illinois
2//
3// This file is part of Theseus.
4//
5// SPDX-License-Identifier: BSD-3-Clause
6#pragma once
7
8#include "mfem.hpp"
10#include "GasModel.hpp"
11#include "LTEGasModel.hpp"
13
14namespace Theseus
15{
17 mfem::real_t mass = 0.0;
18 mfem::real_t ke = 0.0;
19 mfem::real_t en = 0.0;
20 mfem::real_t max_press = 0.0;
21 mfem::real_t min_press = 0.0;
22 mfem::real_t max_temp = 0.0;
23 mfem::real_t min_temp = 0.0;
24 mfem::real_t max_dens = 0.0;
25 mfem::real_t min_dens = 0.0;
26 };
27
28 template<typename PhysicsT>
30 using OperatorGasModel = typename PhysicsT::GasModel;
31 using InviscidFlux = typename PhysicsT::InviscidFlux;
32 // constants needed by kernels
33 int p = 0;
34 int dim = 0;
35 int Np = 0;
36 int Np_x = 0;
37 int Np_y = 0;
38 int Np_z = 0;
39 int num_attr = 0;
40 int num_elements = 0;
46
47 // Host Only: Integration rules, operators, restrictions
48 mfem::IntegrationRules GLIntRules{0, mfem::Quadrature1D::GaussLobatto};
49 const mfem::IntegrationRule *ir = nullptr;
50 const mfem::IntegrationRule *ir_face = nullptr;
51 const mfem::IntegrationRule *ir_vol = nullptr;
52 const mfem::ElementRestrictionOperator *restr_v = nullptr; // for volume elements
53 const mfem::FaceRestriction *restr_f = nullptr; // for interior faces
54 const mfem::FaceRestriction *restr_b = nullptr; // for boundary faces
55 std::unique_ptr<mfem::FaceQuadratureSpace> fqs_int; // interior faces perm
56 std::unique_ptr<mfem::FaceQuadratureSpace> fqs_bnd; // boundary faces perm
57
58 // Aux data for preprocessing
59 mfem::Array<int> inv_fp_map;
60 mfem::Array<int> inv_fp_map_bnd;
61
62 // Fixed data arrays for use on device
63 mfem::Array<int> elem_attr; // size ne, values are 1-based attributes
64 mfem::Array<int> vol_attr_marker; // size nattr, 0/1
65 mfem::Array<int> domain_attr_marker; // size nattr, 0/1
66 mfem::Vector elJac;
67 mfem::Vector elMetric;
68 mfem::Vector elQuadratureWeights;
69 mfem::Vector elRadius; // element-major, then lexicographic volume point
70 mfem::Vector D;
71 mfem::Vector Dhat;
72 mfem::Vector Dhat2;
73 mfem::Vector face_normals;
74 mfem::Vector face_wt_minus;
75 mfem::Vector face_wt_plus;
76 mfem::Vector face_radius; // restriction-face order, shared by both sides
77
78 // Temporaries/aux storage
79 mfem::Vector pdudt;
80 mfem::Vector sVol;
81 mfem::Vector uVol;
82 mfem::Vector volAux;
83 mfem::Vector rhsVol;
84 mfem::Vector uInt;
85 mfem::Vector sInt;
86 mfem::Vector rhsInt;
87 mfem::Vector dudtInt;
88 mfem::Vector uBnd;
89 mfem::Vector sBnd;
90 mfem::Vector rhsBnd;
91 mfem::Vector dudtBnd;
92 mfem::Vector entropyState;
93 mfem::Vector duBnd;
94 mfem::Vector duInt;
95
96 // Eliminate redundant restr calls?
97 bool urestr_ready = false;
98 bool u_vol_restr_ready = false;
99 bool u_bnd_restr_ready = false;
100 bool u_int_restr_ready = false;
104
105 std::vector<mfem::Vector> gradVol;
106 std::vector<mfem::Vector> pGrad;
107 std::vector<mfem::Vector> gradInt;
108 std::vector<mfem::Vector> gradBnd;
109
110 // Domain boundary device arrays
111 mfem::Vector bnd_normals;
112 mfem::Vector bnd_wt;
113 mfem::Vector bnd_xyz;
114 mfem::Vector bnd_radius;
115 mfem::Array<int> bnd_attr;
116 mfem::Array<int> bnd_marker_index;
117 mfem::Array<int> bnd_marker_to_bc_descr;
118 mfem::Array<Theseus::BCDescriptor> bc_descriptors;
119 mfem::Vector bc_scalar_data;
120 mfem::Vector bc_vector_data;
121
122 // Physics parts - used directly on device
123 mutable mfem::Vector elWaveSpeed; // size nelements
124 mutable mfem::Vector ifWaveSpeed; // size ninterior faces
125 mutable mfem::Vector bndWaveSpeed; // size nbnd faces
128 std::unique_ptr<Theseus::LTETable::Data> lteTableData;
129
130#ifdef SUBCELL_FV_BLENDING
131 mfem::Vector subcellMetricXi;
132 mfem::Vector subcellMetricEta;
133 mfem::Vector subcellMetricZeta;
134 mfem::Vector subcellWeights;
135 mfem::Vector indicatorField;
136 mfem::Vector eta;
137 mfem::Vector modal;
138 mfem::Vector keep_M1;
139 mfem::Vector keep_M2;
140 mfem::Vector dUfv;
141 mfem::real_t *dUfv_d = NULL;
142 mfem::real_t *alpha_d = NULL;
143 const mfem::real_t *modal_d = NULL;
144 const mfem::real_t *keep_M1_d = NULL;
145 const mfem::real_t *keep_M2_d = NULL;
146 mfem::real_t *eta_d = NULL;
147 mfem::real_t *indicator_d = NULL;
148#endif
149
150 // nullptr if subcell blending is OFF
151 std::shared_ptr<mfem::ParGridFunction> alpha;
152
153 // Grab the face dof from the restriction (face,point) index
154 // This answers: what is the facial dof that corresponds to
155 // the facial point index for a given face in the restriction?
156 int MapFp(int face_slot, int fp_restr) const
157 {
158 return fqs_int->GetPermutedIndex(face_slot, fp_restr);
159 }
160 // And the inverse mapping
161 int MapFpInv(int face_slot, int fp_perm) const {
162 return inv_fp_map[face_slot*num_face_points + fp_perm];
163 }
164 };
165
166 template<typename PhysicsT>
168 using Gas = typename PhysicsT::GasModel;
169 using InviscidFlux = typename PhysicsT::InviscidFlux;
170
171 int p = 0;
172 int dim = 0;
178 int Np_x = 0;
179 int Np_y = 0;
180 int Np_z = 0;
181 int Np = 0;
182 int num_attr = 0;
183 int num_bcs = 0;
185
186 // Volume elements
187 const int *elem_attr_d = nullptr; // size ne, values are 1-based attributes
188 const int *attr_marker_d = nullptr; // size nattr, 0/1
189 const mfem::real_t *elJac_d = nullptr;
190 const mfem::real_t *elMetric_d = nullptr;
191 const mfem::real_t *D_d = nullptr;
192 const mfem::real_t *Dhat_d = nullptr;
193 const mfem::real_t *Dhat2_d = nullptr;
194 const mfem::real_t *elQWgts_d = nullptr;
195 const mfem::real_t *elRadius_d = nullptr;
196
197 // Internal faces
198 const mfem::real_t *nor_d = nullptr;
199 const mfem::real_t *fw_minus_d = nullptr;
200 const mfem::real_t *fw_plus_d = nullptr;
201 const mfem::real_t *face_radius_d = nullptr;
202
203 // Boundary faces
204 const mfem::real_t *bnd_nor_d = nullptr;
205 const mfem::real_t *bnd_wt_d = nullptr;
206 const mfem::real_t *bnd_radius_d = nullptr;
207 const int *bnd_attr_d = nullptr;
208 const int *bnd_marker_index_d = nullptr;
210 const mfem::real_t *bc_scalar_d = nullptr;
211 const mfem::real_t *bc_vector_d = nullptr;
212 const int *bnd_marker_to_bc_descr_d = nullptr;
213
214 // Physics parts
215 mfem::real_t *elWaveSpeed_d = nullptr;
216 mfem::real_t *ifWaveSpeed_d = nullptr;
217 mfem::real_t *bndWaveSpeed_d = nullptr;
220
221#ifdef SUBCELL_FV_BLENDING
222 const mfem::real_t *subcell_metric_xi_d = nullptr;
223 const mfem::real_t *subcell_metric_eta_d = nullptr;
224 const mfem::real_t *subcell_metric_zeta_d = nullptr;
225 const mfem::real_t *subcell_weights_d = nullptr;
226#endif
227
228 MFEM_HOST_DEVICE inline int iface_idx(int side, int fp, int eq) const
229 {
230 return ((side*num_equations + eq)*num_face_points + fp);
231 }
232 MFEM_HOST_DEVICE inline int iface_size() const
233 {
235 }
236 };
237
238}
Definition AxisymmetricGeometry.hpp:15
static constexpr bool enabled
Definition AxisymmetricGeometry.hpp:29
Definition bc_cache_utilities.hpp:35
Definition dgsem_cache.hpp:167
int Np_z
Definition dgsem_cache.hpp:180
int num_elements
Definition dgsem_cache.hpp:173
const mfem::real_t * bc_vector_d
Definition dgsem_cache.hpp:211
int dim
Definition dgsem_cache.hpp:172
mfem::real_t * ifWaveSpeed_d
Definition dgsem_cache.hpp:216
const Theseus::BCDescriptor * bc_descr_d
Definition dgsem_cache.hpp:209
const mfem::real_t * bnd_radius_d
Definition dgsem_cache.hpp:206
typename PhysicsT::InviscidFlux InviscidFlux
Definition dgsem_cache.hpp:169
int num_attr
Definition dgsem_cache.hpp:182
int Np_y
Definition dgsem_cache.hpp:179
int num_face_points
Definition dgsem_cache.hpp:176
InviscidFlux iflux
Definition dgsem_cache.hpp:219
const int * attr_marker_d
Definition dgsem_cache.hpp:188
const mfem::real_t * Dhat2_d
Definition dgsem_cache.hpp:193
bool axisymmetric
Definition dgsem_cache.hpp:184
mfem::real_t * elWaveSpeed_d
Definition dgsem_cache.hpp:215
const int * elem_attr_d
Definition dgsem_cache.hpp:187
int ndof_scalar_el
Definition dgsem_cache.hpp:174
int num_equations
Definition dgsem_cache.hpp:175
const mfem::real_t * bnd_nor_d
Definition dgsem_cache.hpp:204
const mfem::real_t * elMetric_d
Definition dgsem_cache.hpp:190
const mfem::real_t * Dhat_d
Definition dgsem_cache.hpp:192
const mfem::real_t * D_d
Definition dgsem_cache.hpp:191
int Np
Definition dgsem_cache.hpp:181
typename PhysicsT::GasModel Gas
Definition dgsem_cache.hpp:168
const mfem::real_t * bnd_wt_d
Definition dgsem_cache.hpp:205
MFEM_HOST_DEVICE int iface_size() const
Definition dgsem_cache.hpp:232
const mfem::real_t * nor_d
Definition dgsem_cache.hpp:198
const mfem::real_t * fw_plus_d
Definition dgsem_cache.hpp:200
const mfem::real_t * bc_scalar_d
Definition dgsem_cache.hpp:210
Gas gas
Definition dgsem_cache.hpp:218
const mfem::real_t * fw_minus_d
Definition dgsem_cache.hpp:199
const mfem::real_t * elQWgts_d
Definition dgsem_cache.hpp:194
const mfem::real_t * elRadius_d
Definition dgsem_cache.hpp:195
const int * bnd_attr_d
Definition dgsem_cache.hpp:207
mfem::real_t * bndWaveSpeed_d
Definition dgsem_cache.hpp:217
const mfem::real_t * face_radius_d
Definition dgsem_cache.hpp:201
const int * bnd_marker_to_bc_descr_d
Definition dgsem_cache.hpp:212
const mfem::real_t * elJac_d
Definition dgsem_cache.hpp:189
int p
Definition dgsem_cache.hpp:171
int num_interior_faces
Definition dgsem_cache.hpp:177
int Np_x
Definition dgsem_cache.hpp:178
int num_bcs
Definition dgsem_cache.hpp:183
const int * bnd_marker_index_d
Definition dgsem_cache.hpp:208
MFEM_HOST_DEVICE int iface_idx(int side, int fp, int eq) const
Definition dgsem_cache.hpp:228
Definition dgsem_cache.hpp:29
mfem::Array< int > inv_fp_map_bnd
Definition dgsem_cache.hpp:60
mfem::Vector volAux
Definition dgsem_cache.hpp:82
const mfem::IntegrationRule * ir_face
Definition dgsem_cache.hpp:50
const mfem::FaceRestriction * restr_b
Definition dgsem_cache.hpp:54
mfem::Vector bc_scalar_data
Definition dgsem_cache.hpp:119
mfem::Vector Dhat
Definition dgsem_cache.hpp:71
mfem::Vector bnd_xyz
Definition dgsem_cache.hpp:113
const mfem::FaceRestriction * restr_f
Definition dgsem_cache.hpp:53
mfem::Vector elMetric
Definition dgsem_cache.hpp:67
bool grad_bnd_restr_ready
Definition dgsem_cache.hpp:102
bool u_vol_restr_ready
Definition dgsem_cache.hpp:98
std::unique_ptr< mfem::FaceQuadratureSpace > fqs_int
Definition dgsem_cache.hpp:55
int num_interior_faces
Definition dgsem_cache.hpp:44
mfem::Vector dudtBnd
Definition dgsem_cache.hpp:91
mfem::Vector uVol
Definition dgsem_cache.hpp:81
mfem::Vector ifWaveSpeed
Definition dgsem_cache.hpp:124
int Np_y
Definition dgsem_cache.hpp:37
mfem::Vector duBnd
Definition dgsem_cache.hpp:93
mfem::Array< int > elem_attr
Definition dgsem_cache.hpp:63
mfem::Vector sInt
Definition dgsem_cache.hpp:85
mfem::Vector elRadius
Definition dgsem_cache.hpp:69
typename PhysicsT::GasModel OperatorGasModel
Definition dgsem_cache.hpp:30
mfem::IntegrationRules GLIntRules
Definition dgsem_cache.hpp:48
mfem::Vector elWaveSpeed
Definition dgsem_cache.hpp:123
bool axisymmetric
Definition dgsem_cache.hpp:45
std::vector< mfem::Vector > pGrad
Definition dgsem_cache.hpp:106
mfem::Vector rhsInt
Definition dgsem_cache.hpp:86
mfem::Array< int > domain_attr_marker
Definition dgsem_cache.hpp:65
mfem::Vector face_radius
Definition dgsem_cache.hpp:76
mfem::Vector uInt
Definition dgsem_cache.hpp:84
std::vector< mfem::Vector > gradVol
Definition dgsem_cache.hpp:105
mfem::Vector elJac
Definition dgsem_cache.hpp:66
mfem::Array< Theseus::BCDescriptor > bc_descriptors
Definition dgsem_cache.hpp:118
mfem::Vector duInt
Definition dgsem_cache.hpp:94
typename PhysicsT::InviscidFlux InviscidFlux
Definition dgsem_cache.hpp:31
bool u_bnd_restr_ready
Definition dgsem_cache.hpp:99
const mfem::IntegrationRule * ir
Definition dgsem_cache.hpp:49
mfem::Array< int > inv_fp_map
Definition dgsem_cache.hpp:59
int ndof_scalar_el
Definition dgsem_cache.hpp:42
std::shared_ptr< mfem::ParGridFunction > alpha
Definition dgsem_cache.hpp:151
int Np_z
Definition dgsem_cache.hpp:38
std::vector< mfem::Vector > gradInt
Definition dgsem_cache.hpp:107
std::unique_ptr< Theseus::LTETable::Data > lteTableData
Definition dgsem_cache.hpp:128
mfem::Vector D
Definition dgsem_cache.hpp:70
mfem::Vector rhsBnd
Definition dgsem_cache.hpp:90
int num_attr
Definition dgsem_cache.hpp:39
mfem::Vector rhsVol
Definition dgsem_cache.hpp:83
bool grad_vol_restr_ready
Definition dgsem_cache.hpp:101
int Np
Definition dgsem_cache.hpp:35
mfem::Array< int > bnd_marker_index
Definition dgsem_cache.hpp:116
int MapFp(int face_slot, int fp_restr) const
Definition dgsem_cache.hpp:156
mfem::Vector bndWaveSpeed
Definition dgsem_cache.hpp:125
bool grad_int_restr_ready
Definition dgsem_cache.hpp:103
std::unique_ptr< mfem::FaceQuadratureSpace > fqs_bnd
Definition dgsem_cache.hpp:56
mfem::Vector face_wt_plus
Definition dgsem_cache.hpp:75
mfem::Vector face_normals
Definition dgsem_cache.hpp:73
mfem::Vector Dhat2
Definition dgsem_cache.hpp:72
const mfem::ElementRestrictionOperator * restr_v
Definition dgsem_cache.hpp:52
int MapFpInv(int face_slot, int fp_perm) const
Definition dgsem_cache.hpp:161
mfem::Vector bc_vector_data
Definition dgsem_cache.hpp:120
mfem::Array< int > bnd_marker_to_bc_descr
Definition dgsem_cache.hpp:117
mfem::Vector uBnd
Definition dgsem_cache.hpp:88
int num_elements
Definition dgsem_cache.hpp:40
mfem::Vector face_wt_minus
Definition dgsem_cache.hpp:74
InviscidFlux iflux
Definition dgsem_cache.hpp:127
mfem::Array< int > vol_attr_marker
Definition dgsem_cache.hpp:64
mfem::Vector pdudt
Definition dgsem_cache.hpp:79
mfem::Vector dudtInt
Definition dgsem_cache.hpp:87
std::vector< mfem::Vector > gradBnd
Definition dgsem_cache.hpp:108
mfem::Vector sVol
Definition dgsem_cache.hpp:80
mfem::Vector elQuadratureWeights
Definition dgsem_cache.hpp:68
bool urestr_ready
Definition dgsem_cache.hpp:97
mfem::Vector sBnd
Definition dgsem_cache.hpp:89
mfem::Vector entropyState
Definition dgsem_cache.hpp:92
mfem::Vector bnd_normals
Definition dgsem_cache.hpp:111
int dim
Definition dgsem_cache.hpp:34
int Np_x
Definition dgsem_cache.hpp:36
int num_equations
Definition dgsem_cache.hpp:41
mfem::Array< int > bnd_attr
Definition dgsem_cache.hpp:115
mfem::Vector bnd_radius
Definition dgsem_cache.hpp:114
int num_face_points
Definition dgsem_cache.hpp:43
bool u_int_restr_ready
Definition dgsem_cache.hpp:100
const mfem::IntegrationRule * ir_vol
Definition dgsem_cache.hpp:51
OperatorGasModel gas
Definition dgsem_cache.hpp:126
int p
Definition dgsem_cache.hpp:33
mfem::Vector bnd_wt
Definition dgsem_cache.hpp:112
Definition dgsem_cache.hpp:16
mfem::real_t max_temp
Definition dgsem_cache.hpp:22
mfem::real_t min_dens
Definition dgsem_cache.hpp:25
mfem::real_t en
Definition dgsem_cache.hpp:19
mfem::real_t mass
Definition dgsem_cache.hpp:17
mfem::real_t ke
Definition dgsem_cache.hpp:18
mfem::real_t max_press
Definition dgsem_cache.hpp:20
mfem::real_t max_dens
Definition dgsem_cache.hpp:24
mfem::real_t min_press
Definition dgsem_cache.hpp:21
mfem::real_t min_temp
Definition dgsem_cache.hpp:23