levelSetNormalGrowth.cc
Go to the documentation of this file.
/*
* 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/>.
*
*/
#include <aslDataInc.h>
#include <writers/aslVTKFormatWriters.h>
#include <num/aslLSNormalGrowth.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("levelSetNormalGrowth",
"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<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() + "levelSetNormalGrowth");
writer.addScalars("levelSet", *levelSet);
std::cout << "Finished" << endl;
std::cout << "Numerics initialization..." << flush;
auto lsNum(std::make_shared<asl::LSNormalGrowth>(levelSet, superSaturation));
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;
}
FlT
float FlT
Definition: acousticWaves.cc:40
asl::AVec
Definition: aslVectorsDynamicLength.h:40
asl::AVec::normalize
const AVec normalize(const AVec< T > &a)
Definition: aslVectorsDynamicLengthOperations.h:152
asl::ApplicationParametersManager
Definition: aslParametersManager.h:159
asl::ApplicationParametersManager::load
void load(int argc, char *argv[])
asl::Block
Definition: aslBlocks.h:57
asl::Parameter
Definition: aslParametersManager.h:45
asl::Parameter::v
const T & v() const
Definition: aslParametersManager.h:179
asl::ParametersManager::getDir
std::string getDir()
asl::Timer
Definition: aslTimer.h:34
asl::Timer::realTime
const double realTime() const
Definition: aslTimer.h:45
asl::Timer::stop
void stop()
Definition: aslTimer.h:44
asl::Timer::processorTime
const double processorTime() const
Definition: aslTimer.h:46
asl::Timer::start
void start()
Definition: aslTimer.h:43
asl::Timer::processorLoad
const double processorLoad() const
Definition: aslTimer.h:47
asl::UValue< FlT >
asl::Writer::addScalars
void addScalars(std::string name, AbstractData &data)
asl::WriterVTKXML
Definition: aslVTKFormatWriters.h:42
asl::WriterVTKXML::write
void write()
asl::generateDataContainerConst_SP
SPDataWithGhostNodesACL generateDataContainerConst_SP(const Block &b, T a, unsigned int gN)
asl::dx
acl::VectorOfElements dx(const TemplateVE &a)
differential operator
asl::generateDFSphere
SPDistanceFunction generateDFSphere(double r, const AVec< double > &c)
generates sphere
main
int main(int argc, char *argv[])
Definition: levelSetNormalGrowth.cc:45
FlT
float FlT
Definition: levelSetNormalGrowth.cc:39
type
acl::TypeID type(acl::typeToTypeID< FlT >())
Param
asl::UValue< FlT > Param
Definition: levelSetNormalGrowth.cc:41
acl::TypeID
TypeID
Definition: aclTypes.h:39
asl::initData
void initData(SPAbstractData d, double a)
cl::flush
cl_int flush(void)
Definition: cl.hpp:7042