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);
149 result.
add(-1., aux);
150 f.vector_value(p - incr[0], aux);
151 result.
add(-8., 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();
170 const bool variable_direction = (incr.size() == 1) ?
false :
true;
171 if (variable_direction)
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)
186 paux[i] = points[i] + incr[(variable_direction) ? i : 0
U];
188 for (
unsigned int i = 0; i < n; ++i)
189 paux[i] = points[i] - incr[(variable_direction) ? i : 0
U];
190 f.value_list(paux, aux, component);
191 for (
unsigned int i = 0; i < n; ++i)
196 for (
unsigned int i = 0; i < n; ++i)
197 paux[i] = points[i] - incr[(variable_direction) ? i : 0
U];
198 f.value_list(paux, aux, component);
199 for (
unsigned int i = 0; i < n; ++i)
203 for (
unsigned int i = 0; i < n; ++i)
204 paux[i] = points[i] - 2 * incr[(variable_direction) ? i : 0
U];
206 for (
unsigned int i = 0; i < n; ++i)
207 paux[i] = points[i] + 2 * incr[(variable_direction) ? i : 0
U];
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)
212 paux[i] = points[i] + incr[(variable_direction) ? i : 0
U];
213 f.value_list(paux, aux, component);
214 for (
unsigned int i = 0; i < n; ++i)
216 for (
unsigned int i = 0; i < n; ++i)
217 paux[i] = points[i] - incr[(variable_direction) ? i : 0
U];
218 f.value_list(paux, aux, component);
219 for (
unsigned int i = 0; i < n; ++i)
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)
void add(const std::vector< size_type > &indices, const std::vector< OtherNumber > &values)
void sadd(const Number s, const Vector< Number > &V)