106 template <
class InputVector,
int spacedim>
109 const InputVector & solution,
110 const unsigned int component);
136 template <
class InputVector,
int spacedim>
140 const InputVector & solution,
141 const unsigned int component)
145 std::vector<typename InputVector::value_type> values(1);
151 std::vector<Vector<typename InputVector::value_type>> values(
156 return values[0](component);
167 for (
unsigned int i = 0; i < dim; ++i)
217 template <
class InputVector,
int spacedim>
220 const InputVector & solution,
221 const unsigned int component);
251 template <
class InputVector,
int spacedim>
255 const InputVector & solution,
256 const unsigned int component)
260 std::vector<Tensor<1, dim, typename InputVector::value_type>> values(
268 std::vector<Tensor<1, dim, typename InputVector::value_type>>>
284 return std::fabs(d[0][0]);
301 const double radicand =
302 ::sqr(d[0][0] - d[1][1]) + 4 * ::sqr(d[0][1]);
304 0.5 * (d[0][0] + d[1][1] +
std::sqrt(radicand)),
305 0.5 * (d[0][0] + d[1][1] -
std::sqrt(radicand))};
425 const double am =
trace(d) / 3.;
429 for (
unsigned int i = 0; i < 3; ++i)
432 const double ss01 = s[0][1] * s[0][1], ss12 = s[1][2] * s[1][2],
433 ss02 = s[0][2] * s[0][2];
435 const double J2 = (s[0][0] * s[0][0] + s[1][1] * s[1][1] +
436 s[2][2] * s[2][2] + 2 * (ss01 + ss02 + ss12)) /
440 3. * s[0][0] * (ss01 + ss02) + 3. * s[1][1] * (ss01 + ss12) +
441 3. * s[2][2] * (ss02 + ss12) + 6. * s[0][1] * s[0][2] * s[1][2]) /
444 const double R =
std::sqrt(4. * J2 / 3.);
446 double EE[3] = {0, 0, 0};
453 if (R <= 1e-14 * std::fabs(am))
454 EE[0] = EE[1] = EE[2] = am;
459 const double R3 = R * R * R;
460 const double XX = 4. * J3 / R3;
461 const double YY = 1. - std::fabs(XX);
468 const double a = (XX > 0 ? -1. : 1.) * R / 2;
469 EE[0] = EE[1] = am + a;
474 const double theta = std::acos(XX) / 3.;
482 std::max(std::fabs(EE[1]), std::fabs(EE[2])));
515 for (
unsigned int i = 0; i < dim; ++i)
516 for (
unsigned int j = i + 1; j < dim; ++j)
518 const double s = (d[i][j] + d[j][i]) / 2;
519 d[i][j] = d[j][i] = s;
554 template <
class InputVector,
int spacedim>
557 const InputVector & solution,
558 const unsigned int component);
588 template <
class InputVector,
int spacedim>
592 const InputVector & solution,
593 const unsigned int component)
597 std::vector<Tensor<2, dim, typename InputVector::value_type>> values(
605 std::vector<Tensor<2, dim, typename InputVector::value_type>>>
621 return std::fabs(d[0][0][0]);
645 for (
unsigned int i = 0; i < dim; ++i)
646 for (
unsigned int j = i + 1; j < dim; ++j)
647 for (
unsigned int k = j + 1; k < dim; ++k)
649 const double s = (d[i][j][k] + d[i][k][j] + d[j][i][k] +
650 d[j][k][i] + d[k][i][j] + d[k][j][i]) /
652 d[i][j][k] = d[i][k][j] = d[j][i][k] = d[j][k][i] = d[k][i][j] =
657 for (
unsigned int i = 0; i < dim; ++i)
658 for (
unsigned int j = i + 1; j < dim; ++j)
662 const double s = (d[i][i][j] + d[i][j][i] + d[j][i][i]) / 3;
663 d[i][i][j] = d[i][j][i] = d[j][i][i] = s;
667 const double t = (d[i][j][j] + d[j][i][j] + d[j][j][i]) / 3;
668 d[i][j][j] = d[j][i][j] = d[j][j][i] = t;
673 template <
int order,
int dim>
738 template <
class DerivativeDescription,
746 const InputVector & solution,
747 const unsigned int component,
749 typename DerivativeDescription::Derivative &derivative)
779 std::vector<typename DoFHandler<dim, spacedim>::active_cell_iterator>
789 typename DerivativeDescription::Derivative projected_derivative;
792 x_fe_midpoint_value.
reinit(cell);
798 const typename DerivativeDescription::ProjectedDerivative
799 this_midpoint_value =
800 DerivativeDescription::get_projected_derivative(fe_midpoint_value,
822 GridTools::get_active_neighbors<DoFHandler<dim, spacedim>>(
823 cell, active_neighbors);
828 auto neighbor_ptr = active_neighbors.begin();
829 for (; neighbor_ptr != active_neighbors.end(); ++neighbor_ptr)
831 const auto neighbor = *neighbor_ptr;
834 x_fe_midpoint_value.
reinit(neighbor);
840 const typename DerivativeDescription::ProjectedDerivative
841 neighbor_midpoint_value =
842 DerivativeDescription::get_projected_derivative(
843 neighbor_fe_midpoint_value, solution, component);
857 const double distance = y.
norm();
871 for (
unsigned int i = 0; i < dim; ++i)
872 for (
unsigned int j = 0; j < dim; ++j)
873 Y[i][j] += y[i] * y[j];
878 typename DerivativeDescription::ProjectedDerivative
879 projected_finite_difference =
880 (neighbor_midpoint_value - this_midpoint_value);
881 projected_finite_difference /= distance;
883 projected_derivative +=
outer_product(y, projected_finite_difference);
900 derivative = Y_inverse * projected_derivative;
903 DerivativeDescription::symmetrize(derivative);
913 template <
class DerivativeDescription,
924 const InputVector & solution,
925 const unsigned int component)
928 if (std::get<0>(*cell)->is_locally_owned() ==
false)
929 *std::get<1>(*cell) = 0;
932 typename DerivativeDescription::Derivative derivative;
935 approximate_cell<DerivativeDescription, dim, InputVector, spacedim>(
945 *std::get<1>(*cell) =
946 DerivativeDescription::derivative_norm(derivative);
961 template <
class DerivativeDescription,
968 const InputVector & solution,
969 const unsigned int component,
980 std::tuple<typename DoFHandler<dim, spacedim>::active_cell_iterator,
992 [&mapping, &dof_handler, &solution, component](
996 approximate<DerivativeDescription, dim, InputVector, spacedim>(
997 cell, mapping, dof_handler, solution, component);
999 std::function<void(internal::Assembler::CopyData const &)>(),
1013 template <
int dim,
class InputVector,
int spacedim>
1017 const InputVector & solution,
1019 const unsigned int component)
1021 internal::approximate_derivative<internal::Gradient<dim>, dim>(
1026 template <
int dim,
class InputVector,
int spacedim>
1029 const InputVector & solution,
1031 const unsigned int component)
1033 internal::approximate_derivative<internal::Gradient<dim>, dim>(
1042 template <
int dim,
class InputVector,
int spacedim>
1046 const InputVector & solution,
1048 const unsigned int component)
1050 internal::approximate_derivative<internal::SecondDerivative<dim>, dim>(
1055 template <
int dim,
class InputVector,
int spacedim>
1058 const InputVector & solution,
1060 const unsigned int component)
1062 internal::approximate_derivative<internal::SecondDerivative<dim>, dim>(
1071 template <
int dim,
int spacedim,
class InputVector,
int order>
1076 const InputVector & solution,
1084 const unsigned int component)
1088 mapping, dof, solution, component, cell, derivative);
1093 template <
int dim,
int spacedim,
class InputVector,
int order>
1097 const InputVector & solution,
1105 const unsigned int component)
1109 cell->reference_cell()
1110 .template get_default_linear_mapping<dim, spacedim>(),
1120 template <
int dim,
int order>
1132#include "derivative_approximation.inst"
static ProjectedDerivative get_projected_derivative(const FEValues< dim, spacedim > &fe_values, const InputVector &solution, const unsigned int component)
static const UpdateFlags update_flags
static void symmetrize(Derivative &derivative_tensor)
static double derivative_norm(const Derivative &d)
static const UpdateFlags update_flags
static ProjectedDerivative get_projected_derivative(const FEValues< dim, spacedim > &fe_values, const InputVector &solution, const unsigned int component)
static double derivative_norm(const Derivative &d)
static void symmetrize(Derivative &derivative_tensor)
static ProjectedDerivative get_projected_derivative(const FEValues< dim, spacedim > &fe_values, const InputVector &solution, const unsigned int component)
static double derivative_norm(const Derivative &d)
static const UpdateFlags update_flags
static void symmetrize(Derivative &derivative_tensor)
cell_iterator end() const
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) const
const hp::FECollection< dim, spacedim > & get_fe_collection() const
const Triangulation< dim, spacedim > & get_triangulation() const
active_cell_iterator begin_active(const unsigned int level=0) const
void get_function_values(const InputVector &fe_function, std::vector< typename InputVector::value_type > &values) const
void get_function_gradients(const InputVector &fe_function, std::vector< Tensor< 1, spacedim, typename InputVector::value_type > > &gradients) const
const Point< spacedim > & quadrature_point(const unsigned int q) const
void get_function_hessians(const InputVector &fe_function, std::vector< Tensor< 2, spacedim, typename InputVector::value_type > > &hessians) const
const FiniteElement< dim, spacedim > & get_fe() const
unsigned int n_components() const
Abstract base class for mapping classes.
numbers::NumberTraits< Number >::real_type norm() const
unsigned int n_active_cells() const
const FEValuesType & get_present_fe_values() const
void reinit(const TriaIterator< DoFCellAccessor< dim, spacedim, lda > > &cell, const unsigned int q_index=numbers::invalid_unsigned_int, const unsigned int mapping_index=numbers::invalid_unsigned_int, const unsigned int fe_index=numbers::invalid_unsigned_int)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
@ update_hessians
Second derivatives of shape functions.
@ update_values
Shape function values.
@ update_gradients
Shape function gradients.
@ update_quadrature_points
Transformed quadrature points.
static ::ExceptionBase & ExcInsufficientDirections()
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcVectorLengthVsNActiveCells(int arg1, int arg2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
#define AssertThrow(cond, exc)
typename ActiveSelector::active_cell_iterator active_cell_iterator
void approximate_derivative(const Mapping< dim, spacedim > &mapping, const DoFHandler< dim, spacedim > &dof_handler, const InputVector &solution, const unsigned int component, Vector< float > &derivative_norm)
void approximate_cell(const Mapping< dim, spacedim > &mapping, const DoFHandler< dim, spacedim > &dof_handler, const InputVector &solution, const unsigned int component, const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, typename DerivativeDescription::Derivative &derivative)
void approximate(SynchronousIterators< std::tuple< typename DoFHandler< dim, spacedim >::active_cell_iterator, Vector< float >::iterator > > const &cell, const Mapping< dim, spacedim > &mapping, const DoFHandler< dim, spacedim > &dof_handler, const InputVector &solution, const unsigned int component)
void approximate_gradient(const Mapping< dim, spacedim > &mapping, const DoFHandler< dim, spacedim > &dof, const InputVector &solution, Vector< float > &derivative_norm, const unsigned int component=0)
double derivative_norm(const Tensor< order, dim > &derivative)
void approximate_derivative_tensor(const Mapping< dim, spacedim > &mapping, const DoFHandler< dim, spacedim > &dof, const InputVector &solution, const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, Tensor< order, dim > &derivative, const unsigned int component=0)
void approximate_second_derivative(const Mapping< dim, spacedim > &mapping, const DoFHandler< dim, spacedim > &dof, const InputVector &solution, Vector< float > &derivative_norm, const unsigned int component=0)
void run(const std::vector< std::vector< Iterator > > &colored_iterators, Worker worker, Copier copier, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, const unsigned int queue_length=2 *MultithreadInfo::n_threads(), const unsigned int chunk_size=8)
static constexpr double PI
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > cos(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
constexpr Number determinant(const SymmetricTensor< 2, dim, Number > &)
constexpr SymmetricTensor< 2, dim, Number > invert(const SymmetricTensor< 2, dim, Number > &)
constexpr Number trace(const SymmetricTensor< 2, dim2, Number > &)
std::array< Number, 1 > eigenvalues(const SymmetricTensor< 2, 1, Number > &T)
constexpr SymmetricTensor< 4, dim, Number > outer_product(const SymmetricTensor< 2, dim, Number > &t1, const SymmetricTensor< 2, dim, Number > &t2)