[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
parameters_functional.cpp
1 #include <algorithm>
2 #include <string>
3 
4 #include <deal.II/base/utilities.h>
5 
6 #include "parameters_functional.h"
7 
8 namespace PHiLiP {
9 
10 namespace Parameters {
11 
12 
13 void FunctionalParam::declare_parameters(dealii::ParameterHandler &prm)
14 {
15  prm.enter_subsection("functional");
16  {
17  prm.declare_entry("functional_type", "normLp_volume",
18  dealii::Patterns::Selection(
19  " normLp_volume | "
20  " normLp_boundary | "
21  " weighted_integral_volume | "
22  " weighted_integral_boundary | "
23  " error_normLp_volume | "
24  " error_normLp_boundary | "
25  " lift | "
26  " drag | "
27  " solution_integral | "
28  " outlet_pressure_integral | "
29  ),
30  "Functional that we want to use. "
31  "Choice are "
32  " <normLp_volume | "
33  " normLp_boundary | "
34  " weighted_integral_volume | "
35  " weighted_integral_boundary | "
36  " error_normLp_volume | "
37  " error_normLp_boundary | "
38  " lift | "
39  " drag | "
40  " solution_integral |"
41  " outlet_pressure_integral |"
42  " error_normLp_boundary>.");
43 
44  prm.declare_entry("normLp", "2.0",
45  dealii::Patterns::Double(1.0,dealii::Patterns::Double::max_double_value),
46  "Lp norm strength (may not be used depending on the functional choice).");
47 
48  prm.declare_entry("weight_function_type","exp_solution",
49  dealii::Patterns::Selection(
50  " sine_solution | "
51  " cosine_solution | "
52  " additive_solution | "
53  " exp_solution | "
54  " poly_solution | "
55  " even_poly_solution | "
56  " atan_solution"
57  ),
58  "The weight function we want to use (may not be used depending on the functional choice). "
59  "Choices are "
60  " <sine_solution | "
61  " cosine_solution | "
62  " additive_solution | "
63  " exp_solution | "
64  " poly_solution | "
65  " even_poly_solution | "
66  " atan_solution>.");
67 
68  prm.declare_entry("use_weight_function_laplacian", "false",
69  dealii::Patterns::Bool(),
70  "Indicates whether to use weight function value or laplacian in the functional.");
71 
72  prm.declare_entry("boundary_vector", "[0, 1]",
73  dealii::Patterns::Anything(),
74  "Stores a vector with a list of the (unsigned) integer boundary ID. "
75  "Formatted in square brackets and seperated by commas, eg. \"[0,2]\"");
76 
77  prm.declare_entry("use_all_boundaries", "true",
78  dealii::Patterns::Bool(),
79  "Indicates whether all boundaries should be evaluated (for boundary functionals). "
80  "If set to true (default), overrides the boundary_vector list.");
81  }
82  prm.leave_subsection();
83 }
84 
85 void FunctionalParam::parse_parameters(dealii::ParameterHandler &prm)
86 {
87  prm.enter_subsection("functional");
88  {
89  const std::string functional_string = prm.get("functional_type");
90  if(functional_string == "normLp_volume") {functional_type = FunctionalType::normLp_volume;}
91  else if(functional_string == "normLp_boundary") {functional_type = FunctionalType::normLp_boundary;}
92  else if(functional_string == "weighted_integral_volume") {functional_type = FunctionalType::weighted_integral_volume;}
93  else if(functional_string == "weighted_integral_boundary") {functional_type = FunctionalType::weighted_integral_boundary;}
94  else if(functional_string == "error_normLp_volume") {functional_type = FunctionalType::error_normLp_volume;}
95  else if(functional_string == "error_normLp_boundary") {functional_type = FunctionalType::error_normLp_boundary;}
96  else if(functional_string == "lift") {functional_type = FunctionalType::lift;}
97  else if(functional_string == "drag") {functional_type = FunctionalType::drag;}
98  else if(functional_string == "solution_integral") {functional_type = FunctionalType::solution_integral;}
99  else if(functional_string == "outlet_pressure_integral") {functional_type = FunctionalType::outlet_pressure_integral;}
100 
101  normLp = prm.get_double("normLp");
102 
104  const std::string weight_string = prm.get("weight_function_type");
105  if(weight_string == "sine_solution") {weight_function_type = ManufacturedSolutionEnum::sine_solution;}
106  else if(weight_string == "cosine_solution") {weight_function_type = ManufacturedSolutionEnum::cosine_solution;}
107  else if(weight_string == "additive_solution") {weight_function_type = ManufacturedSolutionEnum::additive_solution;}
108  else if(weight_string == "exp_solution") {weight_function_type = ManufacturedSolutionEnum::exp_solution;}
109  else if(weight_string == "poly_solution") {weight_function_type = ManufacturedSolutionEnum::poly_solution;}
110  else if(weight_string == "even_poly_solution") {weight_function_type = ManufacturedSolutionEnum::even_poly_solution;}
111  else if(weight_string == "atan_solution") {weight_function_type = ManufacturedSolutionEnum::atan_solution;}
112 
113  use_weight_function_laplacian = prm.get_bool("use_weight_function_laplacian");
114 
115  std::string boundary_string = prm.get("boundary_vector");
116 
117  // removing formatting
118  std::string removeChars = "[]";
119  for(unsigned int i = 0; i < removeChars.length(); ++i)
120  boundary_string.erase(std::remove(boundary_string.begin(), boundary_string.end(), removeChars.at(i)), boundary_string.end());
121  std::vector<std::string> boundary_string_vector = dealii::Utilities::split_string_list(boundary_string);
122 
123  // pushing into a vector
124  for(auto entry : boundary_string_vector)
125  boundary_vector.push_back(dealii::Utilities::string_to_int(entry));
126 
127  use_all_boundaries = prm.get_bool("use_all_boundaries");
128  }
129  prm.leave_subsection();
130 }
131 
132 } // namespace Parameters
133 
134 } // namespace PHiLiP
ManufacturedSolutionType
Selects the manufactured solution to be used if use_manufactured_source_term=true.
FunctionalType functional_type
Selection of functinal type.
void parse_parameters(dealii::ParameterHandler &prm)
Parses input file and sets the variables.
ManufacturedSolutionEnum weight_function_type
Choice of manufactured solution function to be used in weighting expression.
std::vector< unsigned int > boundary_vector
Boundary of vector ids to be considered for boundary functional evaluation.
Files for the baseline physics.
Definition: ADTypes.hpp:10
bool use_all_boundaries
Flag for use of all domain boundaries.
double normLp
Choice of Lp norm exponent used in functional calculation.
static void declare_parameters(dealii::ParameterHandler &prm)
Declares the possible variables and sets the defaults.
bool use_weight_function_laplacian
Flag to use weight function laplacian.