18#ifndef LIBMESH_FDM_GRADIENT_H
19#define LIBMESH_FDM_GRADIENT_H
22#include "libmesh/fem_function_base.h"
23#include "libmesh/libmesh_common.h"
24#include "libmesh/tensor_tools.h"
29template <
typename GradType>
43 virtual std::unique_ptr<FEMFunctionBase<GradType>>
clone ()
const override
44 {
return std::make_unique<FDMGradient<GradType>>(*
_val_func,
_eps); }
48 const Real time = 0.)
override
57 val(c, p+
Point(-
_eps), time)) * one_over_dim;
60 val(c, p+
Point(0,-
_eps), time)) * one_over_dim;
64 val(c, p+
Point(0,0,-
_eps), time)) * one_over_dim;
75 auto sz = output.
size();
111 output(i)(2) -= v(i);
129 g(0) = (val.component(c, i, p+
Point(
_eps), time) -
130 val.component(c, i, p+
Point(-
_eps), time)) * one_over_dim;
132 g(1) = (val.component(c, i, p+
Point(0,
_eps), time) -
133 val.component(c, i, p+
Point(0,-
_eps), time)) * one_over_dim;
136 g(2) = (val.component(c, i, p+
Point(0,0,
_eps), time) -
137 val.component(c, i, p+
Point(0,0,-
_eps), time)) * one_over_dim;
Defines a dense vector for use in Finite Element-type computations.
virtual unsigned int size() const override final
virtual void init_context(const FEMContext &c) override
Prepares a context object for use.
FDMGradient(FEMFunctionBase< ValType > &value_func, Real eps)
virtual GradType operator()(const FEMContext &c, const Point &p, const Real time=0.) override
TensorTools::DecrementRank< GradType >::type ValType
std::unique_ptr< FEMFunctionBase< ValType > > _val_func
virtual std::unique_ptr< FEMFunctionBase< GradType > > clone() const override
virtual GradType component(const FEMContext &c, unsigned int i, const Point &p, Real time) override
This class provides all data required for a physics package (e.g.
FEMFunctionBase is a base class from which users can derive in order to define "function-like" object...
A Point defines a location in LIBMESH_DIM dimensional Real space.
The libMesh namespace provides an interface to certain functionality in the library.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...