Skip to content

Commit

Permalink
PeriodicTurbulence Adaptive Time Step MPI Bug Fix (dougshidong#3)
Browse files Browse the repository at this point in the history
* flipping sign on viscous flux

* reverting sign flip on viscous flux

* renaming mean_specific_energy and trying equivalent pressure gradient method

* unused var fix

* removing misleading compute_dimensional_temperature

* const member initialization for sutherlands law temperatures

* bug fix for adaptive time step; using MPI max

* making temperature_inf an input parameter that must be consistent with the Prandtl number

* removing commented code in header

* doxygen fix
  • Loading branch information
jbrillon committed Nov 8, 2022
1 parent e1bfbf8 commit 2b9021e
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 48 deletions.
1 change: 1 addition & 0 deletions src/flow_solver/flow_solver_cases/periodic_turbulence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ void PeriodicTurbulence<dim, nstate>::compute_and_update_integrated_quantities(D
}
}
}
this->maximum_local_wave_speed = dealii::Utilities::MPI::max(this->maximum_local_wave_speed, this->mpi_communicator);

// update integrated quantities
for(int i_quantity=0; i_quantity<NUMBER_OF_INTEGRATED_QUANTITIES; ++i_quantity) {
Expand Down
8 changes: 7 additions & 1 deletion src/parameters/parameters_navier_stokes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ void NavierStokesParam::declare_parameters (dealii::ParameterHandler &prm)
{
prm.declare_entry("prandtl_number", "0.72",
dealii::Patterns::Double(1e-15, dealii::Patterns::Double::max_double_value),
"Prandlt number");
"Prandlt number. Default value is 0.72. "
"NOTE: Must be consitent with temperature_inf.");
prm.declare_entry("reynolds_number_inf", "10000000.0",
dealii::Patterns::Double(1e-15, dealii::Patterns::Double::max_double_value),
"Farfield Reynolds number");
prm.declare_entry("temperature_inf", "273.15",
dealii::Patterns::Double(1e-15, dealii::Patterns::Double::max_double_value),
"Farfield temperature in degree Kelvin [K]. Default value is 273.15K. "
"NOTE: Must be consistent with specified Prandtl number.");
prm.declare_entry("nondimensionalized_isothermal_wall_temperature", "1.0",
dealii::Patterns::Double(1e-15, dealii::Patterns::Double::max_double_value),
"Nondimensionalized isothermal wall temperature.");
Expand All @@ -33,6 +38,7 @@ void NavierStokesParam::parse_parameters (dealii::ParameterHandler &prm)
{
prandtl_number = prm.get_double("prandtl_number");
reynolds_number_inf = prm.get_double("reynolds_number_inf");
temperature_inf = prm.get_double("temperature_inf");
nondimensionalized_isothermal_wall_temperature = prm.get_double("nondimensionalized_isothermal_wall_temperature");

const std::string thermal_boundary_condition_type_string = prm.get("thermal_boundary_condition_type");
Expand Down
1 change: 1 addition & 0 deletions src/parameters/parameters_navier_stokes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class NavierStokesParam

double prandtl_number; ///< Prandtl number
double reynolds_number_inf; ///< Farfield Reynolds number
double temperature_inf; ///< Farfield temperature in degree Kelvin [K]
double nondimensionalized_isothermal_wall_temperature; ///< Nondimensionalized isothermal wall temperature

/// Types of thermal boundary conditions available.
Expand Down
35 changes: 7 additions & 28 deletions src/physics/euler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,37 +320,27 @@ ::compute_specific_enthalpy ( const std::array<real,nstate> &conservative_soln,
template <int dim, int nstate, typename real>
template<typename real2>
inline real2 Euler<dim,nstate,real>
::compute_dimensional_temperature ( const std::array<real2,nstate> &primitive_soln ) const
::compute_temperature ( const std::array<real2,nstate> &primitive_soln ) const
{
const real2 density = primitive_soln[0];
const real2 pressure = primitive_soln[nstate-1];
const real2 temperature = gam*pressure/density;
return temperature;
}

template <int dim, int nstate, typename real>
template<typename real2>
inline real2 Euler<dim,nstate,real>
::compute_temperature ( const std::array<real2,nstate> &primitive_soln ) const
{
const real2 dimensional_temperature = compute_dimensional_temperature<real2>(primitive_soln);
const real2 temperature = dimensional_temperature * mach_inf_sqr;
const real2 temperature = gam*mach_inf_sqr*(pressure/density);
return temperature;
}

template <int dim, int nstate, typename real>
inline real Euler<dim,nstate,real>
::compute_density_from_pressure_temperature ( const real pressure, const real temperature ) const
{
const real density = gam*pressure/temperature * mach_inf_sqr;
const real density = gam*mach_inf_sqr*(pressure/temperature);
return density;
}

template <int dim, int nstate, typename real>
inline real Euler<dim,nstate,real>
::compute_temperature_from_density_pressure ( const real density, const real pressure ) const
{
const real temperature = gam*pressure/density * mach_inf_sqr;
const real temperature = gam*mach_inf_sqr*(pressure/density);
return temperature;
}

Expand Down Expand Up @@ -446,7 +436,7 @@ ::convective_numerical_split_flux_kennedy_gruber(const std::array<real,nstate> &
const real mean_density = compute_mean_density(conservative_soln1, conservative_soln2);
const real mean_pressure = compute_mean_pressure(conservative_soln1, conservative_soln2);
const dealii::Tensor<1,dim,real> mean_velocities = compute_mean_velocities(conservative_soln1,conservative_soln2);
const real mean_specific_energy = compute_mean_specific_energy(conservative_soln1, conservative_soln2);
const real mean_specific_total_energy = compute_mean_specific_total_energy(conservative_soln1, conservative_soln2);

for (int flux_dim = 0; flux_dim < dim; ++flux_dim)
{
Expand All @@ -458,7 +448,7 @@ ::convective_numerical_split_flux_kennedy_gruber(const std::array<real,nstate> &
}
conv_num_split_flux[1+flux_dim][flux_dim] += mean_pressure; // Add diagonal of pressure
// Energy equation
conv_num_split_flux[nstate-1][flux_dim] = mean_density*mean_velocities[flux_dim]*mean_specific_energy + mean_pressure * mean_velocities[flux_dim];
conv_num_split_flux[nstate-1][flux_dim] = mean_density*mean_velocities[flux_dim]*mean_specific_total_energy + mean_pressure * mean_velocities[flux_dim];
}

return conv_num_split_flux;
Expand Down Expand Up @@ -603,7 +593,7 @@ compute_mean_velocities(const std::array<real,nstate> &conservative_soln1,

template <int dim, int nstate, typename real>
inline real Euler<dim,nstate,real>::
compute_mean_specific_energy(const std::array<real,nstate> &conservative_soln1,
compute_mean_specific_total_energy(const std::array<real,nstate> &conservative_soln1,
const std::array<real,nstate> &conservative_soln2) const
{
return ((conservative_soln1[nstate-1]/conservative_soln1[0]) + (conservative_soln2[nstate-1]/conservative_soln2[0]))/2.;
Expand Down Expand Up @@ -1316,17 +1306,6 @@ template FadType Euler < PHILIP_DIM, PHILIP_DIM+2, double >::compute_pres
template FadType Euler < PHILIP_DIM, PHILIP_DIM+2, RadType >::compute_pressure< FadType >(const std::array<FadType, PHILIP_DIM+2> &conservative_soln) const;
template FadType Euler < PHILIP_DIM, PHILIP_DIM+2, FadFadType >::compute_pressure< FadType >(const std::array<FadType, PHILIP_DIM+2> &conservative_soln) const;
template FadType Euler < PHILIP_DIM, PHILIP_DIM+2, RadFadType >::compute_pressure< FadType >(const std::array<FadType, PHILIP_DIM+2> &conservative_soln) const;
// -- compute_dimensional_temperature()
template double Euler < PHILIP_DIM, PHILIP_DIM+2, double >::compute_dimensional_temperature< double >(const std::array<double, PHILIP_DIM+2> &primitive_soln) const;
template FadType Euler < PHILIP_DIM, PHILIP_DIM+2, FadType >::compute_dimensional_temperature< FadType >(const std::array<FadType, PHILIP_DIM+2> &primitive_soln) const;
template RadType Euler < PHILIP_DIM, PHILIP_DIM+2, RadType >::compute_dimensional_temperature< RadType >(const std::array<RadType, PHILIP_DIM+2> &primitive_soln) const;
template FadFadType Euler < PHILIP_DIM, PHILIP_DIM+2, FadFadType >::compute_dimensional_temperature< FadFadType >(const std::array<FadFadType,PHILIP_DIM+2> &primitive_soln) const;
template RadFadType Euler < PHILIP_DIM, PHILIP_DIM+2, RadFadType >::compute_dimensional_temperature< RadFadType >(const std::array<RadFadType,PHILIP_DIM+2> &primitive_soln) const;
// -- -- instantiate all the real types with real2 = FadType for automatic differentiation in NavierStokes::dissipative_flux_directional_jacobian()
template FadType Euler < PHILIP_DIM, PHILIP_DIM+2, double >::compute_dimensional_temperature< FadType >(const std::array<FadType, PHILIP_DIM+2> &primitive_soln) const;
template FadType Euler < PHILIP_DIM, PHILIP_DIM+2, RadType >::compute_dimensional_temperature< FadType >(const std::array<FadType, PHILIP_DIM+2> &primitive_soln) const;
template FadType Euler < PHILIP_DIM, PHILIP_DIM+2, FadFadType >::compute_dimensional_temperature< FadType >(const std::array<FadType, PHILIP_DIM+2> &primitive_soln) const;
template FadType Euler < PHILIP_DIM, PHILIP_DIM+2, RadFadType >::compute_dimensional_temperature< FadType >(const std::array<FadType, PHILIP_DIM+2> &primitive_soln) const;
// -- compute_temperature()
template double Euler < PHILIP_DIM, PHILIP_DIM+2, double >::compute_temperature< double >(const std::array<double, PHILIP_DIM+2> &primitive_soln) const;
template FadType Euler < PHILIP_DIM, PHILIP_DIM+2, FadType >::compute_temperature< FadType >(const std::array<FadType, PHILIP_DIM+2> &primitive_soln) const;
Expand Down
8 changes: 2 additions & 6 deletions src/physics/euler.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,6 @@ class Euler : public PhysicsBase <dim, nstate, real>
/// Given conservative variables, returns Mach number
real compute_mach_number ( const std::array<real,nstate> &conservative_soln ) const;

/// Given primitive variables, returns DIMENSIONALIZED temperature using the equation of state
template<typename real2>
real2 compute_dimensional_temperature ( const std::array<real2,nstate> &primitive_soln ) const;

/// Given primitive variables, returns NON-DIMENSIONALIZED temperature using free-stream non-dimensionalization
/** See the book I do like CFD, sec 4.14.2 */
template<typename real2>
Expand Down Expand Up @@ -316,10 +312,10 @@ class Euler : public PhysicsBase <dim, nstate, real>
const std::array<real,nstate> &conservative_soln1,
const std::array<real,nstate> &convervative_soln2) const;

/// Mean specific energy given two sets of conservative solutions.
/// Mean specific total energy given two sets of conservative solutions.
/** Used in the implementation of the split form.
*/
real compute_mean_specific_energy(
real compute_mean_specific_total_energy(
const std::array<real,nstate> &conservative_soln1,
const std::array<real,nstate> &convervative_soln2) const;

Expand Down
8 changes: 8 additions & 0 deletions src/physics/large_eddy_simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ LargeEddySimulationBase<dim, nstate, real>::LargeEddySimulationBase(
const double side_slip_angle,
const double prandtl_number,
const double reynolds_number_inf,
const double temperature_inf,
const double turbulent_prandtl_number,
const double ratio_of_filter_width_to_cell_size,
const double isothermal_wall_temperature,
Expand All @@ -39,6 +40,7 @@ LargeEddySimulationBase<dim, nstate, real>::LargeEddySimulationBase(
side_slip_angle,
prandtl_number,
reynolds_number_inf,
temperature_inf,
isothermal_wall_temperature,
thermal_boundary_condition_type,
manufactured_solution_function,
Expand Down Expand Up @@ -381,6 +383,7 @@ LargeEddySimulation_Smagorinsky<dim, nstate, real>::LargeEddySimulation_Smagorin
const double side_slip_angle,
const double prandtl_number,
const double reynolds_number_inf,
const double temperature_inf,
const double turbulent_prandtl_number,
const double ratio_of_filter_width_to_cell_size,
const double model_constant,
Expand All @@ -395,6 +398,7 @@ LargeEddySimulation_Smagorinsky<dim, nstate, real>::LargeEddySimulation_Smagorin
side_slip_angle,
prandtl_number,
reynolds_number_inf,
temperature_inf,
turbulent_prandtl_number,
ratio_of_filter_width_to_cell_size,
isothermal_wall_temperature,
Expand Down Expand Up @@ -601,6 +605,7 @@ LargeEddySimulation_WALE<dim, nstate, real>::LargeEddySimulation_WALE(
const double side_slip_angle,
const double prandtl_number,
const double reynolds_number_inf,
const double temperature_inf,
const double turbulent_prandtl_number,
const double ratio_of_filter_width_to_cell_size,
const double model_constant,
Expand All @@ -615,6 +620,7 @@ LargeEddySimulation_WALE<dim, nstate, real>::LargeEddySimulation_WALE(
side_slip_angle,
prandtl_number,
reynolds_number_inf,
temperature_inf,
turbulent_prandtl_number,
ratio_of_filter_width_to_cell_size,
model_constant,
Expand Down Expand Up @@ -722,6 +728,7 @@ LargeEddySimulation_Vreman<dim, nstate, real>::LargeEddySimulation_Vreman(
const double side_slip_angle,
const double prandtl_number,
const double reynolds_number_inf,
const double temperature_inf,
const double turbulent_prandtl_number,
const double ratio_of_filter_width_to_cell_size,
const double model_constant,
Expand All @@ -736,6 +743,7 @@ LargeEddySimulation_Vreman<dim, nstate, real>::LargeEddySimulation_Vreman(
side_slip_angle,
prandtl_number,
reynolds_number_inf,
temperature_inf,
turbulent_prandtl_number,
ratio_of_filter_width_to_cell_size,
model_constant,
Expand Down
4 changes: 4 additions & 0 deletions src/physics/large_eddy_simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class LargeEddySimulationBase : public ModelBase <dim, nstate, real>
const double side_slip_angle,
const double prandtl_number,
const double reynolds_number_inf,
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,
Expand Down Expand Up @@ -152,6 +153,7 @@ class LargeEddySimulation_Smagorinsky : public LargeEddySimulationBase <dim, nst
const double side_slip_angle,
const double prandtl_number,
const double reynolds_number_inf,
const double temperature_inf,
const double turbulent_prandtl_number,
const double ratio_of_filter_width_to_cell_size,
const double model_constant,
Expand Down Expand Up @@ -251,6 +253,7 @@ class LargeEddySimulation_WALE : public LargeEddySimulation_Smagorinsky <dim, ns
const double side_slip_angle,
const double prandtl_number,
const double reynolds_number_inf,
const double temperature_inf,
const double turbulent_prandtl_number,
const double ratio_of_filter_width_to_cell_size,
const double model_constant,
Expand Down Expand Up @@ -306,6 +309,7 @@ class LargeEddySimulation_Vreman : public LargeEddySimulation_Smagorinsky <dim,
const double side_slip_angle,
const double prandtl_number,
const double reynolds_number_inf,
const double temperature_inf,
const double turbulent_prandtl_number,
const double ratio_of_filter_width_to_cell_size,
const double model_constant,
Expand Down
3 changes: 3 additions & 0 deletions src/physics/model_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ ::create_Model(const Parameters::AllParameters *const parameters_input)
parameters_input->euler_param.side_slip_angle,
parameters_input->navier_stokes_param.prandtl_number,
parameters_input->navier_stokes_param.reynolds_number_inf,
parameters_input->navier_stokes_param.temperature_inf,
parameters_input->physics_model_param.turbulent_prandtl_number,
parameters_input->physics_model_param.ratio_of_filter_width_to_cell_size,
parameters_input->physics_model_param.smagorinsky_model_constant,
Expand All @@ -70,6 +71,7 @@ ::create_Model(const Parameters::AllParameters *const parameters_input)
parameters_input->euler_param.side_slip_angle,
parameters_input->navier_stokes_param.prandtl_number,
parameters_input->navier_stokes_param.reynolds_number_inf,
parameters_input->navier_stokes_param.temperature_inf,
parameters_input->physics_model_param.turbulent_prandtl_number,
parameters_input->physics_model_param.ratio_of_filter_width_to_cell_size,
parameters_input->physics_model_param.WALE_model_constant,
Expand All @@ -89,6 +91,7 @@ ::create_Model(const Parameters::AllParameters *const parameters_input)
parameters_input->euler_param.side_slip_angle,
parameters_input->navier_stokes_param.prandtl_number,
parameters_input->navier_stokes_param.reynolds_number_inf,
parameters_input->navier_stokes_param.temperature_inf,
parameters_input->physics_model_param.turbulent_prandtl_number,
parameters_input->physics_model_param.ratio_of_filter_width_to_cell_size,
parameters_input->physics_model_param.vreman_model_constant,
Expand Down
Loading

0 comments on commit 2b9021e

Please sign in to comment.