ElementMarkHandle.hpp
Go to the documentation of this file.
1//===========================================================================
2//
3// File: ElementMarkHandle.hpp
4//
5// Created: June 2 2025
6//
7// Author(s): Antonella Ritorto <antonella.ritorto@opm-op.com>
8// Markus Blatt <markus.blatt@opm-op.com>
9//
10// $Date$
11//
12// $Revision$
13//
14//===========================================================================
15
16/*
17 Copyright 2025 Equinor ASA
18 This file is part of The Open Porous Media project (OPM).
19 OPM is free software: you can redistribute it and/or modify
20 it under the terms of the GNU General Public License as published by
21 the Free Software Foundation, either version 3 of the License, or
22 (at your option) any later version.
23 OPM is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 GNU General Public License for more details.
27 You should have received a copy of the GNU General Public License
28 along with OPM. If not, see <http://www.gnu.org/licenses/>.
29*/
30
31#ifndef OPM_ELEMENTMARKHANDLE_HEADER
32#define OPM_ELEMENTMARKHANDLE_HEADER
33
35
36namespace
37{
39struct ElementMarkHandle {
40
41 using DataType = int;
42
43 ElementMarkHandle(std::vector<DataType>& winningMark)
44 : winningMark_(winningMark)
45 {}
46
47 bool fixedSize(std::size_t, std::size_t)
48 {
49 // For each element, gather/scatter its mark (0, 1, or -1).
50 return true;
51 }
52
53 bool contains(std::size_t, std::size_t codim)
54 {
55 // Only communicate values attached to cells.
56 return codim == 0;
57 }
58
59 template <class T> // T = Entity<0>
60 std::size_t size([[maybe_unused]] const T& element)
61 {
62 return 1;
63 }
64
65 // Gather element mark (0: do nothing, 1: refine, -1 coarse - not supported yet)
66 template <class B, class T> // T = Entity<0>
67 void gather(B& buffer, const T& element)
68 {
69 buffer.write( winningMark_[element.index()] );
70 }
71
72 // Scatter element mark. Rewrite mark to the maximum.
73 template <class B, class T> // T = Entity<0>
74 void scatter(B& buffer, const T& element, [[maybe_unused]] std::size_t size)
75 {
76 DataType tmp_mark;
77 buffer.read(tmp_mark);
78 winningMark_[element.index()] = std::max(winningMark_[element.index()], tmp_mark);
79 }
80
81private:
82 std::vector<DataType>& winningMark_;
83};
84} // namespace
85#endif
mover::MoveBuffer< typename DataHandle::DataType > & buffer
Definition: CpGridData.hpp:1268
std::size_t fixedSize
The number of data items per index if it is fixed, 0 otherwise.
Definition: VariableSizeCommunicator.hpp:267