[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
numerical_flux_factory.cpp
1 #include "numerical_flux_factory.hpp"
2 
3 #include "convective_numerical_flux.hpp"
4 #include "ADTypes.hpp"
5 #include "physics/physics_model.h"
6 
7 namespace PHiLiP {
8 namespace NumericalFlux {
9 
10 using AllParam = Parameters::AllParameters;
11 
12 template <int dim, int nstate, typename real>
13 std::unique_ptr< NumericalFluxConvective<dim,nstate,real> >
16  const AllParam::ConvectiveNumericalFlux conv_num_flux_type,
18  const AllParam::ModelType model_type,
19  std::shared_ptr<Physics::PhysicsBase<dim, nstate, real>> physics_input)
20 {
21  // checks if conv_num_flux_type exists only for Euler equations
22  const bool is_euler_based = ((conv_num_flux_type == AllParam::ConvectiveNumericalFlux::roe) ||
23  (conv_num_flux_type == AllParam::ConvectiveNumericalFlux::l2roe) ||
24  (conv_num_flux_type == AllParam::ConvectiveNumericalFlux::two_point_flux_with_roe_dissipation) ||
25  (conv_num_flux_type == AllParam::ConvectiveNumericalFlux::two_point_flux_with_l2roe_dissipation));
26  // checks if weak dg is being run with two point flux
27  const bool is_two_point_conv = ((conv_num_flux_type == AllParam::ConvectiveNumericalFlux::two_point_flux) ||
28  (conv_num_flux_type == AllParam::ConvectiveNumericalFlux::two_point_flux_with_lax_friedrichs_dissipation) ||
29  (conv_num_flux_type == AllParam::ConvectiveNumericalFlux::two_point_flux_with_roe_dissipation) ||
30  (conv_num_flux_type == AllParam::ConvectiveNumericalFlux::two_point_flux_with_l2roe_dissipation));
31  if(is_two_point_conv && physics_input->all_parameters->use_split_form == false ) {
32  std::cout << "two point flux and not using split form are not compatible, please use another Convective Numerical Flux" << std::endl;
33  std::abort();
34  }
35 
36  if (conv_num_flux_type == AllParam::ConvectiveNumericalFlux::central_flux) {
37  if constexpr (nstate<=5) {
38  return std::make_unique< Central<dim, nstate, real> > (physics_input);
39  }
40  }
41  else if(conv_num_flux_type == AllParam::ConvectiveNumericalFlux::lax_friedrichs) {
42  return std::make_unique< LaxFriedrichs<dim, nstate, real> > (physics_input);
43  }
44  else if(is_euler_based) {
45  if constexpr (dim+2==nstate) {
46  return create_euler_based_convective_numerical_flux(conv_num_flux_type, pde_type, model_type, physics_input);
47  }
48  }
49  else if (conv_num_flux_type == AllParam::ConvectiveNumericalFlux::two_point_flux) {
50  if constexpr (nstate<=5) {
51  return std::make_unique< EntropyConserving<dim, nstate, real> > (physics_input);
52  }
53  }
54  else if (conv_num_flux_type == AllParam::ConvectiveNumericalFlux::two_point_flux_with_lax_friedrichs_dissipation) {
55  if constexpr (nstate<=5) {
56  return std::make_unique< EntropyConservingWithLaxFriedrichsDissipation<dim, nstate, real> > (physics_input);
57  }
58  }
59  else {
60  (void) pde_type;
61  (void) model_type;
62  }
63 
64  std::cout << "Invalid convective numerical flux and/or invalid added Riemann solver dissipation type." << std::endl;
65  return nullptr;
66 }
67 
68 template <int dim, int nstate, typename real>
69 std::unique_ptr< NumericalFluxConvective<dim,nstate,real> >
72  const AllParam::ConvectiveNumericalFlux conv_num_flux_type,
74  const AllParam::ModelType model_type,
75  std::shared_ptr<Physics::PhysicsBase<dim, nstate, real>> physics_input)
76 {
78  using Model_enum = Parameters::AllParameters::ModelType;
79  std::shared_ptr<Physics::PhysicsBase<dim, nstate, real>> euler_based_physics_to_be_passed = physics_input;
80 
81  if(pde_type!=PDE_enum::euler &&
82  pde_type!=PDE_enum::navier_stokes &&
83  !(pde_type==PDE_enum::physics_model && model_type==Model_enum::large_eddy_simulation))
84  {
85  std::cout << "Invalid convective numerical flux for pde_type. Aborting..." << std::endl;
86  std::abort();
87  }
88 
89 #if PHILIP_DIM==3
90  if((pde_type==PDE_enum::physics_model &&
91  model_type==Model_enum::large_eddy_simulation))
92  {
93  if constexpr (dim+2==nstate) {
94  std::shared_ptr<Physics::PhysicsModel<dim,dim+2,real,dim+2>> physics_model = std::dynamic_pointer_cast<Physics::PhysicsModel<dim,dim+2,real,dim+2>>(physics_input);
95  std::shared_ptr<Physics::Euler<dim,dim+2,real>> physics_baseline = std::dynamic_pointer_cast<Physics::Euler<dim,dim+2,real>>(physics_model->physics_baseline);
96  euler_based_physics_to_be_passed = physics_baseline;
97  }
98  }
99  else if((pde_type==PDE_enum::physics_model &&
100  model_type!=Model_enum::large_eddy_simulation))
101  {
102  std::cout << "Invalid convective numerical flux for physics_model and/or corresponding baseline_physics_type" << std::endl;
103  if(nstate!=(dim+2)) std::cout << "Error: Cannot create_euler_based_convective_numerical_flux() for nstate_baseline_physics != nstate." << std::endl;
104  std::abort();
105  }
106 #endif
107  if(conv_num_flux_type == AllParam::ConvectiveNumericalFlux::roe) {
108  if constexpr (dim+2==nstate) return std::make_unique< RoePike<dim, nstate, real> > (euler_based_physics_to_be_passed);
109  }
110  else if(conv_num_flux_type == AllParam::ConvectiveNumericalFlux::l2roe) {
111  if constexpr (dim+2==nstate) return std::make_unique< L2Roe<dim, nstate, real> > (euler_based_physics_to_be_passed);
112  }
113  else if(conv_num_flux_type == AllParam::ConvectiveNumericalFlux::two_point_flux_with_roe_dissipation) {
114  if constexpr (dim+2==nstate) return std::make_unique< EntropyConservingWithRoeDissipation<dim, nstate, real> > (euler_based_physics_to_be_passed);
115  }
116  else if(conv_num_flux_type == AllParam::ConvectiveNumericalFlux::two_point_flux_with_l2roe_dissipation) {
117  if constexpr (dim+2==nstate) return std::make_unique< EntropyConservingWithL2RoeDissipation<dim, nstate, real> > (euler_based_physics_to_be_passed);
118  }
119 
120  (void) pde_type;
121  (void) model_type;
122 
123  std::cout << "Invalid Euler based convective numerical flux" << std::endl;
124  return nullptr;
125 }
126 
127 template <int dim, int nstate, typename real>
128 std::unique_ptr< NumericalFluxDissipative<dim,nstate,real> >
131  const AllParam::DissipativeNumericalFlux diss_num_flux_type,
132  std::shared_ptr <Physics::PhysicsBase<dim, nstate, real>> physics_input,
133  std::shared_ptr<ArtificialDissipationBase<dim, nstate>> artificial_dissipation_input)
134 {
135  if(diss_num_flux_type == AllParam::symm_internal_penalty) {
136  return std::make_unique < SymmetricInternalPenalty<dim, nstate, real> > (physics_input,artificial_dissipation_input);
137  } else if(diss_num_flux_type == AllParam::bassi_rebay_2) {
138  return std::make_unique < BassiRebay2<dim, nstate, real> > (physics_input,artificial_dissipation_input);
139  } else if(diss_num_flux_type == AllParam::central_visc_flux) {
140  return std::make_unique < CentralViscousNumericalFlux<dim, nstate, real> > (physics_input,artificial_dissipation_input);
141  }
142 
143  std::cout << "Invalid dissipative flux" << std::endl;
144  return nullptr;
145 }
146 
177 
178 
179 } // NumericalFlux namespace
180 } // PHiLiP namespace
static std::unique_ptr< NumericalFluxConvective< dim, nstate, real > > create_euler_based_convective_numerical_flux(const AllParam::ConvectiveNumericalFlux conv_num_flux_type, const AllParam::PartialDifferentialEquation pde_type, const AllParam::ModelType model_type, std::shared_ptr< Physics::PhysicsBase< dim, nstate, real >> physics_input)
Creates euler-based convective numerical flux (upwind term)
Base class from which Advection, Diffusion, ConvectionDiffusion, and Euler is derived.
Definition: physics.h:34
static std::unique_ptr< NumericalFluxConvective< dim, nstate, real > > create_convective_numerical_flux(const AllParam::ConvectiveNumericalFlux conv_num_flux_type, const AllParam::PartialDifferentialEquation pde_type, const AllParam::ModelType model_type, std::shared_ptr< Physics::PhysicsBase< dim, nstate, real >> physics_input)
Creates convective numerical flux (baseline flux + upwind term) based on input.
Physics Model equations. Derived from PhysicsBase, holds a baseline physics and model terms and equat...
Definition: physics_model.h:14
PartialDifferentialEquation
Possible Partial Differential Equations to solve.
Files for the baseline physics.
Definition: ADTypes.hpp:10
static std::unique_ptr< NumericalFluxDissipative< dim, nstate, real > > create_dissipative_numerical_flux(const AllParam::DissipativeNumericalFlux diss_num_flux_type, std::shared_ptr< Physics::PhysicsBase< dim, nstate, real >> physics_input, std::shared_ptr< ArtificialDissipationBase< dim, nstate >> artificial_dissipation_input)
Creates dissipative numerical flux based on input.
Creates a NumericalFluxConvective or NumericalFluxDissipative based on input.
ModelType
Types of models available.
DissipativeNumericalFlux
Possible dissipative numerical flux types.
ConvectiveNumericalFlux
Possible convective numerical flux types.
Class to add artificial dissipation with an option to add one of the 3 dissipation types: 1...