ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
levelSetBasic.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/aslInterfaceTrackingAlg1.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
38typedef float FlT;
39//typedef double FlT;
41acl::TypeID type(acl::typeToTypeID<FlT>());
42
43
44int main(int argc, char* argv[])
45{
46 asl::ApplicationParametersManager appParamsManager("levelSetBasic", "1.0");
47
48 asl::Parameter<asl::AVec<int>> size(asl::makeAVec<int>(100, 100, 100), "size", "size");
49 asl::Parameter<FlT> dx(1.0, "dx", "dx");
50 asl::Parameter<FlT> dt(1.0, "dt", "dt");
51 asl::Parameter<asl::AVec<FlT>> v(asl::makeAVec<FlT>(0.0, 0.0, 0.0), "v", "v");
52 asl::Parameter<FlT> radius(10.5, "radius", "initial radius");
53
54
55 asl::Parameter<cl_uint> nIterations(100, "nIterations", "Number of iterations");
56 asl::Parameter<cl_uint> nItOut(10, "nItOut", "Number of iterations for output");
57
58 appParamsManager.load(argc, argv);
59
60 std::cout << "Data initialization... ";
61
62 asl::Block block(size.v(), dx.v());
63 auto levelSet(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
64
65 auto sphere(generateDFSphere(radius.v(), asl::AVec<>(asl::AVec<FlT>(size.v())*FlT(.5))));
66 asl::initData(levelSet, -normalize(sphere,dx.v()));
67
68 auto velocity(asl::generateDataContainerConst_SP(block, v.v(), 1u));
69
70
71 asl::WriterVTKXML writer(appParamsManager.getDir() + "levelSetBasic");
72 writer.addScalars("levelSet", *levelSet);
73
74 std::cout << "Finished" << endl;
75
76 std::cout << "Numerics initialization... " << flush;
77
78 auto lsNum(std::make_shared<asl::InterfaceTrackingAlg1>(levelSet,velocity));
79
80 lsNum->init();
81
82 std::cout << "Finished" << endl;
83 std::cout << "Computing...";
84 asl::Timer timer;
85
86 writer.write();
87
88 timer.start();
89 for (unsigned int i(0); i < nIterations.v(); ++i)
90 {
91 lsNum->execute();
92 if(!(i % nItOut.v()))
93 writer.write();
94 }
95 timer.stop();
96
97 cout << "Finished" << endl;
98
99 cout << "Computation statistic:" << endl;
100 cout << "Real Time = " << timer.realTime() << "; Processor Time = "
101 << timer.processorTime() << "; Processor Load = "
102 << timer.processorLoad() * 100 << "%" << endl;
103
104 return 0;
105}
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)
asl::UValue< FlT > Param
SPDataWrapperACLData generateDataContainerACL_SP(const Block &b, unsigned int n=1)
generates pointer to ACL Data field with n components
SPDataWithGhostNodesACL generateDataContainerConst_SP(const Block &b, T a, unsigned int gN)
acl::TypeID type(acl::typeToTypeID< FlT >())
TypeID
Definition aclTypes.h:39
void initData(SPAbstractData d, double a)
int main()