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;
45 mfem::real_t stabilityAdvectionScale = 0.0;
46 mfem::real_t stabilityDiffusionScale = 0.0;
47 mfem::real_t stabilitySurfaceScale = 1.0;
49
50 // Host Only: Integration rules, operators, restrictions
51 mfem::IntegrationRules GLIntRules{0, mfem::Quadrature1D::GaussLobatto};
52 const mfem::IntegrationRule *ir = nullptr;
53 const mfem::IntegrationRule *ir_face = nullptr;
54 const mfem::IntegrationRule *ir_vol = nullptr;
55 const mfem::ElementRestrictionOperator *restr_v = nullptr; // for volume elements
56 const mfem::FaceRestriction *restr_f = nullptr; // for interior faces
57 const mfem::FaceRestriction *restr_b = nullptr; // for boundary faces
58 std::unique_ptr<mfem::FaceQuadratureSpace> fqs_int; // interior faces perm
59 std::unique_ptr<mfem::FaceQuadratureSpace> fqs_bnd; // boundary faces perm
60
61 // Aux data for preprocessing
62 mfem::Array<int> inv_fp_map;
63 mfem::Array<int> inv_fp_map_bnd;
64
65 // Fixed data arrays for use on device
66 mfem::Array<int> elem_attr; // size ne, values are 1-based attributes
67 mfem::Array<int> vol_attr_marker; // size nattr, 0/1
68 mfem::Array<int> domain_attr_marker; // size nattr, 0/1
69 mfem::Vector elJac;
70 mfem::Vector elMetric;
71 mfem::Vector elQuadratureWeights;
72 mfem::Vector elRadius; // element-major, then lexicographic volume point
73 mfem::Vector D;
74 mfem::Vector Dhat;
75 mfem::Vector Dhat2;
76 mfem::Vector face_normals;
77 mfem::Vector face_wt_minus;
78 mfem::Vector face_wt_plus;
79 mfem::Vector face_radius; // restriction-face order, shared by both sides
80
81 // Temporaries/aux storage
82 mfem::Vector pdudt;
83 mfem::Vector sVol;
84 mfem::Vector uVol;
85 mfem::Vector volAux;
86 mfem::Vector rhsVol;
87 mfem::Vector uInt;
88 mfem::Vector sInt;
89 mfem::Vector rhsInt;
90 mfem::Vector dudtInt;
91 mfem::Vector uBnd;
92 mfem::Vector sBnd;
93 mfem::Vector rhsBnd;
94 mfem::Vector dudtBnd;
95 mfem::Vector entropyState;
96 mfem::Vector duBnd;
97 mfem::Vector duInt;
98
99 // Eliminate redundant restr calls?
100 bool urestr_ready = false;
101 bool u_vol_restr_ready = false;
102 bool u_bnd_restr_ready = false;
103 bool u_int_restr_ready = false;
107
108 std::vector<mfem::Vector> gradVol;
109 std::vector<mfem::Vector> pGrad;
110 std::vector<mfem::Vector> gradInt;
111 std::vector<mfem::Vector> gradBnd;
112
113 // Domain boundary device arrays
114 mfem::Vector bnd_normals;
115 mfem::Vector bnd_wt;
116 mfem::Vector bnd_xyz;
117 mfem::Vector bnd_radius;
118 mfem::Array<int> bnd_attr;
119 mfem::Array<int> bnd_marker_index;
120 mfem::Array<int> bnd_marker_to_bc_descr;
121 mfem::Array<Theseus::BCDescriptor> bc_descriptors;
122 mfem::Vector bc_scalar_data;
123 mfem::Vector bc_vector_data;
124
125 // Physics parts - used directly on device
126 mutable mfem::Vector stabilityAdvectiveRate;
127 mutable mfem::Vector stabilitySurfaceRate;
128 mutable mfem::Vector stabilityDiffusiveRate;
131 std::unique_ptr<Theseus::LTETable::Data> lteTableData;
132
133#ifdef SUBCELL_FV_BLENDING
134 mfem::Vector subcellMetricXi;
135 mfem::Vector subcellMetricEta;
136 mfem::Vector subcellMetricZeta;
137 mfem::Vector subcellWeights;
138 mfem::Vector indicatorField;
139 mfem::Vector eta;
140 mfem::Vector modal;
141 mfem::Vector keep_M1;
142 mfem::Vector keep_M2;
143 mfem::Vector dUfv;
144 mfem::real_t *dUfv_d = NULL;
145 mfem::real_t *alpha_d = NULL;
146 const mfem::real_t *modal_d = NULL;
147 const mfem::real_t *keep_M1_d = NULL;
148 const mfem::real_t *keep_M2_d = NULL;
149 mfem::real_t *eta_d = NULL;
150 mfem::real_t *indicator_d = NULL;
151#endif
152
153 // nullptr if subcell blending is OFF
154 std::shared_ptr<mfem::ParGridFunction> alpha;
155
156 // Grab the face dof from the restriction (face,point) index
157 // This answers: what is the facial dof that corresponds to
158 // the facial point index for a given face in the restriction?
159 int MapFp(int face_slot, int fp_restr) const
160 {
161 return fqs_int->GetPermutedIndex(face_slot, fp_restr);
162 }
163 // And the inverse mapping
164 int MapFpInv(int face_slot, int fp_perm) const {
165 return inv_fp_map[face_slot*num_face_points + fp_perm];
166 }
167 };
168
169 template<typename PhysicsT>
171 using Gas = typename PhysicsT::GasModel;
172 using InviscidFlux = typename PhysicsT::InviscidFlux;
173
174 int p = 0;
175 int dim = 0;
181 int Np_x = 0;
182 int Np_y = 0;
183 int Np_z = 0;
184 int Np = 0;
185 int num_attr = 0;
186 int num_bcs = 0;
188
189 // Volume elements
190 const int *elem_attr_d = nullptr; // size ne, values are 1-based attributes
191 const int *attr_marker_d = nullptr; // size nattr, 0/1
192 const mfem::real_t *elJac_d = nullptr;
193 const mfem::real_t *elMetric_d = nullptr;
194 const mfem::real_t *D_d = nullptr;
195 const mfem::real_t *Dhat_d = nullptr;
196 const mfem::real_t *Dhat2_d = nullptr;
197 const mfem::real_t *elQWgts_d = nullptr;
198 const mfem::real_t *elRadius_d = nullptr;
199
200 // Internal faces
201 const mfem::real_t *nor_d = nullptr;
202 const mfem::real_t *fw_minus_d = nullptr;
203 const mfem::real_t *fw_plus_d = nullptr;
204 const mfem::real_t *face_radius_d = nullptr;
205
206 // Boundary faces
207 const mfem::real_t *bnd_nor_d = nullptr;
208 const mfem::real_t *bnd_wt_d = nullptr;
209 const mfem::real_t *bnd_radius_d = nullptr;
210 const int *bnd_attr_d = nullptr;
211 const int *bnd_marker_index_d = nullptr;
213 const mfem::real_t *bc_scalar_d = nullptr;
214 const mfem::real_t *bc_vector_d = nullptr;
215 const int *bnd_marker_to_bc_descr_d = nullptr;
216
217 // Physics parts
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:170
int Np_z
Definition dgsem_cache.hpp:183
int num_elements
Definition dgsem_cache.hpp:176
const mfem::real_t * bc_vector_d
Definition dgsem_cache.hpp:214
int dim
Definition dgsem_cache.hpp:175
const Theseus::BCDescriptor * bc_descr_d
Definition dgsem_cache.hpp:212
const mfem::real_t * bnd_radius_d
Definition dgsem_cache.hpp:209
typename PhysicsT::InviscidFlux InviscidFlux
Definition dgsem_cache.hpp:172
int num_attr
Definition dgsem_cache.hpp:185
int Np_y
Definition dgsem_cache.hpp:182
int num_face_points
Definition dgsem_cache.hpp:179
InviscidFlux iflux
Definition dgsem_cache.hpp:219
const int * attr_marker_d
Definition dgsem_cache.hpp:191
const mfem::real_t * Dhat2_d
Definition dgsem_cache.hpp:196
bool axisymmetric
Definition dgsem_cache.hpp:187
const int * elem_attr_d
Definition dgsem_cache.hpp:190
int ndof_scalar_el
Definition dgsem_cache.hpp:177
int num_equations
Definition dgsem_cache.hpp:178
const mfem::real_t * bnd_nor_d
Definition dgsem_cache.hpp:207
const mfem::real_t * elMetric_d
Definition dgsem_cache.hpp:193
const mfem::real_t * Dhat_d
Definition dgsem_cache.hpp:195
const mfem::real_t * D_d
Definition dgsem_cache.hpp:194
int Np
Definition dgsem_cache.hpp:184
typename PhysicsT::GasModel Gas
Definition dgsem_cache.hpp:171
const mfem::real_t * bnd_wt_d
Definition dgsem_cache.hpp:208
MFEM_HOST_DEVICE int iface_size() const
Definition dgsem_cache.hpp:232
const mfem::real_t * nor_d
Definition dgsem_cache.hpp:201
const mfem::real_t * fw_plus_d
Definition dgsem_cache.hpp:203
const mfem::real_t * bc_scalar_d
Definition dgsem_cache.hpp:213
Gas gas
Definition dgsem_cache.hpp:218
const mfem::real_t * fw_minus_d
Definition dgsem_cache.hpp:202
const mfem::real_t * elQWgts_d
Definition dgsem_cache.hpp:197
const mfem::real_t * elRadius_d
Definition dgsem_cache.hpp:198
const int * bnd_attr_d
Definition dgsem_cache.hpp:210
const mfem::real_t * face_radius_d
Definition dgsem_cache.hpp:204
const int * bnd_marker_to_bc_descr_d
Definition dgsem_cache.hpp:215
const mfem::real_t * elJac_d
Definition dgsem_cache.hpp:192
int p
Definition dgsem_cache.hpp:174
int num_interior_faces
Definition dgsem_cache.hpp:180
int Np_x
Definition dgsem_cache.hpp:181
int num_bcs
Definition dgsem_cache.hpp:186
const int * bnd_marker_index_d
Definition dgsem_cache.hpp:211
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:63
mfem::Vector volAux
Definition dgsem_cache.hpp:85
const mfem::IntegrationRule * ir_face
Definition dgsem_cache.hpp:53
const mfem::FaceRestriction * restr_b
Definition dgsem_cache.hpp:57
mfem::Vector bc_scalar_data
Definition dgsem_cache.hpp:122
mfem::Vector Dhat
Definition dgsem_cache.hpp:74
mfem::Vector bnd_xyz
Definition dgsem_cache.hpp:116
const mfem::FaceRestriction * restr_f
Definition dgsem_cache.hpp:56
mfem::Vector elMetric
Definition dgsem_cache.hpp:70
bool grad_bnd_restr_ready
Definition dgsem_cache.hpp:105
bool u_vol_restr_ready
Definition dgsem_cache.hpp:101
std::unique_ptr< mfem::FaceQuadratureSpace > fqs_int
Definition dgsem_cache.hpp:58
int num_interior_faces
Definition dgsem_cache.hpp:44
mfem::Vector dudtBnd
Definition dgsem_cache.hpp:94
mfem::Vector uVol
Definition dgsem_cache.hpp:84
int Np_y
Definition dgsem_cache.hpp:37
mfem::Vector stabilityAdvectiveRate
Definition dgsem_cache.hpp:126
mfem::Vector duBnd
Definition dgsem_cache.hpp:96
mfem::Array< int > elem_attr
Definition dgsem_cache.hpp:66
mfem::Vector stabilityDiffusiveRate
Definition dgsem_cache.hpp:128
mfem::Vector sInt
Definition dgsem_cache.hpp:88
mfem::Vector elRadius
Definition dgsem_cache.hpp:72
mfem::Vector stabilitySurfaceRate
Definition dgsem_cache.hpp:127
typename PhysicsT::GasModel OperatorGasModel
Definition dgsem_cache.hpp:30
mfem::IntegrationRules GLIntRules
Definition dgsem_cache.hpp:51
bool axisymmetric
Definition dgsem_cache.hpp:48
std::vector< mfem::Vector > pGrad
Definition dgsem_cache.hpp:109
mfem::Vector rhsInt
Definition dgsem_cache.hpp:89
mfem::Array< int > domain_attr_marker
Definition dgsem_cache.hpp:68
mfem::Vector face_radius
Definition dgsem_cache.hpp:79
mfem::Vector uInt
Definition dgsem_cache.hpp:87
std::vector< mfem::Vector > gradVol
Definition dgsem_cache.hpp:108
mfem::Vector elJac
Definition dgsem_cache.hpp:69
mfem::Array< Theseus::BCDescriptor > bc_descriptors
Definition dgsem_cache.hpp:121
mfem::Vector duInt
Definition dgsem_cache.hpp:97
typename PhysicsT::InviscidFlux InviscidFlux
Definition dgsem_cache.hpp:31
bool u_bnd_restr_ready
Definition dgsem_cache.hpp:102
const mfem::IntegrationRule * ir
Definition dgsem_cache.hpp:52
mfem::Array< int > inv_fp_map
Definition dgsem_cache.hpp:62
int ndof_scalar_el
Definition dgsem_cache.hpp:42
std::shared_ptr< mfem::ParGridFunction > alpha
Definition dgsem_cache.hpp:154
int Np_z
Definition dgsem_cache.hpp:38
std::vector< mfem::Vector > gradInt
Definition dgsem_cache.hpp:110
mfem::real_t stabilitySurfaceScale
Definition dgsem_cache.hpp:47
std::unique_ptr< Theseus::LTETable::Data > lteTableData
Definition dgsem_cache.hpp:131
mfem::Vector D
Definition dgsem_cache.hpp:73
mfem::Vector rhsBnd
Definition dgsem_cache.hpp:93
int num_attr
Definition dgsem_cache.hpp:39
mfem::Vector rhsVol
Definition dgsem_cache.hpp:86
bool grad_vol_restr_ready
Definition dgsem_cache.hpp:104
int Np
Definition dgsem_cache.hpp:35
mfem::Array< int > bnd_marker_index
Definition dgsem_cache.hpp:119
int MapFp(int face_slot, int fp_restr) const
Definition dgsem_cache.hpp:159
bool grad_int_restr_ready
Definition dgsem_cache.hpp:106
std::unique_ptr< mfem::FaceQuadratureSpace > fqs_bnd
Definition dgsem_cache.hpp:59
mfem::Vector face_wt_plus
Definition dgsem_cache.hpp:78
mfem::Vector face_normals
Definition dgsem_cache.hpp:76
mfem::Vector Dhat2
Definition dgsem_cache.hpp:75
const mfem::ElementRestrictionOperator * restr_v
Definition dgsem_cache.hpp:55
int MapFpInv(int face_slot, int fp_perm) const
Definition dgsem_cache.hpp:164
mfem::Vector bc_vector_data
Definition dgsem_cache.hpp:123
mfem::Array< int > bnd_marker_to_bc_descr
Definition dgsem_cache.hpp:120
mfem::Vector uBnd
Definition dgsem_cache.hpp:91
int num_elements
Definition dgsem_cache.hpp:40
mfem::Vector face_wt_minus
Definition dgsem_cache.hpp:77
InviscidFlux iflux
Definition dgsem_cache.hpp:130
mfem::Array< int > vol_attr_marker
Definition dgsem_cache.hpp:67
mfem::Vector pdudt
Definition dgsem_cache.hpp:82
mfem::Vector dudtInt
Definition dgsem_cache.hpp:90
std::vector< mfem::Vector > gradBnd
Definition dgsem_cache.hpp:111
mfem::Vector sVol
Definition dgsem_cache.hpp:83
mfem::Vector elQuadratureWeights
Definition dgsem_cache.hpp:71
bool urestr_ready
Definition dgsem_cache.hpp:100
mfem::Vector sBnd
Definition dgsem_cache.hpp:92
mfem::Vector entropyState
Definition dgsem_cache.hpp:95
mfem::real_t stabilityDiffusionScale
Definition dgsem_cache.hpp:46
mfem::Vector bnd_normals
Definition dgsem_cache.hpp:114
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:118
mfem::Vector bnd_radius
Definition dgsem_cache.hpp:117
mfem::real_t stabilityAdvectionScale
Definition dgsem_cache.hpp:45
int num_face_points
Definition dgsem_cache.hpp:43
bool u_int_restr_ready
Definition dgsem_cache.hpp:103
const mfem::IntegrationRule * ir_vol
Definition dgsem_cache.hpp:54
OperatorGasModel gas
Definition dgsem_cache.hpp:129
int p
Definition dgsem_cache.hpp:33
mfem::Vector bnd_wt
Definition dgsem_cache.hpp:115
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