ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
flowRotatingCylinders.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 <math/aslPositionFunction.h>
34#include <acl/aclGenerators.h>
35#include <writers/aslVTKFormatWriters.h>
36#include <num/aslLBGK.h>
37#include <num/aslLBGKBC.h>
38#include <utilities/aslTimer.h>
39#include <utilities/aslParametersManager.h>
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("flowRotatingCylinders",
55 "1.0");
56 appParamsManager.load(argc, argv);
57
58 Param dx(1.);
59 Param dt(1.);
60 Param nu(.01);
61 Param w(2e-3);
62
63 Param nuNum(nu.v()*dt.v()/dx.v()/dx.v());
64 AVec<int> size(asl::makeAVec(100,100,150));
65
66 AVec<> gSize(dx.v()*AVec<>(size));
67
68
69 std::cout << "Data initialization... ";
70
71 asl::Block block(size,dx.v());
72
73 auto exCylMap(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
74 asl::initData(exCylMap,
75 asl::normalize(-generateDFCylinderInf(.48*gSize[0],
76 makeAVec(0.,0.,1.),
77 .5*gSize),
78 dx.v()));
79 auto inCylMap(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
80 asl::initData(inCylMap,
81 asl::normalize(generateDFCylinderInf(.24*gSize[0],
82 makeAVec(0.,0.,1.),
83 .5*gSize),
84 dx.v()));
85
86 auto computationalDomainMap(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
87 asl::initData(computationalDomainMap,
88 asl::normalize(-generateDFCylinderInf(.48*gSize[0],
89 makeAVec(0.,0.,1.),
90 .5*gSize) |
91 generateDFCylinderInf(.24*gSize[0],
92 makeAVec(0.,0.,1.),
93 .5*gSize) |
94 asl::generateDFInBlock(block, 0),
95 dx.v()));
96
97
98 std::cout << "Finished" << endl;
99
100 std::cout << "Numerics initialization... ";
101
102 asl::SPLBGK lbgk(new asl::LBGK(block,
103 acl::generateVEConstant(FlT(nuNum.v())),
104 &asl::d3q15()));
105
106 lbgk->init();
107 asl::SPLBGKUtilities lbgkUtil(new asl::LBGKUtilities(lbgk));
108 lbgkUtil->initF(acl::generateVEConstant(.0,.0,.0));
109
110 std::vector<asl::SPNumMethod> bc;
111 std::vector<asl::SPNumMethod> bcV;
112
113 auto vfEx(asl::generatePFRotationField(makeAVec(0.,0., w.v()), .5*gSize));
114 auto vfIn(asl::generatePFRotationField(makeAVec(0.,0.,-2.*w.v()), .5*gSize));
115
116 bc.push_back(generateBCVelocity(lbgk, vfEx, exCylMap,computationalDomainMap));
117 bcV.push_back(generateBCNoSlipVel(lbgk, exCylMap));
118 bc.push_back(generateBCVelocity(lbgk, vfIn, inCylMap,computationalDomainMap));
119 bcV.push_back(generateBCNoSlipVel(lbgk, inCylMap));
120 bc.push_back(generateBCNoSlip(lbgk,{asl::Z0, asl::ZE}));
121
122 initAll(bc);
123 initAll(bcV);
124
125 std::cout << "Finished" << endl;
126 std::cout << "Computing...";
127 asl::Timer timer;
128
129 asl::WriterVTKXML writer("flowRotCylRes");
130// writer.addScalars("mapEx", *exCylMap);
131// writer.addScalars("mapIn", *inCylMap);
132 writer.addScalars("map", *computationalDomainMap);
133 writer.addScalars("rho", *lbgk->getRho());
134 writer.addVector("v", *lbgk->getVelocity());
135
136 executeAll(bc);
137
138 executeAll(bcV);
139 writer.write();
140
141 timer.start();
142 for (unsigned int i(0); i < 10001 ; ++i)
143 {
144 lbgk->execute();
145 executeAll(bc);
146 if (!(i%1000))
147 {
148 cout << i << endl;
149 executeAll(bcV);
150 writer.write();
151 }
152 }
153 timer.stop();
154
155 cout << "Finished" << endl;
156
157 cout << "Computation statistic:" << endl;
158 cout << "Real Time = " << timer.realTime() << "; Processor Time = "
159 << timer.processorTime() << "; Processor Load = "
160 << timer.processorLoad() * 100 << "%" << endl;
161
162 return 0;
163}
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
asl::UValue< double > Param
@ ZE
Definition aslBCond.h:309
@ Z0
Definition aslBCond.h:309
SPDataWrapperACLData generateDataContainerACL_SP(const Block &b, unsigned int n=1)
generates pointer to ACL Data field with n components
SPDistanceFunction generateDFInBlock(const Block &b, unsigned int nG)
generates map corresponding to external (ghost) part of the block
SPDistanceFunction normalize(SPDistanceFunction a, double dx)
SPPositionFunction generatePFRotationField(const AVec< double > &axis, const AVec< double > &c)
const VectorTemplate & d3q15()
Vector template.
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
AVec< T > makeAVec(T a1)
std::shared_ptr< LBGK > SPLBGK
Definition aslLBGK.h:133
void initData(SPAbstractData d, double a)
std::shared_ptr< LBGKUtilities > SPLBGKUtilities
Definition aslLBGK.h:161
int main()