<commit_before>// dune-multiscale
// Copyright Holders: <NAME>, <NAME>
// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)

#ifndef DUNE_MS_PROBLEMS_BASE_HH
#define DUNE_MS_PROBLEMS_BASE_HH

#include <config.h>
#include <string>
#include <dune/multiscale/problems/constants.hh>
#include <dune/multiscale/common/traits.hh>
#include <dune/multiscale/msfem/msfem_traits.hh>
#include <dune/stuff/fem/functions/analytical.hh>
#include <dune/stuff/functions/interfaces.hh>
#include <dune/stuff/grid/boundaryinfo.hh>
#include <dune/stuff/common/memory.hh>

namespace Dune {
namespace Multiscale {
namespace Problem {



struct DiffusionBase {

  typedef Dune::Multiscale::CommonTraits::FunctionSpaceType FunctionSpaceType;
  typedef typename FunctionSpaceType::DomainType        DomainType;
  typedef typename FunctionSpaceType::RangeType         RangeType;
  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;

  //! in the linear setting, use the structure
  //! A^{\epsilon}_i(x,\xi) = A^{\epsilon}_{i1}(x) \xi_1 + A^{\epsilon}_{i2}(x) \xi_2
  //! (diffusive) flux = A^{\epsilon}( x , direction )
  //! (typically direction is some 'gradient_of_a_function')
  virtual void diffusiveFlux(const DomainType& x,
                     const JacobianRangeType& direction,
                     JacobianRangeType& flux) const = 0;

  //! the jacobian matrix (JA^{\epsilon}) of the diffusion operator A^{\epsilon} at the position "\nabla v" in direction
  //! "nabla w", i.e.
  //! jacobian diffusiv flux = JA^{\epsilon}(\nabla v) nabla w:
  //! jacobianDiffusiveFlux = A^{\epsilon}( x , position_gradient ) direction_gradient
  virtual void jacobianDiffusiveFlux(const DomainType& x,
                             const JacobianRangeType& /*position_gradient*/,
                             const JacobianRangeType& direction_gradient,
                             JacobianRangeType& flux) const = 0;
};

struct LowerOrderBase : public Dune::Multiscale::CommonTraits::FunctionBaseType
{
  typedef Dune::Multiscale::CommonTraits::FunctionSpaceType FunctionSpaceType;
  typedef typename FunctionSpaceType::DomainType        DomainType;
  typedef typename FunctionSpaceType::RangeType         RangeType;
  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
  typedef double TimeType;

  virtual void evaluate(const DomainType& x, const TimeType& time, RangeType& y) const = 0;
  virtual void evaluate(const DomainType& x, const RangeType& position, const JacobianRangeType& direction_gradient, RangeType& y) const = 0;
  virtual void position_derivative(const DomainType& x, const RangeType& position, const JacobianRangeType& direction_gradient, RangeType& y) const = 0;
  virtual void direction_derivative(const DomainType& x, const RangeType& position, const JacobianRangeType& direction_gradient, JacobianRangeType& y) const = 0;
};

struct ZeroLowerOrder : public LowerOrderBase
{
  typedef Dune::Multiscale::CommonTraits::FunctionSpaceType FunctionSpaceType;
  typedef typename FunctionSpaceType::DomainType        DomainType;
  typedef typename FunctionSpaceType::RangeType         RangeType;
  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
  typedef double TimeType;

  virtual void evaluate(const DomainType&, RangeType& y) const { y = RangeType(0); }
  virtual void evaluate(const DomainType&, const TimeType&, RangeType& y) const { y = RangeType(0); }
  virtual void evaluate(const DomainType&, const RangeType&, const JacobianRangeType&, RangeType& y) const { y = RangeType(0); }
  virtual void position_derivative(const DomainType&, const RangeType&, const JacobianRangeType&, RangeType& y) const { y = RangeType(0); }
  virtual void direction_derivative(const DomainType&, const RangeType&, const JacobianRangeType&, JacobianRangeType& y) const { y = JacobianRangeType(0); }
};

class DirichletDataBase : public Dune::Multiscale::CommonTraits::FunctionBaseType
{
public:
  typedef Dune::Multiscale::CommonTraits::FunctionSpaceType FunctionSpaceType;
  typedef typename FunctionSpaceType::DomainType DomainType;
  typedef typename FunctionSpaceType::RangeType  RangeType;
  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
  typedef DomainFieldType TimeType;

  virtual void evaluate(const DomainType& x, RangeType& y) const = 0;
  virtual void evaluate(const DomainType& x, const TimeType& /*time*/, RangeType& y) const = 0;

  virtual void jacobian(const DomainType& x, JacobianRangeType& y) const = 0;
  virtual void jacobian(const DomainType& x, const TimeType& /*time*/, JacobianRangeType& y) const = 0;
};

class ZeroDirichletData : public DirichletDataBase
{
public:
  typedef Dune::Multiscale::CommonTraits::FunctionSpaceType FunctionSpaceType;
  typedef typename FunctionSpaceType::DomainType DomainType;
  typedef typename FunctionSpaceType::RangeType  RangeType;
  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
  typedef DomainFieldType TimeType;

  virtual void evaluate(const DomainType& x, RangeType& y) const { y = RangeType(0.0); }
  virtual void evaluate(const DomainType& x, const TimeType& /*time*/, RangeType& y) const { y = RangeType(0.0); }

  virtual void jacobian(const DomainType& x, JacobianRangeType& y) const { y = JacobianRangeType(0.0); }
  virtual void jacobian(const DomainType& x, const TimeType& /*time*/, JacobianRangeType& y) const { y = JacobianRangeType(0.0); }
};

class NeumannDataBase : public Dune::Multiscale::CommonTraits::FunctionBaseType
{
public:
  typedef Dune::Multiscale::CommonTraits::FunctionSpaceType FunctionSpaceType;
  typedef typename FunctionSpaceType::DomainType DomainType;
  typedef typename FunctionSpaceType::RangeType  RangeType;
  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
  typedef DomainFieldType TimeType;

  virtual void evaluate(const DomainType& x, RangeType& y) const = 0;
  virtual void evaluate(const DomainType& x, const TimeType& /*time*/, RangeType& y) const = 0;
};

class ZeroNeumannData: public NeumannDataBase
{<commit_msg>Remove jacobians from dirichlet data<commit_after>// dune-multiscale
// Copyright Holders: <NAME>, <NAME>
// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)

#ifndef DUNE_MS_PROBLEMS_BASE_HH
#define DUNE_MS_PROBLEMS_BASE_HH

#include <config.h>
#include <string>
#include <dune/multiscale/problems/constants.hh>
#include <dune/multiscale/common/traits.hh>
#include <dune/multiscale/msfem/msfem_traits.hh>
#include <dune/stuff/fem/functions/analytical.hh>
#include <dune/stuff/functions/interfaces.hh>
#include <dune/stuff/grid/boundaryinfo.hh>
#include <dune/stuff/common/memory.hh>

namespace Dune {
namespace Multiscale {
namespace Problem {



struct DiffusionBase {

  typedef Dune::Multiscale::CommonTraits::FunctionSpaceType FunctionSpaceType;
  typedef typename FunctionSpaceType::DomainType        DomainType;
  typedef typename FunctionSpaceType::RangeType         RangeType;
  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;

  //! in the linear setting, use the structure
  //! A^{\epsilon}_i(x,\xi) = A^{\epsilon}_{i1}(x) \xi_1 + A^{\epsilon}_{i2}(x) \xi_2
  //! (diffusive) flux = A^{\epsilon}( x , direction )
  //! (typically direction is some 'gradient_of_a_function')
  virtual void diffusiveFlux(const DomainType& x,
                     const JacobianRangeType& direction,
                     JacobianRangeType& flux) const = 0;

  //! the jacobian matrix (JA^{\epsilon}) of the diffusion operator A^{\epsilon} at the position "\nabla v" in direction
  //! "nabla w", i.e.
  //! jacobian diffusiv flux = JA^{\epsilon}(\nabla v) nabla w:
  //! jacobianDiffusiveFlux = A^{\epsilon}( x , position_gradient ) direction_gradient
  virtual void jacobianDiffusiveFlux(const DomainType& x,
                             const JacobianRangeType& /*position_gradient*/,
                             const JacobianRangeType& direction_gradient,
                             JacobianRangeType& flux) const = 0;
};

struct LowerOrderBase : public Dune::Multiscale::CommonTraits::FunctionBaseType
{
  typedef Dune::Multiscale::CommonTraits::FunctionSpaceType FunctionSpaceType;
  typedef typename FunctionSpaceType::DomainType        DomainType;
  typedef typename FunctionSpaceType::RangeType         RangeType;
  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
  typedef double TimeType;

  virtual void evaluate(const DomainType& x, const TimeType& time, RangeType& y) const = 0;
  virtual void evaluate(const DomainType& x, const RangeType& position, const JacobianRangeType& direction_gradient, RangeType& y) const = 0;
  virtual void position_derivative(const DomainType& x, const RangeType& position, const JacobianRangeType& direction_gradient, RangeType& y) const = 0;
  virtual void direction_derivative(const DomainType& x, const RangeType& position, const JacobianRangeType& direction_gradient, JacobianRangeType& y) const = 0;
};

struct ZeroLowerOrder : public LowerOrderBase
{
  typedef Dune::Multiscale::CommonTraits::FunctionSpaceType FunctionSpaceType;
  typedef typename FunctionSpaceType::DomainType        DomainType;
  typedef typename FunctionSpaceType::RangeType         RangeType;
  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
  typedef double TimeType;

  virtual void evaluate(const DomainType&, RangeType& y) const { y = RangeType(0); }
  virtual void evaluate(const DomainType&, const TimeType&, RangeType& y) const { y = RangeType(0); }
  virtual void evaluate(const DomainType&, const RangeType&, const JacobianRangeType&, RangeType& y) const { y = RangeType(0); }
  virtual void position_derivative(const DomainType&, const RangeType&, const JacobianRangeType&, RangeType& y) const { y = RangeType(0); }
  virtual void direction_derivative(const DomainType&, const RangeType&, const JacobianRangeType&, JacobianRangeType& y) const { y = JacobianRangeType(0); }
};

class DirichletDataBase : public Dune::Multiscale::CommonTraits::FunctionBaseType
{
public:
  typedef Dune::Multiscale::CommonTraits::FunctionSpaceType FunctionSpaceType;
  typedef typename FunctionSpaceType::DomainType DomainType;
  typedef typename FunctionSpaceType::RangeType  RangeType;
  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
  typedef DomainFieldType TimeType;

  virtual void evaluate(const DomainType& x, RangeType& y) const = 0;
  virtual void evaluate(const DomainType& x, const TimeType& /*time*/, RangeType& y) const = 0;
};

class ZeroDirichletData : public DirichletDataBase
{
public:
  typedef Dune::Multiscale::CommonTraits::FunctionSpaceType FunctionSpaceType;
  typedef typename FunctionSpaceType::DomainType DomainType;
  typedef typename FunctionSpaceType::RangeType  RangeType;
  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
  typedef DomainFieldType TimeType;

  virtual void evaluate(const DomainType& x, RangeType& y) const { y = RangeType(0.0); }
  virtual void evaluate(const DomainType& x, const TimeType& /*time*/, RangeType& y) const { y = RangeType(0.0); }
};

class NeumannDataBase : public Dune::Multiscale::CommonTraits::FunctionBaseType
{
public:
  typedef Dune::Multiscale::CommonTraits::FunctionSpaceType FunctionSpaceType;
  typedef typename FunctionSpaceType::DomainType DomainType;
  typedef typename FunctionSpaceType::RangeType  RangeType;
  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
  typedef DomainFieldType TimeType;

  virtual void evaluate(const DomainType& x, RangeType& y) const = 0;
  virtual void evaluate(const DomainType& x, const TimeType& /*time*/, RangeType& y) const = 0;
};

class ZeroNeumannData: public NeumannDataBase
{
{'fraction_non_alphanumeric': 0.09674402788404318, 'fraction_numerical': 0.004760690300093514, 'mean_word_length': 5.314546430488459, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2468513', 'n_tokens_mistral': 3552, 'n_tokens_neox': 3338, 'n_words': 916}