cubeGravity.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 <aslDataInc.h>
#include <acl/aclGenerators.h>
#include <writers/aslVTKFormatWriters.h>
#include <num/aslFDElasticity.h>
#include <num/aslFDElasticityBC.h>
#include <utilities/aslTimer.h>
#include <utilities/aslParametersManager.h>
#include <math/aslTemplates.h>
#include <acl/aclMath/aclVectorOfElements.h>
#include <aslGeomInc.h>
#include <acl/aclUtilities.h>
typedef float FlT;
//typedef double FlT;
typedef asl::UValue<FlT> Param;
int main(int argc, char* argv[])
{
asl::ApplicationParametersManager appParamsManager("cubeGravity", "1.0");
asl::Parameter<asl::AVec<int> > size("size", "size 3D");
asl::Parameter<cl_float> dx("dx", "dx");
asl::Parameter<cl_float> dt("dt", "dt");
asl::Parameter<cl_float> bulkModulus("bulk_modulus", "bulk modulus");
asl::Parameter<cl_float> shearModulus("shear_modulus", "shear modulus");
asl::Parameter<cl_float> rho("rho", "density");
asl::Parameter<asl::AVec<FlT> > g("g", "gravity vector");
asl::Parameter<unsigned int> tsim("num_iterations", "number of iterations");
asl::Parameter<unsigned int> tout("num_it_out", "number of iterations between outputs");
appParamsManager.load(argc, argv);
Param bulkModulusNum(bulkModulus.v()/rho.v()/dx.v()/dx.v());
Param shearModulusNum(shearModulus.v()/rho.v()/dx.v()/dx.v());
asl::AVec<FlT> gNum(g.v()/dx.v());
std::cout << "Data initialization... " << flush;
asl::Block block(size.v(), dx.v());
auto displacement(asl::generateDataContainerACL_SP<FlT>(block, 3, 1u));
acl::initData(displacement->getEContainer(), acl::generateVEConstantN(3,0));
auto mapDF(asl::normalize(asl::generateDFInBlock(block, 0), dx.v()));
auto map(asl::generateDataContainer_SP(block, mapDF, 1u, acl::typeToTypeID<FlT>()));
auto mapX(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
initData(mapX->getEContainer(), map->getEContainer());
asl::WriterVTKXML writer(appParamsManager.getDir() + "cubeGravity");
writer.addScalars("map", *mapX);
writer.addVector("displacement", *displacement);
writer.write();
std::cout << "Finished" << endl;
std::cout << "Numerics initialization... " << flush;
asl::SPFDElasticity2 elasticity(new asl::FDElasticity2(displacement,
acl::generateVEConstant(bulkModulusNum.v()),
acl::generateVEConstant(shearModulusNum.v()),
acl::generateVEConstant(dt.v()),
&asl::d3q15()));
elasticity->setForce(acl::generateVEConstant(gNum));
elasticity->setDumpingFactor(acl::generateVEConstant(.9));
elasticity->init();
auto bcRigidWall(asl::generateBCRigidWall(elasticity, {asl::X0}));
bcRigidWall->init();
auto bcFreeSurface(generateBCZeroStress(elasticity, mapX));
bcFreeSurface->init();
std::cout << "Finished" << endl;
std::cout << "Computing..." << endl;
asl::Timer timer;
bcFreeSurface->execute();
bcRigidWall->execute();
timer.start();
for (unsigned int i(0); i < tsim.v(); ++i)
{
elasticity->execute();
bcFreeSurface->execute();
bcRigidWall->execute();
if (!(i % tout.v()))
{
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;
}
acl::VectorOfElements::initData
void initData(VectorOfElements a, VectorOfElements initializationValue, const KernelConfiguration &kernelConfig)
asl::AVec
Definition: aslVectorsDynamicLength.h:40
asl::ApplicationParametersManager
Definition: aslParametersManager.h:159
asl::ApplicationParametersManager::load
void load(int argc, char *argv[])
asl::Block
Definition: aslBlocks.h:57
asl::FDElasticity2
Numerical method which computes homogenious isotropic elasticity equation.
Definition: aslFDElasticity.h:167
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::UValue::v
const T & v() const
Definition: aslUValue.h:43
asl::Writer::addVector
void addVector(std::string name, AbstractData &data)
asl::Writer::addScalars
void addScalars(std::string name, AbstractData &data)
asl::WriterVTKXML
Definition: aslVTKFormatWriters.h:42
asl::WriterVTKXML::write
void write()
main
int main(int argc, char *argv[])
Definition: cubeGravity.cc:46
FlT
float FlT
Definition: cubeGravity.cc:41
Param
asl::UValue< FlT > Param
Definition: cubeGravity.cc:43
asl::X0
@ X0
Definition: aslBCond.h:309
asl::generateDataContainer_SP
SPDataWrapperACL generateDataContainer_SP(const Block &b, const acl::VectorOfElements &a)
asl::dx
acl::VectorOfElements dx(const TemplateVE &a)
differential operator
asl::generateBCZeroStress
SPNumMethod generateBCZeroStress(SPElasticityCommonA nm, SPAbstractDataWithGhostNodes map)
Bondary condition set given values to displacement/velocity.
asl::generateDFInBlock
SPDistanceFunction generateDFInBlock(const Block &b, unsigned int nG)
generates map corresponding to external (ghost) part of the block
asl::normalize
SPDistanceFunction normalize(SPDistanceFunction a, double dx)
acl::initData
void initData(Element a, Element initializationValue, const KernelConfiguration &kernelConfig=KERNEL_BASIC)
asl::d3q15
const VectorTemplate & d3q15()
Vector template.
acl::generateVEConstantN
VectorOfElements generateVEConstantN(unsigned int n, T a)
Generates VectorOfElements with n Elements acl::Constant with values a.
acl::generateVEConstant
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
acl::map
std::shared_ptr< T > map(ElementData m)
Definition: aclMemBlock.h:68
asl::generateBCRigidWall
SPBCond generateBCRigidWall(SPFDElasticityIncompressibleStatic nm, const std::vector< SlicesNames > &sl)
Bondary condition corresponding to a rigid wall ( and )
asl::SPFDElasticity2
std::shared_ptr< FDElasticity2 > SPFDElasticity2
Definition: aslFDElasticity.h:193
cl::flush
cl_int flush(void)
Definition: cl.hpp:7042