Skip to content

Commit 2d327a6

Browse files
authored
Merge pull request #6424 from lechevaa/HybridNewton_flag
Hybrid newton flag
2 parents 9cb71ee + 5b0e437 commit 2d327a6

File tree

17 files changed

+1650
-3
lines changed

17 files changed

+1650
-3
lines changed

CMakeLists_files.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ list (APPEND PUBLIC_HEADER_FILES
934934
opm/simulators/flow/GenericThresholdPressure_impl.hpp
935935
opm/simulators/flow/GenericTracerModel.hpp
936936
opm/simulators/flow/GenericTracerModel_impl.hpp
937+
opm/simulators/flow/HybridNewton.hpp
937938
opm/simulators/flow/InterRegFlows.hpp
938939
opm/simulators/flow/KeywordValidation.hpp
939940
opm/simulators/flow/LogOutputHelper.hpp

opm/models/blackoil/blackoilenergymodules.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public:
264264
const FluidState& fluidState)
265265
{
266266
if constexpr (enableEnergy) {
267-
priVars[temperatureIdx] = fluidState.temperature(/*phaseIdx=*/0);
267+
priVars[temperatureIdx] = getValue(fluidState.temperature(/*phaseIdx=*/0));
268268
}
269269
}
270270

opm/simulators/flow/FlowProblem.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ class FlowProblem : public GetPropType<TypeTag, Properties::BaseProblem>
349349
/*!
350350
* \brief Called by the simulator before each time integration.
351351
*/
352-
void beginTimeStep()
352+
virtual void beginTimeStep()
353353
{
354354
OPM_TIMEBLOCK(beginTimeStep);
355355
const int episodeIdx = this->episodeIndex();
@@ -376,7 +376,6 @@ class FlowProblem : public GetPropType<TypeTag, Properties::BaseProblem>
376376
wellModel_.beginTimeStep();
377377
aquiferModel_.beginTimeStep();
378378
tracerModel_.beginTimeStep();
379-
380379
}
381380

382381
/*!

opm/simulators/flow/FlowProblemBlackoil.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
#include <opm/simulators/flow/MixingRateControls.hpp>
5353
#include <opm/simulators/flow/OutputBlackoilModule.hpp>
5454
#include <opm/simulators/flow/VtkTracerModule.hpp>
55+
#include <opm/simulators/flow/HybridNewton.hpp>
56+
#include <opm/simulators/flow/HybridNewtonConfig.hpp>
5557

5658
#include <opm/simulators/utils/satfunc/SatfuncConsistencyCheckManager.hpp>
5759

@@ -148,6 +150,7 @@ class FlowProblemBlackoil : public FlowProblem<TypeTag>
148150
using DiffusionModule = BlackOilDiffusionModule<TypeTag, enableDiffusion>;
149151
using ConvectiveMixingModule = BlackOilConvectiveMixingModule<TypeTag, enableConvectiveMixing>;
150152
using ModuleParams = typename BlackOilLocalResidualTPFA<TypeTag>::ModuleParams;
153+
using HybridNewton = BlackOilHybridNewton<TypeTag>;
151154

152155
using InitialFluidState = typename EquilInitializer<TypeTag>::ScalarFluidState;
153156
using EclWriterType = EclWriter<TypeTag, OutputBlackOilModule<TypeTag> >;
@@ -188,6 +191,7 @@ class FlowProblemBlackoil : public FlowProblem<TypeTag>
188191
simulator.vanguard().summaryState(),
189192
this->wellModel_,
190193
simulator.vanguard().grid().comm())
194+
, hybridNewton_(simulator)
191195
{
192196
this->model().addOutputModule(std::make_unique<VtkTracerModule<TypeTag>>(simulator));
193197

@@ -264,6 +268,15 @@ class FlowProblemBlackoil : public FlowProblem<TypeTag>
264268
this->moduleParams_.convectiveMixingModuleParam);
265269
}
266270

271+
/*!
272+
* \brief Called by the simulator before each time integration.
273+
*/
274+
void beginTimeStep() override
275+
{
276+
FlowProblemType::beginTimeStep();
277+
hybridNewton_.tryApplyHybridNewton();
278+
}
279+
267280
/*!
268281
* \copydoc FvBaseProblem::finishInit
269282
*/
@@ -1695,6 +1708,8 @@ class FlowProblemBlackoil : public FlowProblem<TypeTag>
16951708

16961709
ModuleParams moduleParams_;
16971710

1711+
HybridNewton hybridNewton_;
1712+
16981713
private:
16991714
/// Whether or not the current epsiode will end at the end of the
17001715
/// current time step.

opm/simulators/flow/FlowProblemParameters.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ void registerFlowProblemParameters()
6868

6969
Parameters::Register<Parameters::NumSatfuncConsistencySamplePoints>
7070
("Maximum number of reported failures for each individual saturation function consistency check");
71+
72+
Parameters::Register<Parameters::HyNeConfigFile>
73+
("Use config files for Hybrid Newton");
74+
75+
Parameters::Register<Parameters::UseHyNe>
76+
("Wheter or not to use Hybrid Newton");
7177

7278
// By default, stop it after the universe will probably have stopped
7379
// to exist. (the ECL problem will finish the simulation explicitly

opm/simulators/flow/FlowProblemParameters.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ struct OutputMode { static constexpr auto value = "all"; };
5656
// between writing restart files
5757
struct RestartWritingInterval { static constexpr int value = 0xffffff; }; // disable
5858

59+
// Path to the config file containing all Hybrid Newton parameters
60+
struct HyNeConfigFile { static constexpr auto value = "hybridNewtonConfig.json"; };
61+
// Wheter or not to use Hybrid Newton nonlinear preconditioning
62+
struct UseHyNe { static constexpr bool value = false; };
63+
5964
} // namespace Opm::Parameters
6065

6166
namespace Opm {

0 commit comments

Comments
 (0)