16 #include <deal.II/base/point.h> 17 #include <deal.II/base/function_derivative.h> 18 #include <deal.II/lac/vector.h> 22 DEAL_II_NAMESPACE_OPEN
49 for (
unsigned int i=0; i<
incr.size (); ++i)
69 for (
unsigned int i=0; i<
incr.size (); ++i)
79 const unsigned int component)
const 82 ExcMessage (
"FunctionDerivative was not initialized for constant direction"));
94 Assert(
false, ExcInvalidFormula());
108 ExcMessage (
"FunctionDerivative was not initialized for constant direction"));
119 result.
sadd(1./(2*
h), -1./(2*
h), aux);
124 result.
sadd(1./
h, -1./
h, aux);
129 result.
add(-1., aux);
131 result.
add(-8., aux);
137 Assert(
false, ExcInvalidFormula());
146 std::vector<double> &values,
147 const unsigned int component)
const 149 const unsigned int n = points.size();
150 const bool variable_direction = (
incr.size() == 1) ?
false :
true;
151 if (variable_direction)
153 ExcDimensionMismatch(
incr.size(), points.size()));
156 std::vector<double> aux(n);
158 std::vector<Point<dim> > paux(n);
165 for (
unsigned int i=0; i<n; ++i)
166 paux[i] = points[i]+
incr[(variable_direction) ? i : 0U];
168 for (
unsigned int i=0; i<n; ++i)
169 paux[i] = points[i]-
incr[(variable_direction) ? i : 0U];
171 for (
unsigned int i=0; i<n; ++i)
172 values[i] = (values[i]-aux[i])/(2*
h);
176 for (
unsigned int i=0; i<n; ++i)
177 paux[i] = points[i]-
incr[(variable_direction) ? i : 0U];
179 for (
unsigned int i=0; i<n; ++i)
180 values[i] = (values[i]-aux[i])/
h;
183 for (
unsigned int i=0; i<n; ++i)
184 paux[i] = points[i]-2*
incr[(variable_direction) ? i : 0U];
186 for (
unsigned int i=0; i<n; ++i)
187 paux[i] = points[i]+2*
incr[(variable_direction) ? i : 0U];
189 for (
unsigned int i=0; i<n; ++i)
191 for (
unsigned int i=0; i<n; ++i)
192 paux[i] = points[i]+
incr[(variable_direction) ? i : 0U];
194 for (
unsigned int i=0; i<n; ++i)
195 values[i] += 8.*aux[i];
196 for (
unsigned int i=0; i<n; ++i)
197 paux[i] = points[i]-
incr[(variable_direction) ? i : 0U];
199 for (
unsigned int i=0; i<n; ++i)
200 values[i] = (values[i] - 8.*aux[i])/(12*
h);
203 Assert(
false, ExcInvalidFormula());
215 return sizeof (*this);
225 DEAL_II_NAMESPACE_CLOSE
void sadd(const Number s, const Vector< Number > &V)
virtual double value(const Point< dim > &p, const unsigned int component=0) const
::ExceptionBase & ExcMessage(std::string arg1)
virtual void value_list(const std::vector< Point< dim > > &points, std::vector< double > &values, const unsigned int component=0) const
void set_formula(typename AutoDerivativeFunction< dim >::DifferenceFormula formula=AutoDerivativeFunction< dim >::Euler)
const unsigned int n_components
void add(const std::vector< size_type > &indices, const std::vector< OtherNumber > &values)
#define Assert(cond, exc)
std::size_t memory_consumption() const
FunctionDerivative(const Function< dim > &f, const Point< dim > &direction, const double h=1.e-6)
const Function< dim > & f
AutoDerivativeFunction< dim >::DifferenceFormula formula
virtual Number value(const Point< dim > &p, const unsigned int component=0) const
virtual void vector_value(const Point< dim > &p, Vector< double > &value) const
virtual void value_list(const std::vector< Point< dim > > &points, std::vector< Number > &values, const unsigned int component=0) const
std::vector< Tensor< 1, dim > > incr
unsigned int n_components(const DoFHandler< dim, spacedim > &dh)
virtual void vector_value(const Point< dim > &p, Vector< Number > &values) const
void set_h(const double h)