File: levelSetFacetedGrowth.cc

package info (click to toggle)
asl 0.1.7-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,536 kB
  • sloc: cpp: 36,180; makefile: 26
file content (119 lines) | stat: -rw-r--r-- 3,977 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 * Advanced Simulation Library <http://asl.org.il>
 * 
 * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
 *
 *
 * This file is part of Advanced Simulation Library (ASL).
 *
 * ASL is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, version 3 of the License.
 *
 * ASL is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with ASL. If not, see <http://www.gnu.org/licenses/>.
 *
 */


/**
	\example levelSetFacetedGrowth.cc
	Required input file: default parameters - levelSetFacetedGrowth.ini
*/

#include <aslDataInc.h>
#include <writers/aslVTKFormatWriters.h>
#include <num/aslLSFacetedGrowth.h>
#include <utilities/aslTimer.h>
#include <utilities/aslParametersManager.h>
#include <math/aslTemplates.h>
#include <acl/aclMath/aclVectorOfElements.h>
#include <acl/aclUtilities.h>
#include <aslGeomInc.h>

typedef float FlT;
//typedef double FlT;
typedef asl::UValue<FlT> Param;
acl::TypeID type(acl::typeToTypeID<FlT>()); 


int main(int argc, char* argv[])
{
	asl::ApplicationParametersManager appParamsManager("levelSetFacetedGrowth",
	                                                   "1.0");

	asl::Parameter<asl::AVec<int>> size(asl::makeAVec<int>(100, 100, 100), "size", "size");
	asl::Parameter<FlT> dx(1.0, "dx", "dx");
	asl::Parameter<FlT> dt(1.0, "dt", "dt");
	asl::Parameter<FlT> superS(0.2, "superS", "Super saturation");
	asl::Parameter<FlT> radius(10.5, "radius", "Initial radius");
	asl::Parameter<FlT> betaSt(0.5, "beta_step", "Kinetic coefficient for step");
	asl::Parameter<FlT> betaDisl(0.0, "beta_dislocation", "Kinetic coefficient for dislocation");
	asl::Parameter<FlT> betaRough(0.1, "beta_rough", "Kinetic coefficient for rough region");

	asl::Parameter<map<string, asl::AVec<FlT>>> cr_directions_p("cr_direction_*",
	                                                            "Crystallographic directions");
	
	asl::Parameter<cl_uint> nIterations(100, "nIterations", "Number of iterations");
	asl::Parameter<cl_uint> nItOut(10, "nItOut", "Number of iterations for output");

	appParamsManager.load(argc, argv);

	std::cout << "Data initialization... ";

	asl::Block block(size.v(), dx.v());
	auto levelSet(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));

	asl::AVec<> center(asl::AVec<FlT>(size.v())*FlT(.5));
		
	auto sphere1(generateDFSphere(radius.v(), center*.8));
	auto sphere2(generateDFSphere(radius.v(), center*1.2));
	asl::initData(levelSet, normalize(sphere1 | sphere2, dx.v()));
	
	auto superSaturation(asl::generateDataContainerConst_SP(block, superS.v(), 1u));

	
	asl::WriterVTKXML writer(appParamsManager.getDir() + "levelSetFacetedGrowth");
	writer.addScalars("levelSet", *levelSet);
	
	std::cout << "Finished" << endl;
	
	std::cout << "Numerics initialization... " << flush;

	auto lsNum(std::make_shared<asl::LSFacetedGrowth>(levelSet, superSaturation));

	lsNum->crystallography.betaRough = betaRough.v();
	for (auto it(cr_directions_p.v().begin()); it != cr_directions_p.v().end(); ++it)
		lsNum->crystallography.addFacet(asl::AVec<double>(it->second), betaSt.v(), betaDisl.v());
	
	lsNum->init();

	std::cout << "Finished" << endl;
	std::cout << "Computing...";
	asl::Timer timer;

	writer.write();
	
	timer.start();
	for (unsigned int i(0); i < nIterations.v(); ++i)
	{
		lsNum->execute();
		if (!(i % nItOut.v()))
			writer.write();		
	}
	timer.stop();
	
	cout << "Finished" << endl;	

	cout << "Computation statistic:" << endl;
	cout << "Real Time = " << timer.realTime() << "; Processor Time = "
		 << timer.processorTime() << "; Processor Load = "
		 << timer.processorLoad() * 100 << "%" << endl;

	return 0;
}