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
static void backup (const Grid& grid, const std::string& filename)
{
// 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)
......@@ -73,15 +73,13 @@ namespace Dune
{
// notice: We should also restore the coordinate function
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)
{
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
// Capabilities from dune-grid
// ---------------------------
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator >
struct hasSingleGeometryType< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator > >
template< class HostGrid, class CoordFunction, int order, class Allocator >
struct hasSingleGeometryType< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator> >
{
static const bool v = hasSingleGeometryType< HostGrid > :: v;
static const unsigned int topologyId = hasSingleGeometryType< HostGrid > :: topologyId;
};
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator, int codim >
struct hasEntity< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator >, codim >
template< class HostGrid, class CoordFunction, int order, class Allocator, int codim >
struct hasEntity< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator>, codim >
{
static const bool v = true;
};
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator, int codim >
struct hasEntityIterator< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator >, codim >
template< class HostGrid, class CoordFunction, int order, class Allocator, int codim >
struct hasEntityIterator< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator>, codim >
{
static const bool v = true;
};
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator, int codim >
struct canCommunicate< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator >, codim >
template< class HostGrid, class CoordFunction, int order, class Allocator, int codim >
struct canCommunicate< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator>, codim >
{
static const bool v = canCommunicate< HostGrid, codim >::v && hasEntity< HostGrid, codim >::v;
};
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator >
struct hasBackupRestoreFacilities< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator > >
template< class HostGrid, class CoordFunction, int order, class Allocator >
struct hasBackupRestoreFacilities< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator> >
{
static const bool v = hasBackupRestoreFacilities< HostGrid >::v;
};
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator >
struct isLevelwiseConforming< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator > >
template< class HostGrid, class CoordFunction, int order, class Allocator >
struct isLevelwiseConforming< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator> >
{
static const bool v = isLevelwiseConforming< HostGrid >::v;
};
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator >
struct isLeafwiseConforming< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator > >
template< class HostGrid, class CoordFunction, int order, class Allocator >
struct isLeafwiseConforming< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator> >
{
static const bool v = isLeafwiseConforming< HostGrid >::v;
};
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator >
struct threadSafe< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator > >
template< class HostGrid, class CoordFunction, int order, class Allocator >
struct threadSafe< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator> >
{
static const bool v = false;
};
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator >
struct viewThreadSafe< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator > >
template< class HostGrid, class CoordFunction, int order, class Allocator >
struct viewThreadSafe< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator> >
{
static const bool v = false;
};
......@@ -88,8 +88,8 @@ namespace Dune
// hasHostEntity
// -------------
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator, int codim >
struct hasHostEntity< CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator >, codim >
template< class HostGrid, class CoordFunction, int order, class Allocator, int codim >
struct hasHostEntity< CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator>, codim >
{
static const bool v = hasEntity< HostGrid, codim >::v;
};
......
......@@ -6,7 +6,7 @@
namespace Dune
{
template< class HostGrid, class CoordFunction, int interpolatoryOrder, class Allocator >
template< class HostGrid, class CoordFunction, int lagrangeOrder, class Allocator >
class CurvedSurfaceGrid;
} // namespace Dune
......
......@@ -216,17 +216,19 @@ namespace Dune
Geometry geometry () const
{
if (!geo_) {
if (grid_->useGeometryCaching)
if (grid_->useGeometryCaching())
{
auto const& idSet = grid_->hostGrid().localIdSet();
auto& cached_geo = std::get<codim>(grid_->geometryCache_)[id(idSet)];
// if geometry is already in cache
if(cached_geo)
geo_ = cached_geo;
if (cached_geo)
geo_ = *cached_geo;
// otherwise cache a new constructed geometry
else
cached_geo = geo_ = makeGeometry();
else {
geo_ = makeGeometry();
*cached_geo = *geo_;
}
}
else
{
......
......@@ -52,16 +52,15 @@ namespace Dune
*
* \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
: public GridDefaultImplementation<dim, dow, typename HostGrid::ctype,
CGeo::GridFamily<HostGrid, lagrangeOrder, Allocator> >
, public CGeo::ExportParams<HostGrid>,
, public CGeo::BackupRestoreFacilities<CurvedSurfaceGrid<HostGrid, lagrangeOrder, Allocator> >
: public GridDefaultImplementation<HostGrid::dimension, CoordFunction::dimRange, typename HostGrid::ctype,
CGeo::GridFamily<HostGrid, CoordFunction, lagrangeOrder, Allocator> >
, public CGeo::BackupRestoreFacilities<CurvedSurfaceGrid<HostGrid, CoordFunction, lagrangeOrder, Allocator> >
{
using Self = CurvedSurfaceGrid;
using Super = GridDefaultImplementation<dim, dow, typename HostGrid::ctype,
CGeo::GridFamily<HostGrid, lagrangeOrder, Allocator> >;
using Super = GridDefaultImplementation<HostGrid::dimension, CoordFunction::dimRange, typename HostGrid::ctype,
CGeo::GridFamily<HostGrid, CoordFunction, lagrangeOrder, Allocator> >;
// friend declarations
friend class CGeo::HierarchicIterator<const Self>;
......@@ -75,7 +74,7 @@ namespace Dune
template< class, class > friend class CGeo::CommDataHandle;
public:
using GridFamily = CGeo::GridFamily<HostGrid, lagrangeOrder, Allocator>;
using GridFamily = CGeo::GridFamily<HostGrid, CoordFunction, lagrangeOrder, Allocator>;
/** \name Traits
* \{ */
......@@ -187,12 +186,6 @@ namespace Dune
//! lagrange-order of curved elements
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
......@@ -201,8 +194,7 @@ namespace Dune
//! constructor for host-grid given by reference
/**
* 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
* internally in a std::function.
* wrapper is destroyed.
*
* \param[in] hostGrid reference to the grid to wrap
* \param[in] param mapping from global coordinates in the host geometry
......@@ -227,7 +219,7 @@ namespace Dune
template <class Param>
CurvedSurfaceGrid (std::shared_ptr<HostGrid> hostGrid, Param&& param, const Allocator& allocator = Allocator() )
: hostGrid_(std::move(hostGrid))
, parametrization_(std::forward<Param>(param))
, coordFunction_(wrap_or_move(std::forward<Param>(param)))
, levelIndexSets_(hostGrid_->maxLevel()+1, nullptr, allocator)
, storageAllocator_(allocator)
{}
......@@ -443,7 +435,7 @@ namespace Dune
bool loadBalance (CommDataHandleIF<DataHandle, Data>& datahandle)
{
using DataHandleIF = CommDataHandleIF<DataHandle, Data>;
using WrappedDataHandle = CGeo::CommDataHandle<Grid, DataHandleIF>;
using WrappedDataHandle = CGeo::CommDataHandle<Self, DataHandleIF>;
WrappedDataHandle wrappedDataHandle(*this, datahandle);
const bool gridChanged = hostGrid().loadBalance(wrappedDataHandle);
......@@ -526,7 +518,18 @@ namespace Dune
}
//! 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
private:
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 LeafIndexSet leafIndexSet_;
......@@ -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
// ------------------------
template< class HostGrid, class CoordFunction, int order, bool geoCaching, class Allocator >
template< class HostGrid, class CoordFunction, int order, class Allocator >
template< int codim >
struct CurvedSurfaceGrid< HostGrid, CoordFunction, order, geoCaching, Allocator >::Codim
: public Base::template Codim< codim >
struct CurvedSurfaceGrid< HostGrid, CoordFunction, order, Allocator >::Codim
: public Super::template Codim< codim >
{
/** \name Entity types
* \{ */
......@@ -593,7 +597,7 @@ namespace Dune
*
* 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
* The geometry is a model of Dune::Geometry, implemented through the
* 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
*
......@@ -618,7 +622,7 @@ namespace Dune
* The local geometry is a model of Dune::Geometry, implemented through
* 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
template< PartitionIteratorType pitype >
struct Partition
{
typedef typename Traits::template Codim< codim >
::template Partition< pitype >::LeafIterator
LeafIterator;
typedef typename Traits::template Codim< codim >
::template Partition< pitype >::LevelIterator
LevelIterator;
using LeafIterator
= typename Traits::template Codim<codim>::template Partition< pitype >::LeafIterator;
using LevelIterator
= typename Traits::template Codim<codim>::template Partition< pitype >::LevelIterator;
};
/** \brief type of leaf iterator
......@@ -643,7 +645,7 @@ namespace Dune
*
* 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
*
......@@ -652,7 +654,7 @@ namespace Dune
*
* 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
// GridFamily
// ----------
template< int dim, int dow, class HG, int order, class Allocator >
template< class HG, class CF, int order, class Allocator >
struct GridFamily
{
struct Traits
{
using Grid = CurvedSurfaceGrid<dim, dow, HG, order, Allocator>;
using Grid = CurvedSurfaceGrid<HG, CF, order, Allocator>;
using HostGrid = HG;
using CoordFunction = CF;
using ctype = typename HostGrid::ctype;
static_assert(dim == HostGrid::dimension, "");
static const int dimension = dim;
static const int dimensionworld = dow;
static const int dimension = HostGrid::dimension;
static const int dimensionworld = CoordFunction::dimRange;
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> >;
......@@ -93,8 +93,8 @@ namespace Dune
using CollectiveCommunication = typename HostGrid::Traits::CollectiveCommunication;
// grid views
using LeafGridView = Dune::GridView< CGeo::GridViewTraits< dim, dow, typename HostGrid::LeafGridView, order, Allocator > >;
using LevelGridView = Dune::GridView< CGeo::GridViewTraits< dim, dow, typename HostGrid::LevelGridView, order, Allocator > >;
using LeafGridView = Dune::GridView< CGeo::GridViewTraits< typename HostGrid::LeafGridView, CF, order, Allocator > >;
using LevelGridView = Dune::GridView< CGeo::GridViewTraits< typename HostGrid::LevelGridView, CF, order, Allocator > >;
};
};
......
......@@ -22,27 +22,28 @@ namespace Dune
// 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;
// GridViewTraits
// --------------
template< int dim, int dow, class HGV, int order, class Allocator >
template< class HGV, class CF, int order, class Allocator >
class GridViewTraits
{
friend class GridView<dim, dow, HGV, order, Allocator>;
friend class GridView<HGV, CF, order, Allocator>;
using HostGridView = HGV;
using CoordFunction = CF;
using HostGrid = typename HostGridView::Grid;
using HostIntersection = typename HostGridView::Intersection;
using HostIntersectionIterator = typename HostGridView::IntersectionIterator;
public:
using GridViewImp = GridView<dim, dow, HostGridView, order, Allocator>;
using Grid = Dune::CurvedSurfaceGrid<dim, dow, HostGrid, order, Allocator>;
using GridViewImp = GridView<HostGridView, CoordFunction, order, Allocator>;
using Grid = Dune::CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator>;
using IndexSet = CGeo::IndexSet<const Grid, typename HostGridView::IndexSet>;
using Intersection = Dune::Intersection<const Grid, CGeo::Intersection<const Grid, HostIntersection> >;
......@@ -79,13 +80,13 @@ namespace Dune
// GridView
// --------
template< int dim, int dow, class HGV, int order, class Allocator >
template< class HGV, class CF, int order, class Allocator >
class GridView
{
using Self = GridView;
public:
using Traits = GridViewTraits< dim, dow, HGV, order, Allocator >;
using Traits = GridViewTraits<HGV, CF, order, Allocator>;
using HostGridView = typename Traits::HostGridView;
using Grid = typename Traits::Grid;
......@@ -108,8 +109,17 @@ namespace Dune
, hostGridView_(hostGridView)
{}
GridView (const Self&) = default;
GridView (Self&&) = default;
//! copy constructor. Only copies grid and hostGridView
GridView (const Self& other)
: grid_(other.grid_)
, hostGridView_(other.hostGridView_)
{}
//! move constructor. Only moves grid and hostGridView
GridView (Self&& other)
: grid_(other.grid_)
, hostGridView_(std::move(other.hostGridView_))
{}
//! copy-assignment operator
Self& operator= (const Self& other)
......@@ -162,7 +172,7 @@ namespace Dune
template< int codim, PartitionIteratorType pit >
typename Codim<codim>::template Partition<pit>::Iterator begin () const
{
using IteratorImp = Traits::template Codim<codim>::template Partition<pit>::IteratorImp;
using IteratorImp = typename Traits::template Codim<codim>::template Partition<pit>::IteratorImp;
return IteratorImp::begin(grid(), hostGridView());
}
......@@ -175,7 +185,7 @@ namespace Dune
template< int codim, PartitionIteratorType pit >
typename Codim<codim>::template Partition<pit>::Iterator end () const
{
using IteratorImp = Traits::template Codim<codim>::template Partition<pit>::IteratorImp;
using IteratorImp = typename Traits::template Codim<codim>::template Partition<pit>::IteratorImp;
return IteratorImp::end(grid(), hostGridView());
}
......
......@@ -23,7 +23,7 @@ namespace Dune
using Traits = typename std::remove_const<Grid>::type::Traits;
public:
using IdType typename HostIdSet::IdType;
using IdType = typename HostIdSet::IdType;
public:
IdSet () = default;
......
......@@ -2,7 +2,7 @@
#include <iostream>
#include <cmath>
using namespace Dune::CurvedGeo;
using namespace Dune::CGeo;
// #########################
// ## Geometry-Routines ##
......
......@@ -8,7 +8,7 @@
#include <boost/iostreams/filter/bzip2.hpp> //bzip2 is slower but compresses better, usually.
#endif
using namespace Dune::CurvedGeo;
using namespace Dune::CGeo;
//--------------------< decompress_buffer >
//Use this routine if the size of the uncompressed data 'osize' is known. Decompresses buffer 'ibuf'
......
......@@ -58,15 +58,9 @@ int main(int argc, char** argv)
//case2: projection to a surface-mesh of a sphere
{
<<<<<<< HEAD
SurfaceDistanceCoordFunction surfdistCF("dune-curvedsurfacegrid/example/sphere_fine.vtu");
SurfaceDistanceCoordFunction<> surfdistCF("example/sphere_fine.vtu");
using GridType = CurvedSurfaceGrid<HostGridType, SurfaceDistanceCoordFunction<>, ip_order>;
GridType grid(*hostGrid, surfdistCF);
=======
SurfaceDistanceCoordFunction surfdistCF("example/sphere_fine.vtu");
using GridType = CurvedSurfaceGrid<HostGridType, SurfaceDistanceCoordFunction, ip_order>;
std::shared_ptr<GridType> grid(new GridType(*hostGrid, surfdistCF));
>>>>>>> 5e1a7e879f2f67079d870c2a9990daabaded47d1
using GridView = GridType::LeafGridView;
GridView gridView = grid.leafGridView();
......
Supports Markdown
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