Skip to content

Commit 0bb470a

Browse files
committed
more well state output
1 parent cde3499 commit 0bb470a

File tree

6 files changed

+65
-12
lines changed

6 files changed

+65
-12
lines changed

opm/simulators/wells/MSWellHelpers.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,6 @@ applyUMFPack(Dune::UMFPack<MatrixType>& linsolver,
167167
// Solve
168168
linsolver.apply(y, x, res);
169169

170-
const std::string msg {"tesing numerical problem in UMFPack"};
171-
OPM_THROW_NOLOG(NumericalProblem, msg);
172-
173170
// Checking if there is any inf or nan in y
174171
// it will be the solution before we find a way to catch the singularity of the matrix
175172
for (std::size_t i_block = 0; i_block < y.size(); ++i_block) {

opm/simulators/wells/MultisegmentWell.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@ namespace Opm {
349349

350350
FSInfo getFirstPerforationFluidStateInfo(const Simulator& simulator) const;
351351

352-
void outputDebugInfoNumericalProblem(DeferredLogger& deferred_logger) const;
352+
void outputDebugInfoNumericalProblem(const SingleWellState<Scalar, IndexTraits>& ws,
353+
DeferredLogger& deferred_logger) const;
353354
};
354355

355356
}

opm/simulators/wells/MultisegmentWell_impl.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ namespace Opm
283283
// this is the process with rank zero)
284284
deferred_logger.problem("In MultisegmentWell::recoverWellSolutionAndUpdateWellState for well "
285285
+ this->name() +": "+exp.what());
286-
this->outputDebugInfoNumericalProblem(deferred_logger);
286+
const auto& ws = well_state.well(this->index_of_well_);
287+
this->outputDebugInfoNumericalProblem(ws, deferred_logger);
287288
throw;
288289
}
289290
}
@@ -633,7 +634,8 @@ namespace Opm
633634
// this is the process with rank zero)
634635
deferred_logger.problem("In MultisegmentWell::solveEqAndUpdateWellState for well "
635636
+ this->name() +": "+exp.what());
636-
this->outputDebugInfoNumericalProblem(deferred_logger);
637+
const auto& ws = well_state.well(this->index_of_well_);
638+
this->outputDebugInfoNumericalProblem(ws, deferred_logger);
637639
throw;
638640
}
639641
}
@@ -1609,7 +1611,8 @@ namespace Opm
16091611
// this is the process with rank zero)
16101612
deferred_logger.problem("In MultisegmentWell::iterateWellEqWithControl for well "
16111613
+ this->name() +": "+exp.what());
1612-
this->outputDebugInfoNumericalProblem(deferred_logger);
1614+
const auto& ws = well_state.well(this->index_of_well_);
1615+
this->outputDebugInfoNumericalProblem(ws, deferred_logger);
16131616
throw;
16141617
}
16151618
}
@@ -1791,7 +1794,8 @@ namespace Opm
17911794
// this is the process with rank zero)
17921795
deferred_logger.problem("In MultisegmentWell::iterateWellEqWithSwitching for well "
17931796
+ this->name() +": "+exp.what());
1794-
this->outputDebugInfoNumericalProblem(deferred_logger);
1797+
const auto& ws = well_state.well(this->index_of_well_);
1798+
this->outputDebugInfoNumericalProblem(ws, deferred_logger);
17951799
throw;
17961800
}
17971801
}
@@ -2386,9 +2390,11 @@ namespace Opm
23862390
template <typename TypeTag>
23872391
void
23882392
MultisegmentWell<TypeTag>::
2389-
outputDebugInfoNumericalProblem(DeferredLogger& deferred_logger) const
2393+
outputDebugInfoNumericalProblem(const SingleWellState<Scalar, IndexTraits>& ws,
2394+
DeferredLogger& deferred_logger) const
23902395
{
2391-
std::string msg = this->primary_variables_.debugInfo();
2396+
std::string msg = ws.debugInfo();
2397+
msg += this->primary_variables_.debugInfo();
23922398
deferred_logger.debug(msg);
23932399
}
23942400

opm/simulators/wells/SegmentState.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include <stdexcept>
3232
#include <vector>
3333

34+
#include <fmt/format.h>
35+
3436
namespace {
3537

3638
std::vector<int> make_segment_number(const Opm::WellSegments& segments)
@@ -147,6 +149,27 @@ bool SegmentState<Scalar>::operator==(const SegmentState& rhs) const
147149
this->m_segment_number == rhs.m_segment_number;
148150
}
149151

152+
template<class Scalar>
153+
std::string
154+
SegmentState<Scalar>::debugInfo() const
155+
{
156+
if (this->empty()) {
157+
return "";
158+
}
159+
const std::size_t num_phases = this->rates.size() / this->size();
160+
std::string info = "SegmentState:\n";
161+
for (std::size_t i = 0; i < this->size(); ++i) {
162+
info += fmt::format(" Segment {:4}: Segment number {:4}, Pressure = {:8.2e} Pa, Rate: ",
163+
i, this->m_segment_number[i], this->pressure[i]);
164+
for (std::size_t p = 0; p < num_phases; ++p) {
165+
info += fmt::format(" {: 8.2e}", this->rates[i * num_phases + p]);
166+
}
167+
info += fmt::format("\n");
168+
}
169+
return info;
170+
}
171+
172+
150173
template class SegmentState<double>;
151174

152175
#if FLOW_INSTANTIATE_FLOAT

opm/simulators/wells/SegmentState.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <cstddef>
2424
#include <vector>
25+
#include <string>
2526

2627
namespace Opm {
2728
class WellSegments;
@@ -104,6 +105,7 @@ class SegmentState
104105
std::vector<Scalar> pressure_drop_hydrostatic;
105106
std::vector<Scalar> pressure_drop_accel;
106107

108+
std::string debugInfo() const;
107109
private:
108110
std::vector<int> m_segment_number;
109111
};

opm/simulators/wells/SingleWellState.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,34 @@ SingleWellState<Scalar, IndexTraits>::
423423
debugInfo() const
424424
{
425425
std::string info = "Well name: " + this->name + " well state:\n";
426-
fmt::format_to(std::back_inserter(info), " type: {}, staus: {}, control type: \n",
426+
fmt::format_to(std::back_inserter(info), " type: {}, staus: {}, control type: {}, BHP: {:8.2e} Pa, THP: {:8.2e} Pa\n",
427427
this->producer? "Producer" : " Injector", WellStatus2String(this->status),
428428
this->producer ? WellProducerCMode2String(this->production_cmode)
429-
: WellInjectorCMode2String(this->injection_cmode));
429+
: WellInjectorCMode2String(this->injection_cmode),
430+
this->bhp / Opm::unit::barsa,
431+
this->thp / Opm::unit::barsa);
432+
433+
fmt::format_to(std::back_inserter(info), " Surface rates (m3/s): ");
434+
for (const auto& r : this->surface_rates) {
435+
fmt::format_to(std::back_inserter(info), " {:8.2e}", r);
436+
}
437+
fmt::format_to(std::back_inserter(info), "\n");
438+
fmt::format_to(std::back_inserter(info), " Connection pressures and connection rates:\n");
439+
for (std::size_t perf = 0; perf < this->perf_data.size(); perf++) {
440+
fmt::format_to(std::back_inserter(info),
441+
" Connection {:4}: Pressure: {:8.2e} Pa, Rate:",
442+
perf,
443+
this->perf_data.pressure[perf]);
444+
const auto& connection_rates = this->perf_data.phase_rates;
445+
const std::size_t num_phases = this->pu.numActivePhases();
446+
447+
for (std::size_t p = 0; p < num_phases; ++p) {
448+
fmt::format_to(std::back_inserter(info), " {: 8.2e} m3/s", connection_rates[perf * num_phases + p]);
449+
}
450+
fmt::format_to(std::back_inserter(info), "\n");
451+
}
452+
453+
info += this->segments.debugInfo();
430454

431455
return info;
432456
}

0 commit comments

Comments
 (0)