| 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 |
|
| 24 |
/** |
| 25 |
\example cubePoroelasticGravity.cc |
| 26 |
*/ |
| 27 |
|
| 28 |
#include <aslDataInc.h> |
| 29 |
#include <acl/aclGenerators.h> |
| 30 |
#include <writers/aslVTKFormatWriters.h> |
| 31 |
#include <num/aslFDPoroElasticity.h> |
| 32 |
#include <num/aslFDElasticityBC.h> |
| 33 |
#include <num/aslFDPoroElasticityBC.h> |
| 34 |
#include <utilities/aslTimer.h> |
| 35 |
#include <utilities/aslParametersManager.h> |
| 36 |
#include <math/aslTemplates.h> |
| 37 |
#include <acl/aclMath/aclVectorOfElements.h> |
| 38 |
#include <aslGeomInc.h> |
| 39 |
#include <acl/aclUtilities.h> |
| 40 |
|
| 41 |
|
| 42 |
typedef float FlT; |
| 43 |
//typedef double FlT; |
| 44 |
typedef asl::UValue<FlT> Param; |
| 45 |
|
| 46 |
|
| 47 |
int 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 |
} |