Commit c03faa46 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Merge branch 'issue/cleanup_observer' into 'master'

cleanup wrap_or_share

See merge request !116
parents 5327b924 43961d40
......@@ -138,9 +138,9 @@ restore(Flag initFlag)
// restore grid from file
if (Dune::Capabilities::hasBackupRestoreFacilities<HostGrid>::v)
adoptGrid(Grid::instance(Dune::BackupRestoreFacility<HostGrid>::restore(grid_filename)));
adoptGrid(Grid::instance(std::unique_ptr<HostGrid>(Dune::BackupRestoreFacility<HostGrid>::restore(grid_filename))));
else
adoptGrid(Grid::instance(BackupRestoreByGridFactory<HostGrid>::restore(grid_filename)));
adoptGrid(Grid::instance(std::unique_ptr<HostGrid>(BackupRestoreByGridFactory<HostGrid>::restore(grid_filename))));
// create fespace
if (initFlag.isSet(INIT_FE_SPACE) || initFlag.isSet(INIT_SYSTEM))
......
#pragma once
#include <memory>
#include <type_traits>
#include <utility>
#include <dune/common/shared_ptr.hh>
......@@ -30,15 +31,10 @@ namespace AMDiS
}
template <class T>
std::shared_ptr<T> wrap_or_share(T*& t)
std::shared_ptr<T> wrap_or_share(T* t)
{
return std::shared_ptr<T>(t, Dune::null_deleter<T>());
}
template <class T>
std::shared_ptr<T> wrap_or_share(T*&& t)
{
return std::shared_ptr<T>(t);
static_assert(not std::is_pointer<T*>::value,
"Raw pointers must be wrapped into smart pointers or references to clarify ownership");
}
template <class T>
......@@ -48,13 +44,7 @@ namespace AMDiS
}
template <class T>
std::shared_ptr<T> wrap_or_share(std::unique_ptr<T>& t)
{
return std::shared_ptr<T>(t.get(), Dune::null_deleter<T>());
}
template <class T>
std::shared_ptr<T> wrap_or_share(std::unique_ptr<T>&& t)
std::shared_ptr<T> wrap_or_share(std::unique_ptr<T> t)
{
return std::shared_ptr<T>(std::move(t));
}
......
......@@ -75,8 +75,7 @@ int main(int argc, char** argv)
int ovlp = 1;
{
auto hostGrid = std::make_unique<YaspGrid2d>(lower2d, upper2d, nElements2d, std::bitset<2>(),
ovlp);
YaspGrid2d hostGrid(lower2d, upper2d, nElements2d, std::bitset<2>(), ovlp);
auto grid = AdaptiveGrid<YaspGrid2d>::instance(hostGrid);
auto l1 = LagrangeBasis<YaspGrid2d, 1>::create(grid->leafGridView());
......@@ -86,8 +85,7 @@ int main(int argc, char** argv)
AMDIS_TEST(test(th, "Yasp2d_TH_Ovlp"));
}
{
auto hostGrid = std::make_unique<YaspGrid3d>(lower3d, upper3d, nElements3d, std::bitset<3>(),
ovlp);
YaspGrid3d hostGrid(lower3d, upper3d, nElements3d, std::bitset<3>(), ovlp);
auto grid = AdaptiveGrid<YaspGrid3d>::instance(hostGrid);
auto l1 = LagrangeBasis<YaspGrid3d, 1>::create(grid->leafGridView());
......
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