| 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 |
|
| 24 |
/** |
| 25 |
\example levelSetFacetedGrowth.cc |
| 26 |
Required input file: default parameters - levelSetFacetedGrowth.ini |
| 27 |
*/ |
| 28 |
|
| 29 |
#include <aslDataInc.h> |
| 30 |
#include <writers/aslVTKFormatWriters.h> |
| 31 |
#include <num/aslLSFacetedGrowth.h> |
| 32 |
#include <utilities/aslTimer.h> |
| 33 |
#include <utilities/aslParametersManager.h> |
| 34 |
#include <math/aslTemplates.h> |
| 35 |
#include <acl/aclMath/aclVectorOfElements.h> |
| 36 |
#include <acl/aclUtilities.h> |
| 37 |
#include <aslGeomInc.h> |
| 38 |
|
| 39 |
typedef float FlT; |
| 40 |
//typedef double FlT; |
| 41 |
typedef asl::UValue<FlT> Param; |
| 42 |
acl::TypeID type(acl::typeToTypeID<FlT>()); |
| 43 |
|
| 44 |
|
| 45 |
int 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 |
} |