32 this->add_parameter(
"time dependent",
34 "Controls whether the function parsers support "
35 "time dependent function expressions");
37 background_density_expression_ =
"0.";
38 this->add_parameter(
"background density",
39 background_density_expression_,
40 "A function expression for the background density");
42 if constexpr (dim >= 2) {
43 magnetic_field_z_expression_ =
"0.";
44 this->add_parameter(
"magnetic field z",
45 magnetic_field_z_expression_,
46 "A function expression for the z component of "
47 "the magnetic field");
50 if constexpr (dim == 3) {
51 magnetic_field_x_expression_ =
"0.";
52 this->add_parameter(
"magnetic field x",
53 magnetic_field_x_expression_,
54 "A function expression for the x component of "
55 "the magnetic field");
57 magnetic_field_y_expression_ =
"0.";
58 this->add_parameter(
"magnetic field y",
59 magnetic_field_y_expression_,
60 "A function expression for the y component of "
61 "the magnetic field");
66 const auto set_up_muparser = [
this] {
70 using FP = dealii::FunctionParser<dim>;
71 auto variable_names = FP::default_variable_names();
73 variable_names +=
",t";
75 background_density_ = std::make_unique<FP>(
76 background_density_expression_,
"", variable_names);
78 if constexpr (dim >= 2) {
79 magnetic_field_z_ = std::make_unique<FP>(
80 magnetic_field_z_expression_,
"", variable_names);
83 if constexpr (dim == 3) {
84 magnetic_field_x_ = std::make_unique<FP>(
85 magnetic_field_x_expression_,
"", variable_names);
86 magnetic_field_y_ = std::make_unique<FP>(
87 magnetic_field_y_expression_,
"", variable_names);
92 this->parse_parameters_call_back.connect(set_up_muparser);
103 Number t)
const final
105 if constexpr (dim == 1) {
109 if constexpr (dim == 2) {
110 magnetic_field_z_->set_time(t);
112 {
static_cast<Number
>(magnetic_field_z_->value(point))}};
115 if constexpr (dim == 3) {
116 magnetic_field_x_->set_time(t);
117 magnetic_field_y_->set_time(t);
118 magnetic_field_z_->set_time(t);
120 {
static_cast<Number
>(magnetic_field_x_->value(point)),
121 static_cast<Number
>(magnetic_field_y_->value(point)),
122 static_cast<Number
>(magnetic_field_z_->value(point))}};