ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
locomotive_stability.cc

Example: Locomotive stability Required input file: locomotive.stl

/*
* Advanced Simulation Library <http://asl.org.il>
*
* Copyright 2015 Avtech Scientific <http://avtechscientific.com>
*
*
* This file is part of Advanced Simulation Library (ASL).
*
* ASL is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3 of the License.
*
* ASL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with ASL. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <aslGeomInc.h>
#include <aslDataInc.h>
#include <num/aslLBGK.h>
#include <num/aslLBGKBC.h>
typedef float FlT;
//typedef double FlT;
using asl::AVec;
{
double y(10.33);
double z(3.08);
double h(1.);
double rNozzel(.3);
double n(4.);
double x0(-20.);
double xE(-6.);
double dx(bl.dx);
asl::SPDistanceFunction res(generateDFCylinder(rNozzel,
makeAVec(0., 0., h),
makeAVec(x0, y, z + h * .5)));
for(unsigned int i(1); i < n; ++i)
res = res | generateDFCylinder(rNozzel,
makeAVec(0., 0., h),
makeAVec(x0 + i * (xE-x0)/n, y, z+h*.5));
return normalize(res, dx);
}
int main(int argc, char* argv[])
{
// Optionally add appParamsManager to be able to manipulate at least
// hardware parameters(platform/device) through command line/parameters file
asl::ApplicationParametersManager appParamsManager("locomotive_stability",
"1.0");
asl::Parameter<string> input("input", "path to the geometry input file");
appParamsManager.load(argc, argv);
Param dx(0.25);
Param dt(1.);
Param nu(.01);
Param nuNum(nu.v()*dt.v()/dx.v()/dx.v());
std::cout << "Data initialization... " << flush;
auto locomotive(asl::readSurface(input.v(), dx.v(), .5, 1., 0., 1., 2., 4.));
asl::Block block(locomotive->getInternalBlock());
auto forceField(asl::generateDataContainerACL_SP<FlT>(block, 3, 1u));
asl::initData(forceField, makeAVec(0., 0., 0.));
std::cout << "Finished" << endl;
std::cout << "Numerics initialization... " << flush;
asl::SPLBGK lbgk(new asl::LBGK(block,
&asl::d3q15()));
lbgk->init();
lbgkUtil->initF(acl::generateVEConstant(.1,.0,.05));
auto vfTunnel(asl::generatePFConstant(makeAVec(0.1,0.,0.)));
std::vector<asl::SPNumMethod> bc;
std::vector<asl::SPNumMethod> bcV;
auto nozzelsMap(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
asl::initData(nozzelsMap, generateNozzels(block));
bc.push_back(generateBCNoSlip(lbgk, locomotive));
bcV.push_back(generateBCNoSlipVel(lbgk, locomotive));
bc.push_back(generateBCConstantPressureVelocity(lbgk, 1.,
makeAVec(0.1,0.,0.05),
bc.push_back(generateBCConstantPressureVelocity(lbgk, 1., makeAVec(0.,0.,-0.1), nozzelsMap));
initAll(bc);
initAll(bcV);
auto computeForce(generateComputeSurfaceForce(lbgk, forceField, locomotive));
computeForce->init();
std::cout << "Finished" << endl;
std::cout << "Computing..." << endl;
asl::WriterVTKXML writer(appParamsManager.getDir() + "locomotive_stability");
writer.addScalars("locomotive", *locomotive);
writer.addScalars("nozzels", *nozzelsMap);
writer.addScalars("rho", *lbgk->getRho());
writer.addVector("v", *lbgk->getVelocity());
writer.addVector("force", *forceField);
executeAll(bcV);
computeForce->execute();
writer.write();
asl::Timer timer, timer1, timer2;
timer.start();
for(unsigned int i(1); i < 40001; ++i)
{
lbgk->execute();
if(!(i%1000))
{
cout << i << endl;
executeAll(bcV);
computeForce->execute();
writer.write();
}
}
timer.stop();
cout << "Finished" << endl;
cout << "Computation statistic:" << endl;
cout << "Real Time = " << timer.realTime() << "; Processor Time = "
<< timer.processorTime() << "; Processor Load = "
<< timer.processorLoad() * 100 << "%" << endl;
return 0;
}
float FlT
definition of class АVec<T>
double dx
Definition: aslBlocks.h:66
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 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
const double processorLoad() const
Definition: aslTimer.h:47
Updatable value. This class stores value and its TimeStamp.
Definition: aslUValue.h:35
asl::UValue< FlT > Param
Definition: cubeGravity.cc:43
@ 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
SPDataWithGhostNodesACLData readSurface(const string &fileName, double dx, acl::CommandQueue queue=acl::hardware.defaultQueue)
std::shared_ptr< DistanceFunction > SPDistanceFunction
Definition: aslGeomInc.h:45
SPPositionFunction generatePFConstant(const AVec< double > &a)
const VectorTemplate & d3q15()
Vector template.
SPNumMethod generateComputeSurfaceForce(SPLBGK nm, SPDataWithGhostNodesACLData fF, SPAbstractDataWithGhostNodes map)
SPBCond generateBCConstantPressureVelocity(SPLBGK nm, double p, AVec<> v, const std::vector< SlicesNames > &sl)
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
asl::SPDistanceFunction generateNozzels(asl::Block &bl)
AVec< T > makeAVec(T a1)
std::shared_ptr< LBGKUtilities > SPLBGKUtilities
Definition: aslLBGK.h:161
void initAll(std::vector< T * > &v)
Definition: aslNumMethod.h:67
std::shared_ptr< LBGK > SPLBGK
Definition: aslLBGK.h:133
void initData(SPAbstractData d, double a)
void executeAll(std::vector< T * > &v)
Definition: aslNumMethod.h:55
int main()