mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-11-05 13:47:32 -06:00
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
54 lines
1.8 KiB
C++
54 lines
1.8 KiB
C++
/*
|
|
Copyright 2020 Equinor ASA.
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef OPM_PY_BLACKOIL_SIMULATOR_HEADER_INCLUDED
|
|
#define OPM_PY_BLACKOIL_SIMULATOR_HEADER_INCLUDED
|
|
|
|
#include <opm/simulators/flow/python/PyBaseSimulator.hpp>
|
|
#include <opm/simulators/flow/TTagFlowProblemTPFA.hpp>
|
|
|
|
#include <memory>
|
|
|
|
namespace Opm::Pybind {
|
|
|
|
class PyBlackOilSimulator : public PyBaseSimulator<Opm::Properties::TTag::FlowProblemTPFA>
|
|
{
|
|
private:
|
|
using BaseType = PyBaseSimulator<Opm::Properties::TTag::FlowProblemTPFA>;
|
|
using TypeTag = Opm::Properties::TTag::FlowProblemTPFA;
|
|
|
|
public:
|
|
PyBlackOilSimulator(const std::string& deck_filename,
|
|
const std::vector<std::string>& args)
|
|
: BaseType(deck_filename, args)
|
|
{}
|
|
|
|
PyBlackOilSimulator(std::shared_ptr<Opm::Deck> deck,
|
|
std::shared_ptr<Opm::EclipseState> state,
|
|
std::shared_ptr<Opm::Schedule> schedule,
|
|
std::shared_ptr<Opm::SummaryConfig> summary_config,
|
|
const std::vector<std::string>& args)
|
|
: BaseType(deck, state, schedule, summary_config, args)
|
|
{}
|
|
|
|
};
|
|
|
|
} // namespace Opm::Pybind
|
|
#endif // OPM_PY_BLACKOIL_SIMULATOR_HEADER_INCLUDED
|