ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
compressor.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
31#include <math/aslTemplates.h>
32#include <aslGeomInc.h>
33#include <aslDataInc.h>
35#include <acl/aclGenerators.h>
37#include <num/aslLBGK.h>
38#include <num/aslLBGKBC.h>
39#include <utilities/aslTimer.h>
41
42typedef float FlT;
43//typedef double FlT;
45
46using asl::AVec;
47using asl::makeAVec;
48
50{
51 double rCase((bl.getBPosition()[1] - bl.position[1]) / 2.);
52
53 asl::AVec<> center(.5*(bl.getBPosition() + bl.position));
54 center[1] = bl.position[1] + rCase;
55
56 auto comprCase(-(generateDFCylinderInf(rCase, makeAVec(0., 0., 1.), center)));
57
58 return normalize(comprCase, bl.dx);
59}
60
61
62int main(int argc, char* argv[])
63{
64 // Optionally add appParamsManager to be able to manipulate at least
65 // hardware parameters(platform/device) through command line/parameters file
66 asl::ApplicationParametersManager appParamsManager("compressor",
67 "1.0");
68 asl::Parameter<string> input("input", "path to the compressor geometry input file");
69 appParamsManager.load(argc, argv);
70
71 Param dx(0.5);
72 Param dt(.001);
73 Param nu(.2);
74 // Angular velocity
75 Param w(6.*3.14*2./60.);
76
77 AVec<int> size(makeAVec(33., 33., 90.)*(1./dx.v()));
78 asl::Block bl(size, dx.v(), makeAVec(-16.65, -26.15, -67.7));
79
80// Param nuNum(nu.v()*dt.v()/dx.v()/dx.v());
81 Param nuNum(.2);
82 // Angular velocity in one iteration
83 Param wNum(w.v()*dt.v());
84
85 std::cout << "Data initialization..." << flush;
86
87
88 auto compressorMap(asl::readSurface(input.v(), bl));
89
90 asl::Block block(compressorMap->getInternalBlock());
91
92 auto comprCaseMap(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
93 asl::initData(comprCaseMap, generateCase(block));
94
95
96 std::cout << "Finished" << endl;
97
98 std::cout << "Numerics initialization..." << flush;
99
100 asl::SPLBGK lbgk(new asl::LBGK(block,
101 acl::generateVEConstant(FlT(nuNum.v())),
102 &asl::d3q15()));
103 // Set angular velocity in lbgk
104 lbgk->setOmega(acl::generateVEConstant(makeAVec(0.,0.,wNum.v())));
105 lbgk->init();
106
107 asl::SPLBGKUtilities lbgkUtil(new asl::LBGKUtilities(lbgk));
108 // Initialization of lbgk
109 lbgkUtil->initF(acl::generateVEConstant(.0,.0,.0));
110
111 std::vector<asl::SPNumMethod> bc;
112 std::vector<asl::SPNumMethod> bcVis;
113
114 // Position Function Angular Velocity Field
115 auto vfCase(asl::generatePFRotationField(makeAVec(0.,0., wNum.v()/dx.v()),
116 .5*(block.getBPosition() + block.position)));
117 // Boundary condition
118 bc.push_back(generateBCVelocity(lbgk, vfCase, comprCaseMap));
119 // Boundary condition for visualization
120 bcVis.push_back(generateBCVelocityVel(lbgk, vfCase, comprCaseMap));
121 bc.push_back(asl::generateBCConstantPressure(lbgk, 1., {asl::Z0, asl::ZE}));
122 bc.push_back(generateBCNoSlip(lbgk, compressorMap));
123 bcVis.push_back(generateBCNoSlipVel(lbgk, compressorMap));
124
125 initAll(bc);
126 initAll(bcVis);
127
128
129 std::cout << "Finished" << endl;
130 std::cout << "Computing..." << endl;
131 asl::Timer timer;
132
133 asl::WriterVTKXML writer("compressor");
134 writer.addScalars("compressor", *compressorMap);
135 writer.addScalars("case", *comprCaseMap);
136 writer.addScalars("rho", *lbgk->getRho());
137 writer.addVector("v", *lbgk->getVelocity());
138
139 executeAll(bc);
140 executeAll(bcVis);
141
142 writer.write();
143
144 timer.start();
145 for (unsigned int i(1); i < 10001; ++i)
146 {
147 lbgk->execute();
148 executeAll(bc);
149 if (!(i%2000))
150 {
151 cout << i << endl;
152 executeAll(bcVis);
153 writer.write();
154 }
155 }
156 timer.stop();
157
158 cout << "Finished" << endl;
159
160 cout << "Computation statistic:" << endl;
161 cout << "Real Time = " << timer.realTime() << "; Processor Time = "
162 << timer.processorTime() << "; Processor Load = "
163 << timer.processorLoad() * 100 << "%" << endl;
164
165 return 0;
166}
void load(int argc, char *argv[])
double dx
Definition: aslBlocks.h:66
const V getBPosition() const
Definition: aslBlocks.h:214
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 T & v() const
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: compressor.cc:42
asl::SPDistanceFunction generateCase(asl::Block &bl)
Definition: compressor.cc:49
asl::UValue< double > Param
Definition: compressor.cc:44
@ Z0
Definition: aslBCond.h:309
@ ZE
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 generatePFRotationField(const AVec< double > &axis, const AVec< double > &c)
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()