45 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
47 typedef p_u_T_Calculator<dim, Number> This;
49 typedef CellIntegrator<dim, 1, Number> CellIntegratorScalar;
50 typedef CellIntegrator<dim, dim, Number> CellIntegratorVector;
52 typedef dealii::VectorizedArray<Number> scalar;
53 typedef dealii::Tensor<1, dim, dealii::VectorizedArray<Number>> vector;
56 : matrix_free(
nullptr),
61 heat_capacity_ratio(-1.0),
62 specific_gas_constant(-1.0)
67 initialize(dealii::MatrixFree<dim, Number>
const & matrix_free_in,
68 unsigned int const dof_index_all_in,
69 unsigned int const dof_index_vector_in,
70 unsigned int const dof_index_scalar_in,
71 unsigned int const quad_index_in,
72 double const heat_capacity_ratio_in,
73 double const specific_gas_constant_in)
75 matrix_free = &matrix_free_in;
76 dof_index_all = dof_index_all_in;
77 dof_index_vector = dof_index_vector_in;
78 dof_index_scalar = dof_index_scalar_in;
79 quad_index = quad_index_in;
80 heat_capacity_ratio = heat_capacity_ratio_in;
81 specific_gas_constant = specific_gas_constant_in;
85 compute_pressure(VectorType & pressure, VectorType
const & solution_conserved)
const
87 AssertThrow(heat_capacity_ratio > 0.0,
88 dealii::ExcMessage(
"heat capacity ratio has not been set!"));
89 AssertThrow(specific_gas_constant > 0.0,
90 dealii::ExcMessage(
"specific gas constant has not been set!"));
92 matrix_free->cell_loop(&This::local_apply_pressure,
this, pressure, solution_conserved);
96 compute_velocity(VectorType & velocity, VectorType
const & solution_conserved)
const
98 matrix_free->cell_loop(&This::local_apply_velocity,
this, velocity, solution_conserved);
102 compute_temperature(VectorType & temperature, VectorType
const & solution_conserved)
const
104 AssertThrow(heat_capacity_ratio > 0.0,
105 dealii::ExcMessage(
"heat capacity ratio has not been set!"));
106 AssertThrow(specific_gas_constant > 0.0,
107 dealii::ExcMessage(
"specific gas constant has not been set!"));
109 matrix_free->cell_loop(&This::local_apply_temperature,
this, temperature, solution_conserved);
114 local_apply_pressure(dealii::MatrixFree<dim, Number>
const & matrix_free,
116 VectorType
const & src,
117 std::pair<unsigned int, unsigned int>
const & cell_range)
const
120 CellIntegratorScalar density(matrix_free, dof_index_all, quad_index, 0);
121 CellIntegratorVector momentum(matrix_free, dof_index_all, quad_index, 1);
122 CellIntegratorScalar energy(matrix_free, dof_index_all, quad_index, 1 + dim);
125 CellIntegratorScalar pressure(matrix_free, dof_index_scalar, quad_index, 0);
127 for(
unsigned int cell = cell_range.first; cell < cell_range.second; ++cell)
130 density.reinit(cell);
131 density.read_dof_values(src);
132 density.evaluate(dealii::EvaluationFlags::values);
133 momentum.reinit(cell);
134 momentum.read_dof_values(src);
135 momentum.evaluate(dealii::EvaluationFlags::values);
137 energy.read_dof_values(src);
138 energy.evaluate(dealii::EvaluationFlags::values);
141 pressure.reinit(cell);
143 for(
unsigned int q = 0; q < energy.n_q_points; ++q)
146 scalar rho = density.get_value(q);
147 vector rho_u = momentum.get_value(q);
148 scalar rho_E = energy.get_value(q);
151 vector u = rho_u / rho;
153 scalar p = dealii::make_vectorized_array<Number>(heat_capacity_ratio - 1.0) *
154 (rho_E - 0.5 * rho * scalar_product(u, u));
156 pressure.submit_value(p, q);
159 pressure.integrate(dealii::EvaluationFlags::values);
160 pressure.set_dof_values(dst);
165 local_apply_velocity(dealii::MatrixFree<dim, Number>
const & matrix_free,
167 VectorType
const & src,
168 std::pair<unsigned int, unsigned int>
const & cell_range)
const
171 CellIntegratorScalar density(matrix_free, dof_index_all, quad_index, 0);
172 CellIntegratorVector momentum(matrix_free, dof_index_all, quad_index, 1);
175 CellIntegratorVector velocity(matrix_free, dof_index_vector, quad_index, 0);
177 for(
unsigned int cell = cell_range.first; cell < cell_range.second; ++cell)
180 density.reinit(cell);
181 density.read_dof_values(src);
182 density.evaluate(dealii::EvaluationFlags::values);
183 momentum.reinit(cell);
184 momentum.read_dof_values(src);
185 momentum.evaluate(dealii::EvaluationFlags::values);
188 velocity.reinit(cell);
190 for(
unsigned int q = 0; q < momentum.n_q_points; ++q)
193 scalar rho = density.get_value(q);
194 vector rho_u = momentum.get_value(q);
197 vector u = rho_u / rho;
199 velocity.submit_value(u, q);
202 velocity.integrate(dealii::EvaluationFlags::values);
203 velocity.set_dof_values(dst);
208 local_apply_temperature(dealii::MatrixFree<dim, Number>
const & matrix_free,
210 VectorType
const & src,
211 std::pair<unsigned int, unsigned int>
const & cell_range)
const
214 CellIntegratorScalar density(matrix_free, dof_index_all, quad_index, 0);
215 CellIntegratorVector momentum(matrix_free, dof_index_all, quad_index, 1);
216 CellIntegratorScalar energy(matrix_free, dof_index_all, quad_index, 1 + dim);
219 CellIntegratorScalar temperature(matrix_free, dof_index_scalar, quad_index, 0);
221 for(
unsigned int cell = cell_range.first; cell < cell_range.second; ++cell)
224 density.reinit(cell);
225 density.read_dof_values(src);
226 density.evaluate(dealii::EvaluationFlags::values);
227 momentum.reinit(cell);
228 momentum.read_dof_values(src);
229 momentum.evaluate(dealii::EvaluationFlags::values);
231 energy.read_dof_values(src);
232 energy.evaluate(dealii::EvaluationFlags::values);
235 temperature.reinit(cell);
237 for(
unsigned int q = 0; q < energy.n_q_points; ++q)
240 scalar rho = density.get_value(q);
241 vector rho_u = momentum.get_value(q);
242 scalar rho_E = energy.get_value(q);
245 vector u = rho_u / rho;
246 scalar E = rho_E / rho;
248 scalar T = dealii::make_vectorized_array<Number>((heat_capacity_ratio - 1.0) /
249 specific_gas_constant) *
250 (E - 0.5 * scalar_product(u, u));
252 temperature.submit_value(T, q);
255 temperature.integrate(dealii::EvaluationFlags::values);
256 temperature.set_dof_values(dst);
260 dealii::MatrixFree<dim, Number>
const * matrix_free;
262 unsigned int dof_index_all;
263 unsigned int dof_index_vector;
264 unsigned int dof_index_scalar;
265 unsigned int quad_index;
267 double heat_capacity_ratio;
268 double specific_gas_constant;