Line | Branch | Exec | Source |
---|---|---|---|
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 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup Adaptive | ||
10 | * \brief A free function for h-adaptivity. | ||
11 | */ | ||
12 | #ifndef DUMUX_ADAPTIVE_ADAPT_HH | ||
13 | #define DUMUX_ADAPTIVE_ADAPT_HH | ||
14 | |||
15 | #include "griddatatransfer.hh" | ||
16 | |||
17 | namespace Dumux { | ||
18 | |||
19 | /*! | ||
20 | * \ingroup Adaptive | ||
21 | * \brief Adapt the grid and reconstruct the user data | ||
22 | * | ||
23 | * \param grid The grid to adapt | ||
24 | * \param dataTransfer A class that performs the data | ||
25 | * transfer from the old to the new grid. | ||
26 | */ | ||
27 | template<class Grid> | ||
28 | 15 | bool adapt(Grid& grid, GridDataTransfer<Grid>& dataTransfer) | |
29 | { | ||
30 | // Do pre-adaption step of the grid | ||
31 | 15 | const bool mightCoarsen = grid.preAdapt(); | |
32 | |||
33 | // Let the helper do storage of variables | ||
34 | 15 | dataTransfer.store(grid); | |
35 | |||
36 | // adapt the grid | ||
37 | 15 | const bool refine = grid.adapt(); | |
38 | |||
39 | // (Re-)construct variables to new grid | ||
40 | 15 | dataTransfer.reconstruct(grid); | |
41 | |||
42 | // delete markers in grid | ||
43 |
1/2✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
|
15 | grid.postAdapt(); |
44 | |||
45 | // return boolean if grid has been changed | ||
46 | 15 | return mightCoarsen || refine; | |
47 | } | ||
48 | |||
49 | } // end namespace Dumux | ||
50 | |||
51 | #endif | ||
52 |