[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
bound_preserving_limiter_factory.cpp
1 #include "parameters/all_parameters.h"
2 #include "bound_preserving_limiter_factory.hpp"
3 #include "bound_preserving_limiter.h"
4 #include "tvb_limiter.h"
5 #include "maximum_principle_limiter.h"
6 #include "positivity_preserving_limiter.h"
7 
8 namespace PHiLiP {
9 template <int dim, int nspecies, int nstate, typename real>
10 std::unique_ptr< BoundPreservingLimiter<dim, nspecies, real> >
13  const Parameters::AllParameters* const parameters_input)
14 {
15  if (nspecies > 1)
17  else if (nstate == parameters_input->nstate && nspecies == 1)
19  else if constexpr (nstate > 1 && nspecies == 1)
21  else
22  return nullptr;
23 }
24 
25 template <int dim, int nspecies, int nstate, typename real>
26 std::unique_ptr< BoundPreservingLimiter<dim, nspecies, real> >
29  const Parameters::AllParameters* const parameters_input)
30 {
31  using limiter_enum = Parameters::LimiterParam::LimiterType;
32  using flux_nodes_enum = Parameters::AllParameters::FluxNodes;
33 
34  limiter_enum limiter_type = parameters_input->limiter_param.bound_preserving_limiter;
35  flux_nodes_enum flux_nodes_type = parameters_input->flux_nodes_type;
36 
37  bool apply_tvb = parameters_input->limiter_param.use_tvb_limiter;
38  bool curvilinear_grid = parameters_input->use_curvilinear_grid;
39 
40  if (limiter_type == limiter_enum::none) {
41  if (apply_tvb == true) {
42  if(curvilinear_grid) {
43  std::cout << "Error: Cannot create limiter for curvilinear grid" << std::endl;
44  std::abort();
45  } else if (flux_nodes_type != flux_nodes_enum::GLL) {
46  std::cout << "Error: Can only use limiter with GLL flux nodes" << std::endl;
47  std::abort();
48  } else if (dim == 1) {
49  return std::make_unique < TVBLimiter<dim, nspecies, nstate, real> >(parameters_input);
50  }
51  else {
52  std::cout << "Error: Cannot create TVB limiter for dim > 1" << std::endl;
53  std::abort();
54  }
55  }
56  else
57  return nullptr;
58  } else if(curvilinear_grid) {
59  std::cout << "Error: Cannot create limiter for curvilinear grid" << std::endl;
60  std::abort();
61  } else if (flux_nodes_type != flux_nodes_enum::GLL) {
62  std::cout << "Error: Can only use limiter with GLL flux nodes" << std::endl;
63  std::abort();
64  } else if (limiter_type == limiter_enum::maximum_principle && nspecies==1) {
65  return std::make_unique< MaximumPrincipleLimiter<dim, nspecies, nstate, real> >(parameters_input);
66  } else if ((limiter_type == limiter_enum::positivity_preservingZhang2010 && nspecies==1)
67  || limiter_type == limiter_enum::positivity_preservingWang2012) {
68  if (nstate == dim + nspecies + 1)
69  return std::make_unique< PositivityPreservingLimiter<dim, nspecies, nstate, real> >(parameters_input);
70  else {
71  if(nstate != dim + nspecies + 1) {
72  std::cout << "Error: Cannot create Positivity-Preserving limiter for nstate_input != dim + nspecies + 1" << std::endl;
73  std::cout << "Positivity-Preserving Limiter can only be created for Euler, Navier-Stokes and Real Gas PDEs." << std::endl;
74  std::abort();
75  }
76  }
77  }
78 
79  std::cout << "Error: Cannot create limiter pointer due to an invalid limiter type specified" << std::endl;
80  std::abort();
81  return nullptr;
82 }
83 
84 #if PHILIP_SPECIES == 1
85  // Define a sequence of nstate in the range [1, 6]
86  #define POSSIBLE_NSTATE (1)(2)(3)(4)(5)(6)
87 
88  // Define a macro to instantiate Limiter Factory Function for a specific nstate
89  #define INSTANTIATE_LIMITER(r, data, nstate) \
90  template class BoundPreservingLimiterFactory <PHILIP_DIM, PHILIP_SPECIES, nstate, double>;
91  BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_LIMITER, _, POSSIBLE_NSTATE)
92 #else
94 #endif
95 } // PHiLiP namespace
bool use_curvilinear_grid
Flag to use curvilinear grid.
LimiterType
Limiter type to be applied on the solution.
LimiterParam limiter_param
Contains parameters for limiter.
LimiterType bound_preserving_limiter
Variable to store specified limiter type.
Files for the baseline physics.
Definition: ADTypes.hpp:10
This class creates a new BoundPreservingLimiter object based on input parameters. ...
static std::unique_ptr< BoundPreservingLimiter< dim, nspecies, real > > create_limiter(const Parameters::AllParameters *const parameters_input)
Recursively templated function that calls select_limiter when nstate is equal to one specified in prm...
Main parameter class that contains the various other sub-parameter classes.
int nstate
Number of state variables. Will depend on PDE.
FluxNodes flux_nodes_type
Store selected FluxNodes from the input file.
static std::unique_ptr< BoundPreservingLimiter< dim, nspecies, real > > select_limiter(const Parameters::AllParameters *const parameters_input)
Create a pointer to the limiter specified in prms.
bool use_tvb_limiter
Flag for applying TVB Limiter.