VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
BCFunction.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
35#ifndef D3Q27BCFUNCTION_H
36#define D3Q27BCFUNCTION_H
37
39#include "lbm/constants/D3Q27.h"
40
41#include <muParser.h>
42
45{
46public:
47 static const real INFTIMEDEPENDENT;
48 static const real INFCONST;
49
50public:
52 BCFunction(const mu::Parser &function, const real &starttime, const real &endtime)
54 {
55 }
56 BCFunction(const std::string &functionstring, const real &starttime, const real &endtime)
58 {
59 this->setFunction(functionstring);
60 }
61 BCFunction(const real &velocity, const real &starttime, const real &endtime)
63 {
64 this->setFunction(velocity);
65 }
66
67 void setFunction(const mu::Parser &function) { this->function = function; }
68 void setFunction(const std::string &functionstring) { this->function.SetExpr(functionstring); }
70 {
71 std::stringstream dummy;
73 function.SetExpr(dummy.str());
74 }
75 void setStartTime(const real &starttime) { this->starttime = starttime; }
76 void setEndTime(const real &endtime) { this->endtime = endtime; }
77
78 mu::Parser &getFunction() { return function; }
79 const mu::Parser &getFunction() const { return function; }
80 const real &getStartTime() const { return starttime; }
81 const real &getEndTime() const { return endtime; }
82
83 std::string toString() const
84 {
85 std::stringstream info;
87 info << "start=inf. timedep., ";
88 else if (starttime == INFCONST)
89 info << "start=inf. const., ";
90 else
91 info << "start=" << starttime << ", ";
93 info << "end=inf. timedep." << std::endl;
94 else if (endtime == INFCONST)
95 info << "end=inf. const." << std::endl;
96 else
97 info << "end=" << endtime << std::endl;
98 info << "expr=" << function.GetExpr() << std::endl;
99 info << "with constants: ";
100 mu::valmap_type cmap = function.GetConst();
101 for (mu::valmap_type::const_iterator item = cmap.begin(); item != cmap.end(); ++item)
102 info << item->first << "=" << item->second << ", ";
103 return info.str();
104 }
105 /*==========================================================*/
106 friend inline std::ostream &operator<<(std::ostream &os, const BCFunction &bc)
107 {
108 os << bc.toString();
109 return os;
110 }
111
112protected:
113 mu::Parser function;
116
117private:
118};
119
120#endif // D3Q27BCFUNCTION_H
121
A class implements function parcer for boundary conditions.
Definition BCFunction.h:45
real starttime
Definition BCFunction.h:114
friend std::ostream & operator<<(std::ostream &os, const BCFunction &bc)
Definition BCFunction.h:106
const mu::Parser & getFunction() const
Definition BCFunction.h:79
BCFunction(const std::string &functionstring, const real &starttime, const real &endtime)
Definition BCFunction.h:56
void setStartTime(const real &starttime)
Definition BCFunction.h:75
void setFunction(const real &constVelocity)
Definition BCFunction.h:69
const real & getStartTime() const
Definition BCFunction.h:80
BCFunction(const real &velocity, const real &starttime, const real &endtime)
Definition BCFunction.h:61
void setEndTime(const real &endtime)
Definition BCFunction.h:76
std::string toString() const
Definition BCFunction.h:83
void setFunction(const mu::Parser &function)
Definition BCFunction.h:67
void setFunction(const std::string &functionstring)
Definition BCFunction.h:68
mu::Parser & getFunction()
Definition BCFunction.h:78
const real & getEndTime() const
Definition BCFunction.h:81
BCFunction(const mu::Parser &function, const real &starttime, const real &endtime)
Definition BCFunction.h:52
mu::Parser function
Definition BCFunction.h:113
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
static const real INFCONST
Definition BCFunction.h:48
static const real INFTIMEDEPENDENT
Definition BCFunction.h:47