ASL  0.1.7
Advanced Simulation Library
levelSetNormalGrowth.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 <aslDataInc.h>
30 #include <num/aslLSNormalGrowth.h>
31 #include <utilities/aslTimer.h>
33 #include <math/aslTemplates.h>
35 #include <acl/aclUtilities.h>
36 #include <aslGeomInc.h>
37 
38 
39 typedef float FlT;
40 //typedef double FlT;
42 acl::TypeID type(acl::typeToTypeID<FlT>());
43 
44 
45 int main(int argc, char* argv[])
46 {
47  asl::ApplicationParametersManager appParamsManager("levelSetNormalGrowth",
48  "1.0");
49 
50  asl::Parameter<asl::AVec<int>> size(asl::makeAVec<int>(100, 100, 100), "size", "size");
51  asl::Parameter<FlT> dx(1.0, "dx", "dx");
52  asl::Parameter<FlT> dt(1.0, "dt", "dt");
53  asl::Parameter<FlT> superS(0.2, "superS", "super saturation");
54  asl::Parameter<FlT> radius(10.5, "radius", "initial radius");
55 
56 
57  asl::Parameter<cl_uint> nIterations(100, "nIterations", "Number of iterations");
58  asl::Parameter<cl_uint> nItOut(10, "nItOut", "Number of iterations for output");
59 
60  appParamsManager.load(argc, argv);
61 
62  std::cout << "Data initialization...";
63 
64  asl::Block block(size.v(), dx.v());
65  auto levelSet(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
66 
67  asl::AVec<> center(asl::AVec<FlT>(size.v())*FlT(.5));
68 
69  auto sphere1(generateDFSphere(radius.v(), center*.8));
70  auto sphere2(generateDFSphere(radius.v(), center*1.2));
71  asl::initData(levelSet, normalize(sphere1 | sphere2, dx.v()));
72 
73  auto superSaturation(asl::generateDataContainerConst_SP(block, superS.v(), 1u));
74 
75 
76  asl::WriterVTKXML writer(appParamsManager.getDir() + "levelSetNormalGrowth");
77  writer.addScalars("levelSet", *levelSet);
78 
79  std::cout << "Finished" << endl;
80 
81  std::cout << "Numerics initialization..." << flush;
82 
83  auto lsNum(std::make_shared<asl::LSNormalGrowth>(levelSet, superSaturation));
84 
85  lsNum->init();
86 
87  std::cout << "Finished" << endl;
88  std::cout << "Computing...";
89  asl::Timer timer;
90 
91  writer.write();
92 
93  timer.start();
94  for (unsigned int i(0); i < nIterations.v(); ++i)
95  {
96  lsNum->execute();
97  if (!(i % nItOut.v()))
98  writer.write();
99  }
100  timer.stop();
101 
102  cout << "Finished" << endl;
103 
104  cout << "Computation statistic:" << endl;
105  cout << "Real Time = " << timer.realTime() << "; Processor Time = "
106  << timer.processorTime() << "; Processor Load = "
107  << timer.processorLoad() * 100 << "%" << endl;
108 
109  return 0;
110 }
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
const AVec normalize(const AVec< T > &a)
std::string getDir()
asl::UValue< FlT > Param
SPDataWithGhostNodesACL generateDataContainerConst_SP(const Block &b, T a, unsigned int gN)
const T & v() const
cl_int flush(void)
Definition: cl.hpp:7042
acl::VectorOfElements dx(const TemplateVE &a)
differential operator
void initData(SPAbstractData d, double a)
void addScalars(std::string name, AbstractData &data)
int main(int argc, char *argv[])
void stop()
Definition: aslTimer.h:44
float FlT
void start()
Definition: aslTimer.h:43
TypeID
Definition: aclTypes.h:38
void load(int argc, char *argv[])
const double processorLoad() const
Definition: aslTimer.h:47
acl::TypeID type(acl::typeToTypeID< FlT >())