ASL
0.1.7
Advanced Simulation Library
Toggle main menu visibility
Loading...
Searching...
No Matches
examples
flow
bus_wind.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 <
utilities/aslParametersManager.h
>
31
#include <
math/aslTemplates.h
>
32
#include <
math/aslDistanceFunction.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 <
readers/aslVTKFormatReaders.h
>
41
42
43
44
typedef
float
FlT
;
45
//typedef double FlT;
46
typedef
asl::UValue<double>
Param
;
47
48
using
asl::AVec
;
49
using
asl::makeAVec
;
50
51
52
int
main
(
int
argc,
char
* argv[])
53
{
54
// Optionally add appParamsManager to be able to manipulate at least
55
// hardware parameters(platform/device) through command line/parameters file
56
asl::ApplicationParametersManager
appParamsManager(
"bus_wind"
,
57
"1.0"
);
58
asl::Parameter<string>
input(
"input"
,
"path to the bus geometry input file"
);
59
appParamsManager.
load
(argc, argv);
60
61
Param
dx(8);
62
Param
dt(1.);
63
Param
nu(.01);
64
65
Param
nuNum(nu.
v
()*dt.
v
()/dx.v()/dx.v());
66
67
std::cout <<
"Data initialization... "
<< flush;
68
69
70
auto
object(
asl::readSurface
(input.
v
(), dx.v(), 1.5,.25,0.,1.,3.,1.));
71
72
asl::Block
block(object->getInternalBlock());
73
74
auto
forceField(
asl::generateDataContainerACL_SP<FlT>
(block, 3, 1u));
75
asl::initData
(forceField,
makeAVec
(0.,0.,0.));
76
77
std::cout <<
"Finished"
<< endl;
78
79
std::cout <<
"Numerics initialization... "
<< flush;
80
81
asl::SPLBGK
lbgk(
new
asl::LBGK
(block,
82
acl::generateVEConstant
(
FlT
(nu.
v
())),
83
&
asl::d3q15
()));
84
85
lbgk->init();
86
asl::SPLBGKUtilities
lbgkUtil(
new
asl::LBGKUtilities
(lbgk));
87
lbgkUtil->initF(
acl::generateVEConstant
(-.1,.0,-.05));
88
89
std::vector<asl::SPNumMethod> bc;
90
std::vector<asl::SPNumMethod> bcV;
91
92
bc.push_back(generateBCNoSlip(lbgk,
object
));
93
bcV.push_back(generateBCNoSlipVel(lbgk,
object
));
94
bc.push_back(generateBCConstantPressureVelocity(lbgk, 1.,
95
makeAVec
(-0.1,0.,-0.05),
96
{
asl::X0
,
asl::XE
,
asl::Y0
,
asl::YE
,
asl::Z0
,
asl::ZE
}));
97
initAll(bc);
98
initAll(bcV);
99
100
auto
computeForce(generateComputeSurfaceForce(lbgk, forceField,
object
));
101
computeForce->init();
102
103
104
std::cout <<
"Finished"
<< endl;
105
std::cout <<
"Computing..."
<< endl;
106
107
asl::WriterVTKXML
writer(
"bus_wind"
);
108
writer.
addScalars
(
"bus"
, *
object
);
109
writer.
addScalars
(
"rho"
, *lbgk->getRho());
110
writer.
addVector
(
"v"
, *lbgk->getVelocity());
111
writer.
addVector
(
"force"
, *forceField);
112
113
executeAll(bc);
114
executeAll(bcV);
115
computeForce->execute();
116
117
writer.
write
();
118
119
asl::Timer
timer, timer1, timer2;
120
timer.
start
();
121
timer1.
reset
();
122
timer2.
reset
();
123
for
(
unsigned
int
i(1); i < 101; ++i)
124
{
125
timer1.
start
();
126
lbgk->execute();
127
timer1.
stop
();
128
timer2.
start
();
129
executeAll(bc);
130
timer2.
stop
();
131
if
(!(i%1000))
132
{
133
cout << i << endl;
134
executeAll(bcV);
135
computeForce->execute();
136
writer.
write
();
137
}
138
}
139
timer.
stop
();
140
141
cout <<
"Finished"
<< endl;
142
143
cout <<
"Computation statistic:"
<< endl;
144
cout <<
"Real Time = "
<< timer.
realTime
() <<
"; Processor Time = "
145
<< timer.
processorTime
() <<
"; Processor Load = "
146
<< timer.
processorLoad
() * 100 <<
"%"
<< endl;
147
148
cout <<
"time1 = "
<< timer1.
realTime
() <<
"; time2 = "
<< timer2.
realTime
() << endl;
149
150
return
0;
151
}
aclGenerators.h
FlT
float FlT
Definition
acousticWaves.cc:40
aslDataInc.h
aslDistanceFunction.h
aslLBGK.h
aslLBGKBC.h
aslParametersManager.h
aslPositionFunction.h
aslTemplates.h
aslTimer.h
aslVTKFormatReaders.h
aslVTKFormatWriters.h
makeAVec
AVec< T > makeAVec(T a1)
Definition
aslVectorsDynamicLength.h:176
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::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::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::reset
void reset()
Definition
aslTimer.h:48
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::d3q15
const VectorTemplate & d3q15()
Vector template.
acl::generateVEConstant
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
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