[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
large_eddy_simulation.cpp
1 #include <cmath>
2 #include <vector>
3 #include <complex> // for the jacobian
4 #include <boost/preprocessor/seq/for_each.hpp>
5 
6 #include "ADTypes.hpp"
7 
8 #include "model.h"
9 #include "large_eddy_simulation.h"
10 
11 namespace PHiLiP {
12 namespace Physics {
13 
14 //================================================================
15 // Large Eddy Simulation (LES) Base Class
16 //================================================================
17 template <int dim, int nspecies, int nstate, typename real>
19  const Parameters::AllParameters *const parameters_input,
20  const double ref_length,
21  const double gamma_gas,
22  const double mach_inf,
23  const double angle_of_attack,
24  const double side_slip_angle,
25  const double prandtl_number,
26  const double reynolds_number_inf,
27  const bool use_constant_viscosity,
28  const double constant_viscosity,
29  const double temperature_inf,
30  const double turbulent_prandtl_number,
31  const double ratio_of_filter_width_to_cell_size,
32  const double isothermal_wall_temperature,
33  const thermal_boundary_condition_enum thermal_boundary_condition_type,
34  std::shared_ptr< ManufacturedSolutionFunction<dim,nspecies,real> > manufactured_solution_function,
35  const two_point_num_flux_enum two_point_num_flux_type)
36  : ModelBase<dim,nspecies,nstate,real>(manufactured_solution_function)
37  , turbulent_prandtl_number(turbulent_prandtl_number)
38  , ratio_of_filter_width_to_cell_size(ratio_of_filter_width_to_cell_size)
39  , navier_stokes_physics(std::make_unique < NavierStokes<dim,nspecies,nstate,real> > (
40  parameters_input,
41  ref_length,
42  gamma_gas,
43  mach_inf,
44  angle_of_attack,
45  side_slip_angle,
46  prandtl_number,
47  reynolds_number_inf,
48  use_constant_viscosity,
49  constant_viscosity,
50  temperature_inf,
51  isothermal_wall_temperature,
52  thermal_boundary_condition_type,
53  manufactured_solution_function,
54  two_point_num_flux_type))
55 {
56  static_assert(nstate==dim+2, "ModelBase::LargeEddySimulationBase() should be created with nstate=dim+2");
57 }
58 //----------------------------------------------------------------
59 template <int dim, int nspecies, int nstate, typename real>
60 template<typename real2>
63  const dealii::Tensor<2,dim,real2> &tensor) const
64 {
65  real2 tensor_magnitude_sqr = 0.0; // complex initializes it as 0+0i
66  if(std::is_same<real2,real>::value){
67  tensor_magnitude_sqr = 0.0;
68  }
69  for (int i=0; i<dim; ++i) {
70  for (int j=0; j<dim; ++j) {
71  tensor_magnitude_sqr += tensor[i][j]*tensor[i][j];
72  }
73  }
74  return tensor_magnitude_sqr;
75 }
76 //----------------------------------------------------------------
77 template <int dim, int nspecies, int nstate, typename real>
78 template<typename real2>
81  const dealii::Tensor<2,dim,real2> &tensor) const
82 {
83  const real2 tensor_magnitude_sqr = this->template get_tensor_magnitude_sqr<real2>(tensor);
84  return sqrt(2.0*tensor_magnitude_sqr);
85 }
86 //----------------------------------------------------------------
87 template <int dim, int nspecies, int nstate, typename real>
88 std::array<dealii::Tensor<1,dim,real>,nstate> LargeEddySimulationBase<dim,nspecies,nstate,real>
90  const std::array<real,nstate> &/*conservative_soln*/) const
91 {
92  std::array<dealii::Tensor<1,dim,real>,nstate> conv_flux;
93  for (int i=0; i<nstate; i++) {
94  conv_flux[i] = 0; // No additional convective terms for Large Eddy Simulation
95  }
96  return conv_flux;
97 }
98 //----------------------------------------------------------------
99 template <int dim, int nspecies, int nstate, typename real>
100 std::array<dealii::Tensor<1,dim,real>,nstate> LargeEddySimulationBase<dim,nspecies,nstate,real>
102  const std::array<real,nstate> &conservative_soln,
103  const std::array<dealii::Tensor<1,dim,real>,nstate> &solution_gradient,
104  const dealii::types::global_dof_index cell_index) const
105 {
106  return dissipative_flux_templated<real>(conservative_soln,solution_gradient,cell_index);
107 }
108 //----------------------------------------------------------------
109 template <int dim, int nspecies, int nstate, typename real>
110 template <typename real2>
111 std::array<dealii::Tensor<1,dim,real2>,nstate> LargeEddySimulationBase<dim,nspecies,nstate,real>
113  const std::array<real2,nstate> &conservative_soln,
114  const std::array<dealii::Tensor<1,dim,real2>,nstate> &solution_gradient,
115  const dealii::types::global_dof_index cell_index) const
116 {
117  // Step 1,2: Primitive solution and Gradient of primitive solution
118  const std::array<dealii::Tensor<1,dim,real2>,nstate> primitive_soln_gradient = this->navier_stokes_physics->convert_conservative_gradient_to_primitive_gradient_templated(conservative_soln, solution_gradient);
119  const std::array<real2,nstate> primitive_soln = this->navier_stokes_physics->convert_conservative_to_primitive_templated(conservative_soln); // from Euler
120 
121  // Step 3: Viscous stress tensor, Velocities, Heat flux
122  const dealii::Tensor<1,dim,real2> vel = this->navier_stokes_physics->extract_velocities_from_primitive(primitive_soln); // from Euler
123  // Templated virtual member functions
124  dealii::Tensor<2,dim,real2> viscous_stress_tensor;
125  dealii::Tensor<1,dim,real2> heat_flux;
126  if constexpr(std::is_same<real2,real>::value){
127  viscous_stress_tensor = compute_SGS_stress_tensor(primitive_soln, primitive_soln_gradient,cell_index);
128  heat_flux = compute_SGS_heat_flux(primitive_soln, primitive_soln_gradient,cell_index);
129  }
130  else if constexpr(std::is_same<real2,FadType>::value){
131  viscous_stress_tensor = compute_SGS_stress_tensor_fad(primitive_soln, primitive_soln_gradient,cell_index);
132  heat_flux = compute_SGS_heat_flux_fad(primitive_soln, primitive_soln_gradient,cell_index);
133  }
134  else{
135  std::cout << "ERROR in physics/large_eddy_simulation.cpp --> dissipative_flux_templated(): real2!=real || real2!=FadType)" << std::endl;
136  std::abort();
137  }
138 
139  // Step 4: Construct viscous flux; Note: sign corresponds to LHS
140  std::array<dealii::Tensor<1,dim,real2>,nstate> viscous_flux
141  = this->navier_stokes_physics->dissipative_flux_given_velocities_viscous_stress_tensor_and_heat_flux(vel,viscous_stress_tensor,heat_flux);
142 
143  return viscous_flux;
144 }
145 //----------------------------------------------------------------
146 template <int dim, int nspecies, int nstate, typename real>
149  const std::array<real,nstate> &solution,
150  const std::array<dealii::Tensor<1,dim,real>,nstate> &solution_gradient,
151  const std::array<real,nstate> &/*filtered_solution*/,
152  const std::array<dealii::Tensor<1,dim,real>,nstate> &/*filtered_solution_gradient*/,
153  const bool on_boundary,
154  const dealii::types::global_dof_index cell_index,
155  const dealii::Tensor<1,dim,real> &normal,
156  const int boundary_type) const
157 {
158  std::array<dealii::Tensor<1,dim,real>,nstate> dissipative_flux;
159  std::array<real,nstate> dissipative_flux_dot_normal;
160  dissipative_flux_dot_normal.fill(0.0); // initialize
161  // Associated thermal boundary condition
162  if((on_boundary && (navier_stokes_physics->thermal_boundary_condition_type == thermal_boundary_condition_enum::adiabatic))
163  && (boundary_type == 1001)) {
164 
166  // adiabatic boundary
167  // --> Modify viscous flux such that normal_vector dot gradient of temperature must be zero
168 
169  // REFERENCES:
170  /* (1) Masatsuka 2018 "I do like CFD", p.148, eq.(4.12.1-4.12.4)
171  * (2) For the boundary condition case, refer to the equation above equation 458 of the following paper:
172  * Hartmann, Ralf. "Numerical analysis of higher order discontinuous Galerkin finite element methods." (2008): 1-107.
173  */
174 
175  // Step 1,2: Primitive solution and Gradient of primitive solution
176  const std::array<dealii::Tensor<1,dim,real>,nstate> primitive_soln_gradient = this->navier_stokes_physics->convert_conservative_gradient_to_primitive_gradient_templated(solution, solution_gradient);
177  const std::array<real,nstate> primitive_soln = this->navier_stokes_physics->convert_conservative_to_primitive_templated(solution); // from Euler
178 
179  // Step 3: Viscous stress tensor, Velocities, Heat flux
180  const dealii::Tensor<1,dim,real> vel = this->navier_stokes_physics->extract_velocities_from_primitive(primitive_soln); // from Euler
181  dealii::Tensor<2,dim,real> viscous_stress_tensor = compute_SGS_stress_tensor(primitive_soln, primitive_soln_gradient,cell_index);
182  dealii::Tensor<1,dim,real> heat_flux;
183  for (int flux_dim=0; flux_dim<dim; ++flux_dim) {
184  // set the heat flux to zero since we want the normal dot gradient of temperature to be zero for an adiabatic boundary
185  heat_flux[flux_dim] = 0.0;
186  }
187  // Step 4: Construct viscous flux; Note: sign corresponds to LHS
188  dissipative_flux = this->navier_stokes_physics->dissipative_flux_given_velocities_viscous_stress_tensor_and_heat_flux(vel,viscous_stress_tensor,heat_flux);
189  } else {
190  // if not on boundary and for all other types of boundary conditions (including isothermal) --> no change to dissipative flux
191  // no change to dissipative flux for BCs that do not impose a condition on the gradient at the boundary
192  dissipative_flux = dissipative_flux_templated<real>(solution,solution_gradient,cell_index);
193  }
194 
195  // compute the dot product with the normal vector
196  for (int s=0; s<nstate; s++) {
197  for (int d=0; d<dim; ++d) {
198  dissipative_flux_dot_normal[s] += dissipative_flux[s][d] * normal[d];//compute dot product
199  }
200  }
201 
203 }
204 //----------------------------------------------------------------
205 template <int dim, int nspecies, int nstate, typename real>
208  const std::array<real,nstate> &/*conservative_soln*/,
209  const dealii::Tensor<1,dim,real> &/*normal*/) const
210 {
211  std::array<real,nstate> eig;
212  eig.fill(0.0);
213  return eig;
214 }
215 //----------------------------------------------------------------
216 template <int dim, int nspecies, int nstate, typename real>
218 ::max_convective_eigenvalue (const std::array<real,nstate> &/*conservative_soln*/) const
219 {
220  const real max_eig = 0.0;
221  return max_eig;
222 }
223 //----------------------------------------------------------------
224 template <int dim, int nspecies, int nstate, typename real>
227  const std::array<real,nstate> &/*conservative_soln*/,
228  const dealii::Tensor<1,dim,real> &/*normal*/) const
229 {
230  const real max_eig = 0.0;
231  return max_eig;
232 }
233 //----------------------------------------------------------------
234 template <int dim, int nspecies, int nstate, typename real>
237  const dealii::Point<dim,real> &pos,
238  const std::array<real,nstate> &/*solution*/,
239  const real /*current_time*/,
240  const dealii::types::global_dof_index cell_index) const
241 {
242  /* TO DO Note: Since this is only used for the manufactured solution source term,
243  the grid spacing is fixed --> No AD wrt grid --> Can use same computation as NavierStokes
244  Acceptable if we can ensure that filter_width is the same everywhere in the domain
245  for the manufacture solution cases chosen
246  */
247  std::array<real,nstate> source_term = dissipative_source_term(pos,cell_index);
248  return source_term;
249 }
250 //----------------------------------------------------------------
251 template <int dim, int nspecies, int nstate, typename real>
254  const dealii::Point<dim,real> &/*pos*/,
255  const std::array<real,nstate> &conservative_soln,
256  const std::array<dealii::Tensor<1,dim,real>,nstate> &/*solution_gradient*/,
257  const dealii::types::global_dof_index /*cell_index*/) const
258 {
259  std::array<real,nstate> physical_source;
260  physical_source = this->channel_flow_source_term(conservative_soln);
261 
262  return physical_source;
263 }
264 //----------------------------------------------------------------
265 template <int dim, int nspecies, int nstate, typename real>
268  const std::array<real,nstate> &conservative_soln) const
269 {
270  std::array<real,nstate> source_term;
271  std::fill(source_term.begin(), source_term.end(), 0.0);
272 
273  // Get nondimensional (w.r.t. freestream) bulk velocity
274  // const real density = conservative_soln[0];
275  const std::array<real,nstate> primitive_soln = this->navier_stokes_physics->convert_conservative_to_primitive_templated(conservative_soln);
276  // const real viscosity_coefficient = this->navier_stokes_physics->compute_viscosity_coefficient(primitive_soln);
277  // const real bulk_velocity = viscosity_coefficient*(this->channel_bulk_velocity_reynolds_number)/(density*this->half_channel_height*this->navier_stokes_physics->reynolds_number_inf);
278  const real bulk_velocity = 1.0; // since we nondimensionalize w.r.t. freestream values, which are set at the bulk values, this value is simply 1.0
279 
280  // x-momentum term
281  source_term[1] = (this->bulk_density*bulk_velocity - conservative_soln[1])/this->time_step;
282 
283  // energy term
284  const real x_velocity = primitive_soln[1];
285  source_term[nstate-1] = x_velocity*source_term[1];
286 
287  return source_term;
288 }
289 //----------------------------------------------------------------
290 template <int dim, int nspecies, int nstate, typename real>
292 ::get_filter_width (const dealii::types::global_dof_index cell_index) const
293 {
294  // Compute the LES filter width
299  const int cell_poly_degree = this->cellwise_poly_degree[cell_index];
300  return get_filter_width_from_poly_degree(cell_index,cell_poly_degree);
301 }
302 //----------------------------------------------------------------
303 template <int dim, int nspecies, int nstate, typename real>
306  const dealii::types::global_dof_index cell_index,
307  const int cell_poly_degree) const
308 {
309  // Compute the LES filter width
314  const double cell_volume = this->cellwise_volume[cell_index];
315  double filter_width = pow(cell_volume, (1.0/3.0))/(cell_poly_degree+1);
316  // Resize given the ratio of filter width to cell size
317  filter_width *= ratio_of_filter_width_to_cell_size;
318 
319  return filter_width;
320 }
321 //----------------------------------------------------------------
322 // Returns the value from a CoDiPack or Sacado variable.
323 template<typename real>
324 double getValue(const real &x) {
325  if constexpr(std::is_same<real,double>::value) {
326  return x;
327  }
328  else if constexpr(std::is_same<real,FadType>::value) {
329  return x.val(); // sacado
330  }
331  else if constexpr(std::is_same<real,FadFadType>::value) {
332  return x.val().val(); // sacado
333  }
334  else if constexpr(std::is_same<real,RadType>::value) {
335  return x.value(); // CoDiPack
336  }
337  else if(std::is_same<real,RadFadType>::value) {
338  return x.value().value(); // CoDiPack
339  }
340 }
341 //----------------------------------------------------------------
342 template <int dim, int nspecies, int nstate, typename real>
343 dealii::Tensor<2,nstate,real> LargeEddySimulationBase<dim,nspecies,nstate,real>
345  const std::array<real,nstate> &conservative_soln,
346  const std::array<dealii::Tensor<1,dim,real>,nstate> &solution_gradient,
347  const dealii::Tensor<1,dim,real> &normal,
348  const dealii::types::global_dof_index cell_index) const
349 {
350  using adtype = FadType;
351 
352  // Initialize AD objects
353  std::array<adtype,nstate> AD_conservative_soln;
354  std::array<dealii::Tensor<1,dim,adtype>,nstate> AD_solution_gradient;
355  for (int s=0; s<nstate; s++) {
356  adtype ADvar(nstate, s, getValue<real>(conservative_soln[s])); // create AD variable
357  AD_conservative_soln[s] = ADvar;
358  for (int d=0;d<dim;d++) {
359  AD_solution_gradient[s][d] = getValue<real>(solution_gradient[s][d]);
360  }
361  }
362 
363  // Compute AD dissipative flux
364  std::array<dealii::Tensor<1,dim,adtype>,nstate> AD_dissipative_flux = dissipative_flux_templated<adtype>(AD_conservative_soln, AD_solution_gradient, cell_index);
365 
366  // Assemble the directional Jacobian
367  dealii::Tensor<2,nstate,real> jacobian;
368  for (int sp=0; sp<nstate; sp++) {
369  // for each perturbed state (sp) variable
370  for (int s=0; s<nstate; s++) {
371  jacobian[s][sp] = 0.0;
372  for (int d=0;d<dim;d++) {
373  // Compute directional jacobian
374  jacobian[s][sp] += AD_dissipative_flux[s][d].dx(sp)*normal[d];
375  }
376  }
377  }
378  return jacobian;
379 }
380 //----------------------------------------------------------------
381 template <int dim, int nspecies, int nstate, typename real>
382 dealii::Tensor<2,nstate,real> LargeEddySimulationBase<dim,nspecies,nstate,real>
384  const std::array<real,nstate> &conservative_soln,
385  const std::array<dealii::Tensor<1,dim,real>,nstate> &solution_gradient,
386  const dealii::Tensor<1,dim,real> &normal,
387  const int d_gradient,
388  const dealii::types::global_dof_index cell_index) const
389 {
390  using adtype = FadType;
391 
392  // Initialize AD objects
393  std::array<adtype,nstate> AD_conservative_soln;
394  std::array<dealii::Tensor<1,dim,adtype>,nstate> AD_solution_gradient;
395  for (int s=0; s<nstate; s++) {
396  AD_conservative_soln[s] = getValue<real>(conservative_soln[s]);
397  for (int d=0;d<dim;d++) {
398  if(d == d_gradient){
399  adtype ADvar(nstate, s, getValue<real>(solution_gradient[s][d])); // create AD variable
400  AD_solution_gradient[s][d] = ADvar;
401  }
402  else {
403  AD_solution_gradient[s][d] = getValue<real>(solution_gradient[s][d]);
404  }
405  }
406  }
407 
408  // Compute AD dissipative flux
409  std::array<dealii::Tensor<1,dim,adtype>,nstate> AD_dissipative_flux = dissipative_flux_templated<adtype>(AD_conservative_soln, AD_solution_gradient, cell_index);
410 
411  // Assemble the directional Jacobian
412  dealii::Tensor<2,nstate,real> jacobian;
413  for (int sp=0; sp<nstate; sp++) {
414  // for each perturbed state (sp) variable
415  for (int s=0; s<nstate; s++) {
416  jacobian[s][sp] = 0.0;
417  for (int d=0;d<dim;d++) {
418  // Compute directional jacobian
419  jacobian[s][sp] += AD_dissipative_flux[s][d].dx(sp)*normal[d];
420  }
421  }
422  }
423  return jacobian;
424 }
425 //----------------------------------------------------------------
426 template <int dim, int nspecies, int nstate, typename real>
429  const dealii::Point<dim,real> &pos) const
430 {
431  std::array<real,nstate> manufactured_solution;
432  for (int s=0; s<nstate; s++) {
433  manufactured_solution[s] = this->manufactured_solution_function->value (pos, s);
434  if (s==0) {
435  assert(manufactured_solution[s] > 0);
436  }
437  }
438  return manufactured_solution;
439 }
440 //----------------------------------------------------------------
441 template <int dim, int nspecies, int nstate, typename real>
442 std::array<dealii::Tensor<1,dim,real>,nstate> LargeEddySimulationBase<dim,nspecies,nstate,real>
444  const dealii::Point<dim,real> &pos) const
445 {
446  std::vector<dealii::Tensor<1,dim,real>> manufactured_solution_gradient_dealii(nstate);
447  this->manufactured_solution_function->vector_gradient(pos,manufactured_solution_gradient_dealii);
448  std::array<dealii::Tensor<1,dim,real>,nstate> manufactured_solution_gradient;
449  for (int d=0;d<dim;d++) {
450  for (int s=0; s<nstate; s++) {
451  manufactured_solution_gradient[s][d] = manufactured_solution_gradient_dealii[s][d];
452  }
453  }
454  return manufactured_solution_gradient;
455 }
456 //----------------------------------------------------------------
457 template <int dim, int nspecies, int nstate, typename real>
460  const dealii::Point<dim,real> &pos,
461  const dealii::types::global_dof_index cell_index) const
462 {
467  // Get Manufactured Solution values
468  const std::array<real,nstate> manufactured_solution = get_manufactured_solution_value(pos); // from Euler
469 
470  // Get Manufactured Solution gradient
471  const std::array<dealii::Tensor<1,dim,real>,nstate> manufactured_solution_gradient = get_manufactured_solution_gradient(pos); // from Euler
472 
473  // Get Manufactured Solution hessian
474  std::array<dealii::SymmetricTensor<2,dim,real>,nstate> manufactured_solution_hessian;
475  for (int s=0; s<nstate; s++) {
476  dealii::SymmetricTensor<2,dim,real> hessian = this->manufactured_solution_function->hessian(pos,s);
477  for (int dr=0;dr<dim;dr++) {
478  for (int dc=0;dc<dim;dc++) {
479  manufactured_solution_hessian[s][dr][dc] = hessian[dr][dc];
480  }
481  }
482  }
483 
484  // First term -- wrt to the conservative variables
485  // This is similar, should simply provide this function a flux_directional_jacobian() -- could restructure later
486  dealii::Tensor<1,nstate,real> dissipative_flux_divergence;
487  for (int d=0;d<dim;d++) {
488  dealii::Tensor<1,dim,real> normal;
489  normal[d] = 1.0;
490  const dealii::Tensor<2,nstate,real> jacobian = dissipative_flux_directional_jacobian(manufactured_solution, manufactured_solution_gradient, normal, cell_index);
491 
492  // get the directional jacobian wrt gradient
493  std::array<dealii::Tensor<2,nstate,real>,dim> jacobian_wrt_gradient;
494  for (int d_gradient=0;d_gradient<dim;d_gradient++) {
495 
496  // get the directional jacobian wrt gradient component (x,y,z)
497  const dealii::Tensor<2,nstate,real> jacobian_wrt_gradient_component = dissipative_flux_directional_jacobian_wrt_gradient_component(manufactured_solution, manufactured_solution_gradient, normal, d_gradient, cell_index);
498 
499  // store each component in jacobian_wrt_gradient -- could do this in the function used above
500  for (int sr = 0; sr < nstate; ++sr) {
501  for (int sc = 0; sc < nstate; ++sc) {
502  jacobian_wrt_gradient[d_gradient][sr][sc] = jacobian_wrt_gradient_component[sr][sc];
503  }
504  }
505  }
506 
507  //dissipative_flux_divergence += jacobian*manufactured_solution_gradient[d]; <-- needs second term! (jac wrt gradient)
508  for (int sr = 0; sr < nstate; ++sr) {
509  real jac_grad_row = 0.0;
510  for (int sc = 0; sc < nstate; ++sc) {
511  jac_grad_row += jacobian[sr][sc]*manufactured_solution_gradient[sc][d]; // Euler is the same as this
512  // Second term -- wrt to the gradient of conservative variables
513  // -- add the contribution of each gradient component (e.g. x,y,z for dim==3)
514  for (int d_gradient=0;d_gradient<dim;d_gradient++) {
515  jac_grad_row += jacobian_wrt_gradient[d_gradient][sr][sc]*manufactured_solution_hessian[sc][d_gradient][d]; // symmetric so d indexing works both ways
516  }
517  }
518  dissipative_flux_divergence[sr] += jac_grad_row;
519  }
520  }
521  std::array<real,nstate> dissipative_source_term;
522  for (int s=0; s<nstate; s++) {
523  dissipative_source_term[s] = dissipative_flux_divergence[s];
524  }
525 
527 }
528 //----------------------------------------------------------------
529 //================================================================
530 // Smagorinsky eddy viscosity model
531 //================================================================
532 template <int dim, int nspecies, int nstate, typename real>
534  const Parameters::AllParameters *const parameters_input,
535  const double ref_length,
536  const double gamma_gas,
537  const double mach_inf,
538  const double angle_of_attack,
539  const double side_slip_angle,
540  const double prandtl_number,
541  const double reynolds_number_inf,
542  const bool use_constant_viscosity,
543  const double constant_viscosity,
544  const double temperature_inf,
545  const double turbulent_prandtl_number,
547  const double model_constant,
548  const double isothermal_wall_temperature,
549  const thermal_boundary_condition_enum thermal_boundary_condition_type,
551  const two_point_num_flux_enum two_point_num_flux_type,
552  const bool apply_low_reynolds_number_eddy_viscosity_correction)
553  : LargeEddySimulationBase<dim,nspecies,nstate,real>(parameters_input,
554  ref_length,
555  gamma_gas,
556  mach_inf,
557  angle_of_attack,
558  side_slip_angle,
559  prandtl_number,
560  reynolds_number_inf,
561  use_constant_viscosity,
562  constant_viscosity,
563  temperature_inf,
564  turbulent_prandtl_number,
565  ratio_of_filter_width_to_cell_size,
566  isothermal_wall_temperature,
567  thermal_boundary_condition_type,
569  two_point_num_flux_type)
570  , model_constant(model_constant)
571  , apply_low_reynolds_number_eddy_viscosity_correction(apply_low_reynolds_number_eddy_viscosity_correction)
572 { }
573 //----------------------------------------------------------------
574 template <int dim, int nspecies, int nstate, typename real>
577  const dealii::types::global_dof_index cell_index) const
578 {
579  // Compute the filter width for the cell
580  const double filter_width = this->get_filter_width(cell_index);
581  // Product of the model constant (Cs) and the filter width (delta)
582  const double model_constant_times_filter_width = model_constant*filter_width;
583  return model_constant_times_filter_width;
584 }
585 //----------------------------------------------------------------
586 template <int dim, int nspecies, int nstate, typename real>
589  const dealii::types::global_dof_index cell_index) const
590 {
591  // Product of the model constant (Cs) and the filter width (delta) all squared
592  const double model_constant_times_filter_width = get_model_constant_times_filter_width(cell_index);
593  return model_constant_times_filter_width*model_constant_times_filter_width;
594 }
595 //----------------------------------------------------------------
596 template <int dim, int nspecies, int nstate, typename real>
598 ::set_unfiltered_conservative_solution(const std::array<real,nstate> &unfiltered_conservative_solution_)
599 {
600  for(int s=0; s<nstate; ++s){
601  this->unfiltered_conservative_solution[s] = unfiltered_conservative_solution_[s];
602  }
604  this->scaled_fluid_kinematic_viscosity_from_unfiltered_solution = getValue<real>(fluid_viscosity);
605 }
606 //----------------------------------------------------------------
607 template <int dim, int nspecies, int nstate, typename real>
610  const real uncorrected_eddy_viscosity) const
611 {
612  return get_corrected_eddy_viscosity_low_reynolds_number_templated<real>(uncorrected_eddy_viscosity);
613 }
614 //----------------------------------------------------------------
615 template <int dim, int nspecies, int nstate, typename real>
618  const FadType uncorrected_eddy_viscosity) const
619 {
620  return get_corrected_eddy_viscosity_low_reynolds_number_templated<FadType>(uncorrected_eddy_viscosity);
621 }
622 //----------------------------------------------------------------
623 template <int dim, int nspecies, int nstate, typename real>
626 {
627  const std::array<real,nstate> primitive_soln
628  = this->navier_stokes_physics->convert_conservative_to_primitive(this->unfiltered_conservative_solution); // from Euler
629  // Get scaled fluid kinematic viscosity
630  const real fluid_viscosity
631  = this->navier_stokes_physics->compute_scaled_viscosity_coefficient(primitive_soln)/primitive_soln[0];
632  return fluid_viscosity;
633 }
634 //----------------------------------------------------------------
635 template <int dim, int nspecies, int nstate, typename real>
636 template<typename real2>
639  const real2 uncorrected_eddy_viscosity) const
640 {
641  // Get scaled fluid kinematic viscosity
642  const real2 fluid_viscosity = 1.0*this->scaled_fluid_kinematic_viscosity_from_unfiltered_solution;
643 
644  const real2 corrected_eddy_viscosity = sqrt(uncorrected_eddy_viscosity*uncorrected_eddy_viscosity + fluid_viscosity*fluid_viscosity) - fluid_viscosity;
645  return corrected_eddy_viscosity;
646 }
647 //----------------------------------------------------------------
648 template <int dim, int nspecies, int nstate, typename real>
651  const std::array<real,nstate> &primitive_soln,
652  const std::array<dealii::Tensor<1,dim,real>,nstate> &primitive_soln_gradient,
653  const dealii::types::global_dof_index cell_index) const
654 {
655  return compute_eddy_viscosity_templated<real>(primitive_soln,primitive_soln_gradient,cell_index);
656 }
657 //----------------------------------------------------------------
658 template <int dim, int nspecies, int nstate, typename real>
661  const std::array<FadType,nstate> &primitive_soln,
662  const std::array<dealii::Tensor<1,dim,FadType>,nstate> &primitive_soln_gradient,
663  const dealii::types::global_dof_index cell_index) const
664 {
665  return compute_eddy_viscosity_templated<FadType>(primitive_soln,primitive_soln_gradient,cell_index);
666 }
667 //----------------------------------------------------------------
668 template <int dim, int nspecies, int nstate, typename real>
669 template<typename real2>
672  const std::array<real2,nstate> &/*primitive_soln*/,
673  const std::array<dealii::Tensor<1,dim,real2>,nstate> &primitive_soln_gradient,
674  const dealii::types::global_dof_index cell_index) const
675 {
676  // Get velocity gradient
677  const dealii::Tensor<2,dim,real2> vel_gradient
678  = this->navier_stokes_physics->extract_velocities_gradient_from_primitive_solution_gradient(primitive_soln_gradient);
679  // Get strain rate tensor
680  const dealii::Tensor<2,dim,real2> strain_rate_tensor
681  = this->navier_stokes_physics->compute_strain_rate_tensor(vel_gradient);
682 
683  // Product of the model constant (Cs) and the filter width (delta)
684  const real2 model_constant_times_filter_width_squared = get_model_constant_times_filter_width_squared(cell_index);
685  // Get magnitude of strain_rate_tensor
686  const real2 strain_rate_tensor_magnitude = this->template get_tensor_magnitude<real2>(strain_rate_tensor);
687  // Compute the eddy viscosity
688  const real2 eddy_viscosity = model_constant_times_filter_width_squared*strain_rate_tensor_magnitude;
689 
690  return eddy_viscosity;
691 }
692 //----------------------------------------------------------------
693 template <int dim, int nspecies, int nstate, typename real>
694 template<typename real2>
697  const std::array<real2,nstate> &primitive_soln,
698  const real2 eddy_viscosity) const
699 {
700  // Scaled non-dimensional eddy viscosity; See Plata 2019, Computers and Fluids, Eq.(12)
701  // -- Converts kinematic viscosity (nu) to dynamic viscosity (mu)
702  const real2 scaled_eddy_viscosity = primitive_soln[0]*eddy_viscosity;
703 
704  return scaled_eddy_viscosity;
705 }
706 //----------------------------------------------------------------
707 template <int dim, int nspecies, int nstate, typename real>
710  const std::array<real,nstate> &primitive_soln,
711  const std::array<dealii::Tensor<1,dim,real>,nstate> &primitive_soln_gradient,
712  const dealii::types::global_dof_index cell_index) const
713 {
714  return compute_SGS_heat_flux_templated<real>(primitive_soln,primitive_soln_gradient,cell_index);
715 }
716 //----------------------------------------------------------------
717 template <int dim, int nspecies, int nstate, typename real>
720  const std::array<FadType,nstate> &primitive_soln,
721  const std::array<dealii::Tensor<1,dim,FadType>,nstate> &primitive_soln_gradient,
722  const dealii::types::global_dof_index cell_index) const
723 {
724  return compute_SGS_heat_flux_templated<FadType>(primitive_soln,primitive_soln_gradient,cell_index);
725 }
726 //----------------------------------------------------------------
727 template <int dim, int nspecies, int nstate, typename real>
728 template<typename real2>
731  const std::array<real2,nstate> &primitive_soln,
732  const std::array<dealii::Tensor<1,dim,real2>,nstate> &primitive_soln_gradient,
733  const dealii::types::global_dof_index cell_index) const
734 {
735  // Compute non-dimensional eddy viscosity; See Plata 2019, Computers and Fluids, Eq.(12)
736  real2 eddy_viscosity;
737  if constexpr(std::is_same<real2,real>::value){
738  eddy_viscosity = compute_eddy_viscosity(primitive_soln,primitive_soln_gradient,cell_index);
740  eddy_viscosity = get_corrected_eddy_viscosity_low_reynolds_number(eddy_viscosity);
741  }
742  }
743  else if constexpr(std::is_same<real2,FadType>::value){
744  eddy_viscosity = compute_eddy_viscosity_fad(primitive_soln,primitive_soln_gradient,cell_index);
746  eddy_viscosity = get_corrected_eddy_viscosity_low_reynolds_number_fad(eddy_viscosity);
747  }
748  }
749  else{
750  std::cout << "ERROR in physics/large_eddy_simulation.cpp --> compute_SGS_heat_flux_templated(): real2 != real or FadType" << std::endl;
751  std::abort();
752  }
753 
754  // Scaled non-dimensional eddy viscosity; See Plata 2019, Computers and Fluids, Eq.(12)
755  const real2 scaled_eddy_viscosity = scale_eddy_viscosity_templated<real2>(primitive_soln,eddy_viscosity);
756 
757  // Compute scaled heat conductivity
758  const real2 scaled_heat_conductivity = this->navier_stokes_physics->compute_scaled_heat_conductivity_given_scaled_viscosity_coefficient_and_prandtl_number(scaled_eddy_viscosity,this->turbulent_prandtl_number);
759 
760  // Get temperature gradient
761  const dealii::Tensor<1,dim,real2> temperature_gradient = this->navier_stokes_physics->compute_temperature_gradient(primitive_soln, primitive_soln_gradient);
762 
763  // Compute the SGS stress tensor via the eddy_viscosity and the strain rate tensor
764  dealii::Tensor<1,dim,real2> heat_flux_SGS = this->navier_stokes_physics->compute_heat_flux_given_scaled_heat_conductivity_and_temperature_gradient(scaled_heat_conductivity,temperature_gradient);
765 
766  return heat_flux_SGS;
767 }
768 //----------------------------------------------------------------
769 template <int dim, int nspecies, int nstate, typename real>
772  const std::array<real,nstate> &primitive_soln,
773  const std::array<dealii::Tensor<1,dim,real>,nstate> &primitive_soln_gradient,
774  const dealii::types::global_dof_index cell_index) const
775 {
776  return compute_SGS_stress_tensor_templated<real>(primitive_soln,primitive_soln_gradient,cell_index);
777 }
778 //----------------------------------------------------------------
779 template <int dim, int nspecies, int nstate, typename real>
782  const std::array<FadType,nstate> &primitive_soln,
783  const std::array<dealii::Tensor<1,dim,FadType>,nstate> &primitive_soln_gradient,
784  const dealii::types::global_dof_index cell_index) const
785 {
786  return compute_SGS_stress_tensor_templated<FadType>(primitive_soln,primitive_soln_gradient,cell_index);
787 }
788 //----------------------------------------------------------------
789 template <int dim, int nspecies, int nstate, typename real>
790 template<typename real2>
793  const std::array<real2,nstate> &primitive_soln,
794  const std::array<dealii::Tensor<1,dim,real2>,nstate> &primitive_soln_gradient,
795  const dealii::types::global_dof_index cell_index) const
796 {
797  // Compute non-dimensional eddy viscosity; See Plata 2019, Computers and Fluids, Eq.(12)
798  real2 eddy_viscosity;
799  if constexpr(std::is_same<real2,real>::value){
800  eddy_viscosity = compute_eddy_viscosity(primitive_soln,primitive_soln_gradient,cell_index);
802  eddy_viscosity = get_corrected_eddy_viscosity_low_reynolds_number(eddy_viscosity);
803  }
804  }
805  else if constexpr(std::is_same<real2,FadType>::value){
806  eddy_viscosity = compute_eddy_viscosity_fad(primitive_soln,primitive_soln_gradient,cell_index);
808  eddy_viscosity = get_corrected_eddy_viscosity_low_reynolds_number_fad(eddy_viscosity);
809  }
810  }
811  else{
812  std::cout << "ERROR in physics/large_eddy_simulation.cpp --> compute_SGS_stress_tensor_templated(): real2 != real or FadType" << std::endl;
813  std::abort();
814  }
815 
816  // Scaled non-dimensional eddy viscosity; See Plata 2019, Computers and Fluids, Eq.(12)
817  const real2 scaled_eddy_viscosity = scale_eddy_viscosity_templated<real2>(primitive_soln,eddy_viscosity);
818 
819  // Get velocity gradients
820  const dealii::Tensor<2,dim,real2> vel_gradient
821  = this->navier_stokes_physics->extract_velocities_gradient_from_primitive_solution_gradient(primitive_soln_gradient);
822 
823  // Get strain rate tensor
824  const dealii::Tensor<2,dim,real2> strain_rate_tensor
825  = this->navier_stokes_physics->compute_strain_rate_tensor(vel_gradient);
826 
827  // Compute the SGS stress tensor via the eddy_viscosity and the strain rate tensor
828  dealii::Tensor<2,dim,real2> SGS_stress_tensor;
829  SGS_stress_tensor = this->navier_stokes_physics->compute_viscous_stress_tensor_via_scaled_viscosity_and_strain_rate_tensor(scaled_eddy_viscosity,strain_rate_tensor);
830 
831  return SGS_stress_tensor;
832 }
833 //----------------------------------------------------------------
834 //================================================================
835 // WALE (Wall-Adapting Local Eddy-viscosity) eddy viscosity model
836 //================================================================
837 template <int dim, int nspecies, int nstate, typename real>
839  const Parameters::AllParameters *const parameters_input,
840  const double ref_length,
841  const double gamma_gas,
842  const double mach_inf,
843  const double angle_of_attack,
844  const double side_slip_angle,
845  const double prandtl_number,
846  const double reynolds_number_inf,
847  const bool use_constant_viscosity,
848  const double constant_viscosity,
849  const double temperature_inf,
850  const double turbulent_prandtl_number,
852  const double model_constant,
853  const double isothermal_wall_temperature,
854  const thermal_boundary_condition_enum thermal_boundary_condition_type,
856  const two_point_num_flux_enum two_point_num_flux_type,
858  : LargeEddySimulation_Smagorinsky<dim,nspecies,nstate,real>(parameters_input,
859  ref_length,
860  gamma_gas,
861  mach_inf,
862  angle_of_attack,
863  side_slip_angle,
864  prandtl_number,
865  reynolds_number_inf,
866  use_constant_viscosity,
867  constant_viscosity,
868  temperature_inf,
869  turbulent_prandtl_number,
870  ratio_of_filter_width_to_cell_size,
871  model_constant,
872  isothermal_wall_temperature,
873  thermal_boundary_condition_type,
875  two_point_num_flux_type,
876  apply_low_reynolds_number_eddy_viscosity_correction)
877 { }
878 //----------------------------------------------------------------
879 template <int dim, int nspecies, int nstate, typename real>
882  const std::array<real,nstate> &primitive_soln,
883  const std::array<dealii::Tensor<1,dim,real>,nstate> &primitive_soln_gradient,
884  const dealii::types::global_dof_index cell_index) const
885 {
886  return compute_eddy_viscosity_templated<real>(primitive_soln,primitive_soln_gradient,cell_index);
887 }
888 //----------------------------------------------------------------
889 template <int dim, int nspecies, int nstate, typename real>
892  const std::array<FadType,nstate> &primitive_soln,
893  const std::array<dealii::Tensor<1,dim,FadType>,nstate> &primitive_soln_gradient,
894  const dealii::types::global_dof_index cell_index) const
895 {
896  return compute_eddy_viscosity_templated<FadType>(primitive_soln,primitive_soln_gradient,cell_index);
897 }
898 //----------------------------------------------------------------
899 template <int dim, int nspecies, int nstate, typename real>
900 template<typename real2>
903  const std::array<real2,nstate> &/*primitive_soln*/,
904  const std::array<dealii::Tensor<1,dim,real2>,nstate> &primitive_soln_gradient,
905  const dealii::types::global_dof_index cell_index) const
906 {
907  const dealii::Tensor<2,dim,real2> vel_gradient
908  = this->navier_stokes_physics->extract_velocities_gradient_from_primitive_solution_gradient(primitive_soln_gradient);
909  const dealii::Tensor<2,dim,real2> strain_rate_tensor
910  = this->navier_stokes_physics->compute_strain_rate_tensor(vel_gradient);
911 
912  // Product of the model constant (Cs) and the filter width (delta) squared
913  const real2 model_constant_times_filter_width_squared = this->get_model_constant_times_filter_width_squared(cell_index);
914 
918  // -- Compute $\bm{g}^{2}$
919  dealii::Tensor<2,dim,real2> g_sqr; // $g_{ij}^{2}$
920  for (int i=0; i<dim; ++i) {
921  for (int j=0; j<dim; ++j) {
922 
923  real2 val;if(std::is_same<real2,real>::value){val = 0.0;}
924 
925  for (int k=0; k<dim; ++k) {
926  val += vel_gradient[i][k]*vel_gradient[k][j];
927  }
928  g_sqr[i][j] = val;
929  }
930  }
931  real2 trace_g_sqr;if(std::is_same<real2,real>::value){trace_g_sqr = 0.0;}
932  for (int k=0; k<dim; ++k) {
933  trace_g_sqr += g_sqr[k][k];
934  }
935  dealii::Tensor<2,dim,real2> traceless_symmetric_square_of_velocity_gradient_tensor;
936  for (int i=0; i<dim; ++i) {
937  for (int j=0; j<dim; ++j) {
938  traceless_symmetric_square_of_velocity_gradient_tensor[i][j] = 0.5*(g_sqr[i][j]+g_sqr[j][i]);
939  }
940  }
941  for (int k=0; k<dim; ++k) {
942  traceless_symmetric_square_of_velocity_gradient_tensor[k][k] += -(1.0/3.0)*trace_g_sqr;
943  }
944 
945  // Get magnitude of strain_rate_tensor and ducros_strain_rate_tensor
946  const real2 strain_rate_tensor_magnitude_sqr = this->template get_tensor_magnitude_sqr<real2>(strain_rate_tensor);
947  const real2 traceless_symmetric_square_of_velocity_gradient_tensor_magnitude_sqr = this->template get_tensor_magnitude_sqr<real2>(traceless_symmetric_square_of_velocity_gradient_tensor);
948  // Compute the eddy viscosity
949  // -- Initialize as zero
950  real2 eddy_viscosity;if(std::is_same<real2,real>::value){eddy_viscosity = 0.0;}
951  if((strain_rate_tensor_magnitude_sqr != 0.0) &&
952  (traceless_symmetric_square_of_velocity_gradient_tensor_magnitude_sqr != 0.0)) {
959  eddy_viscosity = model_constant_times_filter_width_squared*pow(traceless_symmetric_square_of_velocity_gradient_tensor_magnitude_sqr,1.5)/(pow(strain_rate_tensor_magnitude_sqr,2.5) + pow(traceless_symmetric_square_of_velocity_gradient_tensor_magnitude_sqr,1.25));
960  }
961 
962  return eddy_viscosity;
963 }
964 //----------------------------------------------------------------
965 //================================================================
966 // Vreman eddy viscosity model
967 //================================================================
968 template <int dim, int nspecies, int nstate, typename real>
970  const Parameters::AllParameters *const parameters_input,
971  const double ref_length,
972  const double gamma_gas,
973  const double mach_inf,
974  const double angle_of_attack,
975  const double side_slip_angle,
976  const double prandtl_number,
977  const double reynolds_number_inf,
978  const bool use_constant_viscosity,
979  const double constant_viscosity,
980  const double temperature_inf,
981  const double turbulent_prandtl_number,
983  const double model_constant,
984  const double isothermal_wall_temperature,
985  const thermal_boundary_condition_enum thermal_boundary_condition_type,
987  const two_point_num_flux_enum two_point_num_flux_type,
989  : LargeEddySimulation_Smagorinsky<dim,nspecies,nstate,real>(parameters_input,
990  ref_length,
991  gamma_gas,
992  mach_inf,
993  angle_of_attack,
994  side_slip_angle,
995  prandtl_number,
996  reynolds_number_inf,
997  use_constant_viscosity,
998  constant_viscosity,
999  temperature_inf,
1000  turbulent_prandtl_number,
1001  ratio_of_filter_width_to_cell_size,
1002  model_constant,
1003  isothermal_wall_temperature,
1004  thermal_boundary_condition_type,
1006  two_point_num_flux_type,
1007  apply_low_reynolds_number_eddy_viscosity_correction)
1008 { }
1009 //----------------------------------------------------------------
1010 template <int dim, int nspecies, int nstate, typename real>
1013  const std::array<real,nstate> &primitive_soln,
1014  const std::array<dealii::Tensor<1,dim,real>,nstate> &primitive_soln_gradient,
1015  const dealii::types::global_dof_index cell_index) const
1016 {
1017  return compute_eddy_viscosity_templated<real>(primitive_soln,primitive_soln_gradient,cell_index);
1018 }
1019 //----------------------------------------------------------------
1020 template <int dim, int nspecies, int nstate, typename real>
1023  const std::array<FadType,nstate> &primitive_soln,
1024  const std::array<dealii::Tensor<1,dim,FadType>,nstate> &primitive_soln_gradient,
1025  const dealii::types::global_dof_index cell_index) const
1026 {
1027  return compute_eddy_viscosity_templated<FadType>(primitive_soln,primitive_soln_gradient,cell_index);
1028 }
1029 //----------------------------------------------------------------
1030 template <int dim, int nspecies, int nstate, typename real>
1031 template<typename real2>
1034  const std::array<real2,nstate> &/*primitive_soln*/,
1035  const std::array<dealii::Tensor<1,dim,real2>,nstate> &primitive_soln_gradient,
1036  const dealii::types::global_dof_index cell_index) const
1037 {
1038  const dealii::Tensor<2,dim,real2> vel_gradient
1039  = this->navier_stokes_physics->extract_velocities_gradient_from_primitive_solution_gradient(primitive_soln_gradient);
1040 
1041  // Compute the filter width for the cell
1042  const double filter_width = this->get_filter_width(cell_index);
1043 
1046  // -- Compute $\bm{beta}$
1047  dealii::Tensor<2,dim,real2> beta_tensor;
1048  for (int i=0; i<dim; ++i) {
1049  for (int j=0; j<dim; ++j) {
1050 
1051  real2 val;if(std::is_same<real2,real>::value){val = 0.0;}
1052 
1053  for (int k=0; k<dim; ++k) {
1054  val += vel_gradient[i][k]*vel_gradient[j][k];
1055  }
1056  beta_tensor[i][j] = filter_width*filter_width*val; // for isotropic filter width
1057  }
1058  }
1059  // Reference: Vreman (2004) - Equation (8) - $B_{\beta}$ (determinant of beta tensor -- symmetrical)
1060  real2 beta_tensor_determinant;if(std::is_same<real2,real>::value){beta_tensor_determinant = 0.0;}
1061  if constexpr(dim>1){
1062  beta_tensor_determinant = beta_tensor[0][0]*beta_tensor[1][1] - beta_tensor[0][1]*beta_tensor[0][1];
1063  }
1064  if constexpr(dim==3){
1065  for (int i=0; i<2; ++i) {
1066  beta_tensor_determinant += beta_tensor[i][i]*beta_tensor[2][2] - beta_tensor[i][2]*beta_tensor[i][2];
1067  }
1068  }
1069 
1070  // Get magnitude of velocity gradient tensor squared
1071  const real2 velocity_gradient_tensor_magnitude_sqr = this->template get_tensor_magnitude_sqr<real2>(vel_gradient);
1072  // Compute the eddy viscosity
1073  // -- Initialize as zero
1074  real2 eddy_viscosity;if(std::is_same<real2,real>::value){eddy_viscosity = 0.0;}
1075  if((velocity_gradient_tensor_magnitude_sqr !=0.0) && (beta_tensor_determinant >= 0.0)) {
1083  // Reference: Vreman (2004) - Equation (5)
1084  eddy_viscosity = this->model_constant*sqrt(beta_tensor_determinant/velocity_gradient_tensor_magnitude_sqr);
1085  }
1086 
1087  return eddy_viscosity;
1088 }
1089 //----------------------------------------------------------------
1090 //================================================================
1091 // Shear-improved Smagorinsky eddy viscosity model
1092 //================================================================
1093 template <int dim, int nspecies, int nstate, typename real>
1095  const Parameters::AllParameters *const parameters_input,
1096  const double ref_length,
1097  const double gamma_gas,
1098  const double mach_inf,
1099  const double angle_of_attack,
1100  const double side_slip_angle,
1101  const double prandtl_number,
1102  const double reynolds_number_inf,
1103  const bool use_constant_viscosity,
1104  const double constant_viscosity,
1105  const double temperature_inf,
1106  const double turbulent_prandtl_number,
1108  const double model_constant,
1109  const double isothermal_wall_temperature,
1110  const thermal_boundary_condition_enum thermal_boundary_condition_type,
1112  const two_point_num_flux_enum two_point_num_flux_type,
1114  : LargeEddySimulation_Smagorinsky<dim,nspecies,nstate,real>(parameters_input,
1115  ref_length,
1116  gamma_gas,
1117  mach_inf,
1118  angle_of_attack,
1119  side_slip_angle,
1120  prandtl_number,
1121  reynolds_number_inf,
1122  use_constant_viscosity,
1123  constant_viscosity,
1124  temperature_inf,
1125  turbulent_prandtl_number,
1126  ratio_of_filter_width_to_cell_size,
1127  model_constant,
1128  isothermal_wall_temperature,
1129  thermal_boundary_condition_type,
1131  two_point_num_flux_type,
1132  apply_low_reynolds_number_eddy_viscosity_correction)
1133 { }
1134 //----------------------------------------------------------------
1135 template <int dim, int nspecies, int nstate, typename real>
1138  const std::array<real,nstate> &primitive_soln,
1139  const std::array<dealii::Tensor<1,dim,real>,nstate> &primitive_soln_gradient,
1140  const dealii::types::global_dof_index cell_index) const
1141 {
1142  return compute_eddy_viscosity_templated<real>(primitive_soln,primitive_soln_gradient,cell_index);
1143 }
1144 //----------------------------------------------------------------
1145 template <int dim, int nspecies, int nstate, typename real>
1148  const std::array<FadType,nstate> &primitive_soln,
1149  const std::array<dealii::Tensor<1,dim,FadType>,nstate> &primitive_soln_gradient,
1150  const dealii::types::global_dof_index cell_index) const
1151 {
1152  return compute_eddy_viscosity_templated<FadType>(primitive_soln,primitive_soln_gradient,cell_index);
1153 }
1154 //----------------------------------------------------------------
1155 template <int dim, int nspecies, int nstate, typename real>
1156 template<typename real2>
1159  const std::array<real2,nstate> &/*primitive_soln*/,
1160  const std::array<dealii::Tensor<1,dim,real2>,nstate> &primitive_soln_gradient,
1161  const dealii::types::global_dof_index cell_index) const
1162 {
1163  /* This SGS model modifies the original Smagorinsky model, therefore two references are provided:
1164  * - Reference 1: de la Llave Plata et al. (2019). "On the performance of a high-order multiscale DG approach to LES at increasing Reynolds number."
1165  * - Reference 2: E. Leveque, F. Toschi, L. Shao and J.-P. Bertoglio (2007, J. Fluid Mech.) "Shear-improved Smagorinsky model for large-eddy simulation of wall-bounded turbulent flows"
1166  * This implementation uses Equation (14) in reference 1 for the original Smagorinsky model,
1167  * and the modification provided by equation (2.4) in reference 2.
1168  */
1169  // Get velocity gradient
1170  const dealii::Tensor<2,dim,real2> vel_gradient
1171  = this->navier_stokes_physics->extract_velocities_gradient_from_primitive_solution_gradient(primitive_soln_gradient);
1172  // Get strain rate tensor
1173  const dealii::Tensor<2,dim,real2> strain_rate_tensor
1174  = this->navier_stokes_physics->compute_strain_rate_tensor(vel_gradient);
1175 
1176  // Product of the model constant (Cs) and the filter width (delta) squared
1177  const real2 model_constant_times_filter_width_squared = this->get_model_constant_times_filter_width_squared(cell_index);
1178  // Get magnitude of strain_rate_tensor
1179  const real2 strain_rate_tensor_magnitude = this->template get_tensor_magnitude<real2>(strain_rate_tensor);
1180  // Compute the eddy viscosity; Eq.(14) in reference 1 with modification by Eq.(2.4) in reference 2
1181  const real2 eddy_viscosity = model_constant_times_filter_width_squared*(
1182  strain_rate_tensor_magnitude - this->cellwise_mean_strain_rate_tensor_magnitude[cell_index]);
1183 
1184  return eddy_viscosity;
1185 }
1186 //----------------------------------------------------------------
1187 //================================================================
1188 // Variational multiscale (VMS) eddy viscosity model
1189 //================================================================
1190 template <int dim, int nspecies, int nstate, typename real>
1192  const Parameters::AllParameters *const parameters_input,
1193  const double ref_length,
1194  const double gamma_gas,
1195  const double mach_inf,
1196  const double angle_of_attack,
1197  const double side_slip_angle,
1198  const double prandtl_number,
1199  const double reynolds_number_inf,
1200  const bool use_constant_viscosity,
1201  const double constant_viscosity,
1202  const double temperature_inf,
1203  const double turbulent_prandtl_number,
1205  const double model_constant,
1206  const unsigned int poly_degree,
1207  const unsigned int poly_degree_large_scales,
1208  const double mesh_size,
1209  const double curve_fit_constant,
1210  const double isothermal_wall_temperature,
1211  const thermal_boundary_condition_enum thermal_boundary_condition_type,
1213  const two_point_num_flux_enum two_point_num_flux_type,
1215  : LargeEddySimulation_Smagorinsky<dim,nspecies,nstate,real>(parameters_input,
1216  ref_length,
1217  gamma_gas,
1218  mach_inf,
1219  angle_of_attack,
1220  side_slip_angle,
1221  prandtl_number,
1222  reynolds_number_inf,
1223  use_constant_viscosity,
1224  constant_viscosity,
1225  temperature_inf,
1226  turbulent_prandtl_number,
1227  ratio_of_filter_width_to_cell_size,
1228  model_constant,
1229  isothermal_wall_temperature,
1230  thermal_boundary_condition_type,
1232  two_point_num_flux_type,
1233  apply_low_reynolds_number_eddy_viscosity_correction)
1234  , poly_degree((double)poly_degree)
1235  , poly_degree_large_scales((double)poly_degree_large_scales)
1236  , mesh_size(mesh_size)
1237  , curve_fit_constant(curve_fit_constant)
1238 { }
1239 //----------------------------------------------------------------
1240 template <int dim, int nspecies, int nstate, typename real>
1243  const dealii::types::global_dof_index /*cell_index*/) const
1244 {
1245  // Smagorinsky constant for a given DG discretization; equation 8 in reference
1246  const double discontinuous_galerkin_smagorinsky_model_constant = 0.172*mesh_size/poly_degree;
1247 
1248  // Model constant times filter width; equations 18 and 14 in reference
1249  double model_constant_times_filter_width = 1.0 - pow(curve_fit_constant*(poly_degree_large_scales/poly_degree), 4.0/3.0);
1250  model_constant_times_filter_width = pow(model_constant_times_filter_width, -3.0/4.0);
1251  model_constant_times_filter_width *= discontinuous_galerkin_smagorinsky_model_constant;
1252 
1253  return model_constant_times_filter_width;
1254 }
1255 //----------------------------------------------------------------
1256 //================================================================
1257 // Small-Small Variational multiscale (VMS) eddy viscosity model
1258 //================================================================
1259 template <int dim, int nspecies, int nstate, typename real>
1261  const Parameters::AllParameters *const parameters_input,
1262  const double ref_length,
1263  const double gamma_gas,
1264  const double mach_inf,
1265  const double angle_of_attack,
1266  const double side_slip_angle,
1267  const double prandtl_number,
1268  const double reynolds_number_inf,
1269  const bool use_constant_viscosity,
1270  const double constant_viscosity,
1271  const double temperature_inf,
1272  const double turbulent_prandtl_number,
1274  const double model_constant,
1275  const unsigned int poly_degree,
1276  const unsigned int poly_degree_large_scales,
1277  const double mesh_size,
1278  const double isothermal_wall_temperature,
1279  const thermal_boundary_condition_enum thermal_boundary_condition_type,
1281  const two_point_num_flux_enum two_point_num_flux_type,
1283  : LargeEddySimulation_VMS<dim,nspecies,nstate,real>(parameters_input,
1284  ref_length,
1285  gamma_gas,
1286  mach_inf,
1287  angle_of_attack,
1288  side_slip_angle,
1289  prandtl_number,
1290  reynolds_number_inf,
1291  use_constant_viscosity,
1292  constant_viscosity,
1293  temperature_inf,
1294  turbulent_prandtl_number,
1295  ratio_of_filter_width_to_cell_size,
1296  model_constant,
1297  poly_degree,
1298  poly_degree_large_scales,
1299  mesh_size,
1300  1.174, // Equation 18 in reference
1301  isothermal_wall_temperature,
1302  thermal_boundary_condition_type,
1304  two_point_num_flux_type,
1305  apply_low_reynolds_number_eddy_viscosity_correction)
1306 { }
1307 //----------------------------------------------------------------
1308 //================================================================
1309 // All-All Variational multiscale (VMS) eddy viscosity model
1310 //================================================================
1311 template <int dim, int nspecies, int nstate, typename real>
1313  const Parameters::AllParameters *const parameters_input,
1314  const double ref_length,
1315  const double gamma_gas,
1316  const double mach_inf,
1317  const double angle_of_attack,
1318  const double side_slip_angle,
1319  const double prandtl_number,
1320  const double reynolds_number_inf,
1321  const bool use_constant_viscosity,
1322  const double constant_viscosity,
1323  const double temperature_inf,
1324  const double turbulent_prandtl_number,
1326  const double model_constant,
1327  const unsigned int poly_degree,
1328  const unsigned int poly_degree_large_scales,
1329  const double mesh_size,
1330  const double isothermal_wall_temperature,
1331  const thermal_boundary_condition_enum thermal_boundary_condition_type,
1333  const two_point_num_flux_enum two_point_num_flux_type,
1335  : LargeEddySimulation_VMS<dim,nspecies,nstate,real>(parameters_input,
1336  ref_length,
1337  gamma_gas,
1338  mach_inf,
1339  angle_of_attack,
1340  side_slip_angle,
1341  prandtl_number,
1342  reynolds_number_inf,
1343  use_constant_viscosity,
1344  constant_viscosity,
1345  temperature_inf,
1346  turbulent_prandtl_number,
1347  ratio_of_filter_width_to_cell_size,
1348  model_constant,
1349  poly_degree,
1350  poly_degree_large_scales,
1351  mesh_size,
1352  1.082, // Equation 14 in reference
1353  isothermal_wall_temperature,
1354  thermal_boundary_condition_type,
1356  two_point_num_flux_type,
1357  apply_low_reynolds_number_eddy_viscosity_correction)
1358 { }
1359 //----------------------------------------------------------------
1360 //================================================================
1361 // Dynamic Smagorinsky Model (DSM)
1362 //================================================================
1363 template <int dim, int nspecies, int nstate, typename real>
1365  const Parameters::AllParameters *const parameters_input,
1366  const double ref_length,
1367  const double gamma_gas,
1368  const double mach_inf,
1369  const double angle_of_attack,
1370  const double side_slip_angle,
1371  const double prandtl_number,
1372  const double reynolds_number_inf,
1373  const bool use_constant_viscosity,
1374  const double constant_viscosity,
1375  const double temperature_inf,
1376  const double turbulent_prandtl_number,
1378  const double model_constant,
1379  const double isothermal_wall_temperature,
1380  const thermal_boundary_condition_enum thermal_boundary_condition_type,
1382  const two_point_num_flux_enum two_point_num_flux_type,
1384  : LargeEddySimulation_Smagorinsky<dim,nspecies,nstate,real>(parameters_input,
1385  ref_length,
1386  gamma_gas,
1387  mach_inf,
1388  angle_of_attack,
1389  side_slip_angle,
1390  prandtl_number,
1391  reynolds_number_inf,
1392  use_constant_viscosity,
1393  constant_viscosity,
1394  temperature_inf,
1395  turbulent_prandtl_number,
1396  ratio_of_filter_width_to_cell_size,
1397  model_constant,
1398  isothermal_wall_temperature,
1399  thermal_boundary_condition_type,
1401  two_point_num_flux_type,
1402  apply_low_reynolds_number_eddy_viscosity_correction)
1403 { }
1404 //----------------------------------------------------------------
1405 template <int dim, int nspecies, int nstate, typename real>
1408  const dealii::types::global_dof_index cell_index) const
1409 {
1410  // Model constant times filter width squared
1412 }
1413 #if PHILIP_SPECIES==1
1414 //----------------------------------------------------------------
1415 //----------------------------------------------------------------
1416 //----------------------------------------------------------------
1417 //----------------------------------------------------------------
1418 // Instantiate explicitly
1419 // Define a sequence of possible types
1420 #define POSSIBLE_TYPES (double)(FadType)(RadType)(FadFadType)(RadFadType)
1421 
1422 // Define a macro to instantiate LES functions for a specific type
1423 #define INSTANTIATE_TYPES(r, data, type) \
1424  template class LargeEddySimulationBase < PHILIP_DIM, PHILIP_SPECIES, PHILIP_DIM+2, type >; \
1425  template class LargeEddySimulation_Smagorinsky < PHILIP_DIM, PHILIP_SPECIES, PHILIP_DIM+2, type >; \
1426  template class LargeEddySimulation_WALE < PHILIP_DIM, PHILIP_SPECIES, PHILIP_DIM+2, type >; \
1427  template class LargeEddySimulation_Vreman < PHILIP_DIM, PHILIP_SPECIES, PHILIP_DIM+2, type >; \
1428  template class LargeEddySimulation_ShearImprovedSmagorinsky < PHILIP_DIM, PHILIP_SPECIES, PHILIP_DIM+2, type >; \
1429  template class LargeEddySimulation_VMS < PHILIP_DIM, PHILIP_SPECIES, PHILIP_DIM+2, type >; \
1430  template class LargeEddySimulation_SmallSmallVMS < PHILIP_DIM, PHILIP_SPECIES, PHILIP_DIM+2, type >; \
1431  template class LargeEddySimulation_AllAllVMS < PHILIP_DIM, PHILIP_SPECIES, PHILIP_DIM+2, type >; \
1432  template class LargeEddySimulation_DynamicSmagorinsky < PHILIP_DIM, PHILIP_SPECIES, PHILIP_DIM+2, type >; \
1433  template type LargeEddySimulationBase < PHILIP_DIM, PHILIP_SPECIES, PHILIP_DIM+2, type >::get_tensor_magnitude_sqr< type >(const dealii::Tensor<2,PHILIP_DIM, type> &tensor) const; \
1434  template type LargeEddySimulationBase < PHILIP_DIM, PHILIP_SPECIES, PHILIP_DIM+2, type >::get_tensor_magnitude< type >(const dealii::Tensor<2,PHILIP_DIM, type> &tensor) const;
1435 BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_TYPES, _, POSSIBLE_TYPES)
1436 
1437 #undef POSSIBLE_TYPES
1438 // Define a sequence of possible types
1439 #define POSSIBLE_TYPES (double)(RadType)(FadFadType)(RadFadType)
1440 // Define a macro to instantiate LES functions for a specific type
1441 // -- -- instantiate all the real types with real2 = FadType for automatic differentiation
1442 #define INSTANTIATE_FADTYPES(r, data, type) \
1443 template FadType LargeEddySimulationBase < PHILIP_DIM, PHILIP_SPECIES, PHILIP_DIM+2, type >::get_tensor_magnitude< FadType >(const dealii::Tensor<2,PHILIP_DIM,FadType > &tensor) const; \
1444 template FadType LargeEddySimulationBase < PHILIP_DIM, PHILIP_SPECIES, PHILIP_DIM+2, type >::get_tensor_magnitude_sqr< FadType >(const dealii::Tensor<2,PHILIP_DIM, FadType > &tensor) const;
1445 BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_FADTYPES, _, POSSIBLE_TYPES)
1446 #endif
1447 } // Physics namespace
1448 } // PHiLiP namespace
double get_filter_width_from_poly_degree(const dealii::types::global_dof_index cell_index, const int cell_poly_degree) const
Compute the nondimensionalized filter width used by the SGS model given a cell index.
real2 compute_eddy_viscosity_templated(const std::array< real2, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, real2 >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const
LargeEddySimulation_WALE(const Parameters::AllParameters *const parameters_input, const double ref_length, const double gamma_gas, const double mach_inf, const double angle_of_attack, const double side_slip_angle, const double prandtl_number, const double reynolds_number_inf, const bool use_constant_viscosity, const double constant_viscosity, const double temperature_inf, const double turbulent_prandtl_number, const double ratio_of_filter_width_to_cell_size, const double model_constant, const double isothermal_wall_temperature=1.0, const thermal_boundary_condition_enum thermal_boundary_condition_type=thermal_boundary_condition_enum::adiabatic, std::shared_ptr< ManufacturedSolutionFunction< dim, nspecies, real > > manufactured_solution_function=nullptr, const two_point_num_flux_enum two_point_num_flux_type=two_point_num_flux_enum::KG, const bool apply_low_reynolds_number_eddy_viscosity_correction=false)
real2 compute_eddy_viscosity_templated(const std::array< real2, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, real2 >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const
Templated nondimensionalized eddy viscosity for the Smagorinsky model.
dealii::Tensor< 1, dim, real > compute_SGS_heat_flux(const std::array< real, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, real >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const
Nondimensionalized sub-grid scale (SGS) heat flux, (q^sgs)*.
Variational multiscale (VMS) eddy viscosity model. Derived from LargeEddySimulation_Smagorinsky for o...
Smagorinsky eddy viscosity model. Derived from Large Eddy Simulation.
real max_convective_eigenvalue(const std::array< real, nstate > &soln) const
Maximum convective eigenvalue of the additional models&#39; PDEs.
virtual dealii::Tensor< 1, dim, real > compute_SGS_heat_flux(const std::array< real, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, real >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const =0
Nondimensionalized sub-grid scale (SGS) heat flux, (q^sgs)*.
dealii::Tensor< 2, dim, real > compute_SGS_stress_tensor(const std::array< real, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, real >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const
Nondimensionalized sub-grid scale (SGS) stress tensor, (tau^sgs)*.
FadType compute_eddy_viscosity_fad(const std::array< FadType, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, FadType >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const override
Sacado::Fad::DFad< double > FadType
Sacado AD type for first derivatives.
Definition: ADTypes.hpp:11
dealii::Tensor< 2, dim, FadType > compute_SGS_stress_tensor_fad(const std::array< FadType, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, FadType >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const
Nondimensionalized sub-grid scale (SGS) stress tensor, (tau^sgs)* (Automatic Differentiation Type: Fa...
double get_model_constant_times_filter_width_squared(const dealii::types::global_dof_index cell_index) const override
real get_corrected_eddy_viscosity_low_reynolds_number(const real uncorrected_eddy_viscosity) const
Corrected eddy viscosity for low Reynolds number flows.
Manufactured solution used for grid studies to check convergence orders.
const double ratio_of_filter_width_to_cell_size
Ratio of filter width to cell size.
real2 get_corrected_eddy_viscosity_low_reynolds_number_templated(const real2 uncorrected_eddy_viscosity) const
dealii::Tensor< 2, dim, real2 > compute_SGS_stress_tensor_templated(const std::array< real2, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, real2 >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const
Templated nondimensionalized sub-grid scale (SGS) stress tensor, (tau^sgs)*.
virtual double get_model_constant_times_filter_width(const dealii::types::global_dof_index cell_index) const
Returns the product of the eddy viscosity model constant and the filter width.
real2 get_tensor_magnitude(const dealii::Tensor< 2, dim, real2 > &tensor) const
Returns the magnitude of the tensor.
Files for the baseline physics.
Definition: ADTypes.hpp:10
std::array< dealii::Tensor< 1, dim, real >, nstate > get_manufactured_solution_gradient(const dealii::Point< dim, real > &pos) const
Get manufactured solution value (repeated from Euler)
LargeEddySimulation_Smagorinsky(const Parameters::AllParameters *const parameters_input, const double ref_length, const double gamma_gas, const double mach_inf, const double angle_of_attack, const double side_slip_angle, const double prandtl_number, const double reynolds_number_inf, const bool use_constant_viscosity, const double constant_viscosity, const double temperature_inf, const double turbulent_prandtl_number, const double ratio_of_filter_width_to_cell_size, const double model_constant, const double isothermal_wall_temperature=1.0, const thermal_boundary_condition_enum thermal_boundary_condition_type=thermal_boundary_condition_enum::adiabatic, std::shared_ptr< ManufacturedSolutionFunction< dim, nspecies, real > > manufactured_solution_function=nullptr, const two_point_num_flux_enum two_point_num_flux_type=two_point_num_flux_enum::KG, const bool apply_low_reynolds_number_eddy_viscosity_correction=false)
LargeEddySimulation_Vreman(const Parameters::AllParameters *const parameters_input, const double ref_length, const double gamma_gas, const double mach_inf, const double angle_of_attack, const double side_slip_angle, const double prandtl_number, const double reynolds_number_inf, const bool use_constant_viscosity, const double constant_viscosity, const double temperature_inf, const double turbulent_prandtl_number, const double ratio_of_filter_width_to_cell_size, const double model_constant, const double isothermal_wall_temperature=1.0, const thermal_boundary_condition_enum thermal_boundary_condition_type=thermal_boundary_condition_enum::adiabatic, std::shared_ptr< ManufacturedSolutionFunction< dim, nspecies, real > > manufactured_solution_function=nullptr, const two_point_num_flux_enum two_point_num_flux_type=two_point_num_flux_enum::KG, const bool apply_low_reynolds_number_eddy_viscosity_correction=false)
real get_scaled_fluid_kinematic_viscosity_from_unfiltered_solution() const
Scaled fluid kinematic viscosity from unfiltered solution.
dealii::Tensor< 1, dim, FadType > compute_SGS_heat_flux_fad(const std::array< FadType, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, FadType >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const
Nondimensionalized sub-grid scale (SGS) heat flux, (q^sgs)* (Automatic Differentiation Type: FadType)...
real compute_eddy_viscosity(const std::array< real, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, real >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const override
const double curve_fit_constant
Curve fit constant for computing the model constant times filter width expresion. ...
Physics model additional terms and equations to the baseline physics.
Definition: model.h:18
double bulk_velocity
Bulk velocity, needed for channel flow case.
Definition: model.h:122
dealii::Tensor< 2, nstate, real > dissipative_flux_directional_jacobian(const std::array< real, nstate > &conservative_soln, const std::array< dealii::Tensor< 1, dim, real >, nstate > &solution_gradient, const dealii::Tensor< 1, dim, real > &normal, const dealii::types::global_dof_index cell_index) const
Main parameter class that contains the various other sub-parameter classes.
LargeEddySimulation_DynamicSmagorinsky(const Parameters::AllParameters *const parameters_input, const double ref_length, const double gamma_gas, const double mach_inf, const double angle_of_attack, const double side_slip_angle, const double prandtl_number, const double reynolds_number_inf, const bool use_constant_viscosity, const double constant_viscosity, const double temperature_inf, const double turbulent_prandtl_number, const double ratio_of_filter_width_to_cell_size, const double model_constant, const double isothermal_wall_temperature=1.0, const thermal_boundary_condition_enum thermal_boundary_condition_type=thermal_boundary_condition_enum::adiabatic, std::shared_ptr< ManufacturedSolutionFunction< dim, nspecies, real > > manufactured_solution_function=nullptr, const two_point_num_flux_enum two_point_num_flux_type=two_point_num_flux_enum::KG, const bool apply_low_reynolds_number_eddy_viscosity_correction=false)
std::array< real, nstate > convective_eigenvalues(const std::array< real, nstate > &, const dealii::Tensor< 1, dim, real > &) const override
Convective eigenvalues of the additional models&#39; PDEs.
LargeEddySimulationBase(const Parameters::AllParameters *const parameters_input, const double ref_length, const double gamma_gas, const double mach_inf, const double angle_of_attack, const double side_slip_angle, const double prandtl_number, const double reynolds_number_inf, const bool use_constant_viscosity, const double constant_viscosity, const double temperature_inf, const double turbulent_prandtl_number, const double ratio_of_filter_width_to_cell_size, const double isothermal_wall_temperature=1.0, const thermal_boundary_condition_enum thermal_boundary_condition_type=thermal_boundary_condition_enum::adiabatic, std::shared_ptr< ManufacturedSolutionFunction< dim, nspecies, real > > manufactured_solution_function=nullptr, const two_point_num_flux_enum two_point_num_flux_type=two_point_num_flux_enum::KG)
Constructor.
LargeEddySimulation_AllAllVMS(const Parameters::AllParameters *const parameters_input, const double ref_length, const double gamma_gas, const double mach_inf, const double angle_of_attack, const double side_slip_angle, const double prandtl_number, const double reynolds_number_inf, const bool use_constant_viscosity, const double constant_viscosity, const double temperature_inf, const double turbulent_prandtl_number, const double ratio_of_filter_width_to_cell_size, const double model_constant, const unsigned int poly_degree, const unsigned int poly_degree_large_scales, const double mesh_size, const double isothermal_wall_temperature=1.0, const thermal_boundary_condition_enum thermal_boundary_condition_type=thermal_boundary_condition_enum::adiabatic, std::shared_ptr< ManufacturedSolutionFunction< dim, nspecies, real > > manufactured_solution_function=nullptr, const two_point_num_flux_enum two_point_num_flux_type=two_point_num_flux_enum::KG, const bool apply_low_reynolds_number_eddy_viscosity_correction=false)
TwoPointNumericalFlux
Two point numerical flux type for split form.
virtual dealii::Tensor< 1, dim, FadType > compute_SGS_heat_flux_fad(const std::array< FadType, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, FadType >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const =0
Nondimensionalized sub-grid scale (SGS) heat flux, (q^sgs)* (Automatic Differentiation Type: FadType)...
std::array< real, nstate > dissipative_flux_dot_normal(const std::array< real, nstate > &solution, const std::array< dealii::Tensor< 1, dim, real >, nstate > &solution_gradient, const std::array< real, nstate > &filtered_solution, const std::array< dealii::Tensor< 1, dim, real >, nstate > &filtered_solution_gradient, const bool on_boundary, const dealii::types::global_dof_index cell_index, const dealii::Tensor< 1, dim, real > &normal, const int boundary_type) const
Dissipative (i.e. viscous) flux: dot normal vector.
std::array< dealii::Tensor< 1, dim, real2 >, nstate > dissipative_flux_templated(const std::array< real2, nstate > &conservative_soln, const std::array< dealii::Tensor< 1, dim, real2 >, nstate > &solution_gradient, const dealii::types::global_dof_index cell_index) const
Templated dissipative (i.e. viscous) flux: .
std::unique_ptr< NavierStokes< dim, nspecies, nstate, real > > navier_stokes_physics
Pointer to Navier-Stokes physics object.
virtual dealii::Tensor< 2, dim, real > compute_SGS_stress_tensor(const std::array< real, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, real >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const =0
Nondimensionalized sub-grid scale (SGS) stress tensor, (tau^sgs)*.
Large Eddy Simulation equations. Derived from Navier-Stokes for modifying the stress tensor and heat ...
virtual double get_model_constant_times_filter_width_squared(const dealii::types::global_dof_index cell_index) const
Returns the product of the eddy viscosity model constant and the filter width squared.
real compute_eddy_viscosity(const std::array< real, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, real >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const override
void set_unfiltered_conservative_solution(const std::array< real, nstate > &unfiltered_conservative_solution_) override
Setter for the unfiltered conservative solution (also sets the scaled_fluid_kinematic_viscosity_from_...
real2 scale_eddy_viscosity_templated(const std::array< real2, nstate > &primitive_soln, const real2 eddy_viscosity) const
Templated scale nondimensionalized eddy viscosity for Smagorinsky model.
LargeEddySimulation_SmallSmallVMS(const Parameters::AllParameters *const parameters_input, const double ref_length, const double gamma_gas, const double mach_inf, const double angle_of_attack, const double side_slip_angle, const double prandtl_number, const double reynolds_number_inf, const bool use_constant_viscosity, const double constant_viscosity, const double temperature_inf, const double turbulent_prandtl_number, const double ratio_of_filter_width_to_cell_size, const double model_constant, const unsigned int poly_degree, const unsigned int poly_degree_large_scales, const double mesh_size, const double isothermal_wall_temperature=1.0, const thermal_boundary_condition_enum thermal_boundary_condition_type=thermal_boundary_condition_enum::adiabatic, std::shared_ptr< ManufacturedSolutionFunction< dim, nspecies, real > > manufactured_solution_function=nullptr, const two_point_num_flux_enum two_point_num_flux_type=two_point_num_flux_enum::KG, const bool apply_low_reynolds_number_eddy_viscosity_correction=false)
std::array< real, nstate > physical_source_term(const dealii::Point< dim, real > &pos, const std::array< real, nstate > &conservative_solution, const std::array< dealii::Tensor< 1, dim, real >, nstate > &solution_gradient, const dealii::types::global_dof_index cell_index) const override
Physical source term.
double time_step
Current time step.
Definition: model.h:126
double get_model_constant_times_filter_width(const dealii::types::global_dof_index cell_index) const override
virtual real compute_eddy_viscosity(const std::array< real, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, real >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const
Nondimensionalized eddy viscosity for the Smagorinsky model.
std::array< real, nstate > source_term(const dealii::Point< dim, real > &pos, const std::array< real, nstate > &solution, const real current_time, const dealii::types::global_dof_index cell_index) const
Source term for manufactured solution functions.
std::array< real, nstate > dissipative_source_term(const dealii::Point< dim, real > &pos, const dealii::types::global_dof_index cell_index) const
Dissipative flux contribution to the source term (repeated from NavierStokes)
dealii::LinearAlgebra::distributed::Vector< double > cellwise_mean_strain_rate_tensor_magnitude
Definition: model.h:129
const double turbulent_prandtl_number
Turbulent Prandtl number.
real compute_eddy_viscosity(const std::array< real, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, real >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const override
const bool apply_low_reynolds_number_eddy_viscosity_correction
Flag for applying the low Reynolds number eddy viscosity correction.
double scaled_fluid_kinematic_viscosity_from_unfiltered_solution
Scaled fluid kinematic viscosity based on the unfiltered solution.
const double poly_degree_large_scales
Polynomial degree of large scale partition of solution.
virtual dealii::Tensor< 2, dim, FadType > compute_SGS_stress_tensor_fad(const std::array< FadType, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, FadType >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const =0
Nondimensionalized sub-grid scale (SGS) stress tensor, (tau^sgs)* (Automatic Differentiation Type: Fa...
dealii::LinearAlgebra::distributed::Vector< double > dynamic_smagorinsky_model_constant_times_filter_width_sqr
Definition: model.h:132
virtual FadType compute_eddy_viscosity_fad(const std::array< FadType, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, FadType >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const
Nondimensionalized eddy viscosity for the Smagorinsky model (Automatic Differentiation Type: FadType)...
LargeEddySimulation_ShearImprovedSmagorinsky(const Parameters::AllParameters *const parameters_input, const double ref_length, const double gamma_gas, const double mach_inf, const double angle_of_attack, const double side_slip_angle, const double prandtl_number, const double reynolds_number_inf, const bool use_constant_viscosity, const double constant_viscosity, const double temperature_inf, const double turbulent_prandtl_number, const double ratio_of_filter_width_to_cell_size, const double model_constant, const double isothermal_wall_temperature=1.0, const thermal_boundary_condition_enum thermal_boundary_condition_type=thermal_boundary_condition_enum::adiabatic, std::shared_ptr< ManufacturedSolutionFunction< dim, nspecies, real > > manufactured_solution_function=nullptr, const two_point_num_flux_enum two_point_num_flux_type=two_point_num_flux_enum::KG, const bool apply_low_reynolds_number_eddy_viscosity_correction=false)
real2 compute_eddy_viscosity_templated(const std::array< real2, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, real2 >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const
std::array< real, nstate > get_manufactured_solution_value(const dealii::Point< dim, real > &pos) const
Get manufactured solution value (repeated from Euler)
FadType get_corrected_eddy_viscosity_low_reynolds_number_fad(const FadType uncorrected_eddy_viscosity) const
Corrected eddy viscosity for low Reynolds number flows (Automatic Differentiation Type: FadType) ...
dealii::Tensor< 1, dim, real2 > compute_SGS_heat_flux_templated(const std::array< real2, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, real2 >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const
Templated nondimensionalized sub-grid scale (SGS) heat flux, (q^sgs)*.
real max_convective_normal_eigenvalue(const std::array< real, nstate > &soln, const dealii::Tensor< 1, dim, real > &normal) const
Maximum convective normal eigenvalue (used in Lax-Friedrichs) of the additional models&#39; PDEs...
FadType compute_eddy_viscosity_fad(const std::array< FadType, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, FadType >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const override
std::array< dealii::Tensor< 1, dim, real >, nstate > dissipative_flux(const std::array< real, nstate > &conservative_soln, const std::array< dealii::Tensor< 1, dim, real >, nstate > &solution_gradient, const dealii::types::global_dof_index cell_index) const
Dissipative (i.e. viscous) flux: .
double get_filter_width(const dealii::types::global_dof_index cell_index) const
Compute the nondimensionalized filter width used by the SGS model given a cell index.
LargeEddySimulation_VMS(const Parameters::AllParameters *const parameters_input, const double ref_length, const double gamma_gas, const double mach_inf, const double angle_of_attack, const double side_slip_angle, const double prandtl_number, const double reynolds_number_inf, const bool use_constant_viscosity, const double constant_viscosity, const double temperature_inf, const double turbulent_prandtl_number, const double ratio_of_filter_width_to_cell_size, const double model_constant, const unsigned int poly_degree, const unsigned int poly_degree_large_scales, const double mesh_size, const double curve_fit_constant, const double isothermal_wall_temperature=1.0, const thermal_boundary_condition_enum thermal_boundary_condition_type=thermal_boundary_condition_enum::adiabatic, std::shared_ptr< ManufacturedSolutionFunction< dim, nspecies, real > > manufactured_solution_function=nullptr, const two_point_num_flux_enum two_point_num_flux_type=two_point_num_flux_enum::KG, const bool apply_low_reynolds_number_eddy_viscosity_correction=false)
dealii::LinearAlgebra::distributed::Vector< int > cellwise_poly_degree
Cellwise polynomial degree.
Definition: model.h:118
const double poly_degree
Polynomial degree of solution.
ThermalBoundaryCondition
Types of thermal boundary conditions available.
FadType compute_eddy_viscosity_fad(const std::array< FadType, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, FadType >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const override
std::array< dealii::Tensor< 1, dim, real >, nstate > convective_flux(const std::array< real, nstate > &conservative_soln) const
Convective flux: .
std::array< real, nstate > channel_flow_source_term(const std::array< real, nstate > &conservative_soln) const
Channel flow source term.
real2 compute_eddy_viscosity_templated(const std::array< real2, nstate > &primitive_soln, const std::array< dealii::Tensor< 1, dim, real2 >, nstate > &primitive_soln_gradient, const dealii::types::global_dof_index cell_index) const
real2 get_tensor_magnitude_sqr(const dealii::Tensor< 2, dim, real2 > &tensor) const
Returns the square of the magnitude of the tensor (i.e. the double dot product of a tensor with itsel...
Navier-Stokes equations. Derived from Euler for the convective terms, which is derived from PhysicsBa...
Definition: navier_stokes.h:12
double bulk_density
Bulk density, needed for channel flow case.
Definition: model.h:120
std::array< real, nstate > unfiltered_conservative_solution
The unfiltered conservative solution.
Definition: model.h:185
std::shared_ptr< ManufacturedSolutionFunction< dim, nspecies, real > > manufactured_solution_function
Manufactured solution function.
Definition: model.h:29
dealii::Tensor< 2, nstate, real > dissipative_flux_directional_jacobian_wrt_gradient_component(const std::array< real, nstate > &conservative_soln, const std::array< dealii::Tensor< 1, dim, real >, nstate > &solution_gradient, const dealii::Tensor< 1, dim, real > &normal, const int d_gradient, const dealii::types::global_dof_index cell_index) const