ASL  0.1.6
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>
29 #include <writers/aslVTKFormatWriters.h>
30 #include <num/aslLSNormalGrowth.h>
31 #include <utilities/aslTimer.h>
32 #include <utilities/aslParametersManager.h>
33 #include <math/aslTemplates.h>
34 #include <acl/aclMath/aclVectorOfElements.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("size", "size");
51  asl::Parameter<FlT> dx("dx", "dx");
52  asl::Parameter<FlT> dt("dt", "dt");
53  asl::Parameter<FlT> superS("superS", "super satuation");
54  asl::Parameter<FlT> radius("radius", "initial radius");
55 
56 
57  asl::Parameter<cl_uint> nIterations("nIterations", "Number of iterations");
58  asl::Parameter<cl_uint> nItOut("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  std::cout << "Finished" << endl;
103 
104  cout << "time=" << timer.getTime() << "; clockTime="
105  << timer.getClockTime() << "; load="
106  << timer.getProcessorLoad() * 100 << "%" << endl;
107 
108  std::cout << "Output...";
109  std::cout << "Finished" << endl;
110  std::cout << "Ok" << endl;
111 
112  return 0;
113 }
const double getTime() const
Definition: aslTimer.h:46
const double getProcessorLoad() const
Definition: aslTimer.h:48
SPDistanceFunction generateDFSphere(double r, const AVec< double > &c)
generates sphere
const double getClockTime() const
Definition: aslTimer.h:47
acl::TypeID type(acl::typeToTypeID< FlT >())
const AVec normalize(const AVec< T > &a)
std::string getDir()
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
float FlT
void initData(SPAbstractData d, double a)
void addScalars(std::string name, AbstractData &data)
int main(int argc, char *argv[])
void stop()
Definition: aslTimer.h:45
asl::UValue< FlT > Param
void start()
Definition: aslTimer.h:43
TypeID
Definition: aclTypes.h:38
void load(int argc, char *argv[])