ASL
0.1.7
Advanced Simulation Library
Toggle main menu visibility
Loading...
Searching...
No Matches
examples
flow
flow.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
28
29
#include <
utilities/aslParametersManager.h
>
30
#include <
aslDataInc.h
>
31
#include <
math/aslTemplates.h
>
32
#include <
aslGeomInc.h
>
33
#include <
acl/aclGenerators.h
>
34
#include <
writers/aslVTKFormatWriters.h
>
35
#include <
num/aslLBGK.h
>
36
#include <
num/aslLBGKBC.h
>
37
#include <
utilities/aslTimer.h
>
38
#include <
acl/aclUtilities.h
>
39
40
41
42
typedef
float
FlT
;
43
//typedef double FlT;
44
typedef
asl::UValue<double>
Param
;
45
46
using
asl::AVec
;
47
using
asl::makeAVec
;
48
49
50
int
main
(
int
argc,
char
* argv[])
51
{
52
// Optionally add appParamsManager to be able to manipulate at least
53
// hardware parameters(platform/device) through command line/parameters file
54
asl::ApplicationParametersManager
appParamsManager(
"flow"
,
55
"1.0"
);
56
appParamsManager.
load
(argc, argv);
57
58
Param
dx(1.);
59
Param
dt(1.);
60
Param
nu(.00625);
61
62
Param
nuNum(nu.
v
()*dt.
v
()/dx.v()/dx.v());
63
AVec<int>
size(
asl::makeAVec
(300, 50, 50));
64
65
auto
gSize(dx.v()*
AVec<>
(size));
66
67
68
std::cout <<
"Data initialization... "
;
69
70
asl::Block
block(size,dx.v());
71
72
auto
ball(generateDFCylinderInf(.125*gSize[1],
73
makeAVec
(0.,1.,0.),
74
.45*
makeAVec
(gSize[1],gSize[1],gSize[2])));
75
// Formula
76
auto
ballMap(
asl::generateDataContainer_SP
(block, ball, 1u,
acl::typeToTypeID<FlT>
()));
77
// Data
78
auto
ballMapMem(
asl::generateDataContainerACL_SP<FlT>
(block, 1, 1u));
79
asl::initData
(ballMapMem, ball);
80
81
82
std::cout <<
"Finished"
<< endl;
83
84
std::cout <<
"Numerics initialization... "
;
85
86
asl::SPLBGK
lbgk(
new
asl::LBGK
(block,
87
acl::generateVEConstant
(
FlT
(nuNum.
v
())),
88
&
asl::d3q15
()));
89
lbgk->init();
90
91
asl::SPLBGKUtilities
lbgkUtil(
new
asl::LBGKUtilities
(lbgk));
92
// Initialization of lbgk
93
lbgkUtil->initF(
acl::generateVEConstant
(.0,.0,.0));
94
// lbgkUtil->initF(acl::generateVEConstant(.1), acl::generateVEConstant(.0,.0,.0));
95
96
std::vector<asl::SPNumMethod> bc;
97
std::vector<asl::SPNumMethod> bcVis;
98
99
bc.push_back(
asl::generateBCConstantPressure
(lbgk, 1.2, {
asl::X0
}));
100
bc.push_back(
asl::generateBCConstantPressure
(lbgk, 0.8, {
asl::XE
}));
101
bc.push_back(generateBCNoSlip(lbgk, {
asl::Y0
,
asl::YE
,
asl::Z0
,
asl::ZE
}));
102
bc.push_back(generateBCNoSlip(lbgk, ballMap));
103
bcVis.push_back(generateBCNoSlipVel(lbgk, ballMap));
104
105
initAll(bc);
106
initAll(bcVis);
107
108
std::cout <<
"Finished"
<< endl;
109
std::cout <<
"Computing..."
;
110
asl::Timer
timer;
111
112
asl::WriterVTKXML
writer(
"flow"
);
113
writer.
addScalars
(
"map"
, *ballMapMem);
114
writer.
addScalars
(
"rho"
, *lbgk->getRho());
115
writer.
addVector
(
"v"
, *lbgk->getVelocity());
116
117
118
119
executeAll(bc);
120
executeAll(bcVis);
121
writer.
write
();
122
123
timer.
start
();
124
for
(
unsigned
int
i(1); i < 1001; ++i)
125
{
126
lbgk->execute();
127
executeAll(bc);
128
if
(!(i%5000))
129
{
130
cout << i << endl;
131
executeAll(bcVis);
132
writer.
write
();
133
}
134
}
135
timer.
stop
();
136
137
138
cout <<
"Finished"
<< endl;
139
140
cout <<
"Computation statistic:"
<< endl;
141
cout <<
"Real Time = "
<< timer.
realTime
() <<
"; Processor Time = "
142
<< timer.
processorTime
() <<
"; Processor Load = "
143
<< timer.
processorLoad
() * 100 <<
"%"
<< endl;
144
145
return
0;
146
}
aclGenerators.h
aclUtilities.h
FlT
float FlT
Definition
acousticWaves.cc:40
aslDataInc.h
aslGeomInc.h
aslLBGK.h
aslLBGKBC.h
aslParametersManager.h
aslTemplates.h
aslTimer.h
aslVTKFormatWriters.h
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::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
makeAVec
AVec< T > makeAVec(T a1)
Definition
aslVectorsDynamicLength.h:176
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::generateDataContainer_SP
SPDataWrapperACL generateDataContainer_SP(const Block &b, const acl::VectorOfElements &a)
asl::d3q15
const VectorTemplate & d3q15()
Vector template.
asl::generateBCConstantPressure
SPBCond generateBCConstantPressure(SPLBGK nm, double p, const std::vector< SlicesNames > &sl)
acl::generateVEConstant
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
acl::typeToTypeID
constexpr const TypeID typeToTypeID()
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