OpenLB
1.8.1
Loading...
Searching...
No Matches
src
core
platform
cpu
sisd
mask.h
Go to the documentation of this file.
1
/* This file is part of the OpenLB library
2
*
3
* Copyright (C) 2021 Adrian Kummerlaender
4
* E-mail contact: info@openlb.net
5
* The most recent release of OpenLB can be downloaded at
6
* <http://www.openlb.net/>
7
*
8
* This program is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU General Public License
10
* as published by the Free Software Foundation; either version 2
11
* of the License, or (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public
19
* License along with this program; if not, write to the Free
20
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21
* Boston, MA 02110-1301, USA.
22
*/
23
24
#ifndef CPU_SISD_MASK_H_
25
#define CPU_SISD_MASK_H_
26
27
#include "
column.h
"
28
29
namespace
olb
{
30
31
template
<
typename
T>
32
class
ConcreteBlockMask
<T,
Platform
::
CPU_SISD
> final :
public
Serializable
{
33
private
:
34
cpu::sisd::Column<bool>
_mask;
35
std::size_t _weight;
36
37
public
:
38
ConcreteBlockMask
(std::size_t size):
39
_mask(size),
40
_weight(0)
41
{ }
42
43
AbstractColumn<bool>
&
asAbstract
() {
44
return
_mask;
45
}
46
47
bool
operator[]
(std::size_t i)
const
{
48
return
_mask[i];
49
}
50
51
void
set
(std::size_t i,
bool
active) {
52
if
( _mask[i] && !active) {
53
_weight -= 1;
54
}
else
if
(!_mask[i] && active) {
55
_weight += 1;
56
}
57
_mask[i] = active;
58
}
59
60
std::size_t
weight
()
const
{
61
return
_weight;
62
}
63
64
void
setProcessingContext
(
ProcessingContext
) { }
65
67
std::size_t getNblock()
const override
;
69
std::size_t getSerializableSize()
const override
;
71
bool
* getBlock(std::size_t iBlock, std::size_t& sizeBlock,
bool
loadingMode)
override
;
72
73
};
74
75
template
<
typename
T>
76
std::size_t
ConcreteBlockMask<T,Platform::CPU_SISD>::getNblock
()
const
77
{
78
return
1 + _mask.getNblock();
79
}
80
81
template
<
typename
T>
82
std::size_t
ConcreteBlockMask<T,Platform::CPU_SISD>::getSerializableSize
()
const
83
{
84
return
sizeof
(_weight) + _mask.getSerializableSize();
85
}
86
87
template
<
typename
T>
88
bool
*
ConcreteBlockMask<T,Platform::CPU_SISD>::getBlock
(std::size_t iBlock, std::size_t& sizeBlock,
bool
loadingMode)
89
{
90
std::size_t currentBlock = 0;
91
bool
* dataPtr =
nullptr
;
92
93
registerVar(iBlock, sizeBlock, currentBlock, dataPtr, _weight);
94
registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, _mask, loadingMode);
95
96
return
dataPtr;
97
}
98
99
100
}
101
102
#endif
olb::ConcreteBlockMask< T, Platform::CPU_SISD >::operator[]
bool operator[](std::size_t i) const
Definition
mask.h:47
olb::ConcreteBlockMask< T, Platform::CPU_SISD >::ConcreteBlockMask
ConcreteBlockMask(std::size_t size)
Definition
mask.h:38
olb::ConcreteBlockMask< T, Platform::CPU_SISD >::weight
std::size_t weight() const
Definition
mask.h:60
olb::ConcreteBlockMask< T, Platform::CPU_SISD >::asAbstract
AbstractColumn< bool > & asAbstract()
Definition
mask.h:43
olb::ConcreteBlockMask< T, Platform::CPU_SISD >::set
void set(std::size_t i, bool active)
Definition
mask.h:51
olb::ConcreteBlockMask< T, Platform::CPU_SISD >::setProcessingContext
void setProcessingContext(ProcessingContext)
Definition
mask.h:64
olb::ConcreteBlockMask
Definition
operator.h:32
olb::Serializable
Base class for serializable objects of constant size. For dynamic size use BufferSerializable.
Definition
serializer.h:145
olb::cpu::sisd::Column
Plain column for SISD CPU targets (default)
Definition
column.h:45
column.h
olb
Top level namespace for all of OpenLB.
Definition
advectionDiffusionDirichlet.h:27
olb::ProcessingContext
ProcessingContext
OpenLB processing contexts.
Definition
platform.h:54
olb::Platform
Platform
OpenLB execution targets.
Definition
platform.h:35
olb::Platform::CPU_SISD
@ CPU_SISD
olb::AbstractColumn
Abstract declarator of Column-like storage.
Definition
column.h:34
Generated on Sat May 17 2025 10:47:59 for OpenLB by
1.12.0