ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
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
31#include <math/aslTemplates.h>
34#include <aslDataInc.h>
35#include <acl/aclGenerators.h>
37#include <num/aslLBGK.h>
38#include <num/aslLBGKBC.h>
39#include <utilities/aslTimer.h>
41
42
43
44typedef float FlT;
45//typedef double FlT;
47
48using asl::AVec;
49using asl::makeAVec;
50
51
52int 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,
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),
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}
float FlT
Definition bus_wind.cc:44
asl::UValue< double > Param
Definition bus_wind.cc:46
void load(int argc, char *argv[])
Numerical method for fluid flow.
Definition aslLBGK.h:78
contains different kernels for preprocessing and posprocessing of data used by LBGK
Definition aslLBGK.h:138
const T & v() const
const double realTime() const
Definition aslTimer.h:45
void stop()
Definition aslTimer.h:44
const double processorTime() const
Definition aslTimer.h:46
void start()
Definition aslTimer.h:43
void reset()
Definition aslTimer.h:48
const double processorLoad() const
Definition aslTimer.h:47
Updatable value. This class stores value and its TimeStamp.
Definition aslUValue.h:35
const T & v() const
Definition aslUValue.h:43
void addVector(std::string name, AbstractData &data)
void addScalars(std::string name, AbstractData &data)
@ Y0
Definition aslBCond.h:309
@ XE
Definition aslBCond.h:309
@ Z0
Definition aslBCond.h:309
@ YE
Definition aslBCond.h:309
@ ZE
Definition aslBCond.h:309
@ X0
Definition aslBCond.h:309
SPDataWrapperACLData generateDataContainerACL_SP(const Block &b, unsigned int n=1)
generates pointer to ACL Data field with n components
SPDataWithGhostNodesACLData readSurface(const string &fileName, double dx, acl::CommandQueue queue=acl::hardware.defaultQueue)
const VectorTemplate & d3q15()
Vector template.
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
AVec< T > makeAVec(T a1)
std::shared_ptr< LBGKUtilities > SPLBGKUtilities
Definition aslLBGK.h:161
std::shared_ptr< LBGK > SPLBGK
Definition aslLBGK.h:133
void initData(SPAbstractData d, double a)
int main()