VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
Field.cpp
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
32//=======================================================================================
33#include "Field.h"
34
35#include "grid/NodeValues.h"
36
37namespace vf::gpu {
38
39Field::Field(uint size) : size(size)
40{
41}
42
44{
45 this->field = new char[this->size];
46}
47
49{
50 delete[] this->field;
51}
52
53// --------------------------------------------------------- //
54// Getter //
55// --------------------------------------------------------- //
57{
58 return this->size;
59}
60
61char Field::getFieldEntry(uint index) const
62{
63 return this->field[index];
64}
65
66// --------------------------------------------------------- //
67// Is //
68// --------------------------------------------------------- //
69bool Field::is(uint index, char type) const
70{
71 return field[index] == type;
72}
73
75{
76 return field[index] == FLUID_CFC;
77}
78
80{
81 return field[index] == FLUID_FCC;
82}
83
84bool Field::isFluid(uint index) const
85{
86 const char type = field[index];
87 return type == FLUID || type == FLUID_CFC || type == FLUID_CFF || type == FLUID_FCC || type == FLUID_FCF || isBoundaryConditionNode(index);
88}
89
90bool Field::isInvalidSolid(uint index) const
91{
92 return field[index] == INVALID_SOLID;
93}
94
96{
97 return field[index] == INVALID_OUT_OF_GRID;
98}
99
101{
102 return field[index] == INVALID_COARSE_UNDER_FINE;
103}
104
106{
107 return field[index] == STOPPER_OUT_OF_GRID;
108}
109
111{
112 return field[index] == STOPPER_COARSE_UNDER_FINE;
113}
114
116{
117 return field[index] == STOPPER_SOLID;
118}
119
120bool Field::isStopper(uint index) const
121{
122 return isStopperOutOfGrid(index) || isStopperCoarseUnderFine(index) || isStopperSolid(index) || is(index, STOPPER_OUT_OF_GRID_BOUNDARY);
123}
124
125bool Field::isQ(uint index) const
126{
127 return field[index] == Q_DEPRECATED;
128}
129
131{
132 return field[index] == BC_SOLID || field[index] == BC_OUTFLOW || field[index] == BC_VELOCITY || field[index] == BC_PRESSURE || field[index] == BC_SLIP || field[index] == BC_STRESS;
133}
134
135// --------------------------------------------------------- //
136// Setter //
137// --------------------------------------------------------- //
139{
140 this->field[index] = val;
141}
142
144{
145 this->field[index] = FLUID;
146}
147
149{
150 this->field[index] = INVALID_SOLID;
151}
152
154{
155 this->field[index] = STOPPER_OUT_OF_GRID;
156}
157
159{
160 this->field[index] = STOPPER_OUT_OF_GRID_BOUNDARY;
161}
162
164{
165 this->field[index] = STOPPER_COARSE_UNDER_FINE;
166}
167
169{
170 this->field[index] = INVALID_COARSE_UNDER_FINE;
171}
172
174{
175 this->field[index] = INVALID_OUT_OF_GRID;
176}
177
178}
179
void setFieldEntry(uint index, char val)
Definition Field.cpp:138
bool isStopperSolid(uint index) const
Definition Field.cpp:115
void setFieldEntryToStopperCoarseUnderFine(uint index)
Definition Field.cpp:163
void setFieldEntryToStopperOutOfGridBoundary(uint index)
Definition Field.cpp:158
void setFieldEntryToStopperOutOfGrid(uint index)
Definition Field.cpp:153
bool isFineToCoarseNode(uint index) const
Definition Field.cpp:79
Field()=default
void setFieldEntryToInvalidOutOfGrid(uint index)
Definition Field.cpp:173
bool isQ(uint index) const
Definition Field.cpp:125
char getFieldEntry(uint index) const
Definition Field.cpp:61
bool isStopperOutOfGrid(uint index) const
Definition Field.cpp:105
void allocateMemory()
Definition Field.cpp:43
bool is(uint index, char type) const
Definition Field.cpp:69
bool isFluid(uint index) const
Definition Field.cpp:84
uint size
Definition Field.h:79
bool isInvalidOutOfGrid(uint index) const
Definition Field.cpp:95
bool isInvalidCoarseUnderFine(uint index) const
Definition Field.cpp:100
bool isCoarseToFineNode(uint index) const
Definition Field.cpp:74
bool isStopperCoarseUnderFine(uint index) const
Definition Field.cpp:110
uint getSize() const
Definition Field.cpp:56
bool isStopper(uint index) const
Definition Field.cpp:120
bool isBoundaryConditionNode(uint index) const
Definition Field.cpp:130
bool isInvalidSolid(uint index) const
Definition Field.cpp:90
void freeMemory()
Definition Field.cpp:48
void setFieldEntryToInvalidSolid(uint index)
Definition Field.cpp:148
void setFieldEntryToFluid(uint index)
Definition Field.cpp:143
void setFieldEntryToInvalidCoarseUnderFine(uint index)
Definition Field.cpp:168
char * field
Definition Field.h:78
unsigned int uint
Definition DataTypes.h:47
UbTypeOp< typenameUbDuoT< N, UbDuo< A, B > >::ResultT >::RefT val(UbDuo< A, B > &d)
Definition UbTuple.h:393