surfaceFlux.cc
/*
* 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 <utilities/aslParametersManager.h>
#include <math/aslTemplates.h>
#include <aslGeomInc.h>
#include <aslDataInc.h>
#include <acl/aclGenerators.h>
#include <writers/aslVTKFormatWriters.h>
#include <num/aslFDAdvectionDiffusion.h>
#include <num/aslBasicBC.h>
#include <utilities/aslTimer.h>
#include <acl/aclUtilities.h>
typedef float FlT;
//typedef double FlT;
typedef asl::UValue<double> Param;
using asl::AVec;
using asl::makeAVec;
int main(int argc, char* argv[])
{
// Optionally add appParamsManager to be able to manipulate at least
// hardware parameters(platform/device) through command line/parameters file
asl::ApplicationParametersManager appParamsManager("surfaceFlux",
"1.0");
appParamsManager.load(argc, argv);
Param dx(1.);
Param dt(1.);
Param diffCoef(.15);
Param diffCoefNum(diffCoef.v()*dt.v()/dx.v()/dx.v());
AVec<int> size(asl::makeAVec(50,50,50));
auto gSize(dx.v()*AVec<>(size));
std::cout << "Data initialization... ";
asl::Block block(size,dx.v());
auto ball(normalize(//generateDFPlane(makeAVec(1.,3.,1.),.5*gSize+makeAVec(.2,.0,.6)) &
generateDFSphere(10, .5*gSize+makeAVec(.2,.1,.3)),
dx.v()));
// Formula
// auto ballMap(asl::generateDataContainer_SP(block, ball, 1u, acl::typeToTypeID<FlT>()));
// Data
auto ballMapMem(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
asl::initData(ballMapMem, ball);
auto ballB(normalize(-generateDFSphere(24, .5*gSize),dx.v() ));
auto ballBMapMem(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
asl::initData(ballBMapMem, ballB);
auto cField(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
asl::initData(cField, 0.);
std::cout << "Finished" << endl;
std::cout << "Numerics initialization... ";
auto templ(&asl::d3q15());
auto nm(generateFDAdvectionDiffusion(cField, diffCoefNum.v(), templ));
nm->init();
std::vector<asl::SPNumMethod> bc;
// bc.push_back(generateBCConstantGradient(cField, 0.1, ballMapMem, templ));
bc.push_back(generateBCConstantGradient2(cField, 0.1, ballMapMem, templ));
bc.push_back(asl::generateBCConstantValue(cField, 0, ballBMapMem));
initAll(bc);
std::cout << "Finished" << endl;
std::cout << "Computing..." << flush;
asl::Timer timer;
asl::WriterVTKXML writer(appParamsManager.getDir() + "surfaceFlux");
writer.addScalars("map", *ballMapMem);
writer.addScalars("mapE", *ballBMapMem);
writer.addScalars("c", *cField);
executeAll(bc);
writer.write();
timer.start();
for (unsigned int i(1); i < 201; ++i)
{
nm->execute();
executeAll(bc);
if (!(i%40))
{
cout << i << endl;
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;
}
asl::AVec
Definition: aslVectorsDynamicLength.h:40
asl::AVec::normalize
const AVec normalize(const AVec< T > &a)
Definition: aslVectorsDynamicLengthOperations.h:152
asl::AVec::makeAVec
AVec< T > makeAVec(T a1)
Definition: aslVectorsDynamicLength.h:176
asl::ApplicationParametersManager
Definition: aslParametersManager.h:159
asl::ApplicationParametersManager::load
void load(int argc, char *argv[])
asl::Block
Definition: aslBlocks.h:57
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< double >
asl::UValue::v
const T & v() const
Definition: aslUValue.h:43
asl::Writer::addScalars
void addScalars(std::string name, AbstractData &data)
asl::WriterVTKXML
Definition: aslVTKFormatWriters.h:42
asl::WriterVTKXML::write
void write()
asl::dx
acl::VectorOfElements dx(const TemplateVE &a)
differential operator
asl::generateBCConstantGradient2
SPNumMethod generateBCConstantGradient2(SPAbstractDataWithGhostNodes d, double v, SPAbstractDataWithGhostNodes map, const VectorTemplate *const t)
Bondary condition that makes fixed gradient, second order accuracy <>
asl::generateBCConstantValue
SPBCond generateBCConstantValue(SPAbstractDataWithGhostNodes d, double v, const std::vector< SlicesNames > &sl)
Bondary condition that puts fixed value in each point.
asl::generateDFSphere
SPDistanceFunction generateDFSphere(double r, const AVec< double > &c)
generates sphere
asl::generateFDAdvectionDiffusion
SPFDAdvectionDiffusion generateFDAdvectionDiffusion(SPDataWithGhostNodesACLData c, double diffustionCoeff, SPAbstractDataWithGhostNodes v, const VectorTemplate *vt, bool compressibilityCorrection=false)
asl::d3q15
const VectorTemplate & d3q15()
Vector template.
asl::makeAVec
AVec< T > makeAVec(T a1)
Definition: aslVectorsDynamicLength.h:176
asl::initAll
void initAll(std::vector< T * > &v)
Definition: aslNumMethod.h:67
asl::initData
void initData(SPAbstractData d, double a)
asl::executeAll
void executeAll(std::vector< T * > &v)
Definition: aslNumMethod.h:55
cl::flush
cl_int flush(void)
Definition: cl.hpp:7042
main
int main(int argc, char *argv[])
Definition: surfaceFlux.cc:48
FlT
float FlT
Definition: surfaceFlux.cc:40
Param
asl::UValue< double > Param
Definition: surfaceFlux.cc:42