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

cleaned up some errors after last merge

parent 68678461
...@@ -60,7 +60,7 @@ namespace Dune ...@@ -60,7 +60,7 @@ namespace Dune
static void backup (const Grid& grid, const std::string& filename) static void backup (const Grid& grid, const std::string& filename)
{ {
// notice: We should also backup the coordinate function // notice: We should also backup the coordinate function
HostBackupRestoreFacility::backup( grid.hostGrid(), filename ); HostBackupRestoreFacility::backup(grid.hostGrid(), filename);
} }
static void backup (const Grid& grid, const std::ostream& stream) static void backup (const Grid& grid, const std::ostream& stream)
...@@ -73,15 +73,13 @@ namespace Dune ...@@ -73,15 +73,13 @@ namespace Dune
{ {
// notice: We should also restore the coordinate function // notice: We should also restore the coordinate function
HostGrid* hostGrid = HostBackupRestoreFacility::restore(filename); HostGrid* hostGrid = HostBackupRestoreFacility::restore(filename);
CoordFunction* coordFunction = new CoordFunction(); return new Grid(hostGrid, CoordFunction{});
return new Grid(hostGrid, coordFunction);
} }
static Grid* restore (const std::istream& stream) static Grid* restore (const std::istream& stream)
{ {
HostGrid* hostGrid = HostBackupRestoreFacility::restore(stream); HostGrid* hostGrid = HostBackupRestoreFacility::restore(stream);
CoordFunction* coordFunction = new CoordFunction(); return new Grid(hostGrid, CoordFunction{});
return new Grid(hostGrid, coordFunction);
} }
}; };
......
...@@ -24,61 +24,61 @@ namespace Dune ...@@ -24,61 +24,61 @@ namespace Dune
// Capabilities from dune-grid // Capabilities from dune-grid
// --------------------------- // ---------------------------
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator > template< class HostGrid, class CoordFunction, int order, class Allocator >
struct hasSingleGeometryType< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator > > struct hasSingleGeometryType< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator> >
{ {
static const bool v = hasSingleGeometryType< HostGrid > :: v; static const bool v = hasSingleGeometryType< HostGrid > :: v;
static const unsigned int topologyId = hasSingleGeometryType< HostGrid > :: topologyId; static const unsigned int topologyId = hasSingleGeometryType< HostGrid > :: topologyId;
}; };
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator, int codim > template< class HostGrid, class CoordFunction, int order, class Allocator, int codim >
struct hasEntity< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator >, codim > struct hasEntity< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator>, codim >
{ {
static const bool v = true; static const bool v = true;
}; };
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator, int codim > template< class HostGrid, class CoordFunction, int order, class Allocator, int codim >
struct hasEntityIterator< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator >, codim > struct hasEntityIterator< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator>, codim >
{ {
static const bool v = true; static const bool v = true;
}; };
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator, int codim > template< class HostGrid, class CoordFunction, int order, class Allocator, int codim >
struct canCommunicate< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator >, codim > struct canCommunicate< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator>, codim >
{ {
static const bool v = canCommunicate< HostGrid, codim >::v && hasEntity< HostGrid, codim >::v; static const bool v = canCommunicate< HostGrid, codim >::v && hasEntity< HostGrid, codim >::v;
}; };
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator > template< class HostGrid, class CoordFunction, int order, class Allocator >
struct hasBackupRestoreFacilities< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator > > struct hasBackupRestoreFacilities< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator> >
{ {
static const bool v = hasBackupRestoreFacilities< HostGrid >::v; static const bool v = hasBackupRestoreFacilities< HostGrid >::v;
}; };
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator > template< class HostGrid, class CoordFunction, int order, class Allocator >
struct isLevelwiseConforming< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator > > struct isLevelwiseConforming< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator> >
{ {
static const bool v = isLevelwiseConforming< HostGrid >::v; static const bool v = isLevelwiseConforming< HostGrid >::v;
}; };
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator > template< class HostGrid, class CoordFunction, int order, class Allocator >
struct isLeafwiseConforming< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator > > struct isLeafwiseConforming< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator> >
{ {
static const bool v = isLeafwiseConforming< HostGrid >::v; static const bool v = isLeafwiseConforming< HostGrid >::v;
}; };
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator > template< class HostGrid, class CoordFunction, int order, class Allocator >
struct threadSafe< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator > > struct threadSafe< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator> >
{ {
static const bool v = false; static const bool v = false;
}; };
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator > template< class HostGrid, class CoordFunction, int order, class Allocator >
struct viewThreadSafe< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator > > struct viewThreadSafe< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator> >
{ {
static const bool v = false; static const bool v = false;
}; };
...@@ -88,8 +88,8 @@ namespace Dune ...@@ -88,8 +88,8 @@ namespace Dune
// hasHostEntity // hasHostEntity
// ------------- // -------------
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator, int codim > template< class HostGrid, class CoordFunction, int order, class Allocator, int codim >
struct hasHostEntity< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator >, codim > struct hasHostEntity< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator>, codim >
{ {
static const bool v = hasEntity< HostGrid, codim >::v; static const bool v = hasEntity< HostGrid, codim >::v;
}; };
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
namespace Dune namespace Dune
{ {
template< class HostGrid, class CoordFunction, int interpolatoryOrder, class Allocator > template< class HostGrid, class CoordFunction, int lagrangeOrder, class Allocator >
class CurvedSurfaceGrid; class CurvedSurfaceGrid;
} // namespace Dune } // namespace Dune
......
...@@ -216,17 +216,19 @@ namespace Dune ...@@ -216,17 +216,19 @@ namespace Dune
Geometry geometry () const Geometry geometry () const
{ {
if (!geo_) { if (!geo_) {
if (grid_->useGeometryCaching) if (grid_->useGeometryCaching())
{ {
auto const& idSet = grid_->hostGrid().localIdSet(); auto const& idSet = grid_->hostGrid().localIdSet();
auto& cached_geo = std::get<codim>(grid_->geometryCache_)[id(idSet)]; auto& cached_geo = std::get<codim>(grid_->geometryCache_)[id(idSet)];
// if geometry is already in cache // if geometry is already in cache
if(cached_geo) if (cached_geo)
geo_ = cached_geo; geo_ = *cached_geo;
// otherwise cache a new constructed geometry // otherwise cache a new constructed geometry
else else {
cached_geo = geo_ = makeGeometry(); geo_ = makeGeometry();
*cached_geo = *geo_;
}
} }
else else
{ {
......
...@@ -52,16 +52,15 @@ namespace Dune ...@@ -52,16 +52,15 @@ namespace Dune
* *
* \nosubgrouping * \nosubgrouping
*/ */
template< int dim, int dow, class HostGrid, int lagrangeOrder = 1, class Allocator = std::allocator<void> > template< class HostGrid, class CoordFunction, int lagrangeOrder, class Allocator = std::allocator<void> >
class CurvedSurfaceGrid class CurvedSurfaceGrid
: public GridDefaultImplementation<dim, dow, typename HostGrid::ctype, : public GridDefaultImplementation<HostGrid::dimension, CoordFunction::dimRange, typename HostGrid::ctype,
CGeo::GridFamily<HostGrid, lagrangeOrder, Allocator> > CGeo::GridFamily<HostGrid, CoordFunction, lagrangeOrder, Allocator> >
, public CGeo::ExportParams<HostGrid>, , public CGeo::BackupRestoreFacilities<CurvedSurfaceGrid<HostGrid, CoordFunction, lagrangeOrder, Allocator> >
, public CGeo::BackupRestoreFacilities<CurvedSurfaceGrid<HostGrid, lagrangeOrder, Allocator> >
{ {
using Self = CurvedSurfaceGrid; using Self = CurvedSurfaceGrid;
using Super = GridDefaultImplementation<dim, dow, typename HostGrid::ctype, using Super = GridDefaultImplementation<HostGrid::dimension, CoordFunction::dimRange, typename HostGrid::ctype,
CGeo::GridFamily<HostGrid, lagrangeOrder, Allocator> >; CGeo::GridFamily<HostGrid, CoordFunction, lagrangeOrder, Allocator> >;
// friend declarations // friend declarations
friend class CGeo::HierarchicIterator<const Self>; friend class CGeo::HierarchicIterator<const Self>;
...@@ -75,7 +74,7 @@ namespace Dune ...@@ -75,7 +74,7 @@ namespace Dune
template< class, class > friend class CGeo::CommDataHandle; template< class, class > friend class CGeo::CommDataHandle;
public: public:
using GridFamily = CGeo::GridFamily<HostGrid, lagrangeOrder, Allocator>; using GridFamily = CGeo::GridFamily<HostGrid, CoordFunction, lagrangeOrder, Allocator>;
/** \name Traits /** \name Traits
* \{ */ * \{ */
...@@ -187,12 +186,6 @@ namespace Dune ...@@ -187,12 +186,6 @@ namespace Dune
//! lagrange-order of curved elements //! lagrange-order of curved elements
static const int order = lagrangeOrder; static const int order = lagrangeOrder;
using HostGlobalCoordinate = typename HostGrid::template Codim<0>::Geometry::GlobalCoordinate;
using GlobalCoordinate = typename Codim<0>::Entity::Geometry::GlobalCoordinate;
//! Storage for the geometry parametrization
using CoordFunction = std::function<GlobalCoordinate(HostGlobalCoordinate)>;
/** \} */ /** \} */
/** \name Construction and Destruction /** \name Construction and Destruction
...@@ -201,8 +194,7 @@ namespace Dune ...@@ -201,8 +194,7 @@ namespace Dune
//! constructor for host-grid given by reference //! constructor for host-grid given by reference
/** /**
* The references to host grid is stored in the grid. It must be valid until this grid * The references to host grid is stored in the grid. It must be valid until this grid
* wrapper is destroyed. The geometry parametrization, on the other hand, is stored * wrapper is destroyed.
* internally in a std::function.
* *
* \param[in] hostGrid reference to the grid to wrap * \param[in] hostGrid reference to the grid to wrap
* \param[in] param mapping from global coordinates in the host geometry * \param[in] param mapping from global coordinates in the host geometry
...@@ -227,7 +219,7 @@ namespace Dune ...@@ -227,7 +219,7 @@ namespace Dune
template <class Param> template <class Param>
CurvedSurfaceGrid (std::shared_ptr<HostGrid> hostGrid, Param&& param, const Allocator& allocator = Allocator() ) CurvedSurfaceGrid (std::shared_ptr<HostGrid> hostGrid, Param&& param, const Allocator& allocator = Allocator() )
: hostGrid_(std::move(hostGrid)) : hostGrid_(std::move(hostGrid))
, parametrization_(std::forward<Param>(param)) , coordFunction_(wrap_or_move(std::forward<Param>(param)))
, levelIndexSets_(hostGrid_->maxLevel()+1, nullptr, allocator) , levelIndexSets_(hostGrid_->maxLevel()+1, nullptr, allocator)
, storageAllocator_(allocator) , storageAllocator_(allocator)
{} {}
...@@ -443,7 +435,7 @@ namespace Dune ...@@ -443,7 +435,7 @@ namespace Dune
bool loadBalance (CommDataHandleIF<DataHandle, Data>& datahandle) bool loadBalance (CommDataHandleIF<DataHandle, Data>& datahandle)
{ {
using DataHandleIF = CommDataHandleIF<DataHandle, Data>; using DataHandleIF = CommDataHandleIF<DataHandle, Data>;
using WrappedDataHandle = CGeo::CommDataHandle<Grid, DataHandleIF>; using WrappedDataHandle = CGeo::CommDataHandle<Self, DataHandleIF>;
WrappedDataHandle wrappedDataHandle(*this, datahandle); WrappedDataHandle wrappedDataHandle(*this, datahandle);
const bool gridChanged = hostGrid().loadBalance(wrappedDataHandle); const bool gridChanged = hostGrid().loadBalance(wrappedDataHandle);
...@@ -526,7 +518,18 @@ namespace Dune ...@@ -526,7 +518,18 @@ namespace Dune
} }
//! obtain constant reference to the coordinate function //! obtain constant reference to the coordinate function
CoordFunction coordFunction () const { return coordFunction_; } CoordFunction const& coordFunction () const { return *coordFunction_; }
CoordFunction& coordFunction () { return *coordFunction_; }
bool useGeometryCaching () const
{
return useGeometryCaching_;
}
void setGeometryCaching (bool cache)
{
useGeometryCaching_ = cache;
}
/** \} */ /** \} */
...@@ -550,8 +553,9 @@ namespace Dune ...@@ -550,8 +553,9 @@ namespace Dune
private: private:
std::shared_ptr<HostGrid> hostGrid_; std::shared_ptr<HostGrid> hostGrid_;
std::shared_ptr<CoordFunction> coordFunction_;
CoordFunction parametrization_; bool useGeometryCaching_ = false;
mutable std::vector<LevelIndexSet*, typename Allocator::template rebind<LevelIndexSet*>::other> levelIndexSets_; mutable std::vector<LevelIndexSet*, typename Allocator::template rebind<LevelIndexSet*>::other> levelIndexSets_;
mutable LeafIndexSet leafIndexSet_; mutable LeafIndexSet leafIndexSet_;
...@@ -574,17 +578,17 @@ namespace Dune ...@@ -574,17 +578,17 @@ namespace Dune
>; >;
}; };
mutable typename GeometryCache<std::make_integer_sequence<int,dim+1>>::type geometryCache_; mutable typename GeometryCache<std::make_integer_sequence<int,Traits::dimension+1>>::type geometryCache_;
}; };
// CurvedSurfaceGrid::Codim // CurvedSurfaceGrid::Codim
// ------------------------ // ------------------------
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator > template< class HostGrid, class CoordFunction, int order, class Allocator >
template< int codim > template< int codim >
struct CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator >::Codim struct CurvedSurfaceGrid< HostGrid, CoordFunction, order, Allocator >::Codim
: public Base::template Codim< codim > : public Super::template Codim< codim >
{ {
/** \name Entity types /** \name Entity types
* \{ */ * \{ */
...@@ -593,7 +597,7 @@ namespace Dune ...@@ -593,7 +597,7 @@ namespace Dune
* *
* The entity is a model of Dune::Entity. * The entity is a model of Dune::Entity.
*/ */
typedef typename Traits::template Codim< codim >::Entity Entity; using Entity = typename Traits::template Codim< codim >::Entity;
/** \} */ /** \} */
...@@ -608,7 +612,7 @@ namespace Dune ...@@ -608,7 +612,7 @@ namespace Dune
* The geometry is a model of Dune::Geometry, implemented through the * The geometry is a model of Dune::Geometry, implemented through the
* generic geometries provided by dune-grid. * generic geometries provided by dune-grid.
*/ */
typedef typename Traits::template Codim< codim >::Geometry Geometry; using Geometry = typename Traits::template Codim< codim >::Geometry;
/** \brief type of local geometry /** \brief type of local geometry
* *
...@@ -618,7 +622,7 @@ namespace Dune ...@@ -618,7 +622,7 @@ namespace Dune
* The local geometry is a model of Dune::Geometry, implemented through * The local geometry is a model of Dune::Geometry, implemented through
* the generic geometries provided by dune-grid. * the generic geometries provided by dune-grid.
*/ */
typedef typename Traits::template Codim< codim >::LocalGeometry LocalGeometry; using LocalGeometry = typename Traits::template Codim< codim >::LocalGeometry;
/** \} */ /** \} */
...@@ -628,12 +632,10 @@ namespace Dune ...@@ -628,12 +632,10 @@ namespace Dune
template< PartitionIteratorType pitype > template< PartitionIteratorType pitype >
struct Partition struct Partition
{ {
typedef typename Traits::template Codim< codim > using LeafIterator
::template Partition< pitype >::LeafIterator = typename Traits::template Codim<codim>::template Partition< pitype >::LeafIterator;
LeafIterator; using LevelIterator
typedef typename Traits::template Codim< codim > = typename Traits::template Codim<codim>::template Partition< pitype >::LevelIterator;
::template Partition< pitype >::LevelIterator
LevelIterator;
}; };
/** \brief type of leaf iterator /** \brief type of leaf iterator
...@@ -643,7 +645,7 @@ namespace Dune ...@@ -643,7 +645,7 @@ namespace Dune
* *
* The level iterator is a model of Dune::LevelIterator. * The level iterator is a model of Dune::LevelIterator.
*/ */
typedef typename Partition< All_Partition >::LeafIterator LeafIterator; using LeafIterator = typename Partition< All_Partition >::LeafIterator;
/** \brief type of level iterator /** \brief type of level iterator
* *
...@@ -652,7 +654,7 @@ namespace Dune ...@@ -652,7 +654,7 @@ namespace Dune
* *
* The leaf iterator is a model of Dune::LeafIterator. * The leaf iterator is a model of Dune::LeafIterator.
*/ */
typedef typename Partition< All_Partition >::LevelIterator LevelIterator; using LevelIterator = typename Partition< All_Partition >::LevelIterator;
/** \} */ /** \} */
}; };
......
...@@ -27,19 +27,19 @@ namespace Dune ...@@ -27,19 +27,19 @@ namespace Dune
// GridFamily // GridFamily
// ---------- // ----------
template< int dim, int dow, class HG, int order, class Allocator > template< class HG, class CF, int order, class Allocator >
struct GridFamily struct GridFamily
{ {
struct Traits struct Traits
{ {
using Grid = CurvedSurfaceGrid<dim, dow, HG, order, Allocator>; using Grid = CurvedSurfaceGrid<HG, CF, order, Allocator>;
using HostGrid = HG; using HostGrid = HG;
using CoordFunction = CF;
using ctype = typename HostGrid::ctype; using ctype = typename HostGrid::ctype;
static_assert(dim == HostGrid::dimension, ""); static const int dimension = HostGrid::dimension;
static const int dimension = dim; static const int dimensionworld = CoordFunction::dimRange;
static const int dimensionworld = dow;
using LeafIntersection = Dune::Intersection<const Grid, CGeo::Intersection<const Grid, typename HostGrid::LeafIntersection> >; using LeafIntersection = Dune::Intersection<const Grid, CGeo::Intersection<const Grid, typename HostGrid::LeafIntersection> >;
using LevelIntersection = Dune::Intersection<const Grid, CGeo::Intersection<const Grid, typename HostGrid::LevelIntersection> >; using LevelIntersection = Dune::Intersection<const Grid, CGeo::Intersection<const Grid, typename HostGrid::LevelIntersection> >;
...@@ -93,8 +93,8 @@ namespace Dune ...@@ -93,8 +93,8 @@ namespace Dune
using CollectiveCommunication = typename HostGrid::Traits::CollectiveCommunication; using CollectiveCommunication = typename HostGrid::Traits::CollectiveCommunication;
// grid views // grid views
using LeafGridView = Dune::GridView< CGeo::GridViewTraits< dim, dow, typename HostGrid::LeafGridView, order, Allocator > >; using LeafGridView = Dune::GridView< CGeo::GridViewTraits< typename HostGrid::LeafGridView, CF, order, Allocator > >;
using LevelGridView = Dune::GridView< CGeo::GridViewTraits< dim, dow, typename HostGrid::LevelGridView, order, Allocator > >; using LevelGridView = Dune::GridView< CGeo::GridViewTraits< typename HostGrid::LevelGridView, CF, order, Allocator > >;
}; };
}; };
......
...@@ -22,27 +22,28 @@ namespace Dune ...@@ -22,27 +22,28 @@ namespace Dune
// Internal Forward Declarations // Internal Forward Declarations
// ----------------------------- // -----------------------------
template< int dim, int dow, class HGV, int order, class Allocator > template< class HGV, class CF, int order, class Allocator >
class GridView; class GridView;
// GridViewTraits // GridViewTraits
// -------------- // --------------
template< int dim, int dow, class HGV, int order, class Allocator > template< class HGV, class CF, int order, class Allocator >
class GridViewTraits class GridViewTraits
{ {
friend class GridView<dim, dow, HGV, order, Allocator>; friend class GridView<HGV, CF, order, Allocator>;
using HostGridView = HGV; using HostGridView = HGV;
using CoordFunction = CF;
using HostGrid = typename HostGridView::Grid; using HostGrid = typename HostGridView::Grid;
using HostIntersection = typename HostGridView::Intersection; using HostIntersection = typename HostGridView::Intersection;
using HostIntersectionIterator = typename HostGridView::IntersectionIterator; using HostIntersectionIterator = typename HostGridView::IntersectionIterator;
public: public:
using GridViewImp = GridView<dim, dow, HostGridView, order, Allocator>; using GridViewImp = GridView<HostGridView, CoordFunction, order, Allocator>;
using Grid = Dune::CurvedSurfaceGrid<dim, dow, HostGrid, order, Allocator>; using Grid = Dune::CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator>;
using IndexSet = CGeo::IndexSet<const Grid, typename HostGridView::IndexSet>; using IndexSet = CGeo::IndexSet<const Grid, typename HostGridView::IndexSet>;
using Intersection = Dune::Intersection<const Grid, CGeo::Intersection<const Grid, HostIntersection> >; using Intersection = Dune::Intersection<const Grid, CGeo::Intersection<const Grid, HostIntersection> >;
...@@ -79,13 +80,13 @@ namespace Dune ...@@ -79,13 +80,13 @@ namespace Dune
// GridView // GridView
// -------- // --------
template< int dim, int dow, class HGV, int order, class Allocator > template< class HGV, class CF, int order, class Allocator >
class GridView class GridView
{ {
using Self = GridView; using Self = GridView;