ASL  0.1.6
Advanced Simulation Library
levelSetFacetedGrowth.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/aslLSFacetedGrowth.h>
31 #include <utilities/aslTimer.h>
33 #include <math/aslTemplates.h>
35 #include <acl/aclUtilities.h>
36 #include <aslGeomInc.h>
37 
38 typedef float FlT;
39 //typedef double FlT;
41 acl::TypeID type(acl::typeToTypeID<FlT>());
42 
43 
44 int main(int argc, char* argv[])
45 {
46  asl::ApplicationParametersManager appParamsManager("levelSetFacetedGrowth",
47  "1.0");
48 
49  asl::Parameter<asl::AVec<int>> size("size", "size");
50  asl::Parameter<FlT> dx("dx", "dx");
51  asl::Parameter<FlT> dt("dt", "dt");
52  asl::Parameter<FlT> superS("superS", "Super saturation");
53  asl::Parameter<FlT> radius("radius", "Initial radius");
54  asl::Parameter<FlT> betaSt("beta_step", "Kinetic coefficient for step");
55  asl::Parameter<FlT> betaDisl("beta_dislocation", "Kinetic coefficient for dislocation");
56  asl::Parameter<FlT> betaRough("beta_rough", "Kinetic coefficient for rough region");
57 
58  asl::Parameter<map<string, asl::AVec<FlT>>> cr_directions_p("cr_direction_*",
59  "Crystallographic directions");
60 
61  asl::Parameter<cl_uint> nIterations("nIterations", "Number of iterations");
62  asl::Parameter<cl_uint> nItOut("nItOut", "Number of iterations for output");
63 
64  appParamsManager.load(argc, argv);
65 
66  std::cout << "Data initialization... ";
67 
68  asl::Block block(size.v(), dx.v());
69  auto levelSet(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
70 
71  asl::AVec<> center(asl::AVec<FlT>(size.v())*FlT(.5));
72 
73  auto sphere1(generateDFSphere(radius.v(), center*.8));
74  auto sphere2(generateDFSphere(radius.v(), center*1.2));
75  asl::initData(levelSet, normalize(sphere1 | sphere2, dx.v()));
76 
77  auto superSaturation(asl::generateDataContainerConst_SP(block, superS.v(), 1u));
78 
79 
80  asl::WriterVTKXML writer(appParamsManager.getDir() + "levelSetFacetedGrowth");
81  writer.addScalars("levelSet", *levelSet);
82 
83  std::cout << "Finished" << endl;
84 
85  std::cout << "Numerics initialization... " << flush;
86 
87  auto lsNum(std::make_shared<asl::LSFacetedGrowth>(levelSet, superSaturation));
88 
89  lsNum->crystallography.betaRough = betaRough.v();
90  for (auto it(cr_directions_p.v().begin()); it != cr_directions_p.v().end(); ++it)
91  lsNum->crystallography.addFacet(asl::AVec<double>(it->second), betaSt.v(), betaDisl.v());
92 
93  lsNum->init();
94 
95  std::cout << "Finished" << endl;
96  std::cout << "Computing...";
97  asl::Timer timer;
98 
99  writer.write();
100 
101  timer.start();
102  for (unsigned int i(0); i < nIterations.v(); ++i)
103  {
104  lsNum->execute();
105  if (!(i % nItOut.v()))
106  writer.write();
107  }
108  timer.stop();
109 
110  std::cout << "Finished" << endl;
111 
112  cout << "time=" << timer.getTime() << "; clockTime="
113  << timer.getClockTime() << "; load="
114  << timer.getProcessorLoad() * 100 << "%" << endl;
115 
116  std::cout << "Output...";
117  std::cout << "Finished" << endl;
118  std::cout << "Ok" << endl;
119 
120  return 0;
121 }
int main(int argc, char *argv[])
SPDistanceFunction generateDFSphere(double r, const AVec< double > &c)
generates sphere
const AVec normalize(const AVec< T > &a)
std::string getDir()
const double getProcessorLoad() const
Definition: aslTimer.h:48
acl::TypeID type(acl::typeToTypeID< FlT >())
SPDataWithGhostNodesACL generateDataContainerConst_SP(const Block &b, T a, unsigned int gN)
asl::UValue< FlT > Param
const T & v() const
cl_int flush(void)
Definition: cl.hpp:7042
acl::VectorOfElements dx(const TemplateVE &a)
differential operator
const double getClockTime() const
Definition: aslTimer.h:47
void initData(SPAbstractData d, double a)
const double getTime() const
Definition: aslTimer.h:46
void addScalars(std::string name, AbstractData &data)
float FlT
void stop()
Definition: aslTimer.h:45
void start()
Definition: aslTimer.h:43
TypeID
Definition: aclTypes.h:38
void load(int argc, char *argv[])