Skip to content

Extract BlackOilFluidState factory into general-purpose free function; drop TypeTag dependency#3

Draft
Copilot wants to merge 15 commits intowellbore_volume_new_approachfrom
copilot/expand-fluid-state-support
Draft

Extract BlackOilFluidState factory into general-purpose free function; drop TypeTag dependency#3
Copilot wants to merge 15 commits intowellbore_volume_new_approachfrom
copilot/expand-fluid-state-support

Conversation

Copy link

Copilot AI commented Mar 5, 2026

createFluidState() was a WellInterface member function tied to well-specific state (pvtRegionIdx(), name()), making it unusable outside the well abstraction. The boolean flags controlling fluid state behaviour were also redundantly extracted from TypeTag despite being direct template parameters of BlackOilFluidState.

Changes

New: opm/simulators/utils/BlackOilFluidStateUtils.hpp

  • Introduces free function createBlackOilFluidState<FluidSystem, Indices, bool...>() — usable from any context (reservoir, aquifer, etc.)
  • Template parameters mirror BlackOilFluidState's own template args directly; no TypeTag required; blackoilproperties.hh / EnergyModuleType.hpp not needed
  • pvtRegionIdx and name are explicit parameters; auto return type avoids repeating the BlackOilFluidState specialisation twice
  • setTemperature guarded by enableTemperature (not just enableEnergy) — correct for ConstantTemperature and SequentialImplicitThermal modes too
// Before: TypeTag-coupled, well-only
template <typename TypeTag, typename ValueType>
auto createBlackOilFluidState(...);  // extracts FluidSystem, Indices, flags from TypeTag

// After: self-contained, no TypeTag
template <class FluidSystem, class Indices,
          bool enableTemperature, bool enableEnergy,
          bool enableEvaporation, bool enableBrine,
          bool enableSaltPrecipitation, bool enableDisgasInWater,
          typename Scalar, typename ValueType>
auto createBlackOilFluidState(...);  // flags match BlackOilFluidState template params 1:1

Updated: opm/simulators/wells/WellInterface_impl.hpp

  • createFluidState() becomes a thin wrapper passing its existing static constexpr members as explicit template arguments:
    return createBlackOilFluidState<FluidSystem, Indices,
                                     energyModuleType != EnergyModules::NoTemperature,
                                     has_energy, has_watVapor, has_brine,
                                     has_saltPrecip, has_disgas_in_water,
                                     Scalar>(fluid_composition, pressure, temperature,
                                             saltConcentration, pvtRegionIdx(), name());

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: GitPaean <6847941+GitPaean@users.noreply.github.com>
Copilot AI changed the title [WIP] Expand createFluidState to support rsw and rvw Expand WellInterface::createFluidState() to support rsw/rvw Mar 5, 2026
Copilot stopped work on behalf of GitPaean due to an error March 5, 2026 12:45
Co-authored-by: GitPaean <6847941+GitPaean@users.noreply.github.com>
Copilot AI changed the title Expand WellInterface::createFluidState() to support rsw/rvw Set saltConcentration on fluid state in createFluidState() Mar 5, 2026
… free function

Co-authored-by: GitPaean <6847941+GitPaean@users.noreply.github.com>
Copilot AI changed the title Set saltConcentration on fluid state in createFluidState() Make createFluidState general-purpose; add saltConcentration support Mar 5, 2026
Copilot AI and others added 2 commits March 5, 2026 13:48
…arameters

Co-authored-by: GitPaean <6847941+GitPaean@users.noreply.github.com>
…template params directly

Co-authored-by: GitPaean <6847941+GitPaean@users.noreply.github.com>
Copilot AI changed the title Make createFluidState general-purpose; add saltConcentration support Extract BlackOilFluidState factory into general-purpose free function; drop TypeTag dependency Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants