ASL  0.1.7
Advanced Simulation Library
surfaceFlux.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 
29 #include <math/aslTemplates.h>
30 #include <aslGeomInc.h>
31 #include <aslDataInc.h>
32 #include <acl/aclGenerators.h>
35 #include <num/aslBasicBC.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 
47 
48 int main(int argc, char* argv[])
49 {
50  // Optionally add appParamsManager to be able to manipulate at least
51  // hardware parameters(platform/device) through command line/parameters file
52  asl::ApplicationParametersManager appParamsManager("surfaceFlux",
53  "1.0");
54  appParamsManager.load(argc, argv);
55 
56  Param dx(1.);
57  Param dt(1.);
58  Param diffCoef(.15);
59 
60  Param diffCoefNum(diffCoef.v()*dt.v()/dx.v()/dx.v());
61  AVec<int> size(asl::makeAVec(50,50,50));
62 
63  auto gSize(dx.v()*AVec<>(size));
64 
65 
66  std::cout << "Data initialization... ";
67 
68  asl::Block block(size,dx.v());
69 
70  auto ball(normalize(//generateDFPlane(makeAVec(1.,3.,1.),.5*gSize+makeAVec(.2,.0,.6)) &
71  generateDFSphere(10, .5*gSize+makeAVec(.2,.1,.3)),
72  dx.v()));
73  // Formula
74 // auto ballMap(asl::generateDataContainer_SP(block, ball, 1u, acl::typeToTypeID<FlT>()));
75  // Data
76  auto ballMapMem(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
77  asl::initData(ballMapMem, ball);
78 
79  auto ballB(normalize(-generateDFSphere(24, .5*gSize),dx.v() ));
80  auto ballBMapMem(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
81  asl::initData(ballBMapMem, ballB);
82 
83  auto cField(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
84  asl::initData(cField, 0.);
85 
86 
87  std::cout << "Finished" << endl;
88 
89  std::cout << "Numerics initialization... ";
90 
91  auto templ(&asl::d3q15());
92  auto nm(generateFDAdvectionDiffusion(cField, diffCoefNum.v(), templ));
93  nm->init();
94 
95  std::vector<asl::SPNumMethod> bc;
96 
97 // bc.push_back(generateBCConstantGradient(cField, 0.1, ballMapMem, templ));
98  bc.push_back(generateBCConstantGradient2(cField, 0.1, ballMapMem, templ));
99  bc.push_back(asl::generateBCConstantValue(cField, 0, ballBMapMem));
100  initAll(bc);
101 
102  std::cout << "Finished" << endl;
103  std::cout << "Computing..." << flush;
104  asl::Timer timer;
105 
106  asl::WriterVTKXML writer(appParamsManager.getDir() + "surfaceFlux");
107  writer.addScalars("map", *ballMapMem);
108  writer.addScalars("mapE", *ballBMapMem);
109  writer.addScalars("c", *cField);
110 
111  executeAll(bc);
112  writer.write();
113 
114  timer.start();
115  for (unsigned int i(1); i < 201; ++i)
116  {
117  nm->execute();
118  executeAll(bc);
119  if (!(i%40))
120  {
121  cout << i << endl;
122  writer.write();
123  }
124  }
125  timer.stop();
126 
127  cout << "Finished" << endl;
128 
129  cout << "Computation statistic:" << endl;
130  cout << "Real Time = " << timer.realTime() << "; Processor Time = "
131  << timer.processorTime() << "; Processor Load = "
132  << timer.processorLoad() * 100 << "%" << endl;
133 
134  return 0;
135 }
const double realTime() const
Definition: aslTimer.h:45
const double processorTime() const
Definition: aslTimer.h:46
SPDistanceFunction generateDFSphere(double r, const AVec< double > &c)
generates sphere
AVec< T > makeAVec(T a1)
SPNumMethod generateBCConstantGradient2(SPAbstractDataWithGhostNodes d, double v, SPAbstractDataWithGhostNodes map, const VectorTemplate *const t)
Bondary condition that makes fixed gradient, second order accuracy.
const T & v() const
Definition: aslUValue.h:43
const AVec normalize(const AVec< T > &a)
void initAll(std::vector< T * > &v)
Definition: aslNumMethod.h:67
AVec< T > makeAVec(T a1)
std::string getDir()
asl::UValue< double > Param
Definition: surfaceFlux.cc:42
float FlT
Definition: surfaceFlux.cc:40
const VectorTemplate & d3q15()
Vector template.
cl_int flush(void)
Definition: cl.hpp:7042
SPFDAdvectionDiffusion generateFDAdvectionDiffusion(SPDataWithGhostNodesACLData c, double diffustionCoeff, SPAbstractDataWithGhostNodes v, const VectorTemplate *vt, bool compressibilityCorrection=false)
acl::VectorOfElements dx(const TemplateVE &a)
differential operator
int main(int argc, char *argv[])
Definition: surfaceFlux.cc:48
void initData(SPAbstractData d, double a)
void executeAll(std::vector< T * > &v)
Definition: aslNumMethod.h:55
void addScalars(std::string name, AbstractData &data)
void stop()
Definition: aslTimer.h:44
void start()
Definition: aslTimer.h:43
SPBCond generateBCConstantValue(SPAbstractDataWithGhostNodes d, double v, const std::vector< SlicesNames > &sl)
Bondary condition that puts fixed value in each point.
void load(int argc, char *argv[])
const double processorLoad() const
Definition: aslTimer.h:47