ASL  0.1.7
Advanced Simulation Library
flow.cc

Example: Flow

/*
* 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 <utilities/aslParametersManager.h>
#include <aslDataInc.h>
#include <math/aslTemplates.h>
#include <aslGeomInc.h>
#include <acl/aclGenerators.h>
#include <writers/aslVTKFormatWriters.h>
#include <num/aslLBGK.h>
#include <num/aslLBGKBC.h>
#include <utilities/aslTimer.h>
#include <acl/aclUtilities.h>
typedef float FlT;
//typedef double FlT;
using asl::AVec;
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("flow",
"1.0");
appParamsManager.load(argc, argv);
Param dx(1.);
Param dt(1.);
Param nu(.00625);
Param nuNum(nu.v()*dt.v()/dx.v()/dx.v());
AVec<int> size(asl::makeAVec(300, 50, 50));
auto gSize(dx.v()*AVec<>(size));
std::cout << "Data initialization... ";
asl::Block block(size,dx.v());
auto ball(generateDFCylinderInf(.125*gSize[1],
makeAVec(0.,1.,0.),
.45*makeAVec(gSize[1],gSize[1],gSize[2])));
// Formula
auto ballMap(asl::generateDataContainer_SP(block, ball, 1u, acl::typeToTypeID<FlT>()));
// Data
auto ballMapMem(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
asl::initData(ballMapMem, ball);
std::cout << "Finished" << endl;
std::cout << "Numerics initialization... ";
asl::SPLBGK lbgk(new asl::LBGK(block,
&asl::d3q15()));
lbgk->init();
// Initialization of lbgk
lbgkUtil->initF(acl::generateVEConstant(.0,.0,.0));
// lbgkUtil->initF(acl::generateVEConstant(.1), acl::generateVEConstant(.0,.0,.0));
std::vector<asl::SPNumMethod> bc;
std::vector<asl::SPNumMethod> bcVis;
bc.push_back(asl::generateBCConstantPressure(lbgk, 1.2, {asl::X0}));
bc.push_back(asl::generateBCConstantPressure(lbgk, 0.8, {asl::XE}));
bc.push_back(generateBCNoSlip(lbgk, {asl::Y0, asl::YE, asl::Z0, asl::ZE}));
bc.push_back(generateBCNoSlip(lbgk, ballMap));
bcVis.push_back(generateBCNoSlipVel(lbgk, ballMap));
initAll(bc);
initAll(bcVis);
std::cout << "Finished" << endl;
std::cout << "Computing...";
asl::Timer timer;
asl::WriterVTKXML writer("flow");
writer.addScalars("map", *ballMapMem);
writer.addScalars("rho", *lbgk->getRho());
writer.addVector("v", *lbgk->getVelocity());
executeAll(bcVis);
writer.write();
timer.start();
for (unsigned int i(1); i < 1001; ++i)
{
lbgk->execute();
if (!(i%5000))
{
cout << i << endl;
executeAll(bcVis);
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;
}
AVec< T > makeAVec(T a1)
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 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
const T & v() const
Definition: aslUValue.h:43
void addVector(std::string name, AbstractData &data)
void addScalars(std::string name, AbstractData &data)
int main(int argc, char *argv[])
Definition: flow.cc:50
float FlT
Definition: flow.cc:42
asl::UValue< double > Param
Definition: flow.cc:44
@ Y0
Definition: aslBCond.h:309
@ X0
Definition: aslBCond.h:309
@ ZE
Definition: aslBCond.h:309
@ Z0
Definition: aslBCond.h:309
@ YE
Definition: aslBCond.h:309
@ XE
Definition: aslBCond.h:309
SPDataWrapperACL generateDataContainer_SP(const Block &b, const acl::VectorOfElements &a)
acl::VectorOfElements dx(const TemplateVE &a)
differential operator
SPDistanceFunction generateDFCylinderInf(double r, const AVec< double > &l, const AVec< double > &c)
generates infinite cylinder
const VectorTemplate & d3q15()
Vector template.
SPBCond generateBCConstantPressure(SPLBGK nm, double p, const std::vector< SlicesNames > &sl)
SPNumMethod generateBCNoSlipVel(SPLBGK nmU, SPAbstractDataWithGhostNodes map)
SPBCond generateBCNoSlip(SPLBGK nm, const std::vector< SlicesNames > &sl)
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
AVec< T > makeAVec(T a1)
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)
std::shared_ptr< LBGKUtilities > SPLBGKUtilities
Definition: aslLBGK.h:161
void executeAll(std::vector< T * > &v)
Definition: aslNumMethod.h:55