25#ifndef ELASTICITY_LOCAL_RESIDUAL_TPSA_HPP
26#define ELASTICITY_LOCAL_RESIDUAL_TPSA_HPP
28#include <dune/common/fvector.hh>
30#include <opm/input/eclipse/Schedule/BCState.hpp>
32#include <opm/material/common/MathToolbox.hpp>
33#include <opm/material/materialstates/MaterialStateTPSA.hpp>
54 return ((i % 3) + 3) % 3;
80template <
class TypeTag>
88 using MaterialState = MaterialStateTPSA<Evaluation>;
89 using Toolbox = MathToolbox<Evaluation>;
91 enum { conti0EqIdx = Indices::conti0EqIdx };
92 enum { contiRotEqIdx = Indices::contiRotEqIdx };
93 enum { contiSolidPresEqIdx = Indices::contiSolidPresEqIdx };
94 enum { numEq = getPropValue<TypeTag, Properties::NumEqTPSA>() };
108 template <
class LhsEval>
110 const MaterialState& materialState,
111 const Problem& problem,
112 const unsigned globalIndex)
118 const Scalar sModulus = problem.shearModulus(globalIndex);
119 for (
unsigned dirIdx = 0; dirIdx < 3; ++dirIdx) {
120 volTerm[contiRotEqIdx + dirIdx] +=
121 Toolbox::template decay<LhsEval>(materialState.rotation(dirIdx))
126 const Scalar lame = problem.lame(globalIndex);
127 volTerm[contiSolidPresEqIdx] +=
128 Toolbox::template decay<LhsEval>(materialState.solidPressure())
146 const MaterialState& materialStateIn,
147 const MaterialState& materialStateEx,
149 const unsigned globalIndexIn,
150 const unsigned globalIndexEx)
156 const Scalar weightAvgIn = problem.weightAverage(globalIndexIn, globalIndexEx);
157 const Scalar weightAvgEx = problem.weightAverage(globalIndexEx, globalIndexIn);
158 const Scalar weightProd = problem.weightProduct(globalIndexIn, globalIndexEx);
159 const Scalar normDist = problem.normalDistance(globalIndexIn, globalIndexEx);
160 const auto& faceNormal = problem.cellFaceNormal(globalIndexIn, globalIndexEx);
163 const Scalar sModulusIn = problem.shearModulus(globalIndexIn);
164 const Scalar sModulusEx = problem.shearModulus(globalIndexEx);
165 const Scalar eff_sModulus = weightAvgIn * sModulusIn + weightAvgEx * sModulusEx;
168 const Scalar distRatio = 0.5 * weightProd / normDist;
171 const Evaluation& solidPIn = materialStateIn.solidPressure();
172 const Scalar solidPEx = decay<Scalar>(materialStateEx.solidPressure());
177 faceTerm[contiSolidPresEqIdx] +=
178 distRatio * eff_sModulus * (solidPIn - solidPEx);
184 for (
int dirIdx = 0; dirIdx < 3; ++dirIdx) {
190 const Scalar faceNormalDir = faceNormal[dirIdx];
191 const Scalar faceNormalNeg = faceNormal[dirIdxNeg];
192 const Scalar faceNormalPos = faceNormal[dirIdxPos];
194 const Evaluation& dispIn = materialStateIn.displacement(dirIdx);
195 const Scalar dispEx = decay<Scalar>(materialStateEx.displacement(dirIdx));
197 const Evaluation& rotInNeg = materialStateIn.rotation(dirIdxNeg);
198 const Evaluation& rotInPos = materialStateIn.rotation(dirIdxPos);
199 const Scalar rotExNeg = decay<Scalar>(materialStateEx.rotation(dirIdxNeg));
200 const Scalar rotExPos = decay<Scalar>(materialStateEx.rotation(dirIdxPos));
202 faceTerm[conti0EqIdx + dirIdx] +=
203 2.0 * (eff_sModulus / normDist) * (dispIn - dispEx)
204 - weightAvgIn * (faceNormalNeg * rotInPos - faceNormalPos * rotInNeg)
205 - weightAvgEx * (faceNormalNeg * rotExPos - faceNormalPos * rotExNeg)
206 - faceNormalDir * (weightAvgIn * solidPIn + weightAvgEx * solidPEx);
209 const Evaluation& dispInNeg = materialStateIn.displacement(dirIdxNeg);
210 const Evaluation& dispInPos = materialStateIn.displacement(dirIdxPos);
211 const Scalar dispExNeg = decay<Scalar>(materialStateEx.displacement(dirIdxNeg));
212 const Scalar dispExPos = decay<Scalar>(materialStateEx.displacement(dirIdxPos));
214 faceTerm[contiRotEqIdx + dirIdx] +=
215 - weightAvgEx * (faceNormalNeg * dispInPos - faceNormalPos * dispInNeg)
216 - weightAvgIn * (faceNormalNeg * dispExPos - faceNormalPos * dispExNeg);
219 faceTerm[contiSolidPresEqIdx] +=
220 - faceNormalDir * (weightAvgEx * dispIn + weightAvgIn * dispEx);
233 template <
class BoundaryConditionData>
235 const MaterialState& materialState,
238 unsigned globalIndex)
241 switch (bdyInfo.
type) {
250 case BCMECHType::FIXED:
251 throw std::runtime_error(
"BCTYPE FIXED has not been implemented in TPSA");
252 case BCMECHType::FREE:
259 case BCMECHType::SPRING:
267 throw std::logic_error(
"Unknown boundary condition type " +
269 " in computeBoundaryFlux()." );
285 template <
class BoundaryConditionData>
287 const MaterialState& materialState,
290 unsigned globalIndex)
301 const Scalar weightAvg = problem.weightAverageBoundary(globalIndex, bfIdx);
302 const Scalar normDist = problem.normalDistanceBoundary(globalIndex, bfIdx);
303 const auto& faceNormal = problem.cellFaceNormalBoundary(globalIndex, bfIdx);
306 const Scalar eff_sModulus = problem.shearModulus(globalIndex);
309 const Evaluation& solidP = materialState.solidPressure();
315 for (
int dirIdx = 0; dirIdx < 3; ++dirIdx) {
321 const Scalar faceNormalDir = faceNormal[dirIdx];
322 const Scalar faceNormalNeg = faceNormal[dirIdxNeg];
323 const Scalar faceNormalPos = faceNormal[dirIdxPos];
325 const Evaluation& disp = materialState.displacement(dirIdx);
327 const Evaluation& rotNeg = materialState.rotation(dirIdxNeg);
328 const Evaluation& rotPos = materialState.rotation(dirIdxPos);
330 bndryTerm[conti0EqIdx + dirIdx] +=
331 2.0 * (eff_sModulus / normDist) * disp
332 - weightAvg * (faceNormalNeg * rotPos - faceNormalPos * rotNeg)
333 - faceNormalDir * weightAvg * solidP;
349 template <
class BoundaryConditionData>
351 const MaterialState& materialState,
354 unsigned globalIndex)
361 const Scalar weightAvg = 1.0;
362 const Scalar normDist = problem.normalDistanceBoundary(globalIndex, bfIdx);
363 const auto& faceNormal = problem.cellFaceNormalBoundary(globalIndex, bfIdx);
365 const Scalar sModulus = problem.shearModulus(globalIndex);
370 const Evaluation& solidP = materialState.solidPressure();
371 bndryTerm[contiSolidPresEqIdx] +=
372 0.5 * (normDist / sModulus) * solidP;
378 Evaluation dotProd = 0;
379 for (
int dirIdx = 0; dirIdx < 3; ++dirIdx) {
380 dotProd += faceNormal[dirIdx] * materialState.rotation(dirIdx);
384 for (
int dirIdx = 0; dirIdx < 3; ++dirIdx) {
390 const Scalar faceNormalDir = faceNormal[dirIdx];
391 const Scalar faceNormalNeg = faceNormal[dirIdxNeg];
392 const Scalar faceNormalPos = faceNormal[dirIdxPos];
394 const Evaluation& dispNeg = materialState.displacement(dirIdxNeg);
395 const Evaluation& dispPos = materialState.displacement(dirIdxPos);
397 const Evaluation& rot = materialState.rotation(dirIdx);
399 bndryTerm[contiRotEqIdx + dirIdx] +=
400 - weightAvg * (faceNormalNeg * dispPos - faceNormalPos * dispNeg)
401 + 0.5 * (normDist / sModulus) * (dotProd * faceNormalDir - rot);
404 const Evaluation& disp = materialState.displacement(dirIdx);
406 bndryTerm[contiSolidPresEqIdx] +=
407 - faceNormalDir * weightAvg * disp;
423 template <
class BoundaryConditionData>
425 const MaterialState& materialState,
428 unsigned globalIndex)
435 const auto& faceNormal = problem.cellFaceNormalBoundary(globalIndex, bfIdx);
436 const Scalar distIn = problem.normalDistanceBoundary(globalIndex, bfIdx);
437 const Scalar distEx = bdyInfo.distance;
438 const Scalar sModulusIn = problem.shearModulus(globalIndex);
439 const Scalar sModulusEx = bdyInfo.shearModulus;
442 const Scalar weightIn = distIn / sModulusIn;
443 const Scalar weightEx = distEx / sModulusEx;
444 const Scalar weightAvgIn = weightIn / (weightIn + weightEx);
445 const Scalar weightAvgEx = 1.0 - weightAvgIn;
446 const Scalar weightProd = weightIn * weightEx;
447 const Scalar normDist = distIn + distEx;
450 const Scalar eff_sModulus = weightAvgIn * sModulusIn + weightAvgEx * sModulusEx;
453 const Scalar distRatio = 0.5 * weightProd / normDist;
456 const Evaluation& solidP = materialState.solidPressure();
457 bndryTerm[contiSolidPresEqIdx] +=
458 distRatio * eff_sModulus * solidP;
461 Evaluation dotProd = 0;
462 for (
int dirIdx = 0; dirIdx < 3; ++dirIdx) {
463 dotProd += faceNormal[dirIdx] * materialState.rotation(dirIdx);
467 for (
int dirIdx = 0; dirIdx < 3; ++dirIdx) {
473 const Scalar faceNormalDir = faceNormal[dirIdx];
474 const Scalar faceNormalNeg = faceNormal[dirIdxNeg];
475 const Scalar faceNormalPos = faceNormal[dirIdxPos];
477 const Evaluation& disp = materialState.displacement(dirIdx);
479 const Evaluation& rotNeg = materialState.rotation(dirIdxNeg);
480 const Evaluation& rotPos = materialState.rotation(dirIdxPos);
482 bndryTerm[conti0EqIdx + dirIdx] +=
483 2.0 * (eff_sModulus / normDist) * disp
484 - weightAvgIn * (faceNormalNeg * rotPos - faceNormalPos * rotNeg)
485 - faceNormalDir * weightAvgIn * solidP;
488 const Evaluation& dispNeg = materialState.displacement(dirIdxNeg);
489 const Evaluation& dispPos = materialState.displacement(dirIdxPos);
491 const Evaluation& rot = materialState.rotation(dirIdx);
493 bndryTerm[contiRotEqIdx + dirIdx] +=
494 - weightAvgEx * (faceNormalNeg * dispPos - faceNormalPos * dispNeg)
495 + distRatio * eff_sModulus * (dotProd * faceNormalDir - rot);
498 bndryTerm[contiSolidPresEqIdx] +=
499 - faceNormalDir * weightAvgEx * disp;
513 unsigned globalSpaceIdex,
521 problem.tpsaSource(sourceTerm, globalSpaceIdex, timeIdx);
Defines a type tags and some fundamental properties all models.
Calculation of (linear) elasticity model terms for the residual.
Definition: elasticitylocalresidualtpsa.hpp:82
static void computeFaceTerm(Dune::FieldVector< Evaluation, numEq > &faceTerm, const MaterialState &materialStateIn, const MaterialState &materialStateEx, Problem &problem, const unsigned globalIndexIn, const unsigned globalIndexEx)
Calculate terms across cell faces in TPSA formulation.
Definition: elasticitylocalresidualtpsa.hpp:145
static void computeBoundaryTermFixed(Dune::FieldVector< Evaluation, numEq > &bndryTerm, const MaterialState &materialState, const BoundaryConditionData &bdyInfo, Problem &problem, unsigned globalIndex)
Calculate fixed displacement boundary condition in TPSA formulation.
Definition: elasticitylocalresidualtpsa.hpp:286
static void computeBoundaryTermFree(Dune::FieldVector< Evaluation, numEq > &bndryTerm, const MaterialState &materialState, const BoundaryConditionData &bdyInfo, Problem &problem, unsigned globalIndex)
Calculate free (or zero traction) boundary condition in TPSA formulation.
Definition: elasticitylocalresidualtpsa.hpp:350
static void computeVolumeTerm(Dune::FieldVector< LhsEval, numEq > &volTerm, const MaterialState &materialState, const Problem &problem, const unsigned globalIndex)
Calculate volume terms in TPSA formulation.
Definition: elasticitylocalresidualtpsa.hpp:109
static void computeSourceTerm(Dune::FieldVector< Evaluation, numEq > &sourceTerm, Problem &problem, unsigned globalSpaceIdex, unsigned timeIdx)
Calculate source term in TPSA formulation.
Definition: elasticitylocalresidualtpsa.hpp:511
static void computeBoundaryTermSpring(Dune::FieldVector< Evaluation, numEq > &bndryTerm, const MaterialState &materialState, const BoundaryConditionData &bdyInfo, Problem &problem, unsigned globalIndex)
Calculate spring boundary condition in TPSA formulation.
Definition: elasticitylocalresidualtpsa.hpp:424
static void computeBoundaryTerm(Dune::FieldVector< Evaluation, numEq > &bndryTerm, const MaterialState &materialState, const BoundaryConditionData &bdyInfo, Problem &problem, unsigned globalIndex)
Calculate boundary conditions in TPSA formulation given by BCCON/BCMECH.
Definition: elasticitylocalresidualtpsa.hpp:234
Declare the properties used by the infrastructure code of the finite volume discretizations.
@ NONE
Definition: DeferredLogger.hpp:46
int modNeg(int i)
Computes modulo 3 of possibly negative integers to get indices in cross product.
Definition: elasticitylocalresidualtpsa.hpp:52
Definition: blackoilbioeffectsmodules.hh:45
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:233
std::string to_string(const ConvergenceReport::ReservoirFailure::Type t)
Definition: tpfalinearizerstructs.hh:89
BCType type
Definition: tpfalinearizerstructs.hh:90
unsigned boundaryFaceIndex
Definition: tpfalinearizerstructs.hh:93