Files
opm-simulators/python/setup.py.in
T
Svenn Tveit 32dd09c78f Add Python gas-water simulator and refactor to template base class
Extend the Python blackoil simulator to support two-phase gas-water
simulations by extracting common functionality into a template base
class and implementing proper module separation.

- Extract PyBaseSimulator<TypeTag> template base class containing all
  common simulator functionality (20+ methods including advance, run,
  step, property access, and MPI handling)
- Add PyGasWaterSimulator for two-phase gas-water simulations using
  FlowGasWaterProblem TypeTag with oil phase disabled
- Split Python modules to avoid ODR violations:
  - BlackOil.so for PyBlackOilSimulator (FlowProblemTPFA)
  - GasWater.so for PyGasWaterSimulator (FlowGasWaterProblem)
- Implement proper template instantiation control with explicit
  instantiations per module

- Eliminate ~400 lines of code duplication between simulators
- Clean inheritance hierarchy: derived classes contain only constructors
- Type-safe specialization through OPM's TypeTag property system
- Separate docstring generation for each simulator type
- Independent build targets with shared infrastructure

- Update CMakeLists.txt to support multiple pybind11 modules
- Add docstrings_gw_simulators.json for gas-water simulator documentation
- Remove centralized Pybind11Exporter.cpp in favor of distributed exports
- Implement proper build dependencies and custom targets

This establishes a scalable foundation for extending OPM's Python
bindings to support additional simulator types (thermal, polymer,
solvent) while maintaining type safety and avoiding symbol conflicts.

Files changed: 21 files, 915 insertions, 428 deletions
2025-09-17 10:06:44 +02:00

53 lines
1.8 KiB
Plaintext

from skbuild import setup
import os
# This script is used by the docker/Dockerfile to build wheels for the python bindings.
setupdir = os.path.dirname(__file__)
if setupdir != '':
os.chdir( setupdir )
with open("README.md", "r") as fh:
long_description = fh.read()
with open("requirements.txt", "r") as fh:
requires = [line.rstrip() for line in fh]
# NOTE (2025-09-12): Removed legacy `setup_requires` and `test_suite` arguments.
# - `setup_requires` triggers setuptools' deprecated fetch_build_eggs path
# (_DeprecatedInstaller). We build via PEP 517 (see pyproject.toml with
# scikit-build), so build-time deps must be declared there instead.
# - `test_suite` is not a supported distribution option and produced
# "Unknown distribution option: 'test_suite'" warnings.
setup(
name='opm-simulators',
version = '@opm-simulators_VERSION@' + '@opm-simulators_PYTHON_PACKAGE_VERSION@',
url='http://www.opm-project.org',
author='The Open Porous Media Project',
author_email='opmuser@gmail.com',
description='OPM-Simulators Python bindings',
long_description=long_description,
long_description_content_type="text/markdown",
packages=[
'opm',
'opm.simulators'
],
package_data={
'opm': [
'$<TARGET_FILE_NAME:BlackOil>',
'$<TARGET_FILE_NAME:GasWater>'
]
},
include_package_data=True,
# SPDX license expression to replace deprecated license classifier usage.
license='GPL-3.0-or-later',
install_requires=requires,
python_requires='>=3.8',
# NOTE (2025-09-12): Remove deprecated license classifier in favor of
# SPDX license expression above. Keep non-license classifiers only.
classifiers=[
"Programming Language :: Python :: 3",
],
)