[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
mesh_error_factory.cpp
1 #include "mesh_error_factory.h"
2 
3 namespace PHiLiP {
4 
5 template <int dim, int nspecies, int nstate, typename real, typename MeshType>
6 std::unique_ptr <MeshErrorEstimateBase <dim,nspecies, real, MeshType>> MeshErrorFactory<dim,nspecies, nstate, real, MeshType>::create_mesh_error(std::shared_ptr< DGBase<dim,nspecies,real,MeshType>> dg)
7 {
8  if (!(dg->all_parameters->mesh_adaptation_param.use_goal_oriented_mesh_adaptation) && nspecies==1)
9  {
10  return std::make_unique<ResidualErrorEstimate<dim,nspecies, real, MeshType>>(dg);
11  }
12 
13  // Recursive templating required because template parameters must be compile time constants
14  // As a results, this recursive template initializes all possible dimensions with all possible nstate
15  // without having 15 different if-else statements
16  if(dim == dg->all_parameters->dimension && nspecies == 1)
17  {
18  // This template parameters dim and nstate match the runtime parameters
19  // then create the selected dual-weighted residual type with template parameters dim and nstate
20  // Otherwise, keep decreasing nstate and dim until it matches
21  if(nstate == dg->all_parameters->nstate)
22  {
23  return std::make_unique<DualWeightedResidualError<dim,nspecies, nstate , real, MeshType>>(dg);
24  }
25  else if constexpr (nstate > 1)
27  else
28  return nullptr;
29  }
30  else
31  {
32  std::cout<<"Cannot create MeshErrorEstimate. Invalid input"<<std::endl;
33  return nullptr;
34  }
35 }
36 
37 #if PHILIP_SPECIES==1
40  #if PHILIP_DIM!=1
42  #endif
43 #else
46  #if PHILIP_DIM!=1
48  #endif
49 #endif
50 } // namespace PHiLiP
Returns pointer to appropriate mesh error class depending on the input parameters.
Files for the baseline physics.
Definition: ADTypes.hpp:10
static std::unique_ptr< MeshErrorEstimateBase< dim, nspecies, real, MeshType > > create_mesh_error(std::shared_ptr< DGBase< dim, nspecies, real, MeshType > > dg)
Returns pointer of the mesh error&#39;s abstract class.
DGBase is independent of the number of state variables.
Definition: dg_base.hpp:82