Commit f2ada9f3 authored by Lukas Riedel's avatar Lukas Riedel

Make IC unit test work

GridView and MCMGMapper somehow do not survive the scope transition
from Fixture to test. GDB indicates that the test case starts a new
thread which might invalidate the GridView stored in the Richards
parameterization instance. It has to be re-built inside every test!
parent 99937c3c
#include <gtest/gtest.h>
#include <vector>
#include <memory>
#include <string>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
......@@ -130,7 +134,15 @@ protected:
std::shared_ptr<spdlog::logger> _log;
std::shared_ptr<Grid> _grid;
std::shared_ptr<GridView> _gv;
std::shared_ptr<RichardsParam> _param;
std::vector<int> _index_map;
/// Update the stored grid view and return a new parameterization instance
std::shared_ptr<RichardsParam> create_param()
{
_gv = std::make_shared<GridView>(_grid->leafGridView());
return std::make_shared<RichardsParam>(
_config_richards, _grid, _index_map);
}
void SetUp () override
{
......@@ -157,24 +169,7 @@ protected:
Dune::Dorie::GridCreator<Grid> gc(_config, helper);
_grid = gc.grid();
_gv = std::make_shared<GridView>(_grid->leafGridView());
const auto index_map = gc.element_index_map();
// Create Richards parameterization
auto _param = std::make_shared<RichardsParam>(_config_richards,
_grid,
index_map);
for (auto&& e : Dune::elements(_grid->levelGridView(0)))
{
_param->bind(e);
_param->cache();
}
auto gv = _grid->leafGridView();
for (auto&& e : elements(gv))
{
_param->bind(e);
}
_index_map = gc.element_index_map();
}
void TearDown () override
......@@ -184,22 +179,15 @@ protected:
}
};
TEST_F (ICFixture, Parameters)
{
auto gv = _grid->leafGridView();
for (auto&& e : elements(gv))
{
_param->bind(e);
}
}
TEST_F (ICFixture, Richards)
{
// Create Richards parameterization
auto param = create_param();
// Create the initial condition
using ICF = Dune::Dorie::RichardsInitialConditionFactory<T, RichardsParam>;
const auto ic = ICF::create(_config_richards,
*_gv,
_param);
param);
const auto quantity = _config_richards.get<std::string>(
"initial.quantity"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment