ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
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
29#include <aslDataInc.h>
32#include <utilities/aslTimer.h>
34#include <math/aslTemplates.h>
36#include <acl/aclUtilities.h>
37#include <aslGeomInc.h>
38
39typedef float FlT;
40//typedef double FlT;
42acl::TypeID type(acl::typeToTypeID<FlT>());
43
44
45int main(int argc, char* argv[])
46{
47 asl::ApplicationParametersManager appParamsManager("levelSetFacetedGrowth",
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 asl::Parameter<FlT> betaSt(0.5, "beta_step", "Kinetic coefficient for step");
56 asl::Parameter<FlT> betaDisl(0.0, "beta_dislocation", "Kinetic coefficient for dislocation");
57 asl::Parameter<FlT> betaRough(0.1, "beta_rough", "Kinetic coefficient for rough region");
58
59 asl::Parameter<map<string, asl::AVec<FlT>>> cr_directions_p("cr_direction_*",
60 "Crystallographic directions");
61
62 asl::Parameter<cl_uint> nIterations(100, "nIterations", "Number of iterations");
63 asl::Parameter<cl_uint> nItOut(10, "nItOut", "Number of iterations for output");
64
65 appParamsManager.load(argc, argv);
66
67 std::cout << "Data initialization... ";
68
69 asl::Block block(size.v(), dx.v());
70 auto levelSet(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
71
72 asl::AVec<> center(asl::AVec<FlT>(size.v())*FlT(.5));
73
74 auto sphere1(generateDFSphere(radius.v(), center*.8));
75 auto sphere2(generateDFSphere(radius.v(), center*1.2));
76 asl::initData(levelSet, normalize(sphere1 | sphere2, dx.v()));
77
78 auto superSaturation(asl::generateDataContainerConst_SP(block, superS.v(), 1u));
79
80
81 asl::WriterVTKXML writer(appParamsManager.getDir() + "levelSetFacetedGrowth");
82 writer.addScalars("levelSet", *levelSet);
83
84 std::cout << "Finished" << endl;
85
86 std::cout << "Numerics initialization... " << flush;
87
88 auto lsNum(std::make_shared<asl::LSFacetedGrowth>(levelSet, superSaturation));
89
90 lsNum->crystallography.betaRough = betaRough.v();
91 for (auto it(cr_directions_p.v().begin()); it != cr_directions_p.v().end(); ++it)
92 lsNum->crystallography.addFacet(asl::AVec<double>(it->second), betaSt.v(), betaDisl.v());
93
94 lsNum->init();
95
96 std::cout << "Finished" << endl;
97 std::cout << "Computing...";
98 asl::Timer timer;
99
100 writer.write();
101
102 timer.start();
103 for (unsigned int i(0); i < nIterations.v(); ++i)
104 {
105 lsNum->execute();
106 if (!(i % nItOut.v()))
107 writer.write();
108 }
109 timer.stop();
110
111 cout << "Finished" << endl;
112
113 cout << "Computation statistic:" << endl;
114 cout << "Real Time = " << timer.realTime() << "; Processor Time = "
115 << timer.processorTime() << "; Processor Load = "
116 << timer.processorLoad() * 100 << "%" << endl;
117
118 return 0;
119}
float FlT
void load(int argc, char *argv[])
const T & v() const
std::string getDir()
const double realTime() const
Definition aslTimer.h:45
void stop()
Definition aslTimer.h:44
const double processorTime() const
Definition aslTimer.h:46
void start()
Definition aslTimer.h:43
const double processorLoad() const
Definition aslTimer.h:47
Updatable value. This class stores value and its TimeStamp.
Definition aslUValue.h:35
void addScalars(std::string name, AbstractData &data)
SPDataWithGhostNodesACL generateDataContainerConst_SP(const Block &b, T a, unsigned int gN)
float FlT
acl::TypeID type(acl::typeToTypeID< FlT >())
asl::UValue< FlT > Param
TypeID
Definition aclTypes.h:39
void initData(SPAbstractData d, double a)
int main()