<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)

#include <dune/stuff/test/test_common.hh>

#include <dune/common/exceptions.hh>

#ifndef HAVE_ALUGRID
static_assert(false, "This test requires alugrid!");
#endif
#include <dune/grid/alugrid.hh>

#undef HAVE_FASP

#include "elliptic-testcases.hh"
#include "elliptic-cg-discretization.hh"
#include "elliptic-sipdg-discretization.hh"
#include "elliptic-swipdg-discretization.hh"

class errors_are_not_as_expected
  : public Dune::Exception
{};

typedef Dune::ALUConformGrid< 2, 2 > AluConform2dGridType;

// change this to toggle output
std::ostream& out = std::cout;
//std::ostream& out = DSC_LOG.devnull();

typedef testing::Types< EllipticTestCase::ESV07< AluConform2dGridType >
                      , EllipticTestCase::LocalThermalBlock< AluConform2dGridType >
                      , EllipticTestCase::ER07< AluConform2dGridType >
                      , EllipticTestCase::MixedBoundaryTypes< AluConform2dGridType >
                      , EllipticTestCase::Spe10Model1< AluConform2dGridType >
                      > AluConform2dTestCases;

template< class TestCase >
struct EllipticCGDiscretization
  : public ::testing::Test
{
  void check() const
  {
    const TestCase test_case;
    test_case.print_header(out);
    out << std::endl;
    EllipticCG::EocStudy< TestCase, 1 > eoc_study(test_case);
    auto errors = eoc_study.run(out);
    for (const auto& norm : eoc_study.provided_norms())
      if (errors[norm] > eoc_study.expected_results(norm))
        DUNE_THROW(errors_are_not_as_expected, "They really ain't (or you have to lower the expectations)!");
  }
};

TYPED_TEST_CASE(EllipticCGDiscretization, AluConform2dTestCases);
TYPED_TEST(EllipticCGDiscretization, produces_correct_results) {
  this->check();
}


template< class TestCase >
struct EllipticSIPDGDiscretization
  : public ::testing::Test
{
  void check() const
  {
    if (std::is_same< TestCase, EllipticTestCase::Spe10Model1< Dune::ALUConformGrid< 2, 2 > > >::value) {
      std::cerr << "EllipticSIPDGDiscretization does not work for EllipticTestCase::Spe10Model1< Dune::ALUConformGrid< 2, 2 > >!";
    } else {
      const TestCase test_case;
      test_case.print_header(out);
      out << std::endl;
      size_t failure = 0;
      EllipticSIPDG::EocStudy< TestCase, 1 > eoc_study_1(test_case);<commit_msg>[test.elliptic-discretizations] updated error msg<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)

#include <dune/stuff/test/test_common.hh>

#include <dune/common/exceptions.hh>

#ifndef HAVE_ALUGRID
static_assert(false, "This test requires alugrid!");
#endif
#include <dune/grid/alugrid.hh>

#include <dune/stuff/common/color.hh>

#undef HAVE_FASP

#include "elliptic-testcases.hh"
#include "elliptic-cg-discretization.hh"
#include "elliptic-sipdg-discretization.hh"
#include "elliptic-swipdg-discretization.hh"

class errors_are_not_as_expected
  : public Dune::Exception
{};

typedef Dune::ALUConformGrid< 2, 2 > AluConform2dGridType;

// change this to toggle output
std::ostream& out = std::cout;
//std::ostream& out = DSC_LOG.devnull();

typedef testing::Types< EllipticTestCase::ESV07< AluConform2dGridType >
                      , EllipticTestCase::LocalThermalBlock< AluConform2dGridType >
                      , EllipticTestCase::ER07< AluConform2dGridType >
                      , EllipticTestCase::MixedBoundaryTypes< AluConform2dGridType >
                      , EllipticTestCase::Spe10Model1< AluConform2dGridType >
                      > AluConform2dTestCases;

template< class TestCase >
struct EllipticCGDiscretization
  : public ::testing::Test
{
  void check() const
  {
    const TestCase test_case;
    test_case.print_header(out);
    out << std::endl;
    EllipticCG::EocStudy< TestCase, 1 > eoc_study(test_case);
    auto errors = eoc_study.run(out);
    for (const auto& norm : eoc_study.provided_norms())
      if (errors[norm] > eoc_study.expected_results(norm))
        DUNE_THROW(errors_are_not_as_expected, "They really ain't (or you have to lower the expectations)!");
  }
};

TYPED_TEST_CASE(EllipticCGDiscretization, AluConform2dTestCases);
TYPED_TEST(EllipticCGDiscretization, produces_correct_results) {
  this->check();
}


template< class TestCase >
struct EllipticSIPDGDiscretization
  : public ::testing::Test
{
  void check() const
  {
    if (std::is_same< TestCase, EllipticTestCase::Spe10Model1< Dune::ALUConformGrid< 2, 2 > > >::value) {
      std::cerr
          << Dune::Stuff::Common::colorStringRed("EllipticSIPDGDiscretization does not work for "
                                                 + "EllipticTestCase::Spe10Model1< Dune::ALUConformGrid< 2, 2 > >!")
          << std::end;
    } else {
      const TestCase test_case;
      test_case.print_header(out);
      out << std::endl;
      size_t failure = 0;
      EllipticSIPDG::EocStudy< TestCase, 1 > eoc_study_1(test_case);
{'fraction_non_alphanumeric': 0.11748947569843092, 'fraction_numerical': 0.012629161882893225, 'mean_word_length': 3.885046728971963, 'pattern_counts': {'":': 0, '<': 58, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5266356', 'n_tokens_mistral': 1883, 'n_tokens_neox': 1798, 'n_words': 333}