mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
add diffusivity to eclTranmissibility
This commit is contained in:
parent
3457d46a00
commit
1abbd9c776
@ -622,6 +622,7 @@ class EclProblem : public GetPropType<TypeTag, Properties::BaseProblem>
|
|||||||
enum { enableExtbo = getPropValue<TypeTag, Properties::EnableExtbo>() };
|
enum { enableExtbo = getPropValue<TypeTag, Properties::EnableExtbo>() };
|
||||||
enum { enableTemperature = getPropValue<TypeTag, Properties::EnableTemperature>() };
|
enum { enableTemperature = getPropValue<TypeTag, Properties::EnableTemperature>() };
|
||||||
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
|
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
|
||||||
|
enum { enableDiffusion = getPropValue<TypeTag, Properties::EnableDiffusion>() };
|
||||||
enum { enableThermalFluxBoundaries = getPropValue<TypeTag, Properties::EnableThermalFluxBoundaries>() };
|
enum { enableThermalFluxBoundaries = getPropValue<TypeTag, Properties::EnableThermalFluxBoundaries>() };
|
||||||
enum { enableApiTracking = getPropValue<TypeTag, Properties::EnableApiTracking>() };
|
enum { enableApiTracking = getPropValue<TypeTag, Properties::EnableApiTracking>() };
|
||||||
enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
|
enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
|
||||||
@ -1372,6 +1373,18 @@ public:
|
|||||||
return pffDofData_.get(context.element(), toDofLocalIdx).transmissibility;
|
return pffDofData_.get(context.element(), toDofLocalIdx).transmissibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \copydoc EclTransmissiblity::diffusivity
|
||||||
|
*/
|
||||||
|
template <class Context>
|
||||||
|
Scalar diffusivity(const Context& context,
|
||||||
|
unsigned OPM_OPTIM_UNUSED fromDofLocalIdx,
|
||||||
|
unsigned toDofLocalIdx) const
|
||||||
|
{
|
||||||
|
assert(fromDofLocalIdx == 0);
|
||||||
|
return *pffDofData_.get(context.element(), toDofLocalIdx).diffusivity;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \copydoc EclTransmissiblity::transmissibilityBoundary
|
* \copydoc EclTransmissiblity::transmissibilityBoundary
|
||||||
*/
|
*/
|
||||||
@ -3072,6 +3085,8 @@ private:
|
|||||||
struct PffDofData_
|
struct PffDofData_
|
||||||
{
|
{
|
||||||
Opm::ConditionalStorage<enableEnergy, Scalar> thermalHalfTrans;
|
Opm::ConditionalStorage<enableEnergy, Scalar> thermalHalfTrans;
|
||||||
|
Opm::ConditionalStorage<enableDiffusion, Scalar> diffusivity;
|
||||||
|
//Scalar diffusivity;
|
||||||
Scalar transmissibility;
|
Scalar transmissibility;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3093,6 +3108,8 @@ private:
|
|||||||
|
|
||||||
if (enableEnergy)
|
if (enableEnergy)
|
||||||
*dofData.thermalHalfTrans = transmissibilities_.thermalHalfTrans(globalCenterElemIdx, globalElemIdx);
|
*dofData.thermalHalfTrans = transmissibilities_.thermalHalfTrans(globalCenterElemIdx, globalElemIdx);
|
||||||
|
if (enableDiffusion)
|
||||||
|
*dofData.diffusivity = transmissibilities_.diffusivity(globalCenterElemIdx, globalElemIdx);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ class EclTransmissibility
|
|||||||
using Intersection = typename GridView::Intersection;
|
using Intersection = typename GridView::Intersection;
|
||||||
|
|
||||||
static const bool enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>();
|
static const bool enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>();
|
||||||
|
static const bool enableDiffusion = getPropValue<TypeTag, Properties::EnableDiffusion>();
|
||||||
|
|
||||||
// Grid and world dimension
|
// Grid and world dimension
|
||||||
enum { dimWorld = GridView::dimensionworld };
|
enum { dimWorld = GridView::dimensionworld };
|
||||||
@ -181,6 +182,13 @@ public:
|
|||||||
thermalHalfTransBoundary_.clear();
|
thermalHalfTransBoundary_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if diffusion is enabled, let's do the same for the "diffusivity"
|
||||||
|
if (enableDiffusion) {
|
||||||
|
diffusivity_->clear();
|
||||||
|
diffusivity_->reserve(numElements*3*1.05);
|
||||||
|
extractPorosity_();
|
||||||
|
}
|
||||||
|
|
||||||
// The MULTZ needs special case if the option is ALL
|
// The MULTZ needs special case if the option is ALL
|
||||||
// Then the smallest multiplier is applied.
|
// Then the smallest multiplier is applied.
|
||||||
// Default is to apply the top and bottom multiplier
|
// Default is to apply the top and bottom multiplier
|
||||||
@ -386,6 +394,42 @@ public:
|
|||||||
faceDir);
|
faceDir);
|
||||||
|
|
||||||
trans_[isId_(elemIdx, outsideElemIdx)] = trans;
|
trans_[isId_(elemIdx, outsideElemIdx)] = trans;
|
||||||
|
|
||||||
|
// update the "thermal half transmissibility" for the intersection
|
||||||
|
if (enableDiffusion) {
|
||||||
|
|
||||||
|
Scalar halfDiffusivity1;
|
||||||
|
Scalar halfDiffusivity2;
|
||||||
|
|
||||||
|
computeHalfDiffusivity_(halfDiffusivity1,
|
||||||
|
faceAreaNormal,
|
||||||
|
distanceVector_(faceCenterInside,
|
||||||
|
intersection.indexInInside(),
|
||||||
|
elemIdx,
|
||||||
|
axisCentroids),
|
||||||
|
porosity_[elemIdx]);
|
||||||
|
computeHalfDiffusivity_(halfDiffusivity2,
|
||||||
|
faceAreaNormal,
|
||||||
|
distanceVector_(faceCenterOutside,
|
||||||
|
intersection.indexInOutside(),
|
||||||
|
outsideElemIdx,
|
||||||
|
axisCentroids),
|
||||||
|
porosity_[outsideElemIdx]);
|
||||||
|
|
||||||
|
applyNtg_(halfDiffusivity1, insideFaceIdx, elemIdx, ntg);
|
||||||
|
applyNtg_(halfDiffusivity2, outsideFaceIdx, outsideElemIdx, ntg);
|
||||||
|
|
||||||
|
//TODO Add support for multipliers
|
||||||
|
Scalar diffusivity;
|
||||||
|
if (std::abs(halfDiffusivity1) < 1e-30 || std::abs(halfDiffusivity2) < 1e-30)
|
||||||
|
// avoid division by zero
|
||||||
|
diffusivity = 0.0;
|
||||||
|
else
|
||||||
|
diffusivity = 1.0 / (1.0/halfDiffusivity1 + 1.0/halfDiffusivity2);
|
||||||
|
|
||||||
|
|
||||||
|
(*diffusivity_)[isId_(elemIdx, outsideElemIdx)] = diffusivity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,6 +494,12 @@ public:
|
|||||||
Scalar thermalHalfTransBoundary(unsigned insideElemIdx, unsigned boundaryFaceIdx) const
|
Scalar thermalHalfTransBoundary(unsigned insideElemIdx, unsigned boundaryFaceIdx) const
|
||||||
{ return thermalHalfTransBoundary_.at(std::make_pair(insideElemIdx, boundaryFaceIdx)); }
|
{ return thermalHalfTransBoundary_.at(std::make_pair(insideElemIdx, boundaryFaceIdx)); }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Return the diffusivity for the intersection between two elements.
|
||||||
|
*/
|
||||||
|
Scalar diffusivity(unsigned elemIdx1, unsigned elemIdx2) const
|
||||||
|
{ return diffusivity_->at(isId_(elemIdx1, elemIdx2)); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void removeSmallNonCartesianTransmissibilities_()
|
void removeSmallNonCartesianTransmissibilities_()
|
||||||
@ -881,6 +931,21 @@ private:
|
|||||||
"(The PERM{X,Y,Z} keywords are missing)");
|
"(The PERM{X,Y,Z} keywords are missing)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void extractPorosity_()
|
||||||
|
{
|
||||||
|
// read the intrinsic porosity from the eclState. Note that all arrays
|
||||||
|
// provided by eclState are one-per-cell of "uncompressed" grid, whereas the
|
||||||
|
// simulation grid might remove a few elements. (e.g. because it is distributed
|
||||||
|
// over several processes.)
|
||||||
|
const auto& fp = vanguard_.eclState().fieldProps();
|
||||||
|
if (fp.has_double("PORO")) {
|
||||||
|
porosity_ = fp.get_double("PORO");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw std::logic_error("Can't read the porosityfrom the ecl state. "
|
||||||
|
"(The PORO keywords are missing)");
|
||||||
|
}
|
||||||
|
|
||||||
std::uint64_t isId_(std::uint32_t elemIdx1, std::uint32_t elemIdx2) const
|
std::uint64_t isId_(std::uint32_t elemIdx1, std::uint32_t elemIdx2) const
|
||||||
{
|
{
|
||||||
std::uint32_t elemAIdx = std::min(elemIdx1, elemIdx2);
|
std::uint32_t elemAIdx = std::min(elemIdx1, elemIdx2);
|
||||||
@ -924,6 +989,20 @@ private:
|
|||||||
halfTrans /= distance.two_norm2();
|
halfTrans /= distance.two_norm2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void computeHalfDiffusivity_(Scalar& halfDiff,
|
||||||
|
const DimVector& areaNormal,
|
||||||
|
const DimVector& distance,
|
||||||
|
const Scalar& poro) const
|
||||||
|
{
|
||||||
|
halfDiff = poro;
|
||||||
|
Scalar val = 0;
|
||||||
|
for (unsigned i = 0; i < areaNormal.size(); ++i)
|
||||||
|
val += areaNormal[i]*distance[i];
|
||||||
|
|
||||||
|
halfDiff *= std::abs(val);
|
||||||
|
halfDiff /= distance.two_norm2();
|
||||||
|
}
|
||||||
|
|
||||||
DimVector distanceVector_(const DimVector& center,
|
DimVector distanceVector_(const DimVector& center,
|
||||||
int faceIdx, // in the reference element that contains the intersection
|
int faceIdx, // in the reference element that contains the intersection
|
||||||
unsigned elemIdx,
|
unsigned elemIdx,
|
||||||
@ -1000,11 +1079,14 @@ private:
|
|||||||
const Vanguard& vanguard_;
|
const Vanguard& vanguard_;
|
||||||
Scalar transmissibilityThreshold_;
|
Scalar transmissibilityThreshold_;
|
||||||
std::vector<DimMatrix> permeability_;
|
std::vector<DimMatrix> permeability_;
|
||||||
|
std::vector<Scalar> porosity_;
|
||||||
std::unordered_map<std::uint64_t, Scalar> trans_;
|
std::unordered_map<std::uint64_t, Scalar> trans_;
|
||||||
std::map<std::pair<unsigned, unsigned>, Scalar> transBoundary_;
|
std::map<std::pair<unsigned, unsigned>, Scalar> transBoundary_;
|
||||||
std::map<std::pair<unsigned, unsigned>, Scalar> thermalHalfTransBoundary_;
|
std::map<std::pair<unsigned, unsigned>, Scalar> thermalHalfTransBoundary_;
|
||||||
Opm::ConditionalStorage<enableEnergy,
|
Opm::ConditionalStorage<enableEnergy,
|
||||||
std::unordered_map<std::uint64_t, Scalar> > thermalHalfTrans_;
|
std::unordered_map<std::uint64_t, Scalar> > thermalHalfTrans_;
|
||||||
|
Opm::ConditionalStorage<enableDiffusion,
|
||||||
|
std::unordered_map<std::uint64_t, Scalar> > diffusivity_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
Loading…
Reference in New Issue
Block a user