mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #4937 from totto82/addOutputResidual
Add output of the residual at the end of a time step
This commit is contained in:
commit
7d4ec59415
@ -551,6 +551,28 @@ assignToSolution(data::Solution& sol)
|
||||
data::TargetType::RESTART_OPM_EXTENDED);
|
||||
}
|
||||
|
||||
if (FluidSystem::phaseIsActive(waterPhaseIdx) &&
|
||||
! this->residual_[waterPhaseIdx].empty())
|
||||
{
|
||||
sol.insert("RES_WAT", UnitSystem::measure::liquid_surface_volume,
|
||||
std::move(this->residual_[waterPhaseIdx]),
|
||||
data::TargetType::RESTART_OPM_EXTENDED);
|
||||
}
|
||||
if (FluidSystem::phaseIsActive(gasPhaseIdx) &&
|
||||
! this->residual_[gasPhaseIdx].empty())
|
||||
{
|
||||
sol.insert("RES_GAS", UnitSystem::measure::gas_surface_volume,
|
||||
std::move(this->residual_[gasPhaseIdx]),
|
||||
data::TargetType::RESTART_OPM_EXTENDED);
|
||||
}
|
||||
if (FluidSystem::phaseIsActive(oilPhaseIdx) &&
|
||||
! this->residual_[oilPhaseIdx].empty())
|
||||
{
|
||||
sol.insert("RES_OIL", UnitSystem::measure::liquid_surface_volume,
|
||||
std::move(this->residual_[oilPhaseIdx]),
|
||||
data::TargetType::RESTART_OPM_EXTENDED);
|
||||
}
|
||||
|
||||
// Fluid in place
|
||||
if (this->outputFipRestart_) {
|
||||
for (const auto& phase : Inplace::phases()) {
|
||||
@ -1135,6 +1157,16 @@ doAllocBuffers(const unsigned bufferSize,
|
||||
}
|
||||
}
|
||||
|
||||
if (rstKeywords["RESIDUAL"] > 0) {
|
||||
rstKeywords["RESIDUAL"] = 0;
|
||||
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
|
||||
{
|
||||
if (FluidSystem::phaseIsActive(phaseIdx)) {
|
||||
this->residual_[phaseIdx].resize(bufferSize, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ROCKC
|
||||
if (rstKeywords["ROCKC"] > 0) {
|
||||
rstKeywords["ROCKC"] = 0;
|
||||
|
@ -470,6 +470,9 @@ protected:
|
||||
|
||||
std::vector<ScalarBuffer> tracerConcentrations_;
|
||||
|
||||
std::array<ScalarBuffer, numPhases> residual_;
|
||||
|
||||
|
||||
std::array<ScalarBuffer, numPhases> flowsi_;
|
||||
std::array<ScalarBuffer, numPhases> flowsj_;
|
||||
std::array<ScalarBuffer, numPhases> flowsk_;
|
||||
|
@ -278,6 +278,7 @@ public:
|
||||
return;
|
||||
|
||||
const auto& problem = elemCtx.simulator().problem();
|
||||
const auto& ebosResid = elemCtx.simulator().model().linearizer().residual();
|
||||
for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) {
|
||||
const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0);
|
||||
const auto& fs = intQuants.fluidState();
|
||||
@ -626,6 +627,15 @@ public:
|
||||
tracerModel.tracerConcentration(tracerIdx, globalDofIdx);
|
||||
}
|
||||
}
|
||||
|
||||
// output residual
|
||||
for ( int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx )
|
||||
{
|
||||
if (!this->residual_[phaseIdx].empty()) {
|
||||
const unsigned activeCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::solventComponentIndex(phaseIdx));
|
||||
this->residual_[phaseIdx][globalDofIdx] = ebosResid[globalDofIdx][activeCompIdx];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user