Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
myconvexproblem.hh 1.23 KiB
// Based on dune/tnnmg/problem-classes/convexproblem.hh
// Allows phi to be const; does away with everything we do not need

#ifndef MY_CONVEX_PROBLEM_HH
#define MY_CONVEX_PROBLEM_HH

// Just for debugging
#include "dune/solvers/computeenergy.hh"

#include "globalnonlinearity.hh"

template <class MatrixTypeTEMPLATE, class VectorTypeTEMPLATE>
class MyConvexProblem {
public:
  using VectorType = VectorTypeTEMPLATE;
  using MatrixType = MatrixTypeTEMPLATE;
  using LocalVectorType = typename VectorType::block_type;
  using LocalMatrixType = typename MatrixType::block_type;

  int static const block_size = VectorType::block_type::dimension;

  /** \brief Constructor with the problem components

      \param A The matrix of the quadratic part
      \param f The linear functional
      \param u The solution vector
  */
  MyConvexProblem(MatrixType const &A,
                  Dune::GlobalNonlinearity<MatrixType, VectorType> const &phi,
                  VectorType const &f)
      : A(A), phi(phi), f(f) {}

  /* Just for debugging */
  double operator()(VectorType const &x) const {
    return phi(x) + computeEnergy(A, x, f);
  }

  MatrixType const &A;
  Dune::GlobalNonlinearity<MatrixType, VectorType> const &phi;
  VectorType const &f;
};

#endif