31 this->add_parameter(
"time dependent",
33 "Controls whether the function parsers support "
34 "time dependent function expressions");
36 background_density_expression_ =
"0.";
37 this->add_parameter(
"background density",
38 background_density_expression_,
39 "A function expression for the background density");
41 if constexpr (dim >= 2) {
42 magnetic_field_z_expression_ =
"0.";
43 this->add_parameter(
"magnetic field z",
44 magnetic_field_z_expression_,
45 "A function expression for the z component of "
46 "the magnetic field");
49 if constexpr (dim == 3) {
50 magnetic_field_x_expression_ =
"0.";
51 this->add_parameter(
"magnetic field x",
52 magnetic_field_x_expression_,
53 "A function expression for the x component of "
54 "the magnetic field");
56 magnetic_field_y_expression_ =
"0.";
57 this->add_parameter(
"magnetic field y",
58 magnetic_field_y_expression_,
59 "A function expression for the y component of "
60 "the magnetic field");
65 const auto set_up_muparser = [
this] {
69 using FP = dealii::FunctionParser<dim>;
70 auto variable_names = FP::default_variable_names();
72 variable_names +=
",t";
74 background_density_ = std::make_unique<FP>(
75 background_density_expression_,
"", variable_names);
77 if constexpr (dim >= 2) {
78 magnetic_field_z_ = std::make_unique<FP>(
79 magnetic_field_z_expression_,
"", variable_names);
82 if constexpr (dim == 3) {
83 magnetic_field_x_ = std::make_unique<FP>(
84 magnetic_field_x_expression_,
"", variable_names);
85 magnetic_field_y_ = std::make_unique<FP>(
86 magnetic_field_y_expression_,
"", variable_names);
91 this->parse_parameters_call_back.connect(set_up_muparser);
102 Number t)
const final
104 if constexpr (dim == 1) {
108 if constexpr (dim == 2) {
109 magnetic_field_z_->set_time(t);
111 {
static_cast<Number
>(magnetic_field_z_->value(point))}};
114 if constexpr (dim == 3) {
115 magnetic_field_x_->set_time(t);
116 magnetic_field_y_->set_time(t);
117 magnetic_field_z_->set_time(t);
119 {
static_cast<Number
>(magnetic_field_x_->value(point)),
120 static_cast<Number
>(magnetic_field_y_->value(point)),
121 static_cast<Number
>(magnetic_field_z_->value(point))}};