ASL  0.1.6
Advanced Simulation Library
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 
30 #include <math/aslTemplates.h>
33 #include <aslDataInc.h>
34 #include <acl/aclGenerators.h>
36 #include <num/aslLBGK.h>
37 #include <num/aslLBGKBC.h>
38 #include <utilities/aslTimer.h>
40 
41 
42 
43 typedef float FlT;
44 //typedef double FlT;
46 
47 using asl::AVec;
48 using asl::makeAVec;
49 
50 
51 int main(int argc, char* argv[])
52 {
53  // Optionally add appParamsManager to be able to manipulate at least
54  // hardware parameters(platform/device) through command line/parameters file
55  asl::ApplicationParametersManager appParamsManager("bus_wind",
56  "1.0");
57  asl::Parameter<string> input("input", "path to the bus geometry input file");
58  appParamsManager.load(argc, argv);
59 
60  Param dx(8);
61  Param dt(1.);
62  Param nu(.01);
63 
64  Param nuNum(nu.v()*dt.v()/dx.v()/dx.v());
65 
66  std::cout << "Data initialization... " << flush;
67 
68 
69  auto object(asl::readSurface(input.v(), dx.v(), 1.5,.25,0.,1.,3.,1.));
70 
71  asl::Block block(object->getInternalBlock());
72 
73  auto forceField(asl::generateDataContainerACL_SP<FlT>(block, 3, 1u));
74  asl::initData(forceField, makeAVec(0.,0.,0.));
75 
76  std::cout << "Finished" << endl;
77 
78  std::cout << "Numerics initialization... " << flush;
79 
80  asl::SPLBGK lbgk(new asl::LBGK(block,
82  &asl::d3q15()));
83 
84  lbgk->init();
85  asl::SPLBGKUtilities lbgkUtil(new asl::LBGKUtilities(lbgk));
86  lbgkUtil->initF(acl::generateVEConstant(-.1,.0,-.05));
87 
88  std::vector<asl::SPNumMethod> bc;
89  std::vector<asl::SPNumMethod> bcV;
90 
91  bc.push_back(generateBCNoSlip(lbgk, object));
92  bcV.push_back(generateBCNoSlipVel(lbgk, object));
93  bc.push_back(generateBCConstantPressureVelocity(lbgk, 1.,
94  makeAVec(-0.1,0.,-0.05),
96  initAll(bc);
97  initAll(bcV);
98 
99  auto computeForce(generateComputeSurfaceForce(lbgk, forceField, object));
100  computeForce->init();
101 
102 
103  std::cout << "Finished" << endl;
104  std::cout << "Computing..." << endl;
105 
106  asl::WriterVTKXML writer("bus_wind");
107  writer.addScalars("bus", *object);
108  writer.addScalars("rho", *lbgk->getRho());
109  writer.addVector("v", *lbgk->getVelocity());
110  writer.addVector("force", *forceField);
111 
112  executeAll(bc);
113  executeAll(bcV);
114  computeForce->execute();
115 
116  writer.write();
117 
118  asl::Timer timer, timer1, timer2;
119  timer.start();
120  timer1.reset();
121  timer2.reset();
122  for (unsigned int i(1); i < 101; ++i)
123  {
124  timer1.resume();
125  lbgk->execute();
126  timer1.stop();
127  timer2.resume();
128  executeAll(bc);
129  timer2.stop();
130  if (!(i%1000))
131  {
132  cout << i << endl;
133  executeAll(bcV);
134  computeForce->execute();
135  writer.write();
136  }
137  }
138  timer.stop();
139 
140  std::cout << "Finished" << endl;
141 
142  cout << "time=" << timer.getTime() << "; clockTime="
143  << timer.getClockTime() << "; load="
144  << timer.getProcessorLoad() * 100 << "%" << endl;
145  cout << "time1=" << timer1.getTime() << "; time2=" << timer2.getTime() << endl;
146 
147  std::cout << "Output...";
148  std::cout << "Finished" << endl;
149  std::cout << "Ok" << endl;
150 
151  return 0;
152 }
AVec< T > makeAVec(T a1)
Numerical method for fluid flow.
Definition: aslLBGK.h:77
void resume()
Definition: aslTimer.h:44
const T & v() const
Definition: aslUValue.h:43
void addVector(std::string name, AbstractData &data)
void initAll(std::vector< T *> &v)
Definition: aslNumMethod.h:67
AVec< T > makeAVec(T a1)
SPDataWithGhostNodesACLData readSurface(const string &fileName, double dx, acl::CommandQueue queue=acl::hardware.defaultQueue)
SPBCond generateBCConstantPressureVelocity(SPLBGK nm, double p, AVec<> v, const std::vector< SlicesNames > &sl)
const double getProcessorLoad() const
Definition: aslTimer.h:48
const VectorTemplate & d3q15()
Vector template.
int main(int argc, char *argv[])
Definition: bus_wind.cc:51
const T & v() const
cl_int flush(void)
Definition: cl.hpp:7042
acl::VectorOfElements dx(const TemplateVE &a)
differential operator
const double getClockTime() const
Definition: aslTimer.h:47
void executeAll(std::vector< T *> &v)
Definition: aslNumMethod.h:55
void reset()
Definition: aslTimer.h:49
void initData(SPAbstractData d, double a)
const double getTime() const
Definition: aslTimer.h:46
void addScalars(std::string name, AbstractData &data)
float FlT
Definition: bus_wind.cc:43
asl::UValue< double > Param
Definition: bus_wind.cc:45
void stop()
Definition: aslTimer.h:45
void start()
Definition: aslTimer.h:43
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
SPNumMethod generateComputeSurfaceForce(SPLBGK nm, SPDataWithGhostNodesACLData fF, SPAbstractDataWithGhostNodes map)
void load(int argc, char *argv[])
SPNumMethod generateBCNoSlipVel(SPLBGK nmU, SPAbstractDataWithGhostNodes map)
for velocity field
contains different kernels for preprocessing and posprocessing of data used by LBGK ...
Definition: aslLBGK.h:137
SPBCond generateBCNoSlip(SPLBGK nm, const std::vector< SlicesNames > &sl)