ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
cubePoroelasticGravity.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>
34#include <utilities/aslTimer.h>
36#include <math/aslTemplates.h>
38#include <aslGeomInc.h>
39#include <acl/aclUtilities.h>
40
41
42typedef float FlT;
43//typedef double FlT;
45
46
47int main(int argc, char* argv[])
48{
49 asl::ApplicationParametersManager appParamsManager("cubePoroelasticGravity",
50 "1.0");
51 asl::Parameter<asl::AVec<int> > size(asl::makeAVec<int>(50, 50, 50), "size", "3D size");
52 asl::Parameter<cl_float> dx(4e-3, "dx", "dx");
53 asl::Parameter<cl_float> dt(0.0001, "dt", "dt");
54 asl::Parameter<cl_float> bulkModulus(1000.0, "bulk_modulus", "bulk modulus");
55 asl::Parameter<cl_float> shearModulus(30.0, "shear_modulus", "shear modulus");
56 asl::Parameter<cl_float> hydraulicConductivity(1e-10, "hydraulic_conductivity", "hydraulic conductivity");
57 asl::Parameter<cl_float> rho(1e3, "rho", "density");
58 asl::Parameter<asl::AVec<FlT> > g(asl::makeAVec<FlT>(-9.8, 0.0, 0.0), "g", "gravity vector");
59
60 asl::Parameter<unsigned int> tsim(20000, "num_iterations", "number of iterations");
61 asl::Parameter<unsigned int> tout(500, "num_it_out", "number of iterations between outputs");
62
63 appParamsManager.load(argc, argv);
64
65 Param bulkModulusNum(bulkModulus.v()/rho.v()/dx.v()/dx.v()*dt.v()*dt.v());
66 Param shearModulusNum(shearModulus.v()/rho.v()/dx.v()/dx.v()*dt.v()*dt.v());
67
68 asl::AVec<FlT> gNum(g.v()*dt.v()*dt.v());
69
70 std::cout << "Data initialization... " << flush;
71
72 asl::Block block(size.v(), dx.v());
73 auto displacement(asl::generateDataContainerACL_SP<FlT>(block, 3, 1u));
74 asl::initData(displacement, asl::makeAVec(0.,0.,0.));
75 auto pressureL(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
76 asl::initData(pressureL, 0.);
77
78 auto mapDF(asl::normalize(asl::generateDFInBlock(block, 0), dx.v()));
79 auto map(asl::generateDataContainer_SP(block, mapDF, 1u, acl::typeToTypeID<FlT>()));
80 auto mapX(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
81 initData(mapX, mapDF);
82
83 std::cout << "Finished" << endl;
84
85 std::cout << "Numerics initialization... " << flush;
86
87 auto elasticity(generateFDPoroElasticity(displacement,
88 pressureL,
89 bulkModulusNum.v(),
90 shearModulusNum.v(),
91 hydraulicConductivity.v(),
92 &asl::d3q15()));
93 elasticity->setForce(acl::generateVEConstant(gNum));
94 elasticity->init();
95
96 std::vector<asl::SPNumMethod> bc;
97 asl::addBCZeroStress(bc, elasticity, mapX);
98 asl::addBCRigidWall(bc, elasticity, {asl::X0});
99 asl::initAll(bc);
100
101 asl::WriterVTKXML writer(appParamsManager.getDir() + "cubePoroelasticGravity");
102 writer.addScalars("map", *mapX);
103 writer.addVector("displacement", *displacement);
104 writer.addScalars("pressure", *elasticity->getPressureData());
105 writer.addScalars("pressureL", *elasticity->getLiquidPressureData());
106
107 std::cout << "Finished" << endl;
108 std::cout << "Computing..." << endl;
109 asl::Timer timer, timerBulk, timerBC;
110
111 executeAll(bc);
112 writer.write();
113
114 timer.start();
115 timerBulk.reset();
116 timerBC.reset();
117 for (unsigned int i(0); i < tsim.v(); ++i)
118 {
119 timerBulk.start();
120 elasticity->execute();
121 timerBulk.stop();
122 timerBC.start();
123 executeAll(bc);
124 timerBC.stop();
125 if (!(i % tout.v()))
126 {
127 cout << i << endl;
128 writer.write();
129 }
130 }
131 timer.stop();
132
133 cout << "Finished" << endl;
134
135 cout << "Computation statistic:" << endl;
136 cout << "Real Time = " << timer.realTime() << "; Processor Time = "
137 << timer.processorTime() << "; Processor Load = "
138 << timer.processorLoad() * 100 << "%" << endl;
139
140 cout << "timeBulk=" << timerBulk.realTime() <<
141 "; timeBC=" << timerBC.realTime() << endl;
142
143 return 0;
144}
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
void reset()
Definition: aslTimer.h:48
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)
float FlT
asl::UValue< FlT > Param
@ X0
Definition: aslBCond.h:309
SPDataWrapperACL generateDataContainer_SP(const Block &b, const acl::VectorOfElements &a)
void addBCZeroStress(std::vector< SPNumMethod > &bcList, SPFDPoroElasticity nm, SPAbstractDataWithGhostNodes map)
Bondary condition set given values to pressure.
SPDistanceFunction generateDFInBlock(const Block &b, unsigned int nG)
generates map corresponding to external (ghost) part of the block
SPDistanceFunction normalize(SPDistanceFunction a, double dx)
const VectorTemplate & d3q15()
Vector template.
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
AVec< T > makeAVec(T a1)
void initAll(std::vector< T * > &v)
Definition: aslNumMethod.h:67
void addBCRigidWall(std::vector< SPNumMethod > &bcList, SPFDPoroElasticity nm, const std::vector< SlicesNames > &sl)
void initData(SPAbstractData d, double a)
int main()