KASKADE 7 development version
cellLocator.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the library KASKADE 7 */
4/* https://www.zib.de/research/projects/kaskade7-finite-element-toolbox */
5/* */
6/* Copyright (C) 2017-2020 Zuse Institute Berlin */
7/* */
8/* KASKADE 7 is distributed under the terms of the ZIB Academic License. */
9/* see $KASKADE/academic.txt */
10/* */
11/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13#ifndef CELLLOCATOR_HH
14#define CELLLOCATOR_HH
15
16#include <memory>
17#include <optional>
18#include <tuple>
19
20#include "dune/common/fvector.hh"
21#include "dune/geometry/type.hh"
22
23#include "utilities/timing.hh"
24
25namespace Kaskade
26{
28 // forward declaration for PIMPL idiome
29 namespace CellLocatorDetail
30 {
31 template <class GridView, int dimw>
33 }
35
36 // ----------------------------------------------------------------------------------------------
37
38
39
53 template <class GridView, int dimw=GridView::Grid::dimension>
55 {
57 using Grid = typename GridView::Grid;
58
59 public:
60 static int const dimension = GridView::Grid::dimension;
61 static int const dimension_world = dimw;
62 using ctype = typename GridView::ctype;
64 using Cell = typename GridView::template Codim<0>::Entity;
65
66
70 CellLocator(GridView const& gridView);
71
72 // we need this because the default destructor doesn't know about the size of SpatialIndex when deallocating via unique_ptr
74
79 ctype diameter() const
80 {
81 return diam;
82 }
89 std::vector<Cell> cells() const;
90
100 std::pair<Cell,double> closestCell(Position const& pos) const;
101
102 private:
103 std::unique_ptr<CellLocatorDetail::SpatialIndex<GridView,dimension_world>> spatialIndex;
104 ctype diam;
105
106 void init(GridView const& gridView);
107
108 };
109}
110
111#endif
static int const dimension
Definition: cellLocator.hh:60
std::vector< Cell > cells() const
Returns a sequence of all cells.
static int const dimension_world
Definition: cellLocator.hh:61
CellLocator(GridView const &gridView)
Constructs a locator based on the grids view.
std::pair< Cell, double > closestCell(Position const &pos) const
Returns a pair consisting of the closest cell to pos and the distance to this cell.
typename GridView::template Codim< 0 >::Entity Cell
Definition: cellLocator.hh:64
ctype diameter() const
The diagonal length of the grid's cartesian bounding box.
Definition: cellLocator.hh:79
typename GridView::ctype ctype
Definition: cellLocator.hh:62