7 #ifndef __darcy_checkerboard_solution_parameters_h 8 #define __darcy_checkerboard_solution_parameters_h 10 #include <deal.II/algorithms/any_data.h> 11 #include <deal.II/base/function.h> 12 #include <deal.II/base/parameter_handler.h> 13 #include <deal.II/lac/full_matrix.h> 15 #include <amandus/darcy/checkerboard/constrained_newton.h> 19 namespace Checkerboard
36 virtual double value(
const Point<3>& p,
const unsigned int component)
const;
37 virtual Tensor<1, 3> gradient(
const Point<3>& p,
const unsigned int component)
const;
40 std::vector<double>
rhs;
46 rhs.push_back(coefficient[0] / coefficient[1]);
47 rhs.push_back(coefficient[1] / coefficient[2]);
48 rhs.push_back(coefficient[2] / coefficient[3]);
62 value = std::tan((numbers::PI / 2 - sigma) * gamma) * std::pow(std::tan(rho * gamma), -1);
64 else if (component == 1)
66 value = std::tan(rho * gamma) * std::pow(std::tan(sigma * gamma), -1);
68 else if (component == 2)
70 value = std::tan(sigma * gamma) * std::pow(std::tan((numbers::PI / 2 - rho) * gamma), -1);
74 Assert(
false, ExcInternalError());
77 return value +
rhs[component];
91 grad[0] = (numbers::PI / 2 - sigma) * std::pow(std::tan(rho * gamma), -1) *
92 std::pow(std::cos(numbers::PI / 2 * gamma - sigma * gamma), -2) -
93 rho * std::tan(numbers::PI / 2 * gamma - sigma * gamma) *
94 std::pow(std::tan(rho * gamma), -2) * std::pow(std::cos(rho * gamma), -2);
96 grad[1] = -1 * gamma * std::pow(std::tan(rho * gamma), -1) *
97 std::pow(std::cos(numbers::PI / 2 * gamma - sigma * gamma), -2);
99 grad[2] = -1 * gamma * std::tan(numbers::PI / 2 * gamma - sigma * gamma) *
100 std::pow(std::cos(rho * gamma), -2) * std::pow(std::tan(rho * gamma), -2);
102 else if (component == 1)
104 grad[0] = rho * std::pow(std::tan(sigma * gamma), -1) * std::pow(std::cos(rho * gamma), -2) -
105 sigma * std::tan(rho * gamma) * std::pow(std::tan(sigma * gamma), -2) *
106 std::pow(std::cos(sigma * gamma), -2);
108 grad[1] = -1 * gamma * std::tan(rho * gamma) * std::pow(std::cos(sigma * gamma), -2) *
109 std::pow(std::tan(sigma * gamma), -2);
111 grad[2] = gamma * std::pow(std::cos(rho * gamma), -2) * std::pow(std::tan(sigma * gamma), -1);
113 else if (component == 2)
115 grad[0] = sigma * std::pow(std::cos(sigma * gamma), -2) *
116 std::pow(std::tan(numbers::PI / 2 * gamma - rho * gamma), -1) -
117 (numbers::PI / 2 - rho) * std::tan(sigma * gamma) *
118 std::pow(std::tan(numbers::PI / 2 * gamma - rho * gamma), -2) *
119 std::pow(std::cos(numbers::PI / 2 * gamma - rho * gamma), -2);
121 grad[1] = gamma * std::pow(std::tan(numbers::PI / 2 * gamma - rho * gamma), -1) *
122 std::pow(std::cos(sigma * gamma), -2);
124 grad[2] = gamma * std::tan(sigma * gamma) *
125 std::pow(std::cos(numbers::PI / 2 * gamma - rho * gamma), -2) *
126 std::pow(std::tan(numbers::PI / 2 * gamma - rho * gamma), -2);
130 Assert(
false, ExcInternalError());
139 template <
int dim,
typename VECTOR>
143 AssertDimension(v.size(), dim);
144 for (
unsigned int i = 0; i < dim; ++i)
153 template <
int dim,
typename number>
155 jacobian(
const Function<dim>& f,
const Point<dim>& p, FullMatrix<number>& J)
157 AssertDimension(J.m(), f.n_components);
158 AssertDimension(J.n(), dim);
159 std::vector<Tensor<1, dim>> grads(f.n_components);
160 f.vector_gradient(p, grads);
161 for (
unsigned int i = 0; i < f.n_components; ++i)
163 for (
unsigned int j = 0; j < dim; ++j)
165 J.set(i, j, grads[i][j]);
174 template <
int dim,
typename VECTOR>
179 virtual void operator()(AnyData& out,
const AnyData& in);
182 SmartPointer<const Function<dim>>
f;
186 template <
int dim,
typename VECTOR>
192 template <
int dim,
typename VECTOR>
196 Assert(in.size() == 1, ExcNotImplemented());
197 Assert(out.size() == 1, ExcNotImplemented());
199 pointify(*(in.read<
const VECTOR*>(0)),
p);
200 f->vector_value(
p, *out.entry<VECTOR*>(0));
207 template <
int dim,
typename VECTOR>
211 typedef typename VECTOR::value_type
number;
214 virtual void operator()(AnyData& out,
const AnyData& in);
217 SmartPointer<const Function<dim>>
f;
219 FullMatrix<number>
J;
220 FullMatrix<number>
iJ;
223 template <
int dim,
typename VECTOR>
229 AssertDimension(dim, f->n_components);
232 template <
int dim,
typename VECTOR>
236 Assert(out.size() == 1, ExcNotImplemented());
237 Assert(in.size() == 2, ExcNotImplemented());
238 Assert(in.name(0) ==
"Newton residual", ExcInternalError());
239 Assert(in.name(1) ==
"Newton iterate", ExcInternalError());
241 pointify(*(in.read<
const VECTOR*>(1)),
p);
244 iJ.vmult(*out.entry<VECTOR*>(0), *(in.read<
const VECTOR*>(0)));
251 template <
int dim,
typename VECTOR>
259 ParameterHandler prm;
260 newton.declare_parameters(prm);
261 prm.enter_subsection(
"Newton");
262 prm.set(
"Stepsize iterations",
"10");
263 prm.set(
"Tolerance",
"1.e-12");
264 prm.set(
"Reduction",
"0.0");
265 prm.set(
"Max steps",
"100000");
266 prm.set(
"Log history",
false);
267 prm.set(
"Log frequency",
"10");
268 prm.leave_subsection();
269 newton.parse_parameters(prm);
275 out.add(p,
"Start and end value");
299 parameters[1] = -1 * dealii::numbers::PI / 4.0;
Definition: solution_parameters.h:283
std::vector< double > rhs
Definition: solution_parameters.h:40
Definition: solution_parameters.h:27
SmartPointer< const Function< dim > > f
Definition: solution_parameters.h:217
FullMatrix< number > J
Definition: solution_parameters.h:219
Definition: solution_parameters.h:175
virtual void operator()(AnyData &out, const AnyData &in)
Definition: solution_parameters.h:234
Vector< double > parameters
The parameters of the exact solution.
Definition: solution_parameters.h:291
virtual void operator()(AnyData &out, const AnyData &in)
Definition: solution_parameters.h:194
Point< dim > p
Definition: solution_parameters.h:183
ParameterEquation(const std::vector< double > &coefficient)
Definition: solution_parameters.h:43
FullMatrix< number > iJ
Definition: solution_parameters.h:220
void jacobian(const Function< dim > &f, const Point< dim > &p, FullMatrix< number > &J)
Definition: solution_parameters.h:155
Point< dim > p
Definition: solution_parameters.h:218
Definition: constrained_newton.h:30
void pointify(const VECTOR &v, Point< dim > &p)
Definition: solution_parameters.h:141
SmartPointer< const Function< dim > > f
Definition: solution_parameters.h:182
Definition: constrained_newton.h:15
NewtonResidual(const Function< dim > *f)
Definition: solution_parameters.h:187
NewtonInvJ(const Function< dim > *f)
Definition: solution_parameters.h:224
virtual double value(const Point< 3 > &p, const unsigned int component) const
Definition: solution_parameters.h:52
VECTOR::value_type number
Definition: solution_parameters.h:211
void find_root(const Function< dim > &f, VECTOR &u)
Definition: solution_parameters.h:253
SolutionParameters(const std::vector< double > &input_parameters)
Definition: solution_parameters.h:294
Definition: solution_parameters.h:208
virtual Tensor< 1, 3 > gradient(const Point< 3 > &p, const unsigned int component) const
Definition: solution_parameters.h:81