VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
VelocityBC.h
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//
33//=======================================================================================
34#ifndef VelocityBC_H
35#define VelocityBC_H
36
37#include <iostream>
38#include <sstream>
39#include <string>
40#include <vector>
41
43
44#include <BC.h>
45#include <BCFunction.h>
46
48
82
83class VelocityBC : public BC
84{
85public:
86 // constructors
87 VelocityBC() { this->init(); }
88
89 VelocityBC(const bool &vx1, const bool &vx2, const bool &vx3, const BCFunction &velVxBC);
90
91 VelocityBC(const bool &vx1, const bool &vx2, const bool &vx3, const mu::Parser &function,
92 const real &startTime, const real &endTime);
93
94 VelocityBC(const bool &vx1, const bool &vx2, const bool &vx3, const mu::Parser &function1,
95 const mu::Parser &function2, const mu::Parser &function3, const real &startTime,
96 const real &endTime);
97
98 VelocityBC(const bool &vx1, const bool &vx2, const bool &vx3, const std::string &functionstring,
99 const real &startTime, const real &endTime);
100
101 VelocityBC(const BCFunction &velBC, bool x1Dir, bool x2Dir, bool x3Dir);
102
104
105 VelocityBC(const std::vector<BCFunction> &velVx1BCs, const std::vector<BCFunction> &velVx2BCs,
106 const std::vector<BCFunction> &velVx3BCs);
107
108 VelocityBC(const real &vx1, const real &vx1StartTime, const real &vx1EndTime, const real &vx2,
109 const real &vx2StartTime, const real &vx2EndTime, const real &vx3,
110 const real &vx3StartTime, const real &vx3EndTime);
111
112 VelocityBC(const std::string &vx1Function, const real &vx1StartTime, const real &vx1EndTime,
113 const std::string &vx2Function, const real &vx2StartTime, const real &vx2EndTime,
114 const std::string &vx3Function, const real &vx3StartTime, const real &vx3EndTime);
115
116 // methods
117 void setTimePeriodic() { (this->type |= TIMEPERIODIC); }
118 void unsetTimePeriodic() { (this->type &= ~TIMEPERIODIC); }
119 bool isTimePeriodic() { return ((this->type & TIMEPERIODIC) == TIMEPERIODIC); }
120
121 // The following is meant for moving objects...
122 void setNewVelocities(const real &vx1, const real &vx1StartTime, const real &vx1EndTime, const real &vx2,
123 const real &vx2StartTime, const real &vx2EndTime, const real &vx3,
124 const real &vx3StartTime, const real &vx3EndTime);
125
126 //------------- implements BC ----- start
127 std::string toString();
128
129 void init(const D3Q27Interactor *const &interactor, const real &time = 0) override;
130 void update(const D3Q27Interactor *const &interactor, const real &time = 0) override;
131
133 const real &worldX2, const real &worldX3, const real &q, const int &fdirection,
134 const real &time = 0) override;
135 void adaptBC(const D3Q27Interactor &interactor, SPtr<BoundaryConditions> bc, const real &worldX1,
136 const real &worldX2, const real &worldX3, const real &time = 0) override;
137
138 //------------- implements BC ----- end
139
140 UbTupleDouble3 getVelocity(const real &x1, const real &x2, const real &x3, const real &timeStep) const;
141
142protected:
143 void init();
144 void init(std::vector<BCFunction> &vxBCs);
145
146 // time dependency is determined automatically via BCFunction intervals!
147 void setTimeDependent() { (this->type |= TIMEDEPENDENT); }
149
150 void clear()
151 {
152 vx1BCs.clear();
153 vx2BCs.clear();
154 vx3BCs.clear();
155 this->init();
156 }
157 void setNodeVelocity(const D3Q27Interactor &interactor, SPtr<BoundaryConditions> bc, const real &worldX1,
158 const real &worldX2, const real &worldX3, const real &timestep);
159
160private:
161 mutable mu::value_type x1, x2, x3;
162 mutable mu::value_type timeStep;
163
164 mu::Parser *tmpVx1Function;
165 mu::Parser *tmpVx2Function;
166 mu::Parser *tmpVx3Function;
167
168 std::vector<BCFunction> vx1BCs;
169 std::vector<BCFunction> vx2BCs;
170 std::vector<BCFunction> vx3BCs;
171};
172
173#endif
174
A class implements function parcer for boundary conditions.
Definition BCFunction.h:45
Abstract class of baundary conditions adapter.
Definition BC.h:48
static const char TIMEDEPENDENT
Definition BC.h:86
char type
Definition BC.h:82
static const char TIMEPERIODIC
Definition BC.h:87
A specialized class for grid generation.
A class implements a tuple.
Definition UbTuple.h:477
A class provides an interface for velocity boundary condition in grid generator.
Definition VelocityBC.h:84
void unsetTimePeriodic()
Definition VelocityBC.h:118
void setTimeDependent()
Definition VelocityBC.h:147
void setTimePeriodic()
Definition VelocityBC.h:117
void clear()
Definition VelocityBC.h:150
VelocityBC(const std::string &vx1Function, const real &vx1StartTime, const real &vx1EndTime, const std::string &vx2Function, const real &vx2StartTime, const real &vx2EndTime, const std::string &vx3Function, const real &vx3StartTime, const real &vx3EndTime)
bool isTimePeriodic()
Definition VelocityBC.h:119
void unsetTimeDependent()
Definition VelocityBC.h:148
VelocityBC(const std::vector< BCFunction > &velVx1BCs, const std::vector< BCFunction > &velVx2BCs, const std::vector< BCFunction > &velVx3BCs)
VelocityBC(const bool &vx1, const bool &vx2, const bool &vx3, const std::string &functionstring, const real &startTime, const real &endTime)
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
std::string toString()
void adaptBC(const D3Q27Interactor &interactor, SPtr< BoundaryConditions > bc, const real &worldX1, const real &worldX2, const real &worldX3, const real &time=0) override
void setNodeVelocity(const D3Q27Interactor &interactor, SPtr< BoundaryConditions > bc, const real &worldX1, const real &worldX2, const real &worldX3, const real &timestep)
UbTupleDouble3 getVelocity(const real &x1, const real &x2, const real &x3, const real &timeStep) const
void adaptBCForDirection(const D3Q27Interactor &interactor, SPtr< BoundaryConditions > bc, const real &worldX1, const real &worldX2, const real &worldX3, const real &q, const int &fdirection, const real &time=0) override
void setNewVelocities(const real &vx1, const real &vx1StartTime, const real &vx1EndTime, const real &vx2, const real &vx2StartTime, const real &vx2EndTime, const real &vx3, const real &vx3StartTime, const real &vx3EndTime)
void update(const D3Q27Interactor *const &interactor, const real &time=0) override