refactor: Add instance generators for constitutive drivers#3687
refactor: Add instance generators for constitutive drivers#3687dkachuma wants to merge 10 commits into
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #3687 +/- ##
========================================
Coverage 57.56% 57.56%
========================================
Files 1235 1235
Lines 106973 106973
========================================
Hits 61578 61578
Misses 45395 45395 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors constitutive driver “runTest” explicit-instantiation boilerplate by switching from many hand-written .cpp instantiation translation units to CMake-driven generation from .cpp.template files plus a JSON spec. This is intended to make adding new constitutive models simpler and more uniform.
Changes:
- Replace per-model explicit instantiation
.cppfiles (PVT + relperm) with generated sources driven bykernelSpecs.json. - Add driver-specific dispatch typelist template generation (
DriverDispatchTypeList.hpp.template) and wire it intoconstitutiveDrivers/CMakeLists.txt. - Extend
generateKernels()to accept an optionalLIST_TEMPLATEfor dispatch type list generation.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreComponents/constitutiveDrivers/relativePermeability/RelpermDriverVanGenuchtenStone2RunTest.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/relativePermeability/RelpermDriverVanGenuchtenBakerRunTest.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/relativePermeability/RelpermDriverTableRelativeRunTest.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/relativePermeability/RelpermDriverTableRelativeHysteresisRunTest.cpp | Removed explicit instantiation TU (previously also carried hysteresis trait specialization). |
| src/coreComponents/constitutiveDrivers/relativePermeability/RelpermDriverRunTestRelPerm.cpp.template | New template for generated relperm runTest explicit instantiation. |
| src/coreComponents/constitutiveDrivers/relativePermeability/RelpermDriverBrooksCoreyStone2RunTest.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/relativePermeability/RelpermDriverBrooksCoreyRunTest.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/kernelSpecs.json | Adds JSON spec listing relperm + fluid model instantiation combinations. |
| src/coreComponents/constitutiveDrivers/fluid/multiFluid/PVTDriverRunTestFluid.cpp.template | New template for generated PVT runTest explicit instantiation. |
| src/coreComponents/constitutiveDrivers/fluid/multiFluid/constant/PVTDriverRunTestInvariantImmiscibleFluid.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/fluid/multiFluid/compositional/PVTDriverRunTestCompositionalTwoPhasePhillipsBrine.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/fluid/multiFluid/compositional/PVTDriverRunTestCompositionalTwoPhaseLohrenzBrayClarkViscosity.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/fluid/multiFluid/compositional/PVTDriverRunTestCompositionalTwoPhaseConstantViscosity.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/fluid/multiFluid/compositional/PVTDriverRunTestCompositionalThreePhaseLohrenzBrayClarkViscosity.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/fluid/multiFluid/compositional/PVTDriverRunTestCompositionalKValuePhillipsBrine.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/fluid/multiFluid/compositional/PVTDriverRunTestCompositionalKValueLohrenzBrayClarkViscosity.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/fluid/multiFluid/CO2Brine/PVTDriverRunTestCO2BrinePhillipsThermalFluid.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/fluid/multiFluid/CO2Brine/PVTDriverRunTestCO2BrinePhillipsFluid.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/fluid/multiFluid/CO2Brine/PVTDriverRunTestCO2BrineEzrokhiThermalFluid.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/fluid/multiFluid/blackOil/PVTDriverRunTestDeadOilFluid.cpp | Removed explicit instantiation TU (now intended to be generated). |
| src/coreComponents/constitutiveDrivers/DriverDispatchTypeList.hpp.template | Adds constitutiveDrivers-specific dispatch typelist template for generated headers. |
| src/coreComponents/constitutiveDrivers/CMakeLists.txt | Wires kernel generation into constitutiveDrivers build and removes per-model instantiation sources. |
| src/cmake/GeosxMacros.cmake | Extends generateKernels() with LIST_TEMPLATE selection for dispatch type list generation. |
Comments suppressed due to low confidence (1)
src/coreComponents/constitutiveDrivers/relativePermeability/RelpermDriverRunTestRelPerm.cpp.template:27
RelpermDriver::runTestrelies on theHasHysteresis<RELPERM_TYPE>trait to decide whether to populate historical saturation fields. The previous dedicated instantiation TU forTableRelativePermeabilityHysteresisprovided a specialization setting this trait totrue, but the new generated instantiation file template does not, so hysteresis run-tests will silently run with the non-hysteresis path.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Initial plan * Fix typos in kernelSpecs embedded docs --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
| relativePermeability/RelpermDriverRunTestRelPerm.cpp.template) | ||
|
|
||
| foreach( kernelTemplateFile ${kernelTemplateFileList} ) | ||
| get_filename_component( jsonKey ${kernelTemplateFile} NAME_WE ) |
| // Hysteresis traits | ||
| template< typename RELPERM_TYPE > | ||
| template< typename RELPERM_TYPE, typename = void > | ||
| struct HasHysteresis : std::false_type {}; | ||
|
|
||
| template< typename RELPERM_TYPE > | ||
| struct HasHysteresis< RELPERM_TYPE, std::void_t< decltype(RELPERM_TYPE::viewKeyStruct::phaseHasHysteresisString()) > > : std::true_type {}; |
This PR replaces hardcoded constitutive driver test instances with an auto-generated CMake/JSON workflow. This significantly reduces boilerplate and makes adding new fluid or relative permeability models as simple as adding a single line to a JSON file.
PVTDriverRunTestFluid.cpp.template,RelpermDriverRunTestRelPerm.cpp.template, andDriverDispatchTypeList.hpp.template).kernelSpecs.jsonto centrally define and manage all fluid and relative permeability model combinations.generateKernelsfunction inGeosxMacros.cmaketo accept aLIST_TEMPLATEargument for custom dispatch type lists..cppfiles in theconstitutiveDriversmodule, as these are now dynamically generated during the build step.