| 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 |
|
| 24 |
/** |
| 25 |
\example bus_wind.cc |
| 26 |
Example: Bus in wind |
| 27 |
Required input file: [bus.stl](http://asl.org.il/input_data/bus.stl) |
| 28 |
*/ |
| 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 |
} |