Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
refinementindicator.hh
Go to the documentation of this file.
1// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set ts=8 sw=4 et sts=4:
3
4// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUFEM_ESTIMATORS_REFINEMENT_INDICATOR_HH
8#define DUNE_FUFEM_ESTIMATORS_REFINEMENT_INDICATOR_HH
9
10#include <array>
11#include <map>
12
20template <class GridType>
22{
23
24 typedef double field_type;
25 typedef typename GridType::LocalIdSet IdSet;
26 typedef typename GridType::template Codim<0>::Entity Element;
27 typedef typename IdSet::IdType IdType;
28
29 enum {dim = GridType::dimension};
30
31public:
32
34 RefinementIndicator(const GridType& grid)
35 : grid_(&grid)
36 {}
37
39 void clear() {
40 for (size_t i=0; i<indicators_.size(); i++)
41 indicators_[i].clear();
42 }
43
46 void set(const Element& element, unsigned int codim, unsigned int subEntity, const field_type);
47
53 field_type value (const Element& element, unsigned int codim, unsigned int subEntity) const;
54
55private:
56
57 const GridType* grid_;
58
59 // One map per codimension
61
62};
63
64
65// Set indicator associated with a subentity of an element
66template <class GridType>
68set(const Element& element, unsigned int codim, unsigned int subEntity, const field_type value)
69{
70 IdType id = grid_->localIdSet().subId(element, subEntity, codim);
71
72 indicators_[codim][id] = value;
73}
74
75
76/* Get indicator associated with a subentity of an element */
77template <class GridType>
78typename RefinementIndicator<GridType>::field_type RefinementIndicator<GridType>::
79value (const Element& element, unsigned int codim, unsigned int subEntity) const
80{
81 IdType id = grid_->localIdSet().subId(element, subEntity, codim);
82 typename std::map<IdType,field_type>::const_iterator indicatorEntry = indicators_[codim].find(id);
83 return (indicatorEntry != indicators_[codim].end()) ? indicatorEntry->second : 0;
84}
85
86template <class Grid>
87auto makeRefinementIndicator(const Grid& grid) {
88 return RefinementIndicator<Grid>(grid);
89}
90
91#endif
int id()
auto makeRefinementIndicator(const Grid &grid)
Definition refinementindicator.hh:87
iterator end()
Holds refinement indicators for a hierarchical grid.
Definition refinementindicator.hh:22
void clear()
Erase all entries.
Definition refinementindicator.hh:39
void set(const Element &element, unsigned int codim, unsigned int subEntity, const field_type)
Set indicator associated with a subentity of an element.
Definition refinementindicator.hh:68
RefinementIndicator(const GridType &grid)
Set up the indicator for a given grid.
Definition refinementindicator.hh:34
field_type value(const Element &element, unsigned int codim, unsigned int subEntity) const
Get indicator associated with a subentity of an element.
Definition refinementindicator.hh:79
T find(T... args)
T size(T... args)