| 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 "aslFDPoroElasticityBC.h" |
| 25 |
#include "aslFDPoroElasticity.h" |
| 26 |
#include "acl/aclMath/aclVectorOfElements.h" |
| 27 |
#include "aslFDElasticityBC.h" |
| 28 |
#include "aslBasicBC.h" |
| 29 |
#include "acl/Kernels/aclKernelConfigurationTemplates.h" |
| 30 |
#include "acl/Kernels/aclKernel.h" |
| 31 |
#include <acl/acl.h> |
| 32 |
#include <acl/aclGenerators.h> |
| 33 |
#include <acl/Kernels/aclExpressionContainer.h> |
| 34 |
#include <math/aslTemplateVE.h> |
| 35 |
#include <aslGenerators.h> |
| 36 |
#include <math/aslIndex2Position.h> |
| 37 |
|
| 38 |
namespace asl |
| 39 |
{ |
| 40 |
|
| 41 |
BCRigidWallPoroElasticity::BCRigidWallPoroElasticity(SPFDPoroElasticity nm): |
| 42 |
BCond(nm->getDisplacementData()->getBlock(),nm->vectorTemplate), |
| 43 |
kernel(new acl::Kernel(acl::KERNEL_BASIC)), |
| 44 |
num(nm), |
| 45 |
value(acl::generateVEConstantN(nD(*nm),0.)) |
| 46 |
{ |
| 47 |
} |
| 48 |
|
| 49 |
BCRigidWallPoroElasticity::~BCRigidWallPoroElasticity(){} |
| 50 |
|
| 51 |
BCRigidWallPoroElasticity::BCRigidWallPoroElasticity(SPFDPoroElasticity nm, acl::VectorOfElements v): |
| 52 |
BCond(nm->getDisplacementData()->getBlock(),nm->vectorTemplate), |
| 53 |
kernel(new acl::Kernel(acl::KERNEL_BASIC)), |
| 54 |
num(nm), |
| 55 |
value(v) |
| 56 |
{ |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
void BCRigidWallPoroElasticity::init() |
| 61 |
{ |
| 62 |
loadIndicesToACL(); |
| 63 |
loadNeighbourIndicesToACL(); |
| 64 |
(*kernel)<<(acl::excerpt(num->getDisplacementData()->getEContainer(), |
| 65 |
*indicesACL) = value); |
| 66 |
(*kernel)<<(acl::excerpt(num->getPressureData()->getEContainer(), |
| 67 |
*indicesACL) = |
| 68 |
acl::excerpt(num->getPressureData()->getEContainer(), |
| 69 |
*neighbourIndicesACL)); |
| 70 |
(*kernel)<<(acl::excerpt(num->getLiquidPressureData()->getEContainer(), |
| 71 |
*indicesACL) = |
| 72 |
acl::excerpt(num->getLiquidPressureData()->getEContainer(), |
| 73 |
*neighbourIndicesACL)); |
| 74 |
kernel->setup(); |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
void BCRigidWallPoroElasticity::execute() |
| 79 |
{ |
| 80 |
kernel->compute(); |
| 81 |
} |
| 82 |
|
| 83 |
BCRigidWallDF::BCRigidWallDF(SPFDPoroElasticity nm, |
| 84 |
SPDistanceFunction rw, |
| 85 |
SPAbstractDataWithGhostNodes map): |
| 86 |
BCondWithMap(map,nm->vectorTemplate), |
| 87 |
kernel(new acl::Kernel(acl::KERNEL_BASIC)), //< It is important to fix generateDCFullSafe- SIMDUA issue |
| 88 |
num(nm), |
| 89 |
rWall(rw) |
| 90 |
{ |
| 91 |
} |
| 92 |
|
| 93 |
BCRigidWallDF::~BCRigidWallDF() |
| 94 |
{ |
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
void BCRigidWallDF::init() |
| 99 |
{ |
| 100 |
double wallVal(.0); |
| 101 |
acl::ExpressionContainer kk; |
| 102 |
initMapInfrastructure(kk); |
| 103 |
|
| 104 |
auto dispX(generateDCFullSafe(num->getDisplacementData())); |
| 105 |
auto pressureX(generateDCFullSafe(num->getPressureData())); |
| 106 |
auto pressureLX(generateDCFullSafe(num->getLiquidPressureData())); |
| 107 |
|
| 108 |
acl::TypeID type(getElementType(mapTVE->values)); |
| 109 |
|
| 110 |
// unsigned int nd(nD(*templ)); |
| 111 |
unsigned int nDir(mapTVE->values.size()); |
| 112 |
// double dx(map->getBlock().dx); |
| 113 |
auto counter(generateVEPrivateVariable(1,type)); |
| 114 |
auto val(generateVEPrivateVariable(1,type)); |
| 115 |
auto inWall(generateVEPrivateVariable(1,type)); |
| 116 |
Index2PositionACL i2p(map->getBlock(), type); |
| 117 |
|
| 118 |
kk <<(inWall=rWall->getDistance(i2p.positionWithInit + |
| 119 |
num->getDisplacementData()->getEContainer())); |
| 120 |
kk << (counter = acl::generateVEConstant(0)); |
| 121 |
|
| 122 |
TemplateVE duTVE; |
| 123 |
duTVE.init(*pressureX, *templ, 0, false); |
| 124 |
kk << duTVE.initValues; |
| 125 |
kk << (val = acl::generateVEConstant(0)); |
| 126 |
for(unsigned int i(1); i < nDir; ++i) |
| 127 |
{ |
| 128 |
kk << (counter += select(acl::generateVEConstant(1.), isComputationNode(i), type)); |
| 129 |
kk << (val += select(duTVE.getValue(i), isComputationNode(i), type)); |
| 130 |
} |
| 131 |
kk << (counter = max(counter, acl::generateVEConstant(.1), type)); |
| 132 |
kk << (acl::assignmentSafe(num->getPressureData()->getEContainer(), |
| 133 |
select(num->getPressureData()->getEContainer(), |
| 134 |
val/counter, |
| 135 |
inWall > wallVal, |
| 136 |
type))); |
| 137 |
|
| 138 |
duTVE.init(*pressureLX, *templ, 0, false); |
| 139 |
kk << duTVE.initValues; |
| 140 |
kk << (val = acl::generateVEConstant(0)); |
| 141 |
for(unsigned int i(1); i < nDir; ++i) |
| 142 |
kk << (val += select(duTVE.getValue(i), isComputationNode(i), type)); |
| 143 |
kk << (acl::assignmentSafe(num->getLiquidPressureData()->getEContainer(), |
| 144 |
select(num->getLiquidPressureData()->getEContainer(), |
| 145 |
val/counter, |
| 146 |
inWall > wallVal, |
| 147 |
type))); |
| 148 |
/* |
| 149 |
for(unsigned int i(0); i < nd; ++i) |
| 150 |
{ |
| 151 |
duTVE.init(*dispX, *templ, i, false); |
| 152 |
kk << (val = acl::generateVEConstant(0)); |
| 153 |
kk << duTVE.initValues; |
| 154 |
for(unsigned int j(1); j < nDir; ++j) |
| 155 |
kk << (val += select(duTVE.getValue(j)+(.5*dx*templ->vectors[j][i]*(inWall-wallVal)), |
| 156 |
isComputationNode(j), type)); |
| 157 |
kk << (acl::assignmentSafe(subVE(num->getDisplacementData()->getEContainer(),i), |
| 158 |
select(subVE(num->getDisplacementData()->getEContainer(),i), |
| 159 |
val/counter, |
| 160 |
inWall > wallVal, |
| 161 |
type))); |
| 162 |
} |
| 163 |
*/ |
| 164 |
kernel->addExpression(acl::elementOperators:: |
| 165 |
ifElse(acl::elementOperators::any((isGhostNode() && |
| 166 |
map->getEContainer() > -.9999)[0]), |
| 167 |
kk.expression, |
| 168 |
{} )); |
| 169 |
kernel->setup(); |
| 170 |
} |
| 171 |
|
| 172 |
void BCRigidWallDF::execute() |
| 173 |
{ |
| 174 |
kernel->compute(); |
| 175 |
} |
| 176 |
|
| 177 |
void addBCRigidWall(std::vector<SPNumMethod> & bcList, |
| 178 |
SPFDPoroElasticity nm, |
| 179 |
const std::vector<SlicesNames> & sl) |
| 180 |
{ |
| 181 |
auto bc(make_shared<BCRigidWallPoroElasticity>(nm)); |
| 182 |
addSlices(*bc,sl); |
| 183 |
bcList.push_back(bc); |
| 184 |
} |
| 185 |
|
| 186 |
void addBCZeroStress(std::vector<SPNumMethod> & bcList, |
| 187 |
SPFDPoroElasticity nm, |
| 188 |
SPAbstractDataWithGhostNodes map) |
| 189 |
{ |
| 190 |
bcList.push_back(asl::generateBCZeroStress(nm, map)); |
| 191 |
bcList.push_back(generateBCConstantValueMiddlePoint(nm->getPressureData(), |
| 192 |
0, |
| 193 |
map, |
| 194 |
nm->vectorTemplate)); |
| 195 |
bcList.push_back(generateBCConstantValueMiddlePoint(nm->getLiquidPressureData(), |
| 196 |
0, |
| 197 |
map, |
| 198 |
nm->vectorTemplate)); |
| 199 |
} |
| 200 |
|
| 201 |
void addBCZeroStress(std::vector<SPNumMethod> & bcList, |
| 202 |
SPFDPoroElasticity nm, |
| 203 |
SPPositionFunction p, |
| 204 |
SPAbstractDataWithGhostNodes map) |
| 205 |
{ |
| 206 |
bcList.push_back(asl::generateBCZeroStress(nm, map)); |
| 207 |
bcList.push_back(generateBCConstantValue(nm->getPressureData(), 0, map)); |
| 208 |
bcList.push_back(generateBCConstantValue(nm->getLiquidPressureData(), p, map)); |
| 209 |
} |
| 210 |
|
| 211 |
void addBCRigidWallDF(std::vector<SPNumMethod> & bcList, |
| 212 |
SPFDPoroElasticity nm, |
| 213 |
SPDistanceFunction rw, |
| 214 |
SPAbstractDataWithGhostNodes map) |
| 215 |
{ |
| 216 |
auto bc(std::make_shared<BCRigidWallDF>(nm, rw, map)); |
| 217 |
bcList.push_back(bc); |
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
void addBCRigidWallDF(std::vector<SPNumMethod> & bcList, |
| 222 |
SPFDPoroElasticity nm, |
| 223 |
SPAbstractDataWithGhostNodes rw, |
| 224 |
SPAbstractDataWithGhostNodes map) |
| 225 |
{ |
| 226 |
auto rwX(generateDCFullSafe(rw,-1.)); |
| 227 |
auto rwXX(std::make_shared<DataInterpolation>(rwX)); |
| 228 |
addBCRigidWallDF(bcList, nm, rwXX, map); |
| 229 |
} |
| 230 |
} // asl |
| 231 |
|