17#include <deal.II/base/point.h>
18#include <deal.II/base/function.h>
19#include <deal.II/base/geometric_utilities.h>
20#include <deal.II/base/tensor.h>
23using namespace dealii;
78 : Function<dim>(1), function_type(type) {}
91 virtual double value(
const Point<dim> & p,
92 const unsigned int component = 0)
const override;
106 virtual Tensor<1, dim>
gradient(
const Point<dim> & p,
107 const unsigned int component = 0)
const override;
124 if (function_type == TYPE_ZERO) {
127 else if (function_type == TYPE_SIN_SIN) {
131 return 2 * std::sin(p[0]) * std::sin(p[1]);
133 else if (function_type == TYPE_X_Y) {
134 return -10 * p[0] * p[1];
136 else if (function_type == TYPE_R_COS) {
137 const auto r = p.norm();
138 const auto theta = std::atan(p[1]/p[0]);
139 return (r - 1/r - (1/r)*(1/R)*(1/R)) * std::cos(theta/R);
153 const unsigned int )
const
155 Tensor<1, dim> return_values;
157 if (function_type == TYPE_ZERO) {
158 return_values[0] = 0;
159 return_values[1] = 0;
161 else if (function_type == TYPE_X_Y) {
162 return_values[0] = -10 * p[1];
163 return_values[1] = -10 * p[0];
165 else if (function_type == TYPE_SIN_SIN) {
167 return_values[0] = 2 * pi * pi * pi * std::cos(pi * p[0]) * std::sin(pi * p[1]);
168 return_values[1] = 2 * pi * pi * pi * std::sin(pi * p[0]) * std::cos(pi * p[1]);
169 return return_values;
171 else if (function_type == TYPE_R_COS) {
174 const auto r = p.norm();
175 const auto theta = std::atan(p[1]/p[0]);
176 return_values[0] = (1 + (1/r)*(1/r)*(1 + (1/R)*(1/R))) * std::cos(theta/R);
177 return_values[1] = (r - 1/r - (1/r) * (1/R) * (1/R)) * (-1) * std::sin(theta/R);
179 return return_values;
Analytic right-hand-side function for the saddle-point Laplace problem.
Definition rhs_function.h:56
RHSFunction(FunctionType type)
Construct a single-component RHSFunction of the requested type.
Definition rhs_function.h:77
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
Evaluate the analytic gradient at point p.
Definition rhs_function.h:152
FunctionType
Selector for the analytic right-hand-side expression to use.
Definition rhs_function.h:61
@ TYPE_R_COS
Definition rhs_function.h:67
@ TYPE_X_Y
Definition rhs_function.h:62
@ TYPE_EXP_COS
Definition rhs_function.h:63
@ TYPE_ZERO
Definition rhs_function.h:65
@ TYPE_SIN_SIN
Definition rhs_function.h:66
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
Evaluate the analytic right-hand side at point p.
Definition rhs_function.h:121