version 3.10-dev
localintersectionindexmapper.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_DISCRETIZATION_LOCAL_INTERSECTION_INDEX_MAPPER_HH
13#define DUMUX_DISCRETIZATION_LOCAL_INTERSECTION_INDEX_MAPPER_HH
14
15#include <array>
16#include <numeric>
17#include <dune/common/float_cmp.hh>
19#include <dumux/common/math.hh>
23
24namespace Dumux {
25
26namespace Detail {
27
28template<class GridView, bool consistentlyOrientedGrid>
30
37template<class GridView>
39{
40 using SmallLocalIndexType = typename IndexTraits<GridView>::SmallLocalIndex;
41 using Element = typename GridView::template Codim<0>::Entity;
42 static constexpr auto numElementFaces = GridView::Grid::dimension * 2;
43public:
44 void update(const GridView& gv, const Element& element)
45 {
46 static const bool makeConsistentlyOriented = getParam<bool>("Grid.MakeConsistentlyOriented", true);
47 if (!makeConsistentlyOriented)
48 {
49 std::iota(realToRefMap_.begin(), realToRefMap_.end(), 0);
50 refToRealMap_ = realToRefMap_;
51 return;
52 }
53
54 for (const auto& is : intersections(gv, element))
55 {
56 const auto& otherOuterNormal = is.centerUnitOuterNormal();
57 const auto idx = normalAxis(otherOuterNormal);
58 const int positveOrientation = !std::signbit(otherOuterNormal[idx]);
59 const auto refIdx = idx * 2 + positveOrientation;
60 const auto realIdx = is.indexInInside();
61 realToRefMap_[realIdx] = refIdx;
62 refToRealMap_[refIdx] = realIdx;
63 }
64 }
65
67 SmallLocalIndexType realToRefIdx(const SmallLocalIndexType localIsIdx) const
68 { return realToRefMap_[localIsIdx]; }
69
71 SmallLocalIndexType refToRealIdx(const SmallLocalIndexType localIsIdx) const
72 { return refToRealMap_[localIsIdx]; }
73
74private:
75 std::array<SmallLocalIndexType, numElementFaces> realToRefMap_ = {};
76 std::array<SmallLocalIndexType, numElementFaces> refToRealMap_ = {};
77};
78
87template<class GridView>
89{
90 using SmallLocalIndexType = typename IndexTraits<GridView>::SmallLocalIndex;
91 using Element = typename GridView::template Codim<0>::Entity;
92public:
93
95 void update(const GridView&, const Element&) {}
96
98 SmallLocalIndexType realToRefIdx(const SmallLocalIndexType localIsIdx) const
99 { return localIsIdx; }
100
102 SmallLocalIndexType refToRealIdx(const SmallLocalIndexType localIsIdx) const
103 { return localIsIdx; }
104};
105
106} // end namespace Detail
107
115template<class GridView>
118
119} // end namespace Dumux
120
121#endif
SmallLocalIndexType refToRealIdx(const SmallLocalIndexType localIsIdx) const
Return the intersection's local reference indexInElement given an actual local index.
Definition: localintersectionindexmapper.hh:71
void update(const GridView &gv, const Element &element)
Definition: localintersectionindexmapper.hh:44
SmallLocalIndexType realToRefIdx(const SmallLocalIndexType localIsIdx) const
Return the intersection's actual local indexInElement given a local reference index.
Definition: localintersectionindexmapper.hh:67
SmallLocalIndexType realToRefIdx(const SmallLocalIndexType localIsIdx) const
Return the intersection's actual local indexInElement given a local reference index.
Definition: localintersectionindexmapper.hh:98
SmallLocalIndexType refToRealIdx(const SmallLocalIndexType localIsIdx) const
Return the intersection's local reference indexInElement given an actual local index.
Definition: localintersectionindexmapper.hh:102
void update(const GridView &, const Element &)
Update the map for getting the corresponding local face indices in another element.
Definition: localintersectionindexmapper.hh:95
Definition: localintersectionindexmapper.hh:29
static std::size_t normalAxis(const Vector &v)
Returns the normal axis index of a unit vector (0 = x, 1 = y, 2 = z)
Definition: normalaxis.hh:26
Defines the index types used for grid and local indices.
Define some often used mathematical functions.
Definition: adapt.hh:17
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
std::uint_least8_t SmallLocalIndex
Definition: indextraits.hh:29