16 #include <deal.II/base/point.h> 17 #include <deal.II/base/auto_derivative_function.h> 18 #include <deal.II/lac/vector.h> 22 DEAL_II_NAMESPACE_OPEN
28 const double initial_time)
55 "match any known difference formula."));
67 for (
unsigned int i=0; i<dim; ++i)
75 const unsigned int comp)
const 83 for (
unsigned int i=0; i<dim; ++i)
86 grad[i]=(this->value(p, comp)-this->value(q1, comp))/h;
93 for (
unsigned int i=0; i<dim; ++i)
97 grad[i]=(this->value(q1, comp)-this->value(q2, comp))/(2*h);
104 for (
unsigned int i=0; i<dim; ++i)
110 grad[i]=(- this->value(q1, comp)
111 +8*this->value(q2, comp)
112 -8*this->value(q3, comp)
113 + this->value(q4, comp))/(12*h);
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;
177 const double h_inv_12=1./(12*h);
178 for (
unsigned int i=0; i<dim; ++i)
184 this->vector_value(q1, v1);
185 this->vector_value(q2, v2);
186 this->vector_value(q3, v3);
187 this->vector_value(q4, v4);
189 for (
unsigned int comp=0; comp<this->
n_components; ++comp)
190 gradients[comp][i]=(-v1(comp)+8*v2(comp)-8*v3(comp)+v4(comp))*h_inv_12;
206 const unsigned int comp)
const 208 Assert (gradients.size() == points.size(),
216 for (
unsigned int p=0; p<points.size(); ++p)
217 for (
unsigned int i=0; i<dim; ++i)
220 gradients[p][i]=(this->value(points[p], comp)-this->value(q1, comp))/h;
228 for (
unsigned int p=0; p<points.size(); ++p)
229 for (
unsigned int i=0; i<dim; ++i)
233 gradients[p][i]=(this->value(q1, comp)-this->value(q2, comp))/(2*h);
241 for (
unsigned int p=0; p<points.size(); ++p)
242 for (
unsigned int i=0; i<dim; ++i)
248 gradients[p][i]=(- this->value(q1, comp)
249 +8*this->value(q2, comp)
250 -8*this->value(q3, comp)
251 + this->value(q4, comp))/(12*h);
269 Assert (gradients.size() == points.size(),
271 for (
unsigned int p=0; p<points.size(); ++p)
280 for (
unsigned int p=0; p<points.size(); ++p)
281 for (
unsigned int i=0; i<dim; ++i)
284 for (
unsigned int comp=0; comp<this->
n_components; ++comp)
285 gradients[p][comp][i]=(this->value(points[p], comp)-this->value(q1, comp))/h;
293 for (
unsigned int p=0; p<points.size(); ++p)
294 for (
unsigned int i=0; i<dim; ++i)
298 for (
unsigned int comp=0; comp<this->
n_components; ++comp)
299 gradients[p][comp][i]=(this->value(q1, comp) -
300 this->value(q2, comp))/(2*h);
308 for (
unsigned int p=0; p<points.size(); ++p)
309 for (
unsigned int i=0; i<dim; ++i)
315 for (
unsigned int comp=0; comp<this->
n_components; ++comp)
316 gradients[p][comp][i]=(- this->value(q1, comp)
317 +8*this->value(q2, comp)
318 -8*this->value(q3, comp)
319 + this->value(q4, comp))/(12*h);
355 DEAL_II_NAMESPACE_CLOSE
virtual void vector_gradient(const Point< dim > &p, std::vector< Tensor< 1, dim > > &gradients) const
static DifferenceFormula get_formula_of_order(const unsigned int ord)
virtual void gradient_list(const std::vector< Point< dim > > &points, std::vector< Tensor< 1, dim > > &gradients, const unsigned int component=0) const
void set_formula(const DifferenceFormula formula=Euler)
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)
virtual void vector_gradient_list(const std::vector< Point< dim > > &points, std::vector< std::vector< Tensor< 1, dim > > > &gradients) const
AutoDerivativeFunction(const double h, const unsigned int n_components=1, const double initial_time=0.0)
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const
static ::ExceptionBase & ExcNotImplemented()
unsigned int n_components(const DoFHandler< dim, spacedim > &dh)