16 #include <deal.II/base/auto_derivative_function.h> 17 #include <deal.II/base/point.h> 19 #include <deal.II/lac/vector.h> 23 DEAL_II_NAMESPACE_OPEN
29 const double initial_time)
55 ExcMessage(
"The argument passed to this function does not " 56 "match any known difference formula."));
68 for (
unsigned int i = 0; i < dim; ++i)
76 const unsigned int comp)
const 84 for (
unsigned int i = 0; i < dim; ++i)
87 grad[i] = (this->value(p, comp) - this->value(q1, comp)) / h;
94 for (
unsigned int i = 0; i < dim; ++i)
99 (this->value(q1, comp) - this->value(q2, comp)) / (2 * h);
106 for (
unsigned int i = 0; i < dim; ++i)
112 grad[i] = (-this->value(q1, comp) + 8 * this->value(q2, comp) -
113 8 * this->value(q3, comp) + this->value(q4, comp)) /
140 const double h_inv = 1. / h;
141 for (
unsigned int i = 0; i < dim; ++i)
144 this->vector_value(p, v);
145 this->vector_value(q1, v1);
147 for (
unsigned int comp = 0; comp < this->
n_components; ++comp)
148 gradients[comp][i] = (v(comp) - v1(comp)) * h_inv;
157 const double h_inv_2 = 1. / (2 * h);
158 for (
unsigned int i = 0; i < dim; ++i)
162 this->vector_value(q1, v1);
163 this->vector_value(q2, v2);
165 for (
unsigned int comp = 0; comp < this->
n_components; ++comp)
166 gradients[comp][i] = (v1(comp) - v2(comp)) * h_inv_2;
176 const double h_inv_12 = 1. / (12 * h);
177 for (
unsigned int i = 0; i < dim; ++i)
183 this->vector_value(q1, v1);
184 this->vector_value(q2, v2);
185 this->vector_value(q3, v3);
186 this->vector_value(q4, v4);
188 for (
unsigned int comp = 0; comp < this->
n_components; ++comp)
190 (-v1(comp) + 8 * v2(comp) - 8 * v3(comp) + v4(comp)) *
207 const unsigned int comp)
const 209 Assert(gradients.size() == points.size(),
217 for (
unsigned int p = 0; p < points.size(); ++p)
218 for (
unsigned int i = 0; i < dim; ++i)
220 q1 = points[p] - ht[i];
222 (this->value(points[p], comp) - this->value(q1, comp)) / h;
230 for (
unsigned int p = 0; p < points.size(); ++p)
231 for (
unsigned int i = 0; i < dim; ++i)
233 q1 = points[p] + ht[i];
234 q2 = points[p] - ht[i];
236 (this->value(q1, comp) - this->value(q2, comp)) / (2 * h);
244 for (
unsigned int p = 0; p < points.size(); ++p)
245 for (
unsigned int i = 0; i < dim; ++i)
247 q2 = points[p] + ht[i];
249 q3 = points[p] - ht[i];
252 (-this->value(q1, comp) + 8 * this->value(q2, comp) -
253 8 * this->value(q3, comp) + this->value(q4, comp)) /
272 Assert(gradients.size() == points.size(),
274 for (
unsigned int p = 0; p < points.size(); ++p)
283 for (
unsigned int p = 0; p < points.size(); ++p)
284 for (
unsigned int i = 0; i < dim; ++i)
286 q1 = points[p] - ht[i];
287 for (
unsigned int comp = 0; comp < this->
n_components; ++comp)
288 gradients[p][comp][i] =
289 (this->value(points[p], comp) - this->value(q1, comp)) / h;
297 for (
unsigned int p = 0; p < points.size(); ++p)
298 for (
unsigned int i = 0; i < dim; ++i)
300 q1 = points[p] + ht[i];
301 q2 = points[p] - ht[i];
302 for (
unsigned int comp = 0; comp < this->
n_components; ++comp)
303 gradients[p][comp][i] =
304 (this->value(q1, comp) - this->value(q2, comp)) / (2 * h);
312 for (
unsigned int p = 0; p < points.size(); ++p)
313 for (
unsigned int i = 0; i < dim; ++i)
315 q2 = points[p] + ht[i];
317 q3 = points[p] - ht[i];
319 for (
unsigned int comp = 0; comp < this->
n_components; ++comp)
320 gradients[p][comp][i] =
321 (-this->value(q1, comp) + 8 * this->value(q2, comp) -
322 8 * this->value(q3, comp) + this->value(q4, comp)) /
359 DEAL_II_NAMESPACE_CLOSE
virtual void gradient_list(const std::vector< Point< dim >> &points, std::vector< Tensor< 1, dim >> &gradients, const unsigned int component=0) const override
static DifferenceFormula get_formula_of_order(const unsigned int ord)
void set_formula(const DifferenceFormula formula=Euler)
virtual void vector_gradient_list(const std::vector< Point< dim >> &points, std::vector< std::vector< Tensor< 1, dim >>> &gradients) const override
virtual void vector_gradient(const Point< dim > &p, std::vector< Tensor< 1, dim >> &gradients) const override
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void set_h(const double h)
AutoDerivativeFunction(const double h, const unsigned int n_components=1, const double initial_time=0.0)
static ::ExceptionBase & ExcNotImplemented()
unsigned int n_components(const DoFHandler< dim, spacedim > &dh)
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override