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

#define DUNE_STUFF_FUNCTIONS_DISABLE_CHECKS 1
#define DUNE_HDD_LINEARELLIPTIC_TESTCASES_BASE_DISABLE_WARNING 1

// This one has to come first (includes the config.h)!
#include <dune/stuff/test/main.hxx>

#include <sstream>

#if HAVE_ALUGRID_SERIAL_H || HAVE_ALUGRID_PARALLEL_H
# define ENABLE_ALUGRID 1
# include <dune/grid/alugrid.hh>
#else
# error This test requires ALUGrid!
#endif

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

#include <dune/stuff/common/print.hh>
#include <dune/stuff/common/float_cmp.hh>

#include <dune/hdd/playground/linearelliptic/testcases/ESV2007.hh>

#include "linearelliptic-swipdg.hh"
#include "linearelliptic-block-swipdg.hh"

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


using namespace Dune;
using namespace HDD;


class OS2014_FVCA7_Poster_convergence_study
  : public ::testing::Test
{
  static std::vector< double > truncate_vector_(const std::vector< double >& in, const size_t size)
  {
    assert(size <= in.size());
    if (size == in.size())
      return in;
    else {
      std::vector< double > ret(size);
      for (size_t ii = 0; ii < size; ++ii)
        ret[ii] = in[ii];
      return ret;
    }
  } // ... truncate_vector(...)

  template< class StudyType >
  static bool check_for_success_(const StudyType& study, std::map< std::string, std::vector< double > >& errors)
  {
    size_t failures = 0;
    std::stringstream ss;
    ss << "\n";
    for (const auto& norm : study.provided_norms())
      if (!Dune::Stuff::Common::FloatCmp::lt(errors[norm],
                                             truncate_vector_(study.expected_results(norm), errors[norm].size()))) {
        ++failures;
        Dune::Stuff::Common::print(errors[norm],                 "errors           (" + norm + ")", ss);
        Dune::Stuff::Common::print(study.expected_results(norm), "expected results (" + norm + ")", ss);
      }
    if (failures)
      DUNE_THROW(errors_are_not_as_expected, ss.str());
    return true;
  } // ... check_for_success_(...)

  typedef ALUGrid< 2, 2, simplex, conforming > GridType;

  typedef LinearElliptic::TestCases::ESV2007< GridType >           TestCaseType;
  typedef LinearElliptic::TestCases::ESV2007Multiscale< GridType > BlockTestCaseType;

  static const GDT::ChooseSpaceBackend  space_backend = GDT::ChooseSpaceBackend::fem;
  static const Stuff::LA::ChooseBackend la_backend    = Stuff::LA::ChooseBackend::istl_sparse;

  typedef LinearElliptic::Tests::EocStudySWIPDG< TestCaseType, 1, space_backend, la_backend > EocStudyType;
  typedef LinearElliptic::Tests::EocStudyBlockSWIPDG< BlockTestCaseType, 1, la_backend >      BlockEocStudyType;

protected:
  bool ESV2007_fine_triangulation() const
  {
    const TestCaseType test_case;
    test_case.print_header(test_out);
    test_out << std::endl;
    EocStudyType eoc_study(test_case);
    auto errors = eoc_study.run(false, test_out);
    return check_for_success_(eoc_study, errors);
  } // ... ESV2007_fine_triangulation(...)

  bool BlockSWIPDG_coarse_triangulation(const std::string partitioning) const
  {
    const BlockTestCaseType test_case(partitioning);
    BlockEocStudyType eoc_study(test_case);
    auto errors = eoc_study.run(false, test_out);
    return check_for_success_(eoc_study, errors);
  } // ... BlockSWIPDG_coarse_triangulation(...)
}; // class OS2014_FVCA7_Poster_convergence_study


TEST_F(OS2014_FVCA7_Poster_convergence_study, ESV2007_fine_triangulation) {
  EXPECT_TRUE(ESV2007_fine_triangulation());
}
TEST_F(OS2014_FVCA7_Poster_convergence_study, BlockSWIPDG_01_subdomain) {
  EXPECT_TRUE(BlockSWIPDG_coarse_triangulation("[1 1 1]"));
}
TEST_F(OS2014_FVCA7_Poster_convergence_study, BlockSWIPDG_04_subdomain) {
  EXPECT_TRUE(BlockSWIPDG_coarse_triangulation("[2 2 1]"));
}
TEST_F(OS2014_FVCA7_Poster_convergence_study, BlockSWIPDG_16_subdomain) {
  EXPECT_TRUE(BlockSWIPDG_coarse_triangulation("[4 4 1]"));
}
TEST_F(OS2014_FVCA7_Poster_convergence_study, BlockSWIPDG_64_subdomain) {
  EXPECT_TRUE(BlockSWIPDG_coarse_triangulation("[8 8 1]"));
}


#include <dune/stuff/test/test_main.cxx><commit_msg>[test.OS2014-FVCA7-Poster] update<commit_after>// This file is part of the dune-hdd project:
//   http://users.dune-project.org/projects/dune-hdd
// Copyright holders: <NAME>
// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)

#define DUNE_STUFF_FUNCTIONS_DISABLE_CHECKS 1
#define DUNE_HDD_LINEARELLIPTIC_TESTCASES_BASE_DISABLE_WARNING 1
#ifndef DUNE_STUFF_TEST_MAIN_ENABLE_INFO_LOGGING
# define DUNE_STUFF_TEST_MAIN_ENABLE_INFO_LOGGING 1
#endif

// This one has to come first (includes the config.h)!
#include <dune/stuff/test/main.hxx>

#include <sstream>

#if HAVE_DUNE_GRID_MULTISCALE && HAVE_DUNE_FEM && HAVE_DUNE_ISTL && HAVE_ALUGRID

# include <dune/stuff/common/disable_warnings.hh>
#   include <dune/grid/alugrid.hh>
# include <dune/stuff/common/reenable_warnings.hh>

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

# include <dune/stuff/common/print.hh>
# include <dune/stuff/common/float_cmp.hh>

# include <dune/hdd/playground/linearelliptic/testcases/ESV2007.hh>

# include "linearelliptic-swipdg.hh"
# include "linearelliptic-block-swipdg.hh"


using namespace Dune;
using namespace HDD;


class OS2014_FVCA7_Poster_convergence_study
  : public ::testing::Test
{
  typedef ALUGrid< 2, 2, simplex, conforming > GridType;

  typedef LinearElliptic::TestCases::ESV2007< GridType >           TestCaseType;
  typedef LinearElliptic::TestCases::ESV2007Multiscale< GridType > BlockTestCaseType;

  static const GDT::ChooseSpaceBackend  space_backend = GDT::ChooseSpaceBackend::fem;
  static const Stuff::LA::ChooseBackend la_backend    = Stuff::LA::ChooseBackend::istl_sparse;

  typedef LinearElliptic::Tests::SWIPDGStudy< TestCaseType, 1, space_backend, la_backend > EocStudyType;
  typedef LinearElliptic::Tests::BlockSWIPDGStudy< BlockTestCaseType, 1, la_backend >      BlockEocStudyType;

protected:
  void ESV2007_fine_triangulation() const
  {
    const TestCaseType test_case;
    test_case.print_header(DSC_LOG_INFO);
    DSC_LOG_INFO << std::endl;
    EocStudyType eoc_study(test_case, {"energy", "eta_ESV2007"});
    Stuff::Test::check_eoc_study_for_success(eoc_study, eoc_study.run_eoc(DSC_LOG_INFO));
  } // ... ESV2007_fine_triangulation(...)

  void BlockSWIPDG_coarse_triangulation(const std::string partitioning) const
  {
    const BlockTestCaseType test_case(partitioning);
    BlockEocStudyType eoc_study(test_case, {"energy", "eta_OS2014"});
    Stuff::Test::check_eoc_study_for_success(eoc_study, eoc_study.run_eoc(DSC_LOG_INFO));
  } // ... BlockSWIPDG_coarse_triangulation(...)
}; // class OS2014_FVCA7_Poster_convergence_study


TEST_F(OS2014_FVCA7_Poster_convergence_study, ESV2007_fine_triangulation) {
  ESV2007_fine_triangulation();
}
TEST_F(OS2014_FVCA7_Poster_convergence_study, BlockSWIPDG_01_subdomain) {
  BlockSWIPDG_coarse_triangulation("[1 1 1]");
}
TEST_F(OS2014_FVCA7_Poster_convergence_study, BlockSWIPDG_04_subdomain) {
  BlockSWIPDG_coarse_triangulation("[2 2 1]");
}
TEST_F(OS2014_FVCA7_Poster_convergence_study, BlockSWIPDG_16_subdomain) {
  BlockSWIPDG_coarse_triangulation("[4 4 1]");
}
TEST_F(OS2014_FVCA7_Poster_convergence_study, BlockSWIPDG_64_subdomain) {
  BlockSWIPDG_coarse_triangulation("[8 8 1]");
}


extern template class LinearElliptic::Tests::BlockSWIPDGStudyExpectations
    < LinearElliptic::TestCases::ESV2007Multiscale< ALUGrid< 2, 2, simplex, conforming > >, 1 >;


#else // HAVE_DUNE_GRID_MULTISCALE && HAVE_DUNE_FEM && HAVE_DUNE_ISTL && HAVE_ALUGRID


TEST_F(DISABLED_OS2014_FVCA7_Poster_convergence_study, ESV2007_fine_triangulation) {}
TEST_F(DISABLED_OS2014_FVCA7_Poster_convergence_study, BlockSWIPDG_01_subdomain) {}
TEST_F(DISABLED_OS2014_FVCA7_Poster_convergence_study, BlockSWIPDG_04_subdomain) {}
TEST_F(DISABLED_OS2014_FVCA7_Poster_convergence_study, BlockSWIPDG_16_subdomain) {}
TEST_F(DISABLED_OS2014_FVCA7_Poster_convergence_study, BlockSWIPDG_64_subdomain) {}


#endif // HAVE_DUNE_GRID_MULTISCALE && HAVE_DUNE_FEM && HAVE_DUNE_ISTL && HAVE_ALUGRID
{'fraction_non_alphanumeric': 0.11409315200385124, 'fraction_numerical': 0.02924539655794921, 'mean_word_length': 5.57957244655582, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 41, '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': '5188348', 'n_tokens_mistral': 3400, 'n_tokens_neox': 3064, 'n_words': 469}