OpenLB
1.7
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
bool
operator[]
(std::size_t i)
const
{
44
return
_mask[i];
45
}
46
47
void
set
(std::size_t i,
bool
active) {
48
if
( _mask[i] && !active) {
49
_weight -= 1;
50
}
else
if
(!_mask[i] && active) {
51
_weight += 1;
52
}
53
_mask[i] = active;
54
}
55
56
std::size_t
weight
()
const
{
57
return
_weight;
58
}
59
60
void
setProcessingContext
(
ProcessingContext
) { }
61
63
std::size_t getNblock()
const override
;
65
std::size_t getSerializableSize()
const override
;
67
bool
* getBlock(std::size_t iBlock, std::size_t& sizeBlock,
bool
loadingMode)
override
;
68
69
};
70
71
template
<
typename
T>
72
std::size_t
ConcreteBlockMask<T,Platform::CPU_SISD>::getNblock
()
const
73
{
74
return
1 + _mask.getNblock();
75
}
76
77
template
<
typename
T>
78
std::size_t
ConcreteBlockMask<T,Platform::CPU_SISD>::getSerializableSize
()
const
79
{
80
return
sizeof
(_weight) + _mask.getSerializableSize();
81
}
82
83
template
<
typename
T>
84
bool
*
ConcreteBlockMask<T,Platform::CPU_SISD>::getBlock
(std::size_t iBlock, std::size_t& sizeBlock,
bool
loadingMode)
85
{
86
std::size_t currentBlock = 0;
87
bool
* dataPtr =
nullptr
;
88
89
registerVar(iBlock, sizeBlock, currentBlock, dataPtr, _weight);
90
registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, _mask, loadingMode);
91
92
return
dataPtr;
93
}
94
95
96
}
97
98
#endif
olb::ConcreteBlockMask< T, Platform::CPU_SISD >::operator[]
bool operator[](std::size_t i) const
Definition
mask.h:43
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:56
olb::ConcreteBlockMask< T, Platform::CPU_SISD >::set
void set(std::size_t i, bool active)
Definition
mask.h:47
olb::ConcreteBlockMask< T, Platform::CPU_SISD >::setProcessingContext
void setProcessingContext(ProcessingContext)
Definition
mask.h:60
olb::ConcreteBlockMask
Definition
blockDynamicsMap.h:39
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
boundaryPostProcessors2D.h:34
olb::ProcessingContext
ProcessingContext
OpenLB processing contexts.
Definition
platform.h:55
olb::Platform
Platform
OpenLB execution targets.
Definition
platform.h:36
olb::Platform::CPU_SISD
@ CPU_SISD
Generated on Tue Mar 5 2024 09:57:45 for OpenLB by
1.10.0