ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
flow3.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
41typedef float FlT;
42//typedef double FlT;
44
45using asl::AVec;
46using asl::makeAVec;
47
49{
50 double r(2.);
51 double spacing(4.);
52
54 asl::SPDistanceFunction resultGeometry;
55 asl::AVec<double> orientation(asl::makeAVec(0., 0., 1.));
56 for (int i = 0; i < block.getSize()[0] / (2 * r + spacing); ++i)
57 {
58 for (int j = 0; j < block.getSize()[1] / (2 * r + spacing); ++j)
59 {
60 cylinder = generateDFCylinderInf(r, orientation, asl::makeAVec(i * (2. * r + spacing) + r + spacing / 2., j * (2. * r + spacing) + r + spacing / 2., 0.));
61 resultGeometry = resultGeometry | cylinder;
62 }
63 }
64
65 return resultGeometry;
66}
67
68
69int main(int argc, char* argv[])
70{
71 // Optionally add appParamsManager to be able to manipulate at least
72 // hardware parameters(platform/device) through command line/parameters file
73 asl::ApplicationParametersManager appParamsManager("flow3",
74 "1.0");
75 appParamsManager.load(argc, argv);
76
77 Param dx(1.);
78 Param dt(1.);
79 Param nu(.00625);
80
81 Param nuNum(nu.v()*dt.v()/dx.v()/dx.v());
82 AVec<int> size(asl::makeAVec(50, 50, 50));
83
84 auto gSize(dx.v()*AVec<>(size));
85
86
87 std::cout << "Flow: Data initialization...";
88
89 asl::Block block(size,dx.v());
90
91 auto cylindersMapMem(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
92 asl::initData(cylindersMapMem, generateOrderedCylinders(block));
93
94
95 std::cout << "Finished" << endl;
96
97 std::cout << "Flow: Numerics initialization...";
98
99 asl::SPLBGK lbgk(new asl::LBGK(block,
100 acl::generateVEConstant(FlT(nuNum.v())),
101 &asl::d3q15()));
102
103 lbgk->init();
104 asl::SPLBGKUtilities lbgkUtil(new asl::LBGKUtilities(lbgk));
105 lbgkUtil->initF(acl::generateVEConstant(.0,.0,.0));
106
107 auto bcNoSlip(generateBCNoSlip(lbgk,{asl::Y0, asl::YE, asl::Z0, asl::ZE}));
108 auto bcNoSlipM(generateBCNoSlip(lbgk, cylindersMapMem));
109 auto bcNoSlipV(generateBCNoSlipVel(lbgk, cylindersMapMem));
112
113 addSliceX0(bcIn);
114 addSliceXE(bcOut);
115
116 bcNoSlip->init();
117 bcNoSlipM->init();
118 bcNoSlipV->init();
119 bcIn.init();
120 bcOut.init();
121
122 std::cout << "Finished" << endl;
123 std::cout << "Computing...";
124 asl::Timer timer;
125
126 asl::WriterVTKXML writer("flow3Res");
127 writer.addScalars("map", *cylindersMapMem);
128 writer.addScalars("rho", *lbgk->getRho());
129 writer.addVector("v", *lbgk->getVelocity());
130
131
132
133 bcIn.execute();
134 bcOut.execute();
135 bcNoSlip->execute();
136 bcNoSlipM->execute();
137
138 bcNoSlipV->execute();
139 writer.write();
140
141 timer.start();
142 for (unsigned int i(0); i < 1000; ++i)
143 {
144 lbgk->execute();
145 bcIn.execute();
146 bcOut.execute();
147 bcNoSlip->execute();
148 bcNoSlipM->execute();
149 if (!(i%100))
150 {
151 cout << i << endl;
152 bcNoSlipV->execute();
153 writer.write();
154 }
155 }
156 timer.stop();
157
158
159 cout << "Finished" << endl;
160
161 cout << "Computation statistic:" << endl;
162 cout << "Real Time = " << timer.realTime() << "; Processor Time = "
163 << timer.processorTime() << "; Processor Load = "
164 << timer.processorLoad() * 100 << "%" << endl;
165
166 return 0;
167}
void load(int argc, char *argv[])
Bondary condition corresponding an in- or outflow boundary conditions with a given pressure.
Definition: aslLBGKBC.h:80
virtual void init()
Builds the necesery internal data and kernels.
virtual void execute()
Executes the numerical procedure.
const DV & getSize() const
Definition: aslBlocks.h:208
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: flow3.cc:41
asl::UValue< double > Param
Definition: flow3.cc:43
asl::SPDistanceFunction generateOrderedCylinders(asl::Block &block)
Definition: flow3.cc:48
@ Y0
Definition: aslBCond.h:309
@ Z0
Definition: aslBCond.h:309
@ YE
Definition: aslBCond.h:309
@ ZE
Definition: aslBCond.h:309
std::shared_ptr< DistanceFunction > SPDistanceFunction
Definition: aslGeomInc.h:45
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< LBGKUtilities > SPLBGKUtilities
Definition: aslLBGK.h:161
std::shared_ptr< LBGK > SPLBGK
Definition: aslLBGK.h:133
void initData(SPAbstractData d, double a)
int main()