ASL  0.1.6
Advanced Simulation Library
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 
28 #include <utilities/aslParametersManager.h>
29 #include <aslDataInc.h>
30 #include <math/aslTemplates.h>
31 #include <aslGeomInc.h>
32 #include <acl/aclGenerators.h>
33 #include <writers/aslVTKFormatWriters.h>
34 #include <num/aslLBGK.h>
35 #include <num/aslLBGKBC.h>
36 #include <utilities/aslTimer.h>
37 #include <acl/aclUtilities.h>
38 
39 
40 typedef float FlT;
41 //typedef double FlT;
43 
44 using asl::AVec;
45 using asl::makeAVec;
46 
48 {
49  double r(2.);
50  double spacing(4.);
51 
52  asl::SPDistanceFunction cylinder;
53  asl::SPDistanceFunction resultGeometry;
54  asl::AVec<double> orientation(asl::makeAVec(0., 0., 1.));
55  for (int i = 0; i < block.getSize()[0] / (2 * r + spacing); ++i)
56  {
57  for (int j = 0; j < block.getSize()[1] / (2 * r + spacing); ++j)
58  {
59  cylinder = generateDFCylinderInf(r, orientation, asl::makeAVec(i * (2. * r + spacing) + r + spacing / 2., j * (2. * r + spacing) + r + spacing / 2., 0.));
60  resultGeometry = resultGeometry | cylinder;
61  }
62  }
63 
64  return resultGeometry;
65 }
66 
67 
68 int main(int argc, char* argv[])
69 {
70  // Optionally add appParamsManager to be able to manipulate at least
71  // hardware parameters(platform/device) through command line/parameters file
72  asl::ApplicationParametersManager appParamsManager("flow3",
73  "1.0");
74  appParamsManager.load(argc, argv);
75 
76  Param dx(1.);
77  Param dt(1.);
78  Param nu(.00625);
79 
80  Param nuNum(nu.v()*dt.v()/dx.v()/dx.v());
81  AVec<int> size(asl::makeAVec(50, 50, 50));
82 
83  auto gSize(dx.v()*AVec<>(size));
84 
85 
86  std::cout << "Flow: Data initialization...";
87 
88  asl::Block block(size,dx.v());
89 
90  auto cylindersMapMem(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
91  asl::initData(cylindersMapMem, generateOrderedCylinders(block));
92 
93 
94  std::cout << "Finished" << endl;
95 
96  std::cout << "Flow: Numerics initialization...";
97 
98  asl::SPLBGK lbgk(new asl::LBGK(block,
99  acl::generateVEConstant(FlT(nuNum.v())),
100  &asl::d3q15()));
101 
102  lbgk->init();
103  asl::SPLBGKUtilities lbgkUtil(new asl::LBGKUtilities(lbgk));
104  lbgkUtil->initF(acl::generateVEConstant(.0,.0,.0));
105 
106  auto bcNoSlip(generateBCNoSlip(lbgk,{asl::Y0, asl::YE, asl::Z0, asl::ZE}));
107  auto bcNoSlipM(generateBCNoSlip(lbgk, cylindersMapMem));
108  auto bcNoSlipV(generateBCNoSlipVel(lbgk, cylindersMapMem));
111 
112  addSliceX0(bcIn);
113  addSliceXE(bcOut);
114 
115  bcNoSlip->init();
116  bcNoSlipM->init();
117  bcNoSlipV->init();
118  bcIn.init();
119  bcOut.init();
120 
121  std::cout << "Finished" << endl;
122  std::cout << "Computing...";
123  asl::Timer timer;
124 
125  asl::WriterVTKXML writer("flow3Res");
126  writer.addScalars("map", *cylindersMapMem);
127  writer.addScalars("rho", *lbgk->getRho());
128  writer.addVector("v", *lbgk->getVelocity());
129 
130 
131 
132  bcIn.execute();
133  bcOut.execute();
134  bcNoSlip->execute();
135  bcNoSlipM->execute();
136 
137  bcNoSlipV->execute();
138  writer.write();
139 
140  timer.start();
141  for (unsigned int i(0); i < 1000; ++i)
142  {
143  lbgk->execute();
144  bcIn.execute();
145  bcOut.execute();
146  bcNoSlip->execute();
147  bcNoSlipM->execute();
148  if (!(i%100))
149  {
150  cout << i << endl;
151  bcNoSlipV->execute();
152  writer.write();
153  }
154  }
155  timer.stop();
156 
157  std::cout << "Finished" << endl;
158 
159  cout << "time=" << timer.getTime() << "; clockTime="
160  << timer.getClockTime() << "; load="
161  << timer.getProcessorLoad() * 100 << "%" << endl;
162 
163  std::cout << "Output...";
164  std::cout << "Finished" << endl;
165  std::cout << "Ok" << endl;
166 
167  return 0;
168 }
const double getTime() const
Definition: aslTimer.h:46
void addSliceX0(BCond &)
void addSliceXE(BCond &)
const double getProcessorLoad() const
Definition: aslTimer.h:48
asl::UValue< double > Param
Definition: flow3.cc:42
Numerical method for fluid flow.
Definition: aslLBGK.h:77
const double getClockTime() const
Definition: aslTimer.h:47
void addVector(std::string name, AbstractData &data)
const T & v() const
Definition: aslUValue.h:43
virtual void execute()
Executes the numerical procedure.
int main(int argc, char *argv[])
Definition: flow3.cc:68
asl::SPDistanceFunction generateOrderedCylinders(asl::Block &block)
Definition: flow3.cc:47
SPDistanceFunction generateDFCylinderInf(double r, const AVec< double > &l, const AVec< double > &c)
generates infinite cylinder
const VectorTemplate & d3q15()
Vector template.
virtual void init()
Builds the necesery internal data and kernels.
acl::VectorOfElements dx(const TemplateVE &a)
differential operator
AVec< T > makeAVec(T a1)
void initData(SPAbstractData d, double a)
Bondary condition corresponding an in- or outflow boundary conditions with a given pressure...
Definition: aslLBGKBC.h:79
void addScalars(std::string name, AbstractData &data)
const DV & getSize() const
Definition: aslBlocks.h:208
void stop()
Definition: aslTimer.h:45
void start()
Definition: aslTimer.h:43
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
float FlT
Definition: flow3.cc:40
void load(int argc, char *argv[])
SPNumMethod generateBCNoSlipVel(SPLBGK nmU, SPAbstractDataWithGhostNodes map)
for velocity field
contains different kernels for preprocessing and posprocessing of data used by LBGK ...
Definition: aslLBGK.h:137
SPBCond generateBCNoSlip(SPLBGK nm, const std::vector< SlicesNames > &sl)