Skip to content
Snippets Groups Projects

Add generalized derivative and local-to-global adapter to handle the global derivatives uniformly

Merged Praetorius, Simon requested to merge feature/gridfunctions_localtoglobal_adaptor into master
4 unresolved threads
1 file
+ 0
35
Compare changes
  • Side-by-side
  • Inline
@@ -367,41 +367,6 @@ public:
return dy;
}
private:
template <class T, class J, class RG>
void test_partial(std::vector<T> const& partial, std::size_t comp, J const& jacobian, RG const& referenceGradients) const
{
for (std::size_t i = 0; i < referenceGradients.size(); ++i) { // J^(-T) * D[phi] -> grad^T
auto grad = jacobian * Dune::MatVec::as_vector(referenceGradients[i]);
auto grad_ = Dune::Functions::flatVectorView(grad);
if (std::abs(grad_[comp] - partial[i]) > 1.e-10) {
print_error(partial[i], comp, grad, jacobian, referenceGradients[i][0]);
error_exit("wrong partial derivatives");
}
}
}
template <class T, class G, class J, class RG>
void print_error(T const& partial_i, std::size_t comp, G const& grad_i, J const& jacobian, RG const& referenceGradient) const
{
msg(__PRETTY_FUNCTION__);
msg("jacobian = {}", jacobian);
auto&& jacobian_mat = Dune::MatVec::as_matrix(jacobian);
msg("jacobian_ = [");
for (std::size_t i = 0; i < jacobian_mat.N(); ++i) {
for (std::size_t j = 0; j < jacobian_mat.M(); ++j) {
msg_("{} ",jacobian_mat[i][j]);
}
msg(";");
}
msg("]");
msg("ref-grad = {}", referenceGradient);
auto grad_ = Dune::Functions::flatVectorView(grad_i);
msg("comp = {}, grad_ = ({}, {}), partial = {}", comp, grad_[0], grad_[1], partial_i);
}
};
Loading