ASL
0.1.7
Advanced Simulation Library
Toggle main menu visibility
Loading...
Searching...
No Matches
examples
flow
locomotive_stability.cc
Go to the documentation of this file.
1
/*
2
* Advanced Simulation Library <http://asl.org.il>
3
*
4
* Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5
*
6
*
7
* This file is part of Advanced Simulation Library (ASL).
8
*
9
* ASL is free software: you can redistribute it and/or modify it
10
* under the terms of the GNU Affero General Public License as
11
* published by the Free Software Foundation, version 3 of the License.
12
*
13
* ASL 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 Affero General Public License for more details.
17
*
18
* You should have received a copy of the GNU Affero General Public License
19
* along with ASL. If not, see <http://www.gnu.org/licenses/>.
20
*
21
*/
22
23
29
30
#include <
math/aslVectors.h
>
31
#include <
math/aslTemplates.h
>
32
#include <
aslGeomInc.h
>
33
#include <
math/aslPositionFunction.h
>
34
#include <
aslDataInc.h
>
35
#include <
acl/aclGenerators.h
>
36
#include <
writers/aslVTKFormatWriters.h
>
37
#include <
num/aslLBGK.h
>
38
#include <
num/aslLBGKBC.h
>
39
#include <
utilities/aslTimer.h
>
40
#include <
acl/aclUtilities.h
>
41
#include <
readers/aslVTKFormatReaders.h
>
42
#include <
utilities/aslParametersManager.h
>
43
44
45
typedef
float
FlT
;
46
//typedef double FlT;
47
typedef
asl::UValue<double>
Param
;
48
49
using
asl::AVec
;
50
using
asl::makeAVec
;
51
52
asl::SPDistanceFunction
generateNozzels
(
asl::Block
& bl)
53
{
54
55
double
y(10.33);
56
double
z(3.08);
57
double
h(1.);
58
double
rNozzel(.3);
59
double
n(4.);
60
double
x0(-20.);
61
double
xE(-6.);
62
63
double
dx(bl.
dx
);
64
65
asl::SPDistanceFunction
res(generateDFCylinder(rNozzel,
66
makeAVec
(0., 0., h),
67
makeAVec
(x0, y, z + h * .5)));
68
for
(
unsigned
int
i(1); i < n; ++i)
69
res = res | generateDFCylinder(rNozzel,
70
makeAVec
(0., 0., h),
71
makeAVec
(x0 + i * (xE-x0)/n, y, z+h*.5));
72
return
normalize(res, dx);
73
}
74
75
76
int
main
(
int
argc,
char
* argv[])
77
{
78
// Optionally add appParamsManager to be able to manipulate at least
79
// hardware parameters(platform/device) through command line/parameters file
80
asl::ApplicationParametersManager
appParamsManager(
"locomotive_stability"
,
81
"1.0"
);
82
asl::Parameter<string>
input(
"input"
,
"path to the geometry input file"
);
83
appParamsManager.
load
(argc, argv);
84
85
Param
dx(0.25);
86
Param
dt(1.);
87
Param
nu(.01);
88
89
Param
nuNum(nu.
v
()*dt.
v
()/dx.v()/dx.v());
90
91
std::cout <<
"Data initialization... "
<< flush;
92
93
auto
locomotive(
asl::readSurface
(input.
v
(), dx.v(), .5, 1., 0., 1., 2., 4.));
94
95
asl::Block
block(locomotive->getInternalBlock());
96
97
auto
forceField(
asl::generateDataContainerACL_SP<FlT>
(block, 3, 1u));
98
asl::initData
(forceField,
makeAVec
(0., 0., 0.));
99
100
std::cout <<
"Finished"
<< endl;
101
102
std::cout <<
"Numerics initialization... "
<< flush;
103
104
asl::SPLBGK
lbgk(
new
asl::LBGK
(block,
105
acl::generateVEConstant
(
FlT
(nu.
v
())),
106
&
asl::d3q15
()));
107
108
lbgk->init();
109
asl::SPLBGKUtilities
lbgkUtil(
new
asl::LBGKUtilities
(lbgk));
110
lbgkUtil->initF(
acl::generateVEConstant
(.1,.0,.05));
111
112
auto
vfTunnel(
asl::generatePFConstant
(
makeAVec
(0.1,0.,0.)));
113
114
std::vector<asl::SPNumMethod> bc;
115
std::vector<asl::SPNumMethod> bcV;
116
117
auto
nozzelsMap(
asl::generateDataContainerACL_SP<FlT>
(block, 1, 1u));
118
asl::initData
(nozzelsMap,
generateNozzels
(block));
119
120
121
bc.push_back(generateBCNoSlip(lbgk, locomotive));
122
bcV.push_back(generateBCNoSlipVel(lbgk, locomotive));
123
bc.push_back(generateBCConstantPressureVelocity(lbgk, 1.,
124
makeAVec
(0.1,0.,0.05),
125
{
asl::X0
,
asl::XE
,
asl::Y0
,
asl::YE
,
asl::Z0
,
asl::ZE
}));
126
bc.push_back(generateBCConstantPressureVelocity(lbgk, 1.,
makeAVec
(0.,0.,-0.1), nozzelsMap));
127
initAll(bc);
128
initAll(bcV);
129
130
auto
computeForce(generateComputeSurfaceForce(lbgk, forceField, locomotive));
131
computeForce->init();
132
133
134
std::cout <<
"Finished"
<< endl;
135
std::cout <<
"Computing..."
<< endl;
136
137
asl::WriterVTKXML
writer(appParamsManager.
getDir
() +
"locomotive_stability"
);
138
writer.
addScalars
(
"locomotive"
, *locomotive);
139
writer.
addScalars
(
"nozzels"
, *nozzelsMap);
140
writer.
addScalars
(
"rho"
, *lbgk->getRho());
141
writer.
addVector
(
"v"
, *lbgk->getVelocity());
142
writer.
addVector
(
"force"
, *forceField);
143
144
executeAll(bc);
145
executeAll(bcV);
146
computeForce->execute();
147
148
writer.
write
();
149
150
asl::Timer
timer, timer1, timer2;
151
timer.
start
();
152
for
(
unsigned
int
i(1); i < 40001; ++i)
153
{
154
lbgk->execute();
155
executeAll(bc);
156
if
(!(i%1000))
157
{
158
cout << i << endl;
159
executeAll(bcV);
160
computeForce->execute();
161
writer.
write
();
162
}
163
}
164
timer.
stop
();
165
166
cout <<
"Finished"
<< endl;
167
168
cout <<
"Computation statistic:"
<< endl;
169
cout <<
"Real Time = "
<< timer.
realTime
() <<
"; Processor Time = "
170
<< timer.
processorTime
() <<
"; Processor Load = "
171
<< timer.
processorLoad
() * 100 <<
"%"
<< endl;
172
173
return
0;
174
}
aclGenerators.h
aclUtilities.h
FlT
float FlT
Definition
acousticWaves.cc:40
aslDataInc.h
aslGeomInc.h
aslLBGK.h
aslLBGKBC.h
aslParametersManager.h
aslPositionFunction.h
aslTemplates.h
aslTimer.h
aslVTKFormatReaders.h
aslVTKFormatWriters.h
aslVectors.h
definition of class АVec<T>
asl::AVec
Definition
aslVectorsDynamicLength.h:40
asl::ApplicationParametersManager
Definition
aslParametersManager.h:159
asl::ApplicationParametersManager::load
void load(int argc, char *argv[])
asl::Block
Definition
aslBlocks.h:57
asl::Block::dx
double dx
Definition
aslBlocks.h:66
asl::LBGK
Numerical method for fluid flow.
Definition
aslLBGK.h:78
asl::LBGKUtilities
contains different kernels for preprocessing and posprocessing of data used by LBGK
Definition
aslLBGK.h:138
asl::Parameter
Definition
aslParametersManager.h:45
asl::Parameter::v
const T & v() const
Definition
aslParametersManager.h:179
asl::ParametersManager::getDir
std::string getDir()
asl::Timer
Definition
aslTimer.h:34
asl::Timer::realTime
const double realTime() const
Definition
aslTimer.h:45
asl::Timer::stop
void stop()
Definition
aslTimer.h:44
asl::Timer::processorTime
const double processorTime() const
Definition
aslTimer.h:46
asl::Timer::start
void start()
Definition
aslTimer.h:43
asl::Timer::processorLoad
const double processorLoad() const
Definition
aslTimer.h:47
asl::UValue
Updatable value. This class stores value and its TimeStamp.
Definition
aslUValue.h:35
asl::UValue::v
const T & v() const
Definition
aslUValue.h:43
asl::Writer::addVector
void addVector(std::string name, AbstractData &data)
asl::Writer::addScalars
void addScalars(std::string name, AbstractData &data)
asl::WriterVTKXML
Definition
aslVTKFormatWriters.h:42
asl::WriterVTKXML::write
void write()
Param
asl::UValue< FlT > Param
Definition
cubeGravity.cc:43
asl::Y0
@ Y0
Definition
aslBCond.h:309
asl::XE
@ XE
Definition
aslBCond.h:309
asl::Z0
@ Z0
Definition
aslBCond.h:309
asl::YE
@ YE
Definition
aslBCond.h:309
asl::ZE
@ ZE
Definition
aslBCond.h:309
asl::X0
@ X0
Definition
aslBCond.h:309
asl::generateDataContainerACL_SP
SPDataWrapperACLData generateDataContainerACL_SP(const Block &b, unsigned int n=1)
generates pointer to ACL Data field with n components
asl::readSurface
SPDataWithGhostNodesACLData readSurface(const string &fileName, double dx, acl::CommandQueue queue=acl::hardware.defaultQueue)
asl::SPDistanceFunction
std::shared_ptr< DistanceFunction > SPDistanceFunction
Definition
aslGeomInc.h:45
asl::generatePFConstant
SPPositionFunction generatePFConstant(const AVec< double > &a)
asl::d3q15
const VectorTemplate & d3q15()
Vector template.
acl::generateVEConstant
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
makeAVec
AVec< T > makeAVec(T a1)
Definition
aslVectorsDynamicLength.h:176
generateNozzels
asl::SPDistanceFunction generateNozzels(asl::Block &bl)
Definition
locomotive_stability.cc:52
asl::makeAVec
AVec< T > makeAVec(T a1)
Definition
aslVectorsDynamicLength.h:176
asl::SPLBGKUtilities
std::shared_ptr< LBGKUtilities > SPLBGKUtilities
Definition
aslLBGK.h:161
asl::SPLBGK
std::shared_ptr< LBGK > SPLBGK
Definition
aslLBGK.h:133
asl::initData
void initData(SPAbstractData d, double a)
main
int main()
Definition
testABDFormat.cc:126
Generated by
1.17.0