Skip to content

Add BlackOilFluidState::createFluidState static factory method#2

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/add-create-fluid-state-function
Draft

Add BlackOilFluidState::createFluidState static factory method#2
Copilot wants to merge 3 commits intomasterfrom
copilot/add-create-fluid-state-function

Conversation

Copy link

Copilot AI commented Mar 5, 2026

createFluidState logic in opm-simulators required passing many TypeTag boolean flags explicitly. Moving it into BlackOilFluidState as a static factory eliminates that redundancy — the class template parameters already encode all feature flags.

Changes

  • BlackOilFluidState.hpp: Added createFluidState<ValueType> static method declaration; added <string_view> and <vector> includes.
  • BlackOilFluidState_impl.hpp (new): Out-of-class implementation included at the bottom of the header. Three-step algorithm:
    1. Compute dissolution/vaporization factors (Rs, Rv, Rsw, Rvw) and invB per phase
    2. Compute reservoir-volume saturations from surface compositions, with mutual-dissolution corrections (Rs/Rv for oil+gas, Rsw/Rvw for water+gas); normalizes by the sum of all active phases (fixing a latent bug in the reference implementation that excluded water from the denominator)
    3. Normalize saturations; compute densities and enthalpies
    • Uses Opm::getValue() in error messages so formatting is safe with AD Evaluation types
    • static_assert(fluidSystemIsStatic) guards against use with non-static fluid systems
  • test_blackoilfluidstate.cpp: Compile-time static_assert verifying the return type and signature of createFluidState<Evaluation>.

Usage

// Caller selects the desired specialization — no TypeTag needed.
using FluidState = BlackOilFluidState<Evaluation, FluidSystem,
    /*storeTemperature=*/true, /*storeEnthalpy=*/false,
    /*enableDissolution=*/true, /*enableVapwat=*/false,
    /*enableBrine=*/true>;

auto fs = FluidState::createFluidState(
    fluidComposition, pressure, temperature, saltConc, pvtRegionIdx, wellName);

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 5, 2026 14:31
Co-authored-by: GitPaean <6847941+GitPaean@users.noreply.github.com>
Co-authored-by: GitPaean <6847941+GitPaean@users.noreply.github.com>
Copilot AI changed the title [WIP] Add function to create fluid state in BlackoilFluidState Add BlackOilFluidState::createFluidState static factory method 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