[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
parameters_manufactured_solution.cpp
1 #include "parameters_manufactured_solution.h"
2 
3 #include <deal.II/base/tensor.h>
4 #include <string>
5 
6 namespace PHiLiP {
7 
8 namespace Parameters {
9 void ManufacturedSolutionParam::declare_parameters(dealii::ParameterHandler &prm)
10 {
11  prm.declare_entry("use_manufactured_source_term", "false",
12  dealii::Patterns::Bool(),
13  "Uses non-zero source term based on the manufactured solution and the PDE.");
14 
15  prm.declare_entry("manufactured_solution_type","exp_solution",
16  dealii::Patterns::Selection(
17  " sine_solution | "
18  " zero_solution | "
19  " cosine_solution | "
20  " additive_solution | "
21  " exp_solution | "
22  " poly_solution | "
23  " even_poly_solution | "
24  " atan_solution | "
25  " boundary_layer_solution | "
26  " s_shock_solution | "
27  " quadratic_solution | "
28  " example_solution | "
29  " navah_solution_1 | "
30  " navah_solution_2 | "
31  " navah_solution_3 | "
32  " navah_solution_4 | "
33  " navah_solution_5"
34  ),
35  "The manufactured solution we want to use (if use_manufactured_source_term==true). "
36  "Choices are "
37  " <sine_solution | "
38  " zero_solution | "
39  " cosine_solution | "
40  " additive_solution | "
41  " exp_solution | "
42  " poly_solution | "
43  " even_poly_solution | "
44  " atan_solution | "
45  " boundary_layer_solution | "
46  " s_shock_solution | "
47  " quadratic_solution | "
48  " navah_solution_1 | "
49  " navah_solution_2 | "
50  " navah_solution_3 | "
51  " navah_solution_4 | "
52  " navah_solution_5>.");
53 
54  // diffusion tensor, get default from function and convert entries to string
55  const dealii::Tensor<2,3,double> default_diffusion_tensor = get_default_diffusion_tensor();
56  for(int i = 0; i < 3; ++i)
57  {
58  for(int j = 0; j < 3; ++j)
59  {
60  const std::string str_i = std::to_string(i);
61  const std::string str_j = std::to_string(j);
62  const std::string name =
63  "diffusion_" + str_i + str_j;
64  const std::string description =
65  "[" + str_i + "," + str_j + "] term of diffusion tensor.";
66  prm.declare_entry(name, std::to_string(default_diffusion_tensor[i][j]),
67  dealii::Patterns::Double(),
68  description);
69  }
70  }
71 
72  // advection vector, get default from function and convert entries to string
73  const dealii::Tensor<1,3,double> default_advection_vector = get_default_advection_vector();
74  for(int i = 0; i < 3; ++i)
75  {
76  const std::string str_i = std::to_string(i);
77  const std::string name =
78  "advection_" + str_i;
79  const std::string description =
80  "[" + str_i + "] term of advection vector.";
81  prm.declare_entry(name, std::to_string(default_advection_vector[i]),
82  dealii::Patterns::Double(),
83  description);
84  }
85 
86  // diffusion coefficient
87  prm.declare_entry("diffusion_coefficient", std::to_string(get_default_diffusion_coefficient()),
88  dealii::Patterns::Double(),
89  "Set the diffusion matrix coefficient.");
90 
91 }
92 
93 void ManufacturedSolutionParam::parse_parameters(dealii::ParameterHandler &prm)
94 {
95  use_manufactured_source_term = prm.get_bool("use_manufactured_source_term");
96 
97  const std::string manufactured_solution_string = prm.get("manufactured_solution_type");
98  if(manufactured_solution_string == "sine_solution") {manufactured_solution_type = sine_solution;}
99  else if(manufactured_solution_string == "zero_solution") {manufactured_solution_type = zero_solution;}
100  else if(manufactured_solution_string == "cosine_solution") {manufactured_solution_type = cosine_solution;}
101  else if(manufactured_solution_string == "additive_solution") {manufactured_solution_type = additive_solution;}
102  else if(manufactured_solution_string == "exp_solution") {manufactured_solution_type = exp_solution;}
103  else if(manufactured_solution_string == "poly_solution") {manufactured_solution_type = poly_solution;}
104  else if(manufactured_solution_string == "even_poly_solution") {manufactured_solution_type = even_poly_solution;}
105  else if(manufactured_solution_string == "atan_solution") {manufactured_solution_type = atan_solution;}
106  else if(manufactured_solution_string == "boundary_layer_solution") {manufactured_solution_type = boundary_layer_solution;}
107  else if(manufactured_solution_string == "s_shock_solution") {manufactured_solution_type = s_shock_solution;}
108  else if(manufactured_solution_string == "quadratic_solution") {manufactured_solution_type = quadratic_solution;}
109  else if(manufactured_solution_string == "example_solution") {manufactured_solution_type = example_solution;}
110  else if(manufactured_solution_string == "navah_solution_1") {manufactured_solution_type = navah_solution_1;}
111  else if(manufactured_solution_string == "navah_solution_2") {manufactured_solution_type = navah_solution_2;}
112  else if(manufactured_solution_string == "navah_solution_3") {manufactured_solution_type = navah_solution_3;}
113  else if(manufactured_solution_string == "navah_solution_4") {manufactured_solution_type = navah_solution_4;}
114  else if(manufactured_solution_string == "navah_solution_5") {manufactured_solution_type = navah_solution_5;}
115 
116  diffusion_tensor[0][0] = prm.get_double("diffusion_00");
117  diffusion_tensor[0][1] = prm.get_double("diffusion_01");
118  diffusion_tensor[1][0] = prm.get_double("diffusion_10");
119  diffusion_tensor[1][1] = prm.get_double("diffusion_11");
120  diffusion_tensor[0][2] = prm.get_double("diffusion_02");
121  diffusion_tensor[2][0] = prm.get_double("diffusion_20");
122  diffusion_tensor[2][1] = prm.get_double("diffusion_21");
123  diffusion_tensor[1][2] = prm.get_double("diffusion_12");
124  diffusion_tensor[2][2] = prm.get_double("diffusion_22");
125 
126  advection_vector[0] = prm.get_double("advection_0");
127  advection_vector[1] = prm.get_double("advection_1");
128  advection_vector[2] = prm.get_double("advection_2");
129 
130  diffusion_coefficient = prm.get_double("diffusion_coefficient");
131 }
132 
134 {
135  dealii::Tensor<2,3,double> default_diffusion_tensor;
136 
137  /* Default before merge */
138  // default_diffusion_tensor[0][0] = 12;
139  // default_diffusion_tensor[0][1] = -2;
140  // default_diffusion_tensor[1][0] = 3;
141  // default_diffusion_tensor[1][1] = 20;
142  // default_diffusion_tensor[0][2] = -6;
143  // default_diffusion_tensor[2][0] = -2;
144  // default_diffusion_tensor[2][1] = 0.5;
145  // default_diffusion_tensor[1][2] = -4;
146  // default_diffusion_tensor[2][2] = 8;
147 
148  /* For after merge, current as of 2021-04-25 */
149  default_diffusion_tensor[0][0] = 12;
150  default_diffusion_tensor[0][1] = 3;
151  default_diffusion_tensor[1][0] = 3;
152  default_diffusion_tensor[1][1] = 20;
153  default_diffusion_tensor[0][2] = -2;
154  default_diffusion_tensor[2][0] = 2;
155  default_diffusion_tensor[2][1] = 5;
156  default_diffusion_tensor[1][2] = -5;
157  default_diffusion_tensor[2][2] = 18;
158 
159  return default_diffusion_tensor;
160 }
161 
163 {
164  dealii::Tensor<1,3,double> default_advection_vector;
165 
166  const double pi = atan(1)*4.0;
167  const double ee = exp(1);
168 
169  default_advection_vector[0] = 1.1;
170  default_advection_vector[1] = -pi/ee;
171  default_advection_vector[2] = ee/pi;
172 
173  return default_advection_vector;
174 }
175 
177 {
178  const double pi = atan(1)*4.0;
179  const double ee = exp(1);
180  return 0.1 * pi/ee;
181 }
182 
183 } // Parameters namespace
184 
185 } // PHiLiP namespace
static dealii::Tensor< 1, 3, double > get_default_advection_vector()
gets the default advection vector
void parse_parameters(dealii::ParameterHandler &prm)
Parses input file and sets the variables.
Files for the baseline physics.
Definition: ADTypes.hpp:10
static dealii::Tensor< 2, 3, double > get_default_diffusion_tensor()
gets the default diffusion tensor
bool use_manufactured_source_term
Uses non-zero source term based on the manufactured solution and the PDE.
dealii::Tensor< 1, 3, double > advection_vector
Advection velocity.
dealii::Tensor< 2, 3, double > diffusion_tensor
Diffusion tensor.
static double get_default_diffusion_coefficient()
gets the default diffusion coefficient;
ManufacturedSolutionType manufactured_solution_type
Selected ManufacturedSolutionType from the input file.
static void declare_parameters(dealii::ParameterHandler &prm)
Declares the possible variables and sets the defaults.