OpenLB 1.8.1
Loading...
Searching...
No Matches
coarseCell.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2024 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 REFINEMENT_COARSE_CELL_H
25#define REFINEMENT_COARSE_CELL_H
26
27namespace olb {
28
29namespace refinement {
30
31template <typename CELL>
33private:
34 CELL _cell;
36
37public:
38 using value_t = typename CELL::value_t;
39 using descriptor_t = typename CELL::descriptor_t;
40
42 : _cell{std::move(cell)}
43 , _fineLatticeR{fineLatticeR}
44 {
45 _cell.setLatticeR(_fineLatticeR / 2);
46 }
47
48 CoarseCell(const CELL& cell, const LatticeR<CELL::descriptor_t::d>& fineLatticeR) any_platform
49 : _cell{cell}
50 , _fineLatticeR{fineLatticeR}
51 {
52 _cell.setLatticeR(_fineLatticeR / 2);
53 }
54
56 : _cell(rhs._cell)
57 , _fineLatticeR(rhs._fineLatticeR)
58 { }
59
61 operator bool() const any_platform {
62 using DESCRIPTOR = typename CELL::descriptor_t;
63 bool coIncident = true;
64 for (unsigned iD=0; iD < DESCRIPTOR::d; ++iD) {
65 coIncident &= !(_fineLatticeR[iD] & 1);
66 }
67 return coIncident;
68 }
69
72 return _cell;
73 }
74
77 return CoarseCell{_cell, _fineLatticeR + offset};
78 }
79
80};
81
82template <typename DATA>
84private:
85 DATA _data;
86
87public:
88 using value_t = typename DATA::value_t;
89 using descriptor_t = typename DATA::descriptor_t;
90
92 : _data{std::move(data)}
93 { }
94
95 ContextData(const DATA& data) any_platform
96 : _data{data}
97 { }
98
100 : _data(rhs._data)
101 { }
102
104 return _data;
105 }
106
108 return &_data;
109 }
110
111};
112
113template <typename DATA>
115private:
116 DATA _data;
117
118public:
119 using value_t = typename DATA::value_t;
120 using descriptor_t = typename DATA::descriptor_t;
121
123 : _data{std::move(data)}
124 { }
125
127 : _data{data}
128 { }
129
131 : _data(rhs._data)
132 { }
133
134 operator bool() const any_platform {
135 return _data.getCellId() != std::numeric_limits<CellID>::max();
136 }
137
139 return _data;
140 }
141
143 return &_data;
144 }
145
147 auto data = _data;
148 const CellID index = data.template getFieldComponent<fields::refinement::CONTEXT_NEIGHBORS>(iN);
149 data.setCellId(index);
150 return ContextDataWithNeighbors{data};
151 }
152
153};
154
155}
156
157}
158
159#endif
Plain old scalar vector.
CoarseCell(const CoarseCell &rhs) any_platform
Definition coarseCell.h:55
CoarseCell neighbor(LatticeR< descriptor_t::d > offset) any_platform
Return neighbor along fine offset.
Definition coarseCell.h:76
typename CELL::descriptor_t descriptor_t
Definition coarseCell.h:39
CoarseCell(CELL &&cell, const LatticeR< CELL::descriptor_t::d > &fineLatticeR) any_platform
Definition coarseCell.h:41
CELL & operator*() any_platform
Return reference to coarse cell (only well defined if isCoIncident)
Definition coarseCell.h:71
typename CELL::value_t value_t
Definition coarseCell.h:38
CoarseCell(const CELL &cell, const LatticeR< CELL::descriptor_t::d > &fineLatticeR) any_platform
Definition coarseCell.h:48
ContextDataWithNeighbors(const DATA &data) any_platform
Definition coarseCell.h:126
ContextDataWithNeighbors neighbor(unsigned iN) any_platform
Definition coarseCell.h:146
ContextDataWithNeighbors(const ContextDataWithNeighbors &rhs) any_platform
Definition coarseCell.h:130
ContextDataWithNeighbors(DATA &&data) any_platform
Definition coarseCell.h:122
typename DATA::descriptor_t descriptor_t
Definition coarseCell.h:120
DATA & operator*() any_platform
Definition coarseCell.h:103
ContextData(const DATA &data) any_platform
Definition coarseCell.h:95
typename DATA::value_t value_t
Definition coarseCell.h:88
ContextData(const ContextData &rhs) any_platform
Definition coarseCell.h:99
DATA * operator->() any_platform
Definition coarseCell.h:107
ContextData(DATA &&data) any_platform
Definition coarseCell.h:91
typename DATA::descriptor_t descriptor_t
Definition coarseCell.h:89
Top level namespace for all of OpenLB.
std::uint32_t CellID
Type for sequential block-local cell indices.
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:77