KASKADE 7 development version
|
Class that checks the derivatives of a functional at a linearization point. More...
#include <check_derivative.hh>
Class that checks the derivatives of a functional at a linearization point.
The analytic derivatives are compared with a finite difference approximation. Note that this just gives you a hint (but a good one if you don't use stupid parameters for the tolerance and the increment) about the correctness of your analytically calculated derivatives. Keep in mind that it is a heuristic.
checkD1 | enable/disable check of first derivative (i.e. disable it if d0() has not been implemented correctly in boundary or domain cache (optional, default=true(enabled)) |
SparseInt | integer type used for sparse matrix indices |
Definition at line 407 of file check_derivative.hh.
Public Types | |
enum | { idOfFirstBlock = 0 , idOfLastBlock = boost::mpl::size<typename Functional::AnsatzVars::Variables>::type::value } |
typedef Functional::Scalar | Scalar |
Public Member Functions | |
DerivativeChecker (Assembler &assembler_, Functional const &f_, EvaluationPoint const &x_, VariableSet const &variableSet_, Scalar const tol=1.0e-6, Scalar const incr=1.0e-9) | |
Constructor. More... | |
void | checkFirstDerivative () |
Check first derivative. More... | |
void | checkSecondDerivative () |
Check second derivative. More... | |
bool | firstDerivativeOk () const |
bool | secondDerivativeOk () const |
void | setTolerance (Scalar const tol) |
Only errors below tolerance will be displayed. More... | |
void | setIncrement (Scalar const incr) |
Set increment for finite differences. More... | |
void | printD1Error () const |
print error in first derivative (only values below tolerance) More... | |
void | printFullD1Error () const |
print error in first derivative More... | |
void | printD2Error () const |
print error in second derivative (only values below tolerance) More... | |
void | printFullD2Error () const |
print error in second derivative More... | |
void | d2ToVTK () |
write d2 to .vtu file More... | |
void | d1ErrorToVTK (int const steps) const |
write error in first derivative to .vtu file More... | |
template<class Vector > | |
void | vectorToVTK (Vector &vector, int const steps=0) const |
write Vector vector to .vtu file More... | |
void | d2ErrorToVTK (int const steps) const |
write error in second derivative to .vtu-file More... | |
void | matrixToVTK (MatrixAsTriplet< Scalar, SparseInt > const &matrix, int const steps=0) const |
write, possibly sparse, matrix in triplet format to .vtu-file More... | |
typedef Functional::Scalar Kaskade::DerivativeChecker< Functional, checkD1, SparseInt >::Scalar |
Definition at line 416 of file check_derivative.hh.
anonymous enum |
Enumerator | |
---|---|
idOfFirstBlock | |
idOfLastBlock |
Definition at line 417 of file check_derivative.hh.
|
inline |
Constructor.
functional | instance of the Functional |
x_ | linearization point |
t | error tolerance (point-wise, default=1.0e-6) |
incr | increment for finite differences (default=1.0e-9) |
Definition at line 427 of file check_derivative.hh.
|
inline |
Check first derivative.
This function is called by the constructor. You only need to call this function if you have changed the tolerance.
Definition at line 440 of file check_derivative.hh.
Referenced by Kaskade::DerivativeChecker< Functional, checkD1, SparseInt >::DerivativeChecker().
|
inline |
Check second derivative.
This function is called by the constructor. You only need to call this function if you have changed the tolerance.
Definition at line 497 of file check_derivative.hh.
Referenced by Kaskade::DerivativeChecker< Functional, checkD1, SparseInt >::DerivativeChecker().
|
inline |
write error in first derivative to .vtu file
Definition at line 629 of file check_derivative.hh.
|
inline |
write error in second derivative to .vtu-file
Definition at line 710 of file check_derivative.hh.
|
inline |
write d2 to .vtu file
Definition at line 620 of file check_derivative.hh.
|
inline |
Definition at line 553 of file check_derivative.hh.
|
inline |
write, possibly sparse, matrix in triplet format to .vtu-file
store index pairs
Definition at line 716 of file check_derivative.hh.
Referenced by Kaskade::DerivativeChecker< Functional, checkD1, SparseInt >::d2ErrorToVTK(), and Kaskade::DerivativeChecker< Functional, checkD1, SparseInt >::d2ToVTK().
|
inline |
print error in first derivative (only values below tolerance)
Definition at line 591 of file check_derivative.hh.
|
inline |
print error in second derivative (only values below tolerance)
Definition at line 606 of file check_derivative.hh.
|
inline |
print error in first derivative
Definition at line 600 of file check_derivative.hh.
|
inline |
print error in second derivative
Definition at line 613 of file check_derivative.hh.
|
inline |
Definition at line 555 of file check_derivative.hh.
|
inline |
Set increment for finite differences.
Definition at line 588 of file check_derivative.hh.
|
inline |
Only errors below tolerance will be displayed.
Definition at line 585 of file check_derivative.hh.
|
inline |
write Vector vector to .vtu file
Vector must provide the function size() and operator[](size_type n)
Definition at line 639 of file check_derivative.hh.
Referenced by Kaskade::DerivativeChecker< Functional, checkD1, SparseInt >::d1ErrorToVTK().