ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
jumpingBox.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 <acl/aclGenerators.h>
30#include <writers/aslVTKFormatWriters.h>
31#include <num/aslFDElasticity.h>
32#include <num/aslFDElasticityBC.h>
33#include <utilities/aslTimer.h>
34#include <utilities/aslParametersManager.h>
35#include <math/aslTemplates.h>
36#include <acl/aclMath/aclVectorOfElements.h>
37
38
39typedef float FlT;
40//typedef double FlT;
42
43
44int main(int argc, char* argv[])
45{
46 asl::ApplicationParametersManager appParamsManager("jumpingBox", "1.0");
47 asl::Parameter<asl::AVec<int> > size(asl::makeAVec<int>(50, 50, 50), "size", "3D size");
48 asl::Parameter<cl_float> dx(1e-3, "dx", "dx");
49 asl::Parameter<cl_float> dt(1e-5, "dt", "dt");
50 asl::Parameter<cl_float> bulkModulus(2.5e6, "bulk_modulus", "bulk modulus");
51 asl::Parameter<cl_float> shearModulus(1e6, "shear_modulus", "shear modulus");
52 asl::Parameter<cl_float> rho(900, "rho", "density");
53 asl::Parameter<asl::AVec<FlT> > g(asl::makeAVec<FlT>(-9.8, 0.0, 0.0), "g", "gravity vector");
54
55 asl::Parameter<unsigned int> tsim(2000, "num_iterations", "number of iterations");
56 asl::Parameter<unsigned int> tout(100, "num_it_out", "number of iterations between outputs");
57
58 appParamsManager.load(argc, argv);
59
60 Param bulkModulusNum(bulkModulus.v()/rho.v()/dx.v()/dx.v());
61 Param shearModulusNum(shearModulus.v()/rho.v()/dx.v()/dx.v());
62
63 asl::AVec<FlT> gNum(g.v()/dx.v());
64
65 std::cout << "Data initialization... ";
66
67 asl::Block block(size.v(), dx.v());
68 auto displacement(asl::generateDataContainerACL_SP<FlT>(block, 3, 1u));
69 acl::initData(displacement->getEContainer(), acl::generateVEConstantN(3,0));
70
71 asl::WriterVTKXML writer(appParamsManager.getDir() + "jumpingBox");
72 writer.addScalars("displacement", *displacement);
73 writer.addVector("displacement", *displacement);
74 writer.write();
75
76 std::cout << "Finished" << endl;
77
78 std::cout << "Numerics initialization... ";
79
80 asl::SPFDElasticity2 elasticity(new asl::FDElasticity2(displacement,
81 acl::generateVEConstant(bulkModulusNum.v()),
82 acl::generateVEConstant(shearModulusNum.v()),
84 &asl::d3q15()));
85 elasticity->setForce(acl::generateVEConstant(gNum));
86 elasticity->setDumpingFactor(acl::generateVEConstant(.90));
87 elasticity->init();
88
89 asl::BCFreeSurface2 bcFreeSurface(elasticity);
90 auto bcRigidWall(generateBCRigidWall(elasticity, {asl::X0}));
91
92 addSliceXE(bcFreeSurface);
93 addSliceY0(bcFreeSurface);
94 addSliceYE(bcFreeSurface);
95 addSliceZ0(bcFreeSurface);
96 addSliceZE(bcFreeSurface);
97
98 bcFreeSurface.init();
99 bcRigidWall->init();
100
101 std::cout << "Finished" << endl;
102 std::cout << "Computing...";
103 asl::Timer timer;
104
105 bcFreeSurface.execute();
106 bcRigidWall->execute();
107
108 timer.start();
109 for (unsigned int i(0); i < tsim.v(); ++i)
110 {
111 elasticity->execute();
112 bcFreeSurface.execute();
113 bcRigidWall->execute();
114 if(!(i % tout.v()))
115 writer.write();
116 }
117 timer.stop();
118
119 cout << "Finished" << endl;
120
121 cout << "Computation statistic:" << endl;
122 cout << "Real Time = " << timer.realTime() << "; Processor Time = "
123 << timer.processorTime() << "; Processor Load = "
124 << timer.processorLoad() * 100 << "%" << endl;
125 return 0;
126}
float FlT
void load(int argc, char *argv[])
Bondary condition corresponding to a free surface ( )
virtual void execute()
Executes the numerical procedure.
virtual void init()
Builds the necesery internal data and kernels.
Numerical method which computes homogenious isotropic elasticity equation.
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
const T & v() const
Definition aslUValue.h:43
void addVector(std::string name, AbstractData &data)
void addScalars(std::string name, AbstractData &data)
asl::UValue< FlT > Param
@ X0
Definition aslBCond.h:309
SPDataWrapperACLData generateDataContainerACL_SP(const Block &b, unsigned int n=1)
generates pointer to ACL Data field with n components
void initData(Element a, Element initializationValue, const KernelConfiguration &kernelConfig=KERNEL_BASIC)
const VectorTemplate & d3q15()
Vector template.
VectorOfElements generateVEConstantN(unsigned int n, T a)
Generates VectorOfElements with n Elements acl::Constant with values a.
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
std::shared_ptr< FDElasticity2 > SPFDElasticity2
int main()