| 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 |
#include "aslFDPoroElasticity.h" |
| 25 |
#include <aslGenerators.h> |
| 26 |
#include <acl/aclGenerators.h> |
| 27 |
#include <acl/acl.h> |
| 28 |
#include <acl/aclMath/aclVectorOfElements.h> |
| 29 |
#include <acl/Kernels/aclKernel.h> |
| 30 |
#include <math/aslTemplateVE.h> |
| 31 |
#include <math/aslTemplates.h> |
| 32 |
#include <data/aslDataWithGhostNodes.h> |
| 33 |
#include <aslDataInc.h> |
| 34 |
|
| 35 |
#include <acl/Kernels/aclKernelConfigurationTemplates.h> |
| 36 |
|
| 37 |
namespace asl |
| 38 |
{ |
| 39 |
FDPoroElasticity::FDPoroElasticity(): |
| 40 |
ElasticityCommonA(), |
| 41 |
pressureData(), |
| 42 |
pressureInternalData(), |
| 43 |
pressureLiquidData(), |
| 44 |
pressureLiquidInternalData(), |
| 45 |
nSubsteps(acl::generateVEConstant(10.)) |
| 46 |
{ |
| 47 |
} |
| 48 |
|
| 49 |
FDPoroElasticity::~FDPoroElasticity() |
| 50 |
{ |
| 51 |
} |
| 52 |
|
| 53 |
FDPoroElasticity::FDPoroElasticity(Data d, Data pl, Param bM, |
| 54 |
Param sM, Param k, |
| 55 |
const VectorTemplate* vT): |
| 56 |
ElasticityCommonA(d,bM,sM,vT), |
| 57 |
pressureData(), |
| 58 |
pressureInternalData(), |
| 59 |
pressureLiquidData(pl), |
| 60 |
pressureLiquidInternalData(), |
| 61 |
hydraulicCondactivity(k), |
| 62 |
nSubsteps(acl::generateVEConstant(10.)) |
| 63 |
{ |
| 64 |
} |
| 65 |
|
| 66 |
void FDPoroElasticity::setNSubsteps(unsigned int n) |
| 67 |
{ |
| 68 |
nSubsteps=acl::generateVEConstant(n); |
| 69 |
} |
| 70 |
|
| 71 |
void FDPoroElasticity::init() |
| 72 |
{ |
| 73 |
|
| 74 |
unsigned int nD(displacementData->getDContainer().size()); |
| 75 |
displacementInternalData=clone(displacementData); |
| 76 |
pressureData = clone(pressureLiquidData); |
| 77 |
pressureInternalData = clone(pressureLiquidData); |
| 78 |
pressureLiquidInternalData = clone(pressureLiquidData); |
| 79 |
|
| 80 |
initData(displacementInternalData->getEContainer(), |
| 81 |
displacementData->getEContainer()); |
| 82 |
asl::initData(pressureData, 0.); |
| 83 |
asl::initData(pressureInternalData, 0.); |
| 84 |
initData(pressureLiquidInternalData->getEContainer(), |
| 85 |
pressureLiquidData->getEContainer()); |
| 86 |
|
| 87 |
acl::TypeID type(getElementType(displacementData->getDContainer())); |
| 88 |
|
| 89 |
acl::VectorOfElements dnew(acl::generateVEPrivateVariable(3,type)); |
| 90 |
acl::VectorOfElements pnew(acl::generateVEPrivateVariable(1,type)); |
| 91 |
acl::VectorOfElements plnew(acl::generateVEPrivateVariable(1,type)); |
| 92 |
acl::VectorOfElements coef1(acl::generateVEPrivateVariable(1,type)); |
| 93 |
acl::VectorOfElements coef2(acl::generateVEPrivateVariable(1,type)); |
| 94 |
|
| 95 |
double sFactor(10.); //< artificial compresibility |
| 96 |
acl::VectorOfElements coefPlP(acl::generateVEConstant(sFactor)); |
| 97 |
|
| 98 |
static const double w(.5); |
| 99 |
|
| 100 |
acl::VectorOfElements wC(acl::generateVEConstant(w)); |
| 101 |
acl::VectorOfElements wm1C(acl::generateVEConstant(1.-w)); |
| 102 |
|
| 103 |
(*kernel)<<(coef1 = shearModulus); |
| 104 |
(*kernel)<<(coef2 = (bulkModulus+shearModulus/3.)); |
| 105 |
|
| 106 |
TemplateVE du; |
| 107 |
du.init(*pressureData,*vectorTemplate); |
| 108 |
(*kernel)<< du.initValues << (pnew=du.getValue(0)*wm1C); |
| 109 |
(*kernel)<<(dnew=-gradient(du)); |
| 110 |
(*kernel)<<(plnew=-coefPlP*du.getValue(0)); |
| 111 |
|
| 112 |
du.init(*pressureLiquidData,*vectorTemplate); |
| 113 |
(*kernel)<< du.initValues; |
| 114 |
(*kernel)<< (plnew+=du.getValue(0) + hydraulicCondactivity/nSubsteps*laplas(du)); |
| 115 |
(*kernel)<<(dnew-=gradient(du)); |
| 116 |
|
| 117 |
for (unsigned int i(0); i<nD; ++i) |
| 118 |
{ |
| 119 |
du.init(*displacementData,*vectorTemplate,i); |
| 120 |
(*kernel)<< du.initValues; |
| 121 |
(*kernel)<< (pnew -= coef2*subVE(gradient(du),i)*wC); |
| 122 |
(*kernel)<< (subVE(dnew,i) += du.getValue(0) + coef1 * laplas(du)); |
| 123 |
} |
| 124 |
(*kernel)<<(plnew+=coefPlP*pnew); |
| 125 |
|
| 126 |
if(force.size()>0) |
| 127 |
(*kernel)<<(dnew+= force); |
| 128 |
|
| 129 |
(*kernel)<<(assignmentSafe (displacementInternalData->getSubContainer(),dnew)); |
| 130 |
(*kernel)<<(assignmentSafe (pressureInternalData->getSubContainer(),pnew)); |
| 131 |
(*kernel)<<(assignmentSafe (pressureLiquidInternalData->getSubContainer(),plnew)); |
| 132 |
|
| 133 |
kernel->setup(); |
| 134 |
|
| 135 |
} |
| 136 |
|
| 137 |
|
| 138 |
void FDPoroElasticity::execute() |
| 139 |
{ |
| 140 |
kernel->compute(); |
| 141 |
swapBuffers(displacementData->getDContainer(), |
| 142 |
displacementInternalData->getDContainer()); |
| 143 |
swapBuffers(pressureData->getDContainer(), |
| 144 |
pressureInternalData->getDContainer()); |
| 145 |
swapBuffers(pressureLiquidData->getDContainer(), |
| 146 |
pressureLiquidInternalData->getDContainer()); |
| 147 |
} |
| 148 |
|
| 149 |
SPFDPoroElasticity generateFDPoroElasticity(SPDataWithGhostNodesACLData d, |
| 150 |
SPDataWithGhostNodesACLData pl, |
| 151 |
double bM, |
| 152 |
double sM, |
| 153 |
double k, |
| 154 |
const VectorTemplate* vT) |
| 155 |
{ |
| 156 |
auto nm(make_shared<FDPoroElasticity> (d, |
| 157 |
pl, |
| 158 |
acl::generateVEConstant(bM), |
| 159 |
acl::generateVEConstant(sM), |
| 160 |
acl::generateVEConstant(k), |
| 161 |
vT)); |
| 162 |
return nm; |
| 163 |
} |
| 164 |
|
| 165 |
template <typename T> |
| 166 |
SPFDPoroElasticity generateFDPoroElasticity(SPDataWithGhostNodesACLData d, |
| 167 |
SPDataWithGhostNodesACLData pl, |
| 168 |
UValue<T> bM, |
| 169 |
UValue<T> sM, |
| 170 |
UValue<T> k, |
| 171 |
const VectorTemplate* vT) |
| 172 |
{ |
| 173 |
auto nm(make_shared<FDPoroElasticity> (d, |
| 174 |
pl, |
| 175 |
acl::generateVEVariableSP(bM.p), |
| 176 |
acl::generateVEVariableSP(sM.p), |
| 177 |
acl::generateVEVariableSP(k.p), |
| 178 |
vT)); |
| 179 |
return nm; |
| 180 |
} |
| 181 |
|
| 182 |
template |
| 183 |
SPFDPoroElasticity generateFDPoroElasticity(SPDataWithGhostNodesACLData d, |
| 184 |
SPDataWithGhostNodesACLData pl, |
| 185 |
UValue<double> bM, |
| 186 |
UValue<double> sM, |
| 187 |
UValue<double> k, |
| 188 |
const VectorTemplate* vT); |
| 189 |
template |
| 190 |
SPFDPoroElasticity generateFDPoroElasticity(SPDataWithGhostNodesACLData d, |
| 191 |
SPDataWithGhostNodesACLData pl, |
| 192 |
UValue<float> bM, |
| 193 |
UValue<float> sM, |
| 194 |
UValue<float> k, |
| 195 |
const VectorTemplate* vT); |
| 196 |
|
| 197 |
} //asl |