OpenLB 1.7
Loading...
Searching...
No Matches
cellD.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2019 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 CELL_D_H
25#define CELL_D_H
26
27#include "fieldArrayD.h"
28
29namespace olb {
30
32template<typename T, typename DESCRIPTOR>
34private:
36
37public:
38 using value_t = T;
39 using descriptor_t = DESCRIPTOR;
40
41 template <typename POPULATIONS>
42 PopulationCellD(POPULATIONS&& pops) any_platform:
43 _data{pops} { }
44
45 const T& operator[](unsigned iPop) const any_platform {
46 return _data[iPop];
47 }
48
49 T& operator[](unsigned iPop) any_platform {
50 return _data[iPop];
51 }
52};
53
55template<typename T, typename DESCRIPTOR>
56class CellD {
57private:
59
60public:
61 using value_t = T;
62 using descriptor_t = DESCRIPTOR;
63
64 CellD(): _fieldsD(1) { }
65
66 const T& operator[](unsigned iPop) const {
67 return _fieldsD.template getFieldComponent<descriptors::POPULATION>(0, iPop);
68 }
69
70 T& operator[](unsigned iPop) {
71 return _fieldsD.template getFieldComponent<descriptors::POPULATION>(0, iPop);
72 }
73
74 template <typename FIELD>
75 auto getField() const {
76 return _fieldsD.template getField<FIELD>(0);
77 }
78
79 template <typename FIELD>
81 _fieldsD.template setField<FIELD>(0, v);
82 }
83
84 template <typename FIELD>
86 return _fieldsD.template getFieldPointer<FIELD>(0);
87 }
88
89 template <typename FIELD>
90 auto getFieldPointer() const {
91 return _fieldsD.template getFieldPointer<FIELD>(0);
92 }
93
94 template <typename FIELD>
95 const auto& getFieldComponent(unsigned iD) const {
96 return _fieldsD.template getFieldComponent<FIELD>(0, iD);
97 }
98
99 template <typename FIELD>
100 auto& getFieldComponent(unsigned iD) {
101 return _fieldsD.template getFieldComponent<FIELD>(0, iD);
102 }
103
104};
105
106}
107
108#endif
Single cell implementing the full field data interface.
Definition cellD.h:56
void setField(const FieldD< T, DESCRIPTOR, FIELD > &v)
Definition cellD.h:80
const T & operator[](unsigned iPop) const
Definition cellD.h:66
DESCRIPTOR descriptor_t
Definition cellD.h:62
auto getField() const
Definition cellD.h:75
auto getFieldPointer()
Definition cellD.h:85
auto & getFieldComponent(unsigned iD)
Definition cellD.h:100
CellD()
Definition cellD.h:64
T & operator[](unsigned iPop)
Definition cellD.h:70
auto getFieldPointer() const
Definition cellD.h:90
T value_t
Definition cellD.h:61
const auto & getFieldComponent(unsigned iD) const
Definition cellD.h:95
Minimal cell storing only population data.
Definition cellD.h:33
PopulationCellD(POPULATIONS &&pops) any_platform
Definition cellD.h:42
DESCRIPTOR descriptor_t
Definition cellD.h:39
T & operator[](unsigned iPop) any_platform
Definition cellD.h:49
const T & operator[](unsigned iPop) const any_platform
Definition cellD.h:45
Plain old scalar vector.
Definition vector.h:47
Top level namespace for all of OpenLB.
typename MultiFieldArrayForDescriptorHelper< T, DESCRIPTOR, PLATFORM >::type MultiFieldArrayForDescriptorD
MultiFieldArrayD containing each field in DESCRIPTOR::fields_t.
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:78