diff --git a/opm/simulators/flow/HybridNewton.hpp b/opm/simulators/flow/HybridNewton.hpp index e4e64c7f33..18ea6000a8 100644 --- a/opm/simulators/flow/HybridNewton.hpp +++ b/opm/simulators/flow/HybridNewton.hpp @@ -147,7 +147,6 @@ private: } protected: - void validateFluidSystem() { const auto& eclState = simulator_.vanguard().eclState(); @@ -230,9 +229,8 @@ protected: * \param config HybridNewtonConfig containing feature definitions and cell indices. * \return A 1D tensor of Evaluation values with the computed layout. */ - ML::Tensor constructInputTensor( - const HybridNewtonConfig& config - ) + ML::Tensor + constructInputTensor(const HybridNewtonConfig& config) { const auto& features = config.input_features; @@ -374,7 +372,8 @@ protected: * output tensor does not match the expected feature layout. */ ML::Tensor - constructOutputTensor(const ML::Tensor& input, const HybridNewtonConfig& config) + constructOutputTensor(const ML::Tensor& input, + const HybridNewtonConfig& config) { const auto& features = config.output_features; const int n_features = features.size(); @@ -415,10 +414,8 @@ protected: * \throws std::runtime_error if an unknown output feature is encountered * or if state consistency cannot be enforced. */ - void updateInitialGuess( - ML::Tensor& output, - const HybridNewtonConfig& config - ) + void updateInitialGuess(ML::Tensor& output, + const HybridNewtonConfig& config) { const auto& features = config.output_features; @@ -492,7 +489,9 @@ protected: ++feature_idx; } - int sat_count = static_cast(flags.has_SWAT) + static_cast(flags.has_SOIL) + static_cast(flags.has_SGAS); + int sat_count = static_cast(flags.has_SWAT) + + static_cast(flags.has_SOIL) + + static_cast(flags.has_SGAS); if (sat_count >= 2) { Scalar sw = sw_val; @@ -543,11 +542,12 @@ protected: simulator_.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx*/0); } - struct FeatureFlags { - bool has_SWAT = false; - bool has_SOIL = false; - bool has_SGAS = false; - bool has_PRESSURE = false; + struct FeatureFlags + { + bool has_SWAT = false; + bool has_SOIL = false; + bool has_SGAS = false; + bool has_PRESSURE = false; }; FeatureFlags flagFeatures(const std::vector>& features) @@ -570,11 +570,11 @@ protected: return flags; } - protected: - Simulator& simulator_; - std::vector configs_; - bool configsLoaded_; - }; +protected: + Simulator& simulator_; + std::vector configs_; + bool configsLoaded_; +}; } // namespace Opm diff --git a/opm/simulators/flow/HybridNewtonConfig.hpp b/opm/simulators/flow/HybridNewtonConfig.hpp index 4b391b9237..8e631771b1 100644 --- a/opm/simulators/flow/HybridNewtonConfig.hpp +++ b/opm/simulators/flow/HybridNewtonConfig.hpp @@ -38,14 +38,16 @@ namespace Opm { * * Supports standard (mean/std) and min-max scaling. */ -struct Scaler { +struct Scaler +{ enum class Type { None, Standard, MinMax } type = Type::None; double mean = 0.0; double std = 1.0; double min = 0.0; double max = 1.0; - double scale(double raw_value) const { + double scale(double raw_value) const + { switch (type) { case Type::Standard: return (std == 0.0) ? mean : (raw_value - mean) / std; @@ -59,7 +61,8 @@ struct Scaler { } } - double unscale(double scaled_value) const { + double unscale(double scaled_value) const + { switch (type) { case Type::Standard: return scaled_value * std + mean; case Type::MinMax: return scaled_value * (max - min) + min; @@ -75,18 +78,21 @@ struct Scaler { * Supports log, log10, log1p, and no transform. Provides forward * and inverse methods. */ -struct Transform { +struct Transform +{ enum class Type { None, Log, Log10, Log1p } type = Type::None; Transform() = default; - explicit Transform(const std::string& name) { + explicit Transform(const std::string& name) + { if (name == "log10") type = Type::Log10; else if (name == "log") type = Type::Log; else if (name == "log1p") type = Type::Log1p; else type = Type::None; } - double apply(double raw_value) const { + double apply(double raw_value) const + { switch (type) { case Type::Log10: return std::log10(raw_value); case Type::Log: return std::log(raw_value); @@ -96,7 +102,8 @@ struct Transform { } } - double applyInverse(double transformed_value) const { + double applyInverse(double transformed_value) const + { switch (type) { case Type::Log10: return std::pow(10.0, transformed_value); case Type::Log: return std::exp(transformed_value); @@ -112,7 +119,8 @@ struct Transform { * * Includes transformation, scaling, delta flag, and actual feature name. */ -struct FeatureSpec { +struct FeatureSpec +{ Transform transform; Scaler scaler; bool is_delta = false; @@ -127,7 +135,8 @@ struct FeatureSpec { * Encapsulates model path, cell indices, apply times, input/output * features, and validation. Can be constructed from a PropertyTree. */ -class HybridNewtonConfig { +class HybridNewtonConfig +{ public: std::string model_path; std::string cell_indices_file;