<commit_before>// This file is part of the dune-gdt project:
//   http://users.dune-project.org/projects/dune-gdt
// Copyright holders: <NAME>
// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)

#ifndef DUNE_GDT_TEST_PRODUCTS_SWIPDGPENALTY_HH
#define DUNE_GDT_TEST_PRODUCTS_SWIPDGPENALTY_HH

#include <dune/stuff/functions/checkerboard.hh>
#include <dune/stuff/functions/constant.hh>
#include <dune/stuff/functions/expression.hh>
#include <dune/stuff/functions/interfaces.hh>
#include <dune/stuff/la/container/common.hh>

#include <dune/gdt/discretefunction/default.hh>
#include <dune/gdt/operators/projections.hh>
#include <dune/gdt/localevaluation/swipdg.hh>
#include <dune/gdt/playground/products/swipdgpenalty.hh>

#include "products.hh"

using namespace Dune;
using namespace Dune::GDT;


template <class SpaceType>
struct SwipdgPenaltyProductBase : public ::testing::Test
{
  typedef typename SpaceType::GridViewType GridViewType;
  typedef typename GridViewType::Grid GridType;
  typedef Dune::Stuff::Grid::Providers::Cube<GridType> GridProviderType;
  typedef typename GridViewType::template Codim<0>::Entity EntityType;
  typedef typename SpaceType::DomainFieldType DomainFieldType;
  static const unsigned int dimDomain = SpaceType::dimDomain;
  typedef typename SpaceType::RangeFieldType RangeFieldType;
  static const unsigned int dimRange = SpaceType::dimRange;
  typedef Stuff::Functions::Expression<EntityType, DomainFieldType, dimDomain, RangeFieldType, dimRange> ScalarType;
  typedef Stuff::Functions::Constant<EntityType, DomainFieldType, dimDomain, RangeFieldType, dimDomain, dimDomain>
      TensorType;
  typedef Stuff::Functions::Checkerboard<EntityType, DomainFieldType, dimDomain, RangeFieldType, dimRange>
      JumpFunctionType;
  typedef Stuff::LocalizableFunctionInterface<EntityType, DomainFieldType, dimDomain, RangeFieldType, dimRange>
      FunctionType;

  static DSC::Configuration jump_config()
  {
    DSC::Configuration cfg = JumpFunctionType::default_config();
    cfg["num_elements"]    = "[2 1 1]";
    cfg["values"]          = "[0 1]";
    return cfg;
  }

  SwipdgPenaltyProductBase()
    : grid_provider_(0.0, 1.0, 2u)
    , space_(grid_provider_.template leaf<SpaceType::part_view_type>())
    , one_("x", "1", 0)
    , unit_matrix_(Stuff::Functions::internal::unit_matrix<RangeFieldType, dimDomain>())
    , continuous_("x", "x[0] - 1", 1)
    , jump_(JumpFunctionType::create(jump_config()))
  {
  }

  virtual RangeFieldType compute(const FunctionType& function) const = 0;

  void continuous_arguments() const
  {
    // there is no jump in the middle, but at the left boundary we are not zero
    // the 1 is the order of continuous_
    check(compute(continuous_), LocalEvaluation::SWIPDG::internal::boundary_sigma(1), 1e-13);
  }

  void discontinuous_arguments() const
  {
    // there is a jump in the middle and at the right boundary we are not zero
    // the 0 is the order of *jump_
    // *0.5 because the value of *jump_ is 0 left and 1 right
    check(compute(*jump_),
          0.5 * LocalEvaluation::SWIPDG::internal::inner_sigma(0)
              + LocalEvaluation::SWIPDG::internal::boundary_sigma(0));
  }

  void check(const RangeFieldType& result, const RangeFieldType& expected, const RangeFieldType epsilon = 1e-14) const
  {
    const auto error = std::abs(expected - result);
    EXPECT_LE(error, epsilon) << "result:   " << result << "\n"
                              << "expected: " << expected << "\n"
                              << "difference: " << std::scientific << error;
  } // ... check(...)

  GridProviderType grid_provider_;
  const SpaceType space_;
  const ScalarType one_;
  const TensorType unit_matrix_;
  const ScalarType continuous_;
  const std::unique_ptr<const JumpFunctionType> jump_;
}; // struct SwipdgPenaltyProductBase


template <class SpaceType>
struct SwipdgPenaltyLocalizableProduct : public SwipdgPenaltyProductBase<SpaceType>
{
  typedef SwipdgPenaltyProductBase<SpaceType> BaseType;<commit_msg>[test.products_swipdgpenalty] update sigma<commit_after>// This file is part of the dune-gdt project:
//   http://users.dune-project.org/projects/dune-gdt
// Copyright holders: <NAME>
// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)

#ifndef DUNE_GDT_TEST_PRODUCTS_SWIPDGPENALTY_HH
#define DUNE_GDT_TEST_PRODUCTS_SWIPDGPENALTY_HH

#include <dune/stuff/functions/checkerboard.hh>
#include <dune/stuff/functions/constant.hh>
#include <dune/stuff/functions/expression.hh>
#include <dune/stuff/functions/interfaces.hh>
#include <dune/stuff/la/container/common.hh>

#include <dune/gdt/discretefunction/default.hh>
#include <dune/gdt/operators/projections.hh>
#include <dune/gdt/localevaluation/swipdg.hh>
#include <dune/gdt/playground/products/swipdgpenalty.hh>

#include "products.hh"

using namespace Dune;
using namespace Dune::GDT;


template <class SpaceType>
struct SwipdgPenaltyProductBase : public ::testing::Test
{
  typedef typename SpaceType::GridViewType GridViewType;
  typedef typename GridViewType::Grid GridType;
  typedef Dune::Stuff::Grid::Providers::Cube<GridType> GridProviderType;
  typedef typename GridViewType::template Codim<0>::Entity EntityType;
  typedef typename SpaceType::DomainFieldType DomainFieldType;
  static const unsigned int dimDomain = SpaceType::dimDomain;
  typedef typename SpaceType::RangeFieldType RangeFieldType;
  static const unsigned int dimRange = SpaceType::dimRange;
  typedef Stuff::Functions::Expression<EntityType, DomainFieldType, dimDomain, RangeFieldType, dimRange> ScalarType;
  typedef Stuff::Functions::Constant<EntityType, DomainFieldType, dimDomain, RangeFieldType, dimDomain, dimDomain>
      TensorType;
  typedef Stuff::Functions::Checkerboard<EntityType, DomainFieldType, dimDomain, RangeFieldType, dimRange>
      JumpFunctionType;
  typedef Stuff::LocalizableFunctionInterface<EntityType, DomainFieldType, dimDomain, RangeFieldType, dimRange>
      FunctionType;

  static DSC::Configuration jump_config()
  {
    DSC::Configuration cfg = JumpFunctionType::default_config();
    cfg["num_elements"]    = "[2 1 1]";
    cfg["values"]          = "[0 1]";
    return cfg;
  }

  SwipdgPenaltyProductBase()
    : grid_provider_(0.0, 1.0, 2u)
    , space_(grid_provider_.template leaf<SpaceType::part_view_type>())
    , one_("x", "1", 0)
    , unit_matrix_(Stuff::Functions::internal::unit_matrix<RangeFieldType, dimDomain>())
    , continuous_("x", "x[0] - 1", 1)
    , jump_(JumpFunctionType::create(jump_config()))
  {
  }

  virtual RangeFieldType compute(const FunctionType& function) const = 0;

  void continuous_arguments() const
  {
    // there is no jump in the middle, but at the left boundary we are not zero
    // the 1 is the order of continuous_
    check(compute(continuous_), LocalEvaluation::SIPDG::internal::boundary_sigma(1), 1e-13);
  }

  void discontinuous_arguments() const
  {
    // there is a jump in the middle and at the right boundary we are not zero
    // the 0 is the order of *jump_
    // *0.5 because the value of *jump_ is 0 left and 1 right
    check(compute(*jump_),
          0.5 * LocalEvaluation::SIPDG::internal::inner_sigma(0) + LocalEvaluation::SIPDG::internal::boundary_sigma(0));
  }

  void check(const RangeFieldType& result, const RangeFieldType& expected, const RangeFieldType epsilon = 1e-14) const
  {
    const auto error = std::abs(expected - result);
    EXPECT_LE(error, epsilon) << "result:   " << result << "\n"
                              << "expected: " << expected << "\n"
                              << "difference: " << std::scientific << error;
  } // ... check(...)

  GridProviderType grid_provider_;
  const SpaceType space_;
  const ScalarType one_;
  const TensorType unit_matrix_;
  const ScalarType continuous_;
  const std::unique_ptr<const JumpFunctionType> jump_;
}; // struct SwipdgPenaltyProductBase


template <class SpaceType>
struct SwipdgPenaltyLocalizableProduct : public SwipdgPenaltyProductBase<SpaceType>
{
  typedef SwipdgPenaltyProductBase<SpaceType> BaseType;
{'fraction_non_alphanumeric': 0.11431756254644539, 'fraction_numerical': 0.008917513004706465, 'mean_word_length': 4.662692847124824, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6694966', 'n_tokens_mistral': 2626, 'n_tokens_neox': 2468, 'n_words': 577}