ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
flow.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 <aslDataInc.h>
31#include <math/aslTemplates.h>
32#include <aslGeomInc.h>
33#include <acl/aclGenerators.h>
35#include <num/aslLBGK.h>
36#include <num/aslLBGKBC.h>
37#include <utilities/aslTimer.h>
38#include <acl/aclUtilities.h>
39
40
41
42typedef float FlT;
43//typedef double FlT;
45
46using asl::AVec;
47using asl::makeAVec;
48
49
50int main(int argc, char* argv[])
51{
52 // Optionally add appParamsManager to be able to manipulate at least
53 // hardware parameters(platform/device) through command line/parameters file
54 asl::ApplicationParametersManager appParamsManager("flow",
55 "1.0");
56 appParamsManager.load(argc, argv);
57
58 Param dx(1.);
59 Param dt(1.);
60 Param nu(.00625);
61
62 Param nuNum(nu.v()*dt.v()/dx.v()/dx.v());
63 AVec<int> size(asl::makeAVec(300, 50, 50));
64
65 auto gSize(dx.v()*AVec<>(size));
66
67
68 std::cout << "Data initialization... ";
69
70 asl::Block block(size,dx.v());
71
72 auto ball(generateDFCylinderInf(.125*gSize[1],
73 makeAVec(0.,1.,0.),
74 .45*makeAVec(gSize[1],gSize[1],gSize[2])));
75 // Formula
76 auto ballMap(asl::generateDataContainer_SP(block, ball, 1u, acl::typeToTypeID<FlT>()));
77 // Data
78 auto ballMapMem(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
79 asl::initData(ballMapMem, ball);
80
81
82 std::cout << "Finished" << endl;
83
84 std::cout << "Numerics initialization... ";
85
86 asl::SPLBGK lbgk(new asl::LBGK(block,
88 &asl::d3q15()));
89 lbgk->init();
90
91 asl::SPLBGKUtilities lbgkUtil(new asl::LBGKUtilities(lbgk));
92 // Initialization of lbgk
93 lbgkUtil->initF(acl::generateVEConstant(.0,.0,.0));
94// lbgkUtil->initF(acl::generateVEConstant(.1), acl::generateVEConstant(.0,.0,.0));
95
96 std::vector<asl::SPNumMethod> bc;
97 std::vector<asl::SPNumMethod> bcVis;
98
99 bc.push_back(asl::generateBCConstantPressure(lbgk, 1.2, {asl::X0}));
100 bc.push_back(asl::generateBCConstantPressure(lbgk, 0.8, {asl::XE}));
101 bc.push_back(generateBCNoSlip(lbgk, {asl::Y0, asl::YE, asl::Z0, asl::ZE}));
102 bc.push_back(generateBCNoSlip(lbgk, ballMap));
103 bcVis.push_back(generateBCNoSlipVel(lbgk, ballMap));
104
105 initAll(bc);
106 initAll(bcVis);
107
108 std::cout << "Finished" << endl;
109 std::cout << "Computing...";
110 asl::Timer timer;
111
112 asl::WriterVTKXML writer("flow");
113 writer.addScalars("map", *ballMapMem);
114 writer.addScalars("rho", *lbgk->getRho());
115 writer.addVector("v", *lbgk->getVelocity());
116
117
118
119 executeAll(bc);
120 executeAll(bcVis);
121 writer.write();
122
123 timer.start();
124 for (unsigned int i(1); i < 1001; ++i)
125 {
126 lbgk->execute();
127 executeAll(bc);
128 if (!(i%5000))
129 {
130 cout << i << endl;
131 executeAll(bcVis);
132 writer.write();
133 }
134 }
135 timer.stop();
136
137
138 cout << "Finished" << endl;
139
140 cout << "Computation statistic:" << endl;
141 cout << "Real Time = " << timer.realTime() << "; Processor Time = "
142 << timer.processorTime() << "; Processor Load = "
143 << timer.processorLoad() * 100 << "%" << endl;
144
145 return 0;
146}
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
Updatable value. This class stores value and its TimeStamp.
Definition aslUValue.h:35
const T & v() const
Definition aslUValue.h:43
void addVector(std::string name, AbstractData &data)
void addScalars(std::string name, AbstractData &data)
float FlT
Definition flow.cc:42
asl::UValue< double > Param
Definition flow.cc:44
@ 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
SPDataWrapperACL generateDataContainer_SP(const Block &b, const acl::VectorOfElements &a)
const VectorTemplate & d3q15()
Vector template.
SPBCond generateBCConstantPressure(SPLBGK nm, double p, const std::vector< SlicesNames > &sl)
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
AVec< T > makeAVec(T a1)
std::shared_ptr< LBGKUtilities > SPLBGKUtilities
Definition aslLBGK.h:161
std::shared_ptr< LBGK > SPLBGK
Definition aslLBGK.h:133
void initData(SPAbstractData d, double a)
int main()