mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #5908 from akva2/janitoring_sca_various
Janitoring: address various static analyzer issues
This commit is contained in:
commit
06904dc93f
@ -571,7 +571,7 @@ private:
|
|||||||
const auto& matParams = this->materialLawParams(context, spaceIdx, timeIdx);
|
const auto& matParams = this->materialLawParams(context, spaceIdx, timeIdx);
|
||||||
MaterialLaw::capillaryPressures(pC, matParams, fs);
|
MaterialLaw::capillaryPressures(pC, matParams, fs);
|
||||||
|
|
||||||
fs.setPressure(liquidPhaseIdx, pl + (pC[liquidPhaseIdx] - pC[liquidPhaseIdx]));
|
fs.setPressure(liquidPhaseIdx, pl);
|
||||||
fs.setPressure(gasPhaseIdx, pl + (pC[gasPhaseIdx] - pC[liquidPhaseIdx]));
|
fs.setPressure(gasPhaseIdx, pl + (pC[gasPhaseIdx] - pC[liquidPhaseIdx]));
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -194,14 +194,17 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Adding dispersion in the gas phase leads to
|
// Adding dispersion in the gas phase leads to
|
||||||
// convergence issues and unphysical results.
|
// convergence issues and unphysical results.
|
||||||
// We disable dispersion in the gas phase for now
|
// We disable dispersion in the gas phase for now
|
||||||
|
// See comment below
|
||||||
if (FluidSystem::gasPhaseIdx == phaseIdx) {
|
if (FluidSystem::gasPhaseIdx == phaseIdx) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no dispersion in gas for blackoil models unless gas can contain evaporated water or oil
|
// no dispersion in gas for blackoil models unless gas can contain evaporated water or oil
|
||||||
if ((!FluidSystem::enableVaporizedWater() && !FluidSystem::enableVaporizedOil()) && FluidSystem::gasPhaseIdx == phaseIdx) {
|
// phase check disabled due to if above, reenable when removing unconditional gas phase disablement
|
||||||
|
if ((!FluidSystem::enableVaporizedWater() && !FluidSystem::enableVaporizedOil())
|
||||||
|
/*&& FluidSystem::gasPhaseIdx == phaseIdx*/) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,8 +167,8 @@ public:
|
|||||||
{ return 1.0 - upstreamWeight(phaseIdx); }
|
{ return 1.0 - upstreamWeight(phaseIdx); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
short upstreamScvIdx_[numPhases];
|
short upstreamScvIdx_[numPhases]{};
|
||||||
short downstreamScvIdx_[numPhases];
|
short downstreamScvIdx_[numPhases]{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -500,10 +500,10 @@ private:
|
|||||||
Evaluation pressureDifference_[numPhases];
|
Evaluation pressureDifference_[numPhases];
|
||||||
|
|
||||||
// the local indices of the interior and exterior degrees of freedom
|
// the local indices of the interior and exterior degrees of freedom
|
||||||
unsigned short interiorDofIdx_;
|
unsigned short interiorDofIdx_{};
|
||||||
unsigned short exteriorDofIdx_;
|
unsigned short exteriorDofIdx_{};
|
||||||
short upIdx_[numPhases];
|
short upIdx_[numPhases]{};
|
||||||
short dnIdx_[numPhases];
|
short dnIdx_[numPhases]{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -122,7 +122,7 @@ public:
|
|||||||
{};
|
{};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int dofOffset_;
|
int dofOffset_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -124,10 +124,10 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// local indices of the interior and the exterior sub-control-volumes
|
// local indices of the interior and the exterior sub-control-volumes
|
||||||
unsigned short interiorScvIdx_;
|
unsigned short interiorScvIdx_{};
|
||||||
unsigned short exteriorScvIdx_;
|
unsigned short exteriorScvIdx_{};
|
||||||
|
|
||||||
Scalar extrusionFactor_;
|
Scalar extrusionFactor_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -341,9 +341,9 @@ private:
|
|||||||
#if HAVE_DUNE_LOCALFUNCTIONS
|
#if HAVE_DUNE_LOCALFUNCTIONS
|
||||||
static LocalFiniteElementCache feCache_;
|
static LocalFiniteElementCache feCache_;
|
||||||
|
|
||||||
const LocalFiniteElement* localFiniteElement_;
|
const LocalFiniteElement* localFiniteElement_{nullptr};
|
||||||
std::vector<Dune::FieldVector<Scalar, 1>> p1Value_[maxFap];
|
std::vector<Dune::FieldVector<Scalar, 1>> p1Value_[maxFap]{};
|
||||||
DimVector p1Gradient_[maxFap][maxDof];
|
DimVector p1Gradient_[maxFap][maxDof]{};
|
||||||
#endif // HAVE_DUNE_LOCALFUNCTIONS
|
#endif // HAVE_DUNE_LOCALFUNCTIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -839,7 +839,12 @@ public:
|
|||||||
|
|
||||||
numVertices = e.subEntities(/*codim=*/dim);
|
numVertices = e.subEntities(/*codim=*/dim);
|
||||||
numEdges = e.subEntities(/*codim=*/dim-1);
|
numEdges = e.subEntities(/*codim=*/dim-1);
|
||||||
numFaces = (dim<3)?0:e.subEntities(/*codim=*/1);
|
if constexpr (dim == 3) {
|
||||||
|
numFaces = e.subEntities(/*codim=*/1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
numFaces = 0;
|
||||||
|
}
|
||||||
|
|
||||||
numBoundarySegments_ = 0; // TODO: really required here(?)
|
numBoundarySegments_ = 0; // TODO: really required here(?)
|
||||||
|
|
||||||
@ -913,13 +918,13 @@ public:
|
|||||||
// cases which don't apply.
|
// cases which don't apply.
|
||||||
LocalPosition ipLocal_;
|
LocalPosition ipLocal_;
|
||||||
DimVector diffVec;
|
DimVector diffVec;
|
||||||
if (dim==1) {
|
if constexpr (dim == 1) {
|
||||||
subContVolFace[k].ipLocal_ = 0.5;
|
subContVolFace[k].ipLocal_ = 0.5;
|
||||||
subContVolFace[k].normal_ = 1.0;
|
subContVolFace[k].normal_ = 1.0;
|
||||||
subContVolFace[k].area_ = 1.0;
|
subContVolFace[k].area_ = 1.0;
|
||||||
ipLocal_ = subContVolFace[k].ipLocal_;
|
ipLocal_ = subContVolFace[k].ipLocal_;
|
||||||
}
|
}
|
||||||
else if (dim==2) {
|
else if constexpr (dim == 2) {
|
||||||
ipLocal_ = referenceElement.position(static_cast<int>(k), dim-1) + elementLocal;
|
ipLocal_ = referenceElement.position(static_cast<int>(k), dim-1) + elementLocal;
|
||||||
ipLocal_ *= 0.5;
|
ipLocal_ *= 0.5;
|
||||||
subContVolFace[k].ipLocal_ = ipLocal_;
|
subContVolFace[k].ipLocal_ = ipLocal_;
|
||||||
@ -937,7 +942,7 @@ public:
|
|||||||
subContVolFace[k].area_ = subContVolFace[k].normal_.two_norm();
|
subContVolFace[k].area_ = subContVolFace[k].normal_.two_norm();
|
||||||
subContVolFace[k].normal_ /= subContVolFace[k].area_;
|
subContVolFace[k].normal_ /= subContVolFace[k].area_;
|
||||||
}
|
}
|
||||||
else if (dim==3) {
|
else if constexpr (dim == 3) {
|
||||||
unsigned leftFace;
|
unsigned leftFace;
|
||||||
unsigned rightFace;
|
unsigned rightFace;
|
||||||
getFaceIndices(numVertices, k, leftFace, rightFace);
|
getFaceIndices(numVertices, k, leftFace, rightFace);
|
||||||
@ -973,17 +978,17 @@ public:
|
|||||||
unsigned bfIdx = numBoundarySegments_;
|
unsigned bfIdx = numBoundarySegments_;
|
||||||
++numBoundarySegments_;
|
++numBoundarySegments_;
|
||||||
|
|
||||||
if (dim == 1) {
|
if constexpr (dim == 1) {
|
||||||
boundaryFace_[bfIdx].ipLocal_ = referenceElement.position(static_cast<int>(vertInElement), dim);
|
boundaryFace_[bfIdx].ipLocal_ = referenceElement.position(static_cast<int>(vertInElement), dim);
|
||||||
boundaryFace_[bfIdx].area_ = 1.0;
|
boundaryFace_[bfIdx].area_ = 1.0;
|
||||||
}
|
}
|
||||||
else if (dim == 2) {
|
else if constexpr (dim == 2) {
|
||||||
boundaryFace_[bfIdx].ipLocal_ = referenceElement.position(static_cast<int>(vertInElement), dim)
|
boundaryFace_[bfIdx].ipLocal_ = referenceElement.position(static_cast<int>(vertInElement), dim)
|
||||||
+ referenceElement.position(static_cast<int>(face), 1);
|
+ referenceElement.position(static_cast<int>(face), 1);
|
||||||
boundaryFace_[bfIdx].ipLocal_ *= 0.5;
|
boundaryFace_[bfIdx].ipLocal_ *= 0.5;
|
||||||
boundaryFace_[bfIdx].area_ = 0.5 * intersection.geometry().volume();
|
boundaryFace_[bfIdx].area_ = 0.5 * intersection.geometry().volume();
|
||||||
}
|
}
|
||||||
else if (dim == 3) {
|
else if constexpr (dim == 3) {
|
||||||
unsigned leftEdge;
|
unsigned leftEdge;
|
||||||
unsigned rightEdge;
|
unsigned rightEdge;
|
||||||
getEdgeIndices(numVertices, face, vertInElement, leftEdge, rightEdge);
|
getEdgeIndices(numVertices, face, vertInElement, leftEdge, rightEdge);
|
||||||
@ -1113,12 +1118,12 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
void fillSubContVolData_()
|
void fillSubContVolData_()
|
||||||
{
|
{
|
||||||
if (dim == 1) {
|
if constexpr (dim == 1) {
|
||||||
// 1D
|
// 1D
|
||||||
subContVol[0].volume_ = 0.5*elementVolume;
|
subContVol[0].volume_ = 0.5*elementVolume;
|
||||||
subContVol[1].volume_ = 0.5*elementVolume;
|
subContVol[1].volume_ = 0.5*elementVolume;
|
||||||
}
|
}
|
||||||
else if (dim == 2) {
|
else if constexpr (dim == 2) {
|
||||||
switch (numVertices) {
|
switch (numVertices) {
|
||||||
case 3: // 2D, triangle
|
case 3: // 2D, triangle
|
||||||
subContVol[0].volume_ = elementVolume/3;
|
subContVol[0].volume_ = elementVolume/3;
|
||||||
@ -1152,7 +1157,7 @@ private:
|
|||||||
+", numVertices = "+std::to_string(numVertices));
|
+", numVertices = "+std::to_string(numVertices));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dim == 3) {
|
else if constexpr (dim == 3) {
|
||||||
switch (numVertices) {
|
switch (numVertices) {
|
||||||
case 4: // 3D, tetrahedron
|
case 4: // 3D, tetrahedron
|
||||||
for (unsigned k = 0; k < numVertices; k++)
|
for (unsigned k = 0; k < numVertices; k++)
|
||||||
|
@ -231,17 +231,11 @@ public:
|
|||||||
fluidState_.setCompressFactor(1, Z_V);
|
fluidState_.setCompressFactor(1, Z_V);
|
||||||
|
|
||||||
// Print saturation
|
// Print saturation
|
||||||
if (flashVerbosity >= 5) {
|
if (flashVerbosity >= 5) {
|
||||||
std::cout << "So = " << So <<std::endl;
|
std::cout << "So = " << So << std::endl;
|
||||||
std::cout << "Sg = " << Sg <<std::endl;
|
std::cout << "Sg = " << Sg << std::endl;
|
||||||
}
|
std::cout << "Z_L = " << Z_L << std::endl;
|
||||||
|
std::cout << "Z_V = " << Z_V << std::endl;
|
||||||
// Print saturation
|
|
||||||
if (flashVerbosity >= 5) {
|
|
||||||
std::cout << "So = " << So <<std::endl;
|
|
||||||
std::cout << "Sg = " << Sg <<std::endl;
|
|
||||||
std::cout << "Z_L = " << Z_L <<std::endl;
|
|
||||||
std::cout << "Z_V = " << Z_V <<std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
|
@ -581,13 +581,13 @@ public:
|
|||||||
using FsToolbox = Opm::MathToolbox<typename FluidState::Scalar>;
|
using FsToolbox = Opm::MathToolbox<typename FluidState::Scalar>;
|
||||||
|
|
||||||
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
|
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
|
||||||
bool oldPhasePresent = (oldPhasePresence& (1 << phaseIdx)) > 0;
|
bool oldPhasePresent = (oldPhasePresence & (1 << phaseIdx)) > 0;
|
||||||
bool newPhasePresent = newPv.phaseIsPresent(phaseIdx);
|
bool newPhasePresent = newPv.phaseIsPresent(phaseIdx);
|
||||||
if (oldPhasePresent == newPhasePresent)
|
if (oldPhasePresent == newPhasePresent)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const auto& pos = elemCtx.pos(dofIdx, /*timeIdx=*/0);
|
const auto& pos = elemCtx.pos(dofIdx, /*timeIdx=*/0);
|
||||||
if (oldPhasePresent && !newPhasePresent) {
|
if (oldPhasePresent) {
|
||||||
std::cout << "'" << FluidSystem::phaseName(phaseIdx)
|
std::cout << "'" << FluidSystem::phaseName(phaseIdx)
|
||||||
<< "' phase disappears at position " << pos
|
<< "' phase disappears at position " << pos
|
||||||
<< ". saturation=" << fs.saturation(phaseIdx)
|
<< ". saturation=" << fs.saturation(phaseIdx)
|
||||||
|
@ -1098,7 +1098,7 @@ localIdxToGlobalIdx(unsigned localIdx) const
|
|||||||
throw std::logic_error("index map is not created on this rank");
|
throw std::logic_error("index map is not created on this rank");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localIdx > this->localIdxToGlobalIdx_.size()) {
|
if (localIdx >= this->localIdxToGlobalIdx_.size()) {
|
||||||
throw std::logic_error("local index is outside map range");
|
throw std::logic_error("local index is outside map range");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ public:
|
|||||||
if (this->sub_step_report_.max_linear_iterations != 0) {
|
if (this->sub_step_report_.max_linear_iterations != 0) {
|
||||||
miscSummaryData["NLINSMAX"] = this->sub_step_report_.max_linear_iterations;
|
miscSummaryData["NLINSMAX"] = this->sub_step_report_.max_linear_iterations;
|
||||||
}
|
}
|
||||||
if (this->simulation_report_.success.total_newton_iterations != 0) {
|
if (this->simulation_report_.success.total_linear_iterations != 0) {
|
||||||
miscSummaryData["MSUMLINS"] = this->simulation_report_.success.total_linear_iterations;
|
miscSummaryData["MSUMLINS"] = this->simulation_report_.success.total_linear_iterations;
|
||||||
}
|
}
|
||||||
if (this->simulation_report_.success.total_newton_iterations != 0) {
|
if (this->simulation_report_.success.total_newton_iterations != 0) {
|
||||||
|
@ -337,9 +337,6 @@ public:
|
|||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
timer.report(ss);
|
timer.report(ss);
|
||||||
OpmLog::debug(ss.str());
|
OpmLog::debug(ss.str());
|
||||||
}
|
|
||||||
|
|
||||||
if (terminalOutput_) {
|
|
||||||
details::outputReportStep(timer);
|
details::outputReportStep(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,10 +61,10 @@ namespace details {
|
|||||||
|
|
||||||
std::uint64_t isId(std::uint32_t elemIdx1, std::uint32_t elemIdx2)
|
std::uint64_t isId(std::uint32_t elemIdx1, std::uint32_t elemIdx2)
|
||||||
{
|
{
|
||||||
std::uint32_t elemAIdx = std::min(elemIdx1, elemIdx2);
|
const std::uint32_t elemAIdx = std::min(elemIdx1, elemIdx2);
|
||||||
std::uint64_t elemBIdx = std::max(elemIdx1, elemIdx2);
|
const std::uint64_t elemBIdx = std::max(elemIdx1, elemIdx2);
|
||||||
|
|
||||||
return (elemBIdx<<elemIdxShift) + elemAIdx;
|
return (elemBIdx << elemIdxShift) + elemAIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::uint32_t, std::uint32_t> isIdReverse(const std::uint64_t& id)
|
std::pair<std::uint32_t, std::uint32_t> isIdReverse(const std::uint64_t& id)
|
||||||
@ -72,15 +72,15 @@ namespace details {
|
|||||||
// Assigning an unsigned integer to a narrower type discards the most significant bits.
|
// Assigning an unsigned integer to a narrower type discards the most significant bits.
|
||||||
// See "The C programming language", section A.6.2.
|
// See "The C programming language", section A.6.2.
|
||||||
// NOTE that the ordering of element A and B may have changed
|
// NOTE that the ordering of element A and B may have changed
|
||||||
std::uint32_t elemAIdx = id;
|
const std::uint32_t elemAIdx = static_cast<uint32_t>(id);
|
||||||
std::uint32_t elemBIdx = (id - elemAIdx) >> elemIdxShift;
|
const std::uint32_t elemBIdx = (id - elemAIdx) >> elemIdxShift;
|
||||||
|
|
||||||
return std::make_pair(elemAIdx, elemBIdx);
|
return std::make_pair(elemAIdx, elemBIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t directionalIsId(std::uint32_t elemIdx1, std::uint32_t elemIdx2)
|
std::uint64_t directionalIsId(std::uint32_t elemIdx1, std::uint32_t elemIdx2)
|
||||||
{
|
{
|
||||||
return (std::uint64_t(elemIdx1)<<elemIdxShift) + elemIdx2;
|
return (std::uint64_t(elemIdx1) << elemIdxShift) + elemIdx2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
HYPRE_IJMatrixAssemble(A_hypre_);
|
HYPRE_IJMatrixAssemble(A_hypre_);
|
||||||
HYPRE_IJMatrixGetObject(A_hypre_, (void**)&parcsr_A_);
|
HYPRE_IJMatrixGetObject(A_hypre_, reinterpret_cast<void**>(&parcsr_A_));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -350,8 +350,8 @@ private:
|
|||||||
|
|
||||||
HYPRE_IJVectorAssemble(x_hypre_);
|
HYPRE_IJVectorAssemble(x_hypre_);
|
||||||
HYPRE_IJVectorAssemble(b_hypre_);
|
HYPRE_IJVectorAssemble(b_hypre_);
|
||||||
HYPRE_IJVectorGetObject(x_hypre_, (void**)&par_x_);
|
HYPRE_IJVectorGetObject(x_hypre_, reinterpret_cast<void**>(&par_x_));
|
||||||
HYPRE_IJVectorGetObject(b_hypre_, (void**)&par_b_);
|
HYPRE_IJVectorGetObject(b_hypre_, reinterpret_cast<void**>(&par_b_));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -978,7 +978,7 @@ void ChowPatelIlu<block_size>::gpu_decomposition(
|
|||||||
OPM_THROW(std::logic_error, oss.str());
|
OPM_THROW(std::logic_error, oss.str());
|
||||||
} catch (const std::logic_error& error) {
|
} catch (const std::logic_error& error) {
|
||||||
// rethrow exception by OPM_THROW in the try{}
|
// rethrow exception by OPM_THROW in the try{}
|
||||||
throw error;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,16 +341,16 @@ create_preconditioner(BlockedMatrix<Scalar>* mat)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Scalar, unsigned int block_size>
|
template<class Scalar, unsigned int block_size>
|
||||||
void openclBISAI<Scalar,block_size>::apply(const cl::Buffer& x, cl::Buffer& y)
|
void openclBISAI<Scalar,block_size>::apply(const cl::Buffer& y, cl::Buffer& x)
|
||||||
{
|
{
|
||||||
const unsigned int bs = block_size;
|
const unsigned int bs = block_size;
|
||||||
|
|
||||||
OpenclKernels<Scalar>::spmv(d_invLvals, d_rowIndices, d_colPointers,
|
OpenclKernels<Scalar>::spmv(d_invLvals, d_rowIndices, d_colPointers,
|
||||||
x, d_invL_x, Nb, bs, true, true); // application of isaiL is a simple spmv with addition
|
y, d_invL_x, Nb, bs, true, true); // application of isaiL is a simple spmv with addition
|
||||||
// (to compensate for the unitary diagonal that is not
|
// (to compensate for the unitary diagonal that is not
|
||||||
// included in isaiL, for simplicity)
|
// included in isaiL, for simplicity)
|
||||||
OpenclKernels<Scalar>::spmv(d_invUvals, d_rowIndices, d_colPointers,
|
OpenclKernels<Scalar>::spmv(d_invUvals, d_rowIndices, d_colPointers,
|
||||||
d_invL_x, y, Nb, bs); // application of isaiU is a simple spmv
|
d_invL_x, x, Nb, bs); // application of isaiU is a simple spmv
|
||||||
}
|
}
|
||||||
|
|
||||||
#define INSTANTIATE_TYPE(T) \
|
#define INSTANTIATE_TYPE(T) \
|
||||||
|
@ -219,7 +219,7 @@ openclSolverBackend(int verbosity_,
|
|||||||
OPM_THROW(std::logic_error, oss.str());
|
OPM_THROW(std::logic_error, oss.str());
|
||||||
} catch (const std::logic_error& error) {
|
} catch (const std::logic_error& error) {
|
||||||
// rethrow exception by OPM_THROW in the try{}, without this, a segfault occurs
|
// rethrow exception by OPM_THROW in the try{}, without this, a segfault occurs
|
||||||
throw error;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,7 +479,7 @@ initialize(std::shared_ptr<BlockedMatrix<Scalar>> matrix,
|
|||||||
OPM_THROW(std::logic_error, oss.str());
|
OPM_THROW(std::logic_error, oss.str());
|
||||||
} catch (const std::logic_error& error) {
|
} catch (const std::logic_error& error) {
|
||||||
// rethrow exception by OPM_THROW in the try{}, without this, a segfault occurs
|
// rethrow exception by OPM_THROW in the try{}, without this, a segfault occurs
|
||||||
throw error;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
@ -649,7 +649,7 @@ solve_system(WellContributions<Scalar>& wellContribs, GpuResult& res)
|
|||||||
OPM_THROW(std::logic_error, oss.str());
|
OPM_THROW(std::logic_error, oss.str());
|
||||||
} catch (const std::logic_error& error) {
|
} catch (const std::logic_error& error) {
|
||||||
// rethrow exception by OPM_THROW in the try{}, without this, a segfault occurs
|
// rethrow exception by OPM_THROW in the try{}, without this, a segfault occurs
|
||||||
throw error;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbosity > 2) {
|
if (verbosity > 2) {
|
||||||
|
@ -70,7 +70,7 @@ namespace Opm::Satfunc::PhaseChecks::Gas {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Minimum gas saturation.
|
/// Minimum gas saturation.
|
||||||
Scalar sgl_;
|
Scalar sgl_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
@ -124,7 +124,7 @@ namespace Opm::Satfunc::PhaseChecks::Gas {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Maximum gas saturation.
|
/// Maximum gas saturation.
|
||||||
Scalar sgu_;
|
Scalar sgu_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
@ -182,13 +182,13 @@ namespace Opm::Satfunc::PhaseChecks::Gas {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Minimum gas saturation.
|
/// Minimum gas saturation.
|
||||||
Scalar sgl_;
|
Scalar sgl_{};
|
||||||
|
|
||||||
/// Critical gas saturation.
|
/// Critical gas saturation.
|
||||||
Scalar sgcr_;
|
Scalar sgcr_{};
|
||||||
|
|
||||||
/// Maximum gas saturation.
|
/// Maximum gas saturation.
|
||||||
Scalar sgu_;
|
Scalar sgu_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
|
@ -70,7 +70,7 @@ namespace Opm::Satfunc::PhaseChecks::Oil {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Critical oil saturation in gas/oil system.
|
/// Critical oil saturation in gas/oil system.
|
||||||
Scalar sogcr_;
|
Scalar sogcr_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
@ -128,10 +128,10 @@ namespace Opm::Satfunc::PhaseChecks::Oil {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Minimum (connate) water saturation in gas/oil system.
|
/// Minimum (connate) water saturation in gas/oil system.
|
||||||
Scalar swl_;
|
Scalar swl_{};
|
||||||
|
|
||||||
/// Maximum gas saturation in gas/oil system.
|
/// Maximum gas saturation in gas/oil system.
|
||||||
Scalar sgu_;
|
Scalar sgu_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
@ -192,13 +192,13 @@ namespace Opm::Satfunc::PhaseChecks::Oil {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Minimum water saturation.
|
/// Minimum water saturation.
|
||||||
Scalar swl_;
|
Scalar swl_{};
|
||||||
|
|
||||||
/// Minimum gas saturation.
|
/// Minimum gas saturation.
|
||||||
Scalar sgl_;
|
Scalar sgl_{};
|
||||||
|
|
||||||
/// Critical oil saturation in gas/oil system.
|
/// Critical oil saturation in gas/oil system.
|
||||||
Scalar sogcr_;
|
Scalar sogcr_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
@ -259,13 +259,13 @@ namespace Opm::Satfunc::PhaseChecks::Oil {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Minimum water saturation.
|
/// Minimum water saturation.
|
||||||
Scalar swl_;
|
Scalar swl_{};
|
||||||
|
|
||||||
/// Critical gas saturation.
|
/// Critical gas saturation.
|
||||||
Scalar sgcr_;
|
Scalar sgcr_{};
|
||||||
|
|
||||||
/// Critical oil saturation in gas/oil system
|
/// Critical oil saturation in gas/oil system
|
||||||
Scalar sogcr_;
|
Scalar sogcr_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
@ -321,7 +321,7 @@ namespace Opm::Satfunc::PhaseChecks::Oil {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Critical oil saturation in oil/water system.
|
/// Critical oil saturation in oil/water system.
|
||||||
Scalar sowcr_;
|
Scalar sowcr_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
@ -379,10 +379,10 @@ namespace Opm::Satfunc::PhaseChecks::Oil {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Minimum gas saturation. Typically zero.
|
/// Minimum gas saturation. Typically zero.
|
||||||
Scalar sgl_;
|
Scalar sgl_{};
|
||||||
|
|
||||||
/// Minimum (connate) saturation.
|
/// Minimum (connate) saturation.
|
||||||
Scalar swu_;
|
Scalar swu_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
@ -443,13 +443,13 @@ namespace Opm::Satfunc::PhaseChecks::Oil {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Minimum (connate) water saturation.
|
/// Minimum (connate) water saturation.
|
||||||
Scalar swl_;
|
Scalar swl_{};
|
||||||
|
|
||||||
/// Minimum gas saturation. Typically zero.
|
/// Minimum gas saturation. Typically zero.
|
||||||
Scalar sgl_;
|
Scalar sgl_{};
|
||||||
|
|
||||||
/// Critical oil saturation in oil/water system.
|
/// Critical oil saturation in oil/water system.
|
||||||
Scalar sowcr_;
|
Scalar sowcr_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
@ -510,13 +510,13 @@ namespace Opm::Satfunc::PhaseChecks::Oil {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Minimum gas saturation. Typically zero.
|
/// Minimum gas saturation. Typically zero.
|
||||||
Scalar sgl_;
|
Scalar sgl_{};
|
||||||
|
|
||||||
/// Critical water saturation.
|
/// Critical water saturation.
|
||||||
Scalar swcr_;
|
Scalar swcr_{};
|
||||||
|
|
||||||
/// Critical oil saturation in oil/water system.
|
/// Critical oil saturation in oil/water system.
|
||||||
Scalar sowcr_;
|
Scalar sowcr_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
|
@ -77,10 +77,10 @@ namespace Opm {
|
|||||||
NoFamily
|
NoFamily
|
||||||
};
|
};
|
||||||
|
|
||||||
SaturationFunctionFamily satFamily_;
|
SaturationFunctionFamily satFamily_{NoFamily};
|
||||||
|
|
||||||
std::vector<EclEpsScalingPointsInfo<double> > unscaledEpsInfo_;
|
std::vector<EclEpsScalingPointsInfo<double> > unscaledEpsInfo_{};
|
||||||
std::vector<EclEpsScalingPointsInfo<double> > scaledEpsInfo_;
|
std::vector<EclEpsScalingPointsInfo<double> > scaledEpsInfo_{};
|
||||||
|
|
||||||
|
|
||||||
///Check the phase that used.
|
///Check the phase that used.
|
||||||
|
@ -82,16 +82,16 @@ namespace Opm::Satfunc::PhaseChecks::ThreePointHorizontal {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Minimum (connate) water saturation.
|
/// Minimum (connate) water saturation.
|
||||||
Scalar swl_;
|
Scalar swl_{};
|
||||||
|
|
||||||
/// Critical oil saturation in two-phase gas/oil system.
|
/// Critical oil saturation in two-phase gas/oil system.
|
||||||
Scalar sogcr_;
|
Scalar sogcr_{};
|
||||||
|
|
||||||
/// Critical gas saturation.
|
/// Critical gas saturation.
|
||||||
Scalar sgcr_;
|
Scalar sgcr_{};
|
||||||
|
|
||||||
/// Maximum gas saturation.
|
/// Maximum gas saturation.
|
||||||
Scalar sgu_;
|
Scalar sgu_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
@ -157,16 +157,16 @@ namespace Opm::Satfunc::PhaseChecks::ThreePointHorizontal {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Minimum gas saturation.
|
/// Minimum gas saturation.
|
||||||
Scalar sgl_;
|
Scalar sgl_{};
|
||||||
|
|
||||||
/// Critical oil saturation in two-phase oil/water system.
|
/// Critical oil saturation in two-phase oil/water system.
|
||||||
Scalar sowcr_;
|
Scalar sowcr_{};
|
||||||
|
|
||||||
/// Critical water saturation.
|
/// Critical water saturation.
|
||||||
Scalar swcr_;
|
Scalar swcr_{};
|
||||||
|
|
||||||
/// Maximum water saturation.
|
/// Maximum water saturation.
|
||||||
Scalar swu_;
|
Scalar swu_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
|
@ -70,7 +70,7 @@ namespace Opm::Satfunc::PhaseChecks::Water {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Minimum (connate) water saturation.
|
/// Minimum (connate) water saturation.
|
||||||
Scalar swl_;
|
Scalar swl_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
@ -124,7 +124,7 @@ namespace Opm::Satfunc::PhaseChecks::Water {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Maximum water saturation.
|
/// Maximum water saturation.
|
||||||
Scalar swu_;
|
Scalar swu_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
@ -182,13 +182,13 @@ namespace Opm::Satfunc::PhaseChecks::Water {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Minimum (connate) water saturation.
|
/// Minimum (connate) water saturation.
|
||||||
Scalar swl_;
|
Scalar swl_{};
|
||||||
|
|
||||||
/// Critical water saturation.
|
/// Critical water saturation.
|
||||||
Scalar swcr_;
|
Scalar swcr_{};
|
||||||
|
|
||||||
/// Maximum water saturation.
|
/// Maximum water saturation.
|
||||||
Scalar swu_;
|
Scalar swu_{};
|
||||||
|
|
||||||
/// Run check against a set of saturation function end-points.
|
/// Run check against a set of saturation function end-points.
|
||||||
///
|
///
|
||||||
|
@ -253,9 +253,7 @@ initFromRestartFile(const RestartValue& restartValues,
|
|||||||
config.model().target(),
|
config.model().target(),
|
||||||
restartValues.wells,
|
restartValues.wells,
|
||||||
this->guideRate_);
|
this->guideRate_);
|
||||||
}
|
|
||||||
|
|
||||||
if (config.has_model()) {
|
|
||||||
BlackoilWellModelRestart(*this).
|
BlackoilWellModelRestart(*this).
|
||||||
loadRestartGuideRates(report_step,
|
loadRestartGuideRates(report_step,
|
||||||
config,
|
config,
|
||||||
|
@ -1852,9 +1852,8 @@ namespace Opm {
|
|||||||
|
|
||||||
if (this->terminal_output_) {
|
if (this->terminal_output_) {
|
||||||
global_deferredLogger.logMessages();
|
global_deferredLogger.logMessages();
|
||||||
}
|
|
||||||
// Log debug messages for NaN or too large residuals.
|
// Log debug messages for NaN or too large residuals.
|
||||||
if (this->terminal_output_) {
|
|
||||||
for (const auto& f : report.wellFailures()) {
|
for (const auto& f : report.wellFailures()) {
|
||||||
if (f.severity() == ConvergenceReport::Severity::NotANumber) {
|
if (f.severity() == ConvergenceReport::Severity::NotANumber) {
|
||||||
OpmLog::debug("NaN residual found with phase " + std::to_string(f.phase()) + " for well " + f.wellName());
|
OpmLog::debug("NaN residual found with phase " + std::to_string(f.phase()) + " for well " + f.wellName());
|
||||||
|
@ -1048,11 +1048,10 @@ GasLiftSingleWellGeneric<Scalar>::
|
|||||||
increaseALQtoPositiveOilRate_(Scalar alq,
|
increaseALQtoPositiveOilRate_(Scalar alq,
|
||||||
const LimitedRates& orig_rates) const
|
const LimitedRates& orig_rates) const
|
||||||
{
|
{
|
||||||
bool stop_iteration = false;
|
|
||||||
Scalar temp_alq = alq;
|
Scalar temp_alq = alq;
|
||||||
// use the copy constructor to only copy the rates
|
// use the copy constructor to only copy the rates
|
||||||
BasicRates rates = orig_rates;
|
BasicRates rates = orig_rates;
|
||||||
while (!stop_iteration) {
|
while (true) {
|
||||||
temp_alq += this->increment_;
|
temp_alq += this->increment_;
|
||||||
if (temp_alq > this->max_alq_)
|
if (temp_alq > this->max_alq_)
|
||||||
break;
|
break;
|
||||||
@ -1078,10 +1077,9 @@ increaseALQtoMinALQ_(const Scalar orig_alq,
|
|||||||
assert(min_alq >= 0);
|
assert(min_alq >= 0);
|
||||||
assert(orig_alq < min_alq);
|
assert(orig_alq < min_alq);
|
||||||
assert(min_alq < this->max_alq_);
|
assert(min_alq < this->max_alq_);
|
||||||
bool stop_iteration = false;
|
|
||||||
Scalar alq = orig_alq;
|
Scalar alq = orig_alq;
|
||||||
LimitedRates rates = orig_rates;
|
LimitedRates rates = orig_rates;
|
||||||
while (!stop_iteration) {
|
while (true) {
|
||||||
Scalar temp_alq = alq + this->increment_;
|
Scalar temp_alq = alq + this->increment_;
|
||||||
|
|
||||||
alq = temp_alq;
|
alq = temp_alq;
|
||||||
@ -1175,11 +1173,10 @@ GasLiftSingleWellGeneric<Scalar>::
|
|||||||
reduceALQtoGroupAlqLimits_(const Scalar orig_alq,
|
reduceALQtoGroupAlqLimits_(const Scalar orig_alq,
|
||||||
const LimitedRates& orig_rates) const
|
const LimitedRates& orig_rates) const
|
||||||
{
|
{
|
||||||
bool stop_this_iteration = false;
|
|
||||||
Scalar alq = orig_alq;
|
Scalar alq = orig_alq;
|
||||||
BasicRates rates {orig_rates};
|
BasicRates rates {orig_rates};
|
||||||
Scalar temp_alq = orig_alq;
|
Scalar temp_alq = orig_alq;
|
||||||
while (!stop_this_iteration) {
|
while (true) {
|
||||||
if (temp_alq == 0)
|
if (temp_alq == 0)
|
||||||
break;
|
break;
|
||||||
temp_alq -= this->increment_;
|
temp_alq -= this->increment_;
|
||||||
@ -1268,8 +1265,7 @@ reduceALQtoWellTarget_(const Scalar orig_alq,
|
|||||||
Scalar alq = orig_alq;
|
Scalar alq = orig_alq;
|
||||||
Scalar temp_alq = alq;
|
Scalar temp_alq = alq;
|
||||||
std::optional<LimitedRates> new_rates;
|
std::optional<LimitedRates> new_rates;
|
||||||
bool stop_iteration = false;
|
while (true) {
|
||||||
while (!stop_iteration) {
|
|
||||||
if (temp_alq == 0)
|
if (temp_alq == 0)
|
||||||
break;
|
break;
|
||||||
temp_alq -= this->increment_;
|
temp_alq -= this->increment_;
|
||||||
|
@ -412,8 +412,8 @@ protected:
|
|||||||
Scalar delta_alq) const;
|
Scalar delta_alq) const;
|
||||||
|
|
||||||
LimitedRates
|
LimitedRates
|
||||||
updateRatesToGroupLimits_(const BasicRates& rates,
|
updateRatesToGroupLimits_(const BasicRates& old_rates,
|
||||||
const LimitedRates& new_rates,
|
const LimitedRates& rates,
|
||||||
const std::string& gr_name = "") const;
|
const std::string& gr_name = "") const;
|
||||||
|
|
||||||
void updateWellStateAlqFixedValue_(const GasLiftWell& well);
|
void updateWellStateAlqFixedValue_(const GasLiftWell& well);
|
||||||
|
@ -1656,32 +1656,28 @@ namespace Opm
|
|||||||
// if we fail to solve eqs, we reset status/operability before leaving
|
// if we fail to solve eqs, we reset status/operability before leaving
|
||||||
const auto well_status_orig = this->wellStatus_;
|
const auto well_status_orig = this->wellStatus_;
|
||||||
const auto operability_orig = this->operability_status_;
|
const auto operability_orig = this->operability_status_;
|
||||||
auto well_status_cur = well_status_orig;
|
|
||||||
// don't allow opening wells that are stopped from schedule or has a stopped well state
|
// don't allow opening wells that are stopped from schedule or has a stopped well state
|
||||||
const bool allow_open = this->well_ecl_.getStatus() == WellStatus::OPEN &&
|
const bool allow_open = this->well_ecl_.getStatus() == WellStatus::OPEN &&
|
||||||
well_state.well(this->index_of_well_).status == WellStatus::OPEN;
|
well_state.well(this->index_of_well_).status == WellStatus::OPEN;
|
||||||
// don't allow switcing for wells under zero rate target or requested fixed status and control
|
// don't allow switcing for wells under zero rate target or requested fixed status and control
|
||||||
const bool allow_switching = !this->wellUnderZeroRateTarget(simulator, well_state, deferred_logger) &&
|
const bool allow_switching = !this->wellUnderZeroRateTarget(simulator, well_state, deferred_logger) &&
|
||||||
(!fixed_control || !fixed_status) && allow_open;
|
(!fixed_control || !fixed_status) && allow_open;
|
||||||
bool changed = false;
|
|
||||||
bool final_check = false;
|
bool final_check = false;
|
||||||
// well needs to be set operable or else solving/updating of re-opened wells is skipped
|
// well needs to be set operable or else solving/updating of re-opened wells is skipped
|
||||||
this->operability_status_.resetOperability();
|
this->operability_status_.resetOperability();
|
||||||
this->operability_status_.solvable = true;
|
this->operability_status_.solvable = true;
|
||||||
|
|
||||||
for (; it < max_iter_number; ++it, ++debug_cost_counter_) {
|
for (; it < max_iter_number; ++it, ++debug_cost_counter_) {
|
||||||
its_since_last_switch++;
|
++its_since_last_switch;
|
||||||
if (allow_switching && its_since_last_switch >= min_its_after_switch){
|
if (allow_switching && its_since_last_switch >= min_its_after_switch){
|
||||||
const Scalar wqTotal = this->primary_variables_.getWQTotal().value();
|
const Scalar wqTotal = this->primary_variables_.getWQTotal().value();
|
||||||
changed = this->updateWellControlAndStatusLocalIteration(simulator, well_state, group_state,
|
bool changed = this->updateWellControlAndStatusLocalIteration(simulator, well_state, group_state,
|
||||||
inj_controls, prod_controls, wqTotal,
|
inj_controls, prod_controls, wqTotal,
|
||||||
deferred_logger, fixed_control, fixed_status);
|
deferred_logger, fixed_control,
|
||||||
if (changed){
|
fixed_status);
|
||||||
|
if (changed) {
|
||||||
its_since_last_switch = 0;
|
its_since_last_switch = 0;
|
||||||
switch_count++;
|
++switch_count;
|
||||||
if (well_status_cur != this->wellStatus_) {
|
|
||||||
well_status_cur = this->wellStatus_;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!changed && final_check) {
|
if (!changed && final_check) {
|
||||||
break;
|
break;
|
||||||
@ -1690,7 +1686,8 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assembleWellEqWithoutIteration(simulator, dt, inj_controls, prod_controls, well_state, group_state, deferred_logger);
|
assembleWellEqWithoutIteration(simulator, dt, inj_controls, prod_controls,
|
||||||
|
well_state, group_state, deferred_logger);
|
||||||
|
|
||||||
const BVectorWell dx_well = this->linSys_.solve();
|
const BVectorWell dx_well = this->linSys_.solve();
|
||||||
|
|
||||||
|
@ -171,10 +171,9 @@ findThpFromBhpIteratively(const std::function<Scalar(const Scalar, const Scalar)
|
|||||||
auto pressure_loss = getVfpBhpAdjustment(bhp + dp, thp_limit);
|
auto pressure_loss = getVfpBhpAdjustment(bhp + dp, thp_limit);
|
||||||
auto thp = thp_func(bhp, pressure_loss);
|
auto thp = thp_func(bhp, pressure_loss);
|
||||||
const Scalar tolerance = 1e-5 * unit::barsa;
|
const Scalar tolerance = 1e-5 * unit::barsa;
|
||||||
bool do_iterate = true;
|
|
||||||
int it = 1;
|
int it = 1;
|
||||||
int max_iterations = 50;
|
int max_iterations = 50;
|
||||||
while (do_iterate) {
|
while (true) {
|
||||||
if (it > max_iterations) {
|
if (it > max_iterations) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -919,48 +919,44 @@ template<class Scalar>
|
|||||||
void WellState<Scalar>::communicateGroupRates(const Parallel::Communication& comm)
|
void WellState<Scalar>::communicateGroupRates(const Parallel::Communication& comm)
|
||||||
{
|
{
|
||||||
// Compute the size of the data.
|
// Compute the size of the data.
|
||||||
std::size_t sz = 0;
|
std::size_t sz = std::accumulate(this->well_rates.begin(), this->well_rates.end(), std::size_t{0},
|
||||||
for (const auto& [_, owner_rates] : this->well_rates) {
|
[](const std::size_t acc, const auto& rates)
|
||||||
(void)_;
|
{ return acc + rates.second.second.size(); });
|
||||||
const auto& [__, rates] = owner_rates;
|
|
||||||
(void)__;
|
|
||||||
sz += rates.size();
|
|
||||||
}
|
|
||||||
sz += this->alq_state.pack_size();
|
sz += this->alq_state.pack_size();
|
||||||
|
|
||||||
// Make a vector and collect all data into it.
|
// Make a vector and collect all data into it.
|
||||||
std::vector<Scalar> data(sz);
|
std::vector<Scalar> data(sz);
|
||||||
std::size_t pos = 0;
|
auto pos = data.begin();
|
||||||
for (const auto& [_, owner_rates] : this->well_rates) {
|
std::for_each(this->well_rates.begin(), this->well_rates.end(),
|
||||||
(void)_;
|
[&pos](const auto& input)
|
||||||
const auto& [owner, rates] = owner_rates;
|
{
|
||||||
for (const auto& value : rates) {
|
const auto& [owner, rates] = input.second;
|
||||||
if (owner)
|
if (owner) {
|
||||||
data[pos++] = value;
|
std::copy(rates.begin(), rates.end(), pos);
|
||||||
else
|
}
|
||||||
data[pos++] = 0;
|
pos += rates.size();
|
||||||
}
|
});
|
||||||
|
|
||||||
|
if (pos != data.end()) {
|
||||||
|
pos += this->alq_state.pack_data(&(*pos));
|
||||||
}
|
}
|
||||||
if (!data.empty() && pos != sz) {
|
assert(pos == data.end());
|
||||||
pos += this->alq_state.pack_data(&data[pos]);
|
|
||||||
}
|
|
||||||
assert(pos == sz);
|
|
||||||
|
|
||||||
// Communicate it with a single sum() call.
|
// Communicate it with a single sum() call.
|
||||||
comm.sum(data.data(), data.size());
|
comm.sum(data.data(), data.size());
|
||||||
|
|
||||||
pos = 0;
|
pos = data.begin();
|
||||||
for (auto& [_, owner_rates] : this->well_rates) {
|
std::for_each(this->well_rates.begin(), this->well_rates.end(),
|
||||||
(void)_;
|
[&pos](auto& input)
|
||||||
auto& [__, rates] = owner_rates;
|
{
|
||||||
(void)__;
|
auto& rates = input.second.second;
|
||||||
for (auto& value : rates)
|
std::copy(pos, pos + rates.size(), rates.begin());
|
||||||
value = data[pos++];
|
pos += rates.size();
|
||||||
|
});
|
||||||
|
if (pos != data.end()) {
|
||||||
|
pos += this->alq_state.unpack_data(&(*pos));
|
||||||
}
|
}
|
||||||
if (!data.empty() && pos != sz) {
|
assert(pos == data.end());
|
||||||
pos += this->alq_state.unpack_data(&data[pos]);
|
|
||||||
}
|
|
||||||
assert(pos == sz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Scalar>
|
template<class Scalar>
|
||||||
|
Loading…
Reference in New Issue
Block a user