Skip to content
Snippets Groups Projects
Forked from agnumpde / dune-tectonic
1118 commits behind the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
globalnonlinearity.hh 897 B
#ifndef DUNE_TECTONIC_GLOBAL_NONLINEARITY_HH
#define DUNE_TECTONIC_GLOBAL_NONLINEARITY_HH

#include <dune/common/fvector.hh>
#include <dune/common/shared_ptr.hh>
#include <dune/istl/bvector.hh>
#include <dune/istl/bcrsmatrix.hh>

#include "nicefunction.hh"
#include "localnonlinearity.hh"

namespace Dune {
template <int dim, class VectorType = BlockVector<FieldVector<double, dim>>,
          class MatrixType = BCRSMatrix<FieldMatrix<double, dim, dim>>>
class GlobalNonlinearity {
public:
  /*
    Return a restriction of the outer function to the i'th node.
  */
  virtual shared_ptr<LocalNonlinearity<dim> const> restriction(int i) const = 0;

  virtual void addHessian(const VectorType& v, MatrixType& hessian) const {
    // TODO: is this correct?
    for (size_t i = 0; i < v.size(); ++i) {
      auto res = restriction(i);
      res->addHessian(v[i], hessian[i][i]);
    }
  }
};
}
#endif