[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
navier_stokes_model.cpp
1 #include <cmath>
2 #include <vector>
3 
4 #include "ADTypes.hpp"
5 
6 #include "model.h"
7 #include "navier_stokes_model.h"
8 
9 namespace PHiLiP {
10 namespace Physics {
11 
12 //================================================================
13 // Navier Stokes with Model Source Terms Class
14 //================================================================
15 template <int dim, int nspecies, int nstate, typename real>
17  const Parameters::AllParameters *const parameters_input,
18  const double ref_length,
19  const double gamma_gas,
20  const double mach_inf,
21  const double angle_of_attack,
22  const double side_slip_angle,
23  const double prandtl_number,
24  const double reynolds_number_inf,
25  const bool use_constant_viscosity,
26  const double constant_viscosity,
27  const double temperature_inf,
28  const double relaxation_coefficient,
29  const double isothermal_wall_temperature,
30  const thermal_boundary_condition_enum thermal_boundary_condition_type,
31  std::shared_ptr< ManufacturedSolutionFunction<dim,nspecies,real> > manufactured_solution_function,
32  const two_point_num_flux_enum two_point_num_flux_type)
33  : ModelBase<dim,nspecies,nstate,real>(manufactured_solution_function)
34  , relaxation_coefficient(relaxation_coefficient)
35  , navier_stokes_physics(std::make_unique < NavierStokes<dim,nspecies,nstate,real> > (
36  parameters_input,
37  ref_length,
38  gamma_gas,
39  mach_inf,
40  angle_of_attack,
41  side_slip_angle,
42  prandtl_number,
43  reynolds_number_inf,
44  use_constant_viscosity,
45  constant_viscosity,
46  temperature_inf,
47  isothermal_wall_temperature,
48  thermal_boundary_condition_type,
49  manufactured_solution_function,
50  two_point_num_flux_type))
51 {
52  static_assert(nstate==dim+2, "ModelBase::NavierStokesWithModelSourceTerms() should be created with nstate=dim+2");
53  // initialize zero arrays / tensors
54  for (int s=0; s<nstate; ++s) {
55  zero_array[s] = 0.0;
56  for (int d=0; d<dim; ++d) {
57  zero_tensor_array[s][d] = 0.0;
58  }
59  }
60 }
61 //----------------------------------------------------------------
62 template <int dim, int nspecies, int nstate, typename real>
63 std::array<dealii::Tensor<1,dim,real>,nstate> NavierStokesWithModelSourceTerms<dim,nspecies,nstate,real>
65  const std::array<real,nstate> &/*conservative_soln*/) const
66 {
67  return this->zero_tensor_array;
68 }
69 //----------------------------------------------------------------
70 template <int dim, int nspecies, int nstate, typename real>
71 std::array<dealii::Tensor<1,dim,real>,nstate> NavierStokesWithModelSourceTerms<dim,nspecies,nstate,real>
73  const std::array<real,nstate> &/*conservative_soln*/,
74  const std::array<dealii::Tensor<1,dim,real>,nstate> &/*solution_gradient*/,
75  const dealii::types::global_dof_index /*cell_index*/) const
76 {
77  return this->zero_tensor_array;
78 }
79 //----------------------------------------------------------------
80 template <int dim, int nspecies, int nstate, typename real>
83  const std::array<real,nstate> &/*solution*/,
84  const std::array<dealii::Tensor<1,dim,real>,nstate> &/*solution_gradient*/,
85  const std::array<real,nstate> &/*filtered_solution*/,
86  const std::array<dealii::Tensor<1,dim,real>,nstate> &/*filtered_solution_gradient*/,
87  const bool /*on_boundary*/,
88  const dealii::types::global_dof_index /*cell_index*/,
89  const dealii::Tensor<1,dim,real> &/*normal*/,
90  const int /*boundary_type*/) const
91 {
92  std::array<real,nstate> dissipative_flux_dot_normal;
93  dissipative_flux_dot_normal.fill(0.0); // initialize
94 
96 }
97 //----------------------------------------------------------------
98 template <int dim, int nspecies, int nstate, typename real>
101  const std::array<real,nstate> &/*conservative_soln*/,
102  const dealii::Tensor<1,dim,real> &/*normal*/) const
103 {
104  return this->zero_array;
105 }
106 //----------------------------------------------------------------
107 template <int dim, int nspecies, int nstate, typename real>
109 ::max_convective_eigenvalue (const std::array<real,nstate> &/*conservative_soln*/) const
110 {
111  const real max_eig = 0.0;
112  return max_eig;
113 }
114 //----------------------------------------------------------------
115 template <int dim, int nspecies, int nstate, typename real>
118  const std::array<real,nstate> &/*conservative_soln*/,
119  const dealii::Tensor<1,dim,real> &/*normal*/) const
120 {
121  const real max_eig = 0.0;
122  return max_eig;
123 }
124 //----------------------------------------------------------------
125 template <int dim, int nspecies, int nstate, typename real>
128  const dealii::Point<dim,real> &/*pos*/,
129  const std::array<real,nstate> &/*solution*/,
130  const real /*current_time*/,
131  const dealii::types::global_dof_index /*cell_index*/) const
132 {
133  return this->zero_array;
134 }
135 //----------------------------------------------------------------
136 template <int dim, int nspecies, int nstate, typename real>
139  const dealii::Point<dim,real> &/*pos*/,
140  const std::array<real,nstate> &conservative_soln,
141  const std::array<dealii::Tensor<1,dim,real>,nstate> &/*solution_gradient*/,
142  const dealii::types::global_dof_index /*cell_index*/) const
143 {
144  std::array<real,nstate> physical_source;
145  physical_source = this->channel_flow_source_term(conservative_soln);
146 
147  return physical_source;
148 }
149 //----------------------------------------------------------------
150 template <int dim, int nspecies, int nstate, typename real>
153  const std::array<real,nstate> &/*conservative_soln*/) const
154 {
155  std::array<real,nstate> source_term;
156  std::fill(source_term.begin(), source_term.end(), 0.0);
157 
161  if(!this->navier_stokes_physics->use_constant_viscosity){
162  // TO DO: use pcout and move this to the constructor
163  std::cout << "ERROR: Cannot run the turbulent channel flow with a non-constant viscosity. Aborting..." << std::endl;
164  std::abort();
165  }
166  // x-momentum term
167  const real bulk_reynolds_number = this->navier_stokes_physics->reynolds_number_inf;
168  const real viscosity_coefficient = this->navier_stokes_physics->constant_viscosity;
169  const real scaled_viscosity_coefficient = this->navier_stokes_physics->scale_viscosity_coefficient(viscosity_coefficient);
170  const real expected_mass_flow_rate = scaled_viscosity_coefficient * bulk_reynolds_number / this->half_channel_height;
171  source_term[1] = this->resultant_wall_shear_force/this->domain_volume - this->relaxation_coefficient*(this->bulk_mass_flow_rate - expected_mass_flow_rate)/this->time_step;
172 
173  // energy term
174  source_term[nstate-1] = this->bulk_velocity*source_term[1];
175 
176  return source_term;
177 }
178 //----------------------------------------------------------------
179 //----------------------------------------------------------------
180 //----------------------------------------------------------------
181 // Instantiate explicitly
182 // -- NavierStokesWithModelSourceTerms
188 
189 } // Physics namespace
190 } // PHiLiP namespace
Manufactured solution used for grid studies to check convergence orders.
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.
double domain_volume
Domain volume, needed for channel flow case.
Definition: model.h:123
Files for the baseline physics.
Definition: ADTypes.hpp:10
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 > 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.
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
double half_channel_height
Half channel height, needed for channel flow case.
Definition: model.h:124
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.
Main parameter class that contains the various other sub-parameter classes.
std::array< real, nstate > channel_flow_source_term(const std::array< real, nstate > &conservative_soln) const
Channel flow source term.
double resultant_wall_shear_force
Resultant wall shear force, needed for channel flow case.
Definition: model.h:125
TwoPointNumericalFlux
Two point numerical flux type for split form.
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 time_step
Current time step.
Definition: model.h:126
std::unique_ptr< NavierStokes< dim, nspecies, nstate, real > > navier_stokes_physics
Pointer to Navier-Stokes physics object.
std::array< dealii::Tensor< 1, dim, real >, nstate > zero_tensor_array
Tensor array of zeros.
const double relaxation_coefficient
Relaxation coefficient for the channel flow source term.
Navier Stokes equations with model source term.
std::array< real, nstate > zero_array
Array of zeros.
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...
ThermalBoundaryCondition
Types of thermal boundary conditions available.
std::array< dealii::Tensor< 1, dim, real >, nstate > convective_flux(const std::array< real, nstate > &conservative_soln) const
Convective flux: .
double bulk_mass_flow_rate
Bulk mass flow rate, needed for channel flow case.
Definition: model.h:121
Navier-Stokes equations. Derived from Euler for the convective terms, which is derived from PhysicsBa...
Definition: navier_stokes.h:12
NavierStokesWithModelSourceTerms(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 relaxation_coefficient, 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.
real max_convective_eigenvalue(const std::array< real, nstate > &soln) const
Maximum convective eigenvalue of the additional models&#39; PDEs.