ASL  0.1.7
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 
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 
44 typedef float FlT;
45 //typedef double FlT;
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,
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 }
const double realTime() const
Definition: aslTimer.h:45
const double processorTime() const
Definition: aslTimer.h:46
AVec< T > makeAVec(T a1)
Numerical method for fluid flow.
Definition: aslLBGK.h:77
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)
std::shared_ptr< LBGKUtilities > SPLBGKUtilities
Definition: aslLBGK.h:161
std::shared_ptr< LBGK > SPLBGK
Definition: aslLBGK.h:133
const VectorTemplate & d3q15()
Vector template.
int main(int argc, char *argv[])
Definition: bus_wind.cc:52
const T & v() const
cl_int flush(void)
Definition: cl.hpp:7042
acl::VectorOfElements dx(const TemplateVE &a)
differential operator
void reset()
Definition: aslTimer.h:48
void initData(SPAbstractData d, double a)
void executeAll(std::vector< T * > &v)
Definition: aslNumMethod.h:55
void addScalars(std::string name, AbstractData &data)
float FlT
Definition: bus_wind.cc:44
asl::UValue< double > Param
Definition: bus_wind.cc:46
void stop()
Definition: aslTimer.h:44
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[])
const double processorLoad() const
Definition: aslTimer.h:47
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)