[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
physics_post_processor.cpp
1 #include "physics_post_processor.h"
2 #include "physics/physics_factory.h"
3 #include "physics/model_factory.h"
4 
5 namespace PHiLiP {
6 namespace Postprocess {
7 
8 template <int dim>
9 std::unique_ptr< dealii::DataPostprocessor<dim> > PostprocessorFactory<dim>
10 ::create_Postprocessor(const Parameters::AllParameters *const parameters_input)
11 {
13  const PDE_enum pde_type = parameters_input->pde_type;
14  using Model_enum = Parameters::AllParameters::ModelType;
15  const Model_enum model_type = parameters_input->model_type;
17  const RANSModel_enum rans_model_type = parameters_input->physics_model_param.RANS_model_type;
18 
19  if (pde_type == PDE_enum::advection) {
20  return std::make_unique< PhysicsPostprocessor<dim,1> >(parameters_input);
21  } else if (pde_type == PDE_enum::advection_vector) {
22  return std::make_unique< PhysicsPostprocessor<dim,2> >(parameters_input);
23  } else if (pde_type == PDE_enum::diffusion) {
24  return std::make_unique< PhysicsPostprocessor<dim,1> >(parameters_input);
25  } else if (pde_type == PDE_enum::convection_diffusion) {
26  return std::make_unique< PhysicsPostprocessor<dim,1> >(parameters_input);
27  } else if (pde_type == PDE_enum::burgers_inviscid) {
28  return std::make_unique< PhysicsPostprocessor<dim,dim> >(parameters_input);
29  } else if (pde_type == PDE_enum::burgers_viscous) {
30  return std::make_unique< PhysicsPostprocessor<dim,dim> >(parameters_input);
31  } else if (pde_type == PDE_enum::burgers_rewienski) {
32  return std::make_unique< PhysicsPostprocessor<dim,dim> >(parameters_input);
33  } else if (pde_type == PDE_enum::euler) {
34  return std::make_unique< PhysicsPostprocessor<dim,dim+2> >(parameters_input);
35  } else if (pde_type == PDE_enum::navier_stokes) {
36  return std::make_unique< PhysicsPostprocessor<dim,dim+2> >(parameters_input);
37  } else if ((pde_type == PDE_enum::physics_model) && (model_type == Model_enum::reynolds_averaged_navier_stokes) && (rans_model_type == RANSModel_enum::SA_negative)) {
38  return std::make_unique< PhysicsPostprocessor<dim,dim+3> >(parameters_input);
39  }
40 #if PHILIP_DIM==3
41  else if ((pde_type == PDE_enum::physics_model) && (model_type == Model_enum::large_eddy_simulation)) {
42  return std::make_unique< PhysicsPostprocessor<dim,dim+2> >(parameters_input);
43  }
44 #endif
45  else {
46  std::cout << "Invalid PDE when creating post-processor" << std::endl;
47  std::abort();
48  }
49 }
51 
52 template <int dim, int nstate> PhysicsPostprocessor<dim,nstate>
53 ::PhysicsPostprocessor (const Parameters::AllParameters *const parameters_input)
54  : model(Physics::ModelFactory<dim,nstate,double>::create_Model(parameters_input))
55  , physics(Physics::PhysicsFactory<dim,nstate,double>::create_Physics(parameters_input,model))
56 { }
57 
58 template <int dim, int nstate> void PhysicsPostprocessor<dim,nstate>
59 ::evaluate_vector_field (const dealii::DataPostprocessorInputs::Vector<dim> &inputs, std::vector<dealii::Vector<double>> &computed_quantities) const
60 {
61  const unsigned int n_quadrature_points = inputs.solution_values.size();
62  Assert (computed_quantities.size() == n_quadrature_points, dealii::ExcInternalError());
63  Assert (inputs.solution_values[0].size() == nstate, dealii::ExcInternalError());
64  for (unsigned int q=0; q<n_quadrature_points; ++q)
65  {
66  computed_quantities[q] = this->physics->post_compute_derived_quantities_vector(
67  inputs.solution_values[q],
68  inputs.solution_gradients[q],
69  inputs.solution_hessians[q],
70  inputs.normals[q],
71  inputs.evaluation_points[q]);
72  }
73 }
74 
75 template <int dim, int nstate> void PhysicsPostprocessor<dim,nstate>
76 ::evaluate_scalar_field (const dealii::DataPostprocessorInputs::Scalar<dim> &inputs, std::vector<dealii::Vector<double>> &computed_quantities) const
77 {
78  const unsigned int n_quadrature_points = inputs.solution_values.size();
79  Assert (computed_quantities.size() == n_quadrature_points, dealii::ExcInternalError());
80  for (unsigned int q=0; q<n_quadrature_points; ++q)
81  {
82  computed_quantities[q] = this->physics->post_compute_derived_quantities_scalar(
83  inputs.solution_values[q],
84  inputs.solution_gradients[q],
85  inputs.solution_hessians[q],
86  inputs.normals[q],
87  inputs.evaluation_points[q]);
88  }
89 }
90 
91 
92 template <int dim, int nstate>
93 std::vector<std::string> PhysicsPostprocessor<dim,nstate>::get_names () const
94 {
95  return this->physics->post_get_names();
96 }
97 template <int dim, int nstate>
98 std::vector<dealii::DataComponentInterpretation::DataComponentInterpretation>
100 {
101  return this->physics->post_get_data_component_interpretation();
102 }
103 template <int dim, int nstate>
105 {
106  return this->physics->post_get_needed_update_flags();
107 }
108 
115 
116 } // Postprocess namespace
117 } // PHiLiP namespace
118 
119 
120 
PartialDifferentialEquation pde_type
Store the PDE type to be solved.
virtual std::vector< dealii::DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const override
Queries the Physics for the type (scalar/vector) of output data variables.
Postprocessor to output solution and other values computed by associated physics. ...
virtual dealii::UpdateFlags get_needed_update_flags() const override
Queries the Physics for the required update flags to evaluate output data.
PartialDifferentialEquation
Possible Partial Differential Equations to solve.
Files for the baseline physics.
Definition: ADTypes.hpp:10
ModelType
Types of models available.
Main parameter class that contains the various other sub-parameter classes.
virtual void evaluate_vector_field(const dealii::DataPostprocessorInputs::Vector< dim > &inputs, std::vector< dealii::Vector< double >> &computed_quantities) const override
Queries the Physics to output data of a vector-valued problem.
virtual void evaluate_scalar_field(const dealii::DataPostprocessorInputs::Scalar< dim > &inputs, std::vector< dealii::Vector< double >> &computed_quantities) const override
Queries the Physics to output data of a scalar-valued problem.
virtual std::vector< std::string > get_names() const override
Queries the Physics for the names of output data variables.
ReynoldsAveragedNavierStokesModel
Types of Reynolds-averaged Navier-Stokes (RANS) models that can be used.
static std::unique_ptr< dealii::DataPostprocessor< dim > > create_Postprocessor(const Parameters::AllParameters *const parameters_input)
Create the post-processor with the correct template parameters.
ReynoldsAveragedNavierStokesModel RANS_model_type
Store the Reynolds-averaged Navier-Stokes (RANS) model type.
PhysicsPostprocessor(const Parameters::AllParameters *const parameters_input)
Constructor.
ModelType model_type
Store the model type.
PhysicsModelParam physics_model_param
Contains parameters for Physics Model.