[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 nstate, typename real, typename MeshType>
6 std::unique_ptr <MeshErrorEstimateBase <dim, real, MeshType>> MeshErrorFactory<dim, nstate, real, MeshType>::create_mesh_error(std::shared_ptr< DGBase<dim,real,MeshType>> dg)
7 {
8  if (!(dg->all_parameters->mesh_adaptation_param.use_goal_oriented_mesh_adaptation))
9  {
10  return std::make_unique<ResidualErrorEstimate<dim, 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)
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, 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 
39 #if PHILIP_DIM!=1
41 #endif
42 } // namespace PHiLiP
static std::unique_ptr< MeshErrorEstimateBase< dim, real, MeshType > > create_mesh_error(std::shared_ptr< DGBase< dim, real, MeshType > > dg)
Returns pointer of the mesh error&#39;s abstract class.
Returns pointer to appropriate mesh error class depending on the input parameters.
Files for the baseline physics.
Definition: ADTypes.hpp:10
DGBase is independent of the number of state variables.
Definition: dg_base.hpp:82