48 for (
unsigned int i = 0; i <
incr.size(); ++i)
70 ExcMessage(
"The argument passed to this function does not "
71 "match any known difference formula."));
83 for (
unsigned int i = 0; i < incr.size(); ++i)
93 const unsigned int component)
const
97 "FunctionDerivative was not initialized for constant direction"));
102 return (f.value(p + incr[0], component) -
103 f.value(p - incr[0], component)) /
106 return (f.value(p, component) - f.value(p - incr[0], component)) / h;
108 return (-f.value(p + 2 * incr[0], component) +
109 8 * f.value(p + incr[0], component) -
110 8 * f.value(p - incr[0], component) +
111 f.value(p - 2 * incr[0], component)) /
128 "FunctionDerivative was not initialized for constant direction"));
138 f.vector_value(p - incr[0], aux);
139 result.sadd(1. / (2 * h), -1. / (2 * h), aux);
143 f.vector_value(p - incr[0], aux);
144 result.sadd(1. / h, -1. / h, aux);
148 f.vector_value(p + 2 * incr[0], aux);
150 f.vector_value(p - incr[0], aux);
152 f.vector_value(p + incr[0], aux);
166 std::vector<double> & values,
167 const unsigned int component)
const
169 const unsigned int n = points.
size();
172 Assert(incr.size() == points.size(),
176 std::vector<double> aux(n);
178 std::vector<Point<dim>>
paux(n);
185 for (
unsigned int i = 0; i < n; ++i)
187 f.value_list(
paux, values, component);
188 for (
unsigned int i = 0; i < n; ++i)
190 f.value_list(
paux, aux, component);
191 for (
unsigned int i = 0; i < n; ++i)
192 values[i] = (values[i] - aux[i]) / (2 * h);
196 for (
unsigned int i = 0; i < n; ++i)
198 f.value_list(
paux, aux, component);
199 for (
unsigned int i = 0; i < n; ++i)
200 values[i] = (values[i] - aux[i]) / h;
203 for (
unsigned int i = 0; i < n; ++i)
205 f.value_list(
paux, values, component);
206 for (
unsigned int i = 0; i < n; ++i)
208 f.value_list(
paux, aux, component);
209 for (
unsigned int i = 0; i < n; ++i)
211 for (
unsigned int i = 0; i < n; ++i)
213 f.value_list(
paux, aux, component);
214 for (
unsigned int i = 0; i < n; ++i)
215 values[i] += 8. * aux[i];
216 for (
unsigned int i = 0; i < n; ++i)
218 f.value_list(
paux, aux, component);
219 for (
unsigned int i = 0; i < n; ++i)
220 values[i] = (values[i] - 8. * aux[i]) / (12 * h);
235 return sizeof(*this);
virtual std::size_t memory_consumption() const override
virtual void vector_value(const Point< dim > &p, Vector< double > &value) const override
void set_h(const double h)
virtual void value_list(const std::vector< Point< dim > > &points, std::vector< double > &values, const unsigned int component=0) const override
FunctionDerivative(const Function< dim > &f, const Point< dim > &direction, const double h=1.e-6)
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
std::vector< Tensor< 1, dim > > incr
void set_formula(typename AutoDerivativeFunction< dim >::DifferenceFormula formula=AutoDerivativeFunction< dim >::Euler)
virtual void value_list(const std::vector< Point< dim > > &points, std::vector< RangeNumberType > &values, const unsigned int component=0) const
virtual void vector_value(const Point< dim > &p, Vector< RangeNumberType > &values) const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)