Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
geometricmarking.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM Project contributors, see file AUTHORS.md
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
3
4#ifndef DUNE_GEOMETRIC_ERROR_ESTIMATOR_HH
5#define DUNE_GEOMETRIC_ERROR_ESTIMATOR_HH
6
8
11template <class GridType>
13
14 enum {dim = GridType::dimension};
15 enum {dimworld = GridType::dimensionworld};
16
17 public:
18 static void estimate(GridType& grid,
19 bool (*refinementCondition)(const Dune::FieldVector<double, dim>& pos)) {
20
21 for (const auto& e : elements(grid.leafGridView())) {
22
23 // Compute element's center of mass
24 const auto& geometry = e.geometry();
25 auto center = geometry.corner(0);
26
27 for (int i=1; i<geometry.corners(); i++)
28 center += geometry.corner(i);
29
30 center /= (double)geometry.corners();
31
32 // Mark if the condition is fulfilled
33 if ((*refinementCondition)(center) )
34 grid.mark(1, e);
35 }
36 }
37
38 template <class BlockVectorType>
39 static void estimate(GridType& grid,
40 bool (*refinementCondition)(const Dune::FieldVector<double, dimworld>& pos),
41 const BlockVectorType& deformation) {
42
43 const auto& indexSet = grid.leafIndexSet();
44
45 for (const auto& e : elements(grid.leafGridView())) {
46
47 // Compute element's center of mass
49 const auto& geometry = e.geometry();
50
51 for (int i=0; i<geometry.corners(); i++)
52 center += geometry.corner(i) + deformation[indexSet.template subIndex<dim>(e,i)];
53
54 center /= (double) geometry.corners();
55
56 // Mark if the condition is fulfilled
57 if ( (*refinementCondition)(center) > 0)
58 grid.mark(1, e);
59 }
60 }
61};
62
63#endif
LeafGridView leafGridView() const
bool mark(int refCount, const typename Codim< 0 >::Entity &e)
const LeafIndexSet & leafIndexSet() const
Error estimator which marks an element for refinement if it fulfills a geometric condition.
Definition geometricmarking.hh:12
static void estimate(GridType &grid, bool(*refinementCondition)(const Dune::FieldVector< double, dim > &pos))
Definition geometricmarking.hh:18
static void estimate(GridType &grid, bool(*refinementCondition)(const Dune::FieldVector< double, dimworld > &pos), const BlockVectorType &deformation)
Definition geometricmarking.hh:39