Skip to content

Commit 54cd9a5

Browse files
authored
refactor: Add instance generators for constitutive drivers (#3687)
* Add kernelSpec.json * Add relative permeability template * Add hysteresis check * Correct embedded documentation typos in kernelSpecs.json (#4086) * Fix typos in kernelSpecs embedded docs
1 parent d83bf22 commit 54cd9a5

24 files changed

Lines changed: 152 additions & 454 deletions

src/cmake/GeosxMacros.cmake

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,18 +221,22 @@ endmacro()
221221
## KEY <key to use when looking up the kernel specification in the JSON object>
222222
## RESULT <name of the variable to store the list of generated files in>
223223
## SPLIT <delimiter used to split the instantiation strings into lists>
224-
## JSON <name of the JSON object variable> )
224+
## JSON <name of the JSON object variable>
225+
## LIST_TEMPLATE <path to the dispatch type list template> )
225226
##
226227
## This function generates kernel files from a template.
227228
## The kernel specification is looked up in a JSON object using the provided key.
228229
## The list of generated files is stored in the provided variable in the parent scope.
229230
## The delimiter is used to split the instantiation strings into lists of symbol values.
230231
## The JSON object is expected to be defined in the calling scope.
232+
## The dispatch type list template will be used to generate a list of types for dispatch of the
233+
## kernel. If this is not specified KernelDispatchTypeList.hpp.template in the parent directory
234+
## will be used.
231235
##
232236
##------------------------------------------------------------------------------
233237
function(generateKernels)
234238
set(options)
235-
set(oneValueArgs TEMPLATE KEY HEADERS SOURCES SPLIT JSON)
239+
set(oneValueArgs TEMPLATE KEY HEADERS SOURCES SPLIT JSON LIST_TEMPLATE)
236240
set(multiValueArgs)
237241

238242
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
@@ -309,7 +313,11 @@ function(generateKernels)
309313
set(generatedFileName "${CMAKE_BINARY_DIR}/include/${relativeSourceDir}/${localRelDir}/${KERNEL_GROUP_NAME}DispatchTypeList.hpp")
310314
string(REPLACE "coreComponents/" "" generatedFileName "${generatedFileName}")
311315
message(STATUS "Generating file: ${generatedFileName}")
312-
configure_file(../KernelDispatchTypeList.hpp.template "${generatedFileName}" @ONLY)
316+
set(LIST_TEMPLATE "${ARG_LIST_TEMPLATE}")
317+
if ("${LIST_TEMPLATE}" STREQUAL "")
318+
set(LIST_TEMPLATE "../KernelDispatchTypeList.hpp.template")
319+
endif()
320+
configure_file(${LIST_TEMPLATE} "${generatedFileName}" @ONLY)
313321
list(APPEND generatedHeadersList ${generatedFileName})
314322

315323
# The list of generated files is returned by setting the variable in the parent scope

src/coreComponents/constitutiveDrivers/CMakeLists.txt

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,7 @@ set( constitutiveDrivers_headers
3636
set( constitutiveDrivers_sources
3737
ConstitutiveDriver.cpp
3838
fluid/multiFluid/PVTDriver.cpp
39-
fluid/multiFluid/constant/PVTDriverRunTestInvariantImmiscibleFluid.cpp
40-
fluid/multiFluid/blackOil/PVTDriverRunTestDeadOilFluid.cpp
41-
fluid/multiFluid/CO2Brine/PVTDriverRunTestCO2BrinePhillipsFluid.cpp
42-
fluid/multiFluid/CO2Brine/PVTDriverRunTestCO2BrinePhillipsThermalFluid.cpp
43-
fluid/multiFluid/CO2Brine/PVTDriverRunTestCO2BrineEzrokhiFluid.cpp
44-
fluid/multiFluid/CO2Brine/PVTDriverRunTestCO2BrineEzrokhiThermalFluid.cpp
45-
fluid/multiFluid/compositional/PVTDriverRunTestCompositionalKValueLohrenzBrayClarkViscosity.cpp
46-
fluid/multiFluid/compositional/PVTDriverRunTestCompositionalKValuePhillipsBrine.cpp
47-
fluid/multiFluid/compositional/PVTDriverRunTestCompositionalThreePhaseLohrenzBrayClarkViscosity.cpp
48-
fluid/multiFluid/compositional/PVTDriverRunTestCompositionalTwoPhaseConstantViscosity.cpp
49-
fluid/multiFluid/compositional/PVTDriverRunTestCompositionalTwoPhasePhillipsBrine.cpp
50-
fluid/multiFluid/compositional/PVTDriverRunTestCompositionalTwoPhaseLohrenzBrayClarkViscosity.cpp
5139
relativePermeability/RelpermDriver.cpp
52-
relativePermeability/RelpermDriverBrooksCoreyBakerRunTest.cpp
53-
relativePermeability/RelpermDriverBrooksCoreyStone2RunTest.cpp
54-
relativePermeability/RelpermDriverBrooksCoreyRunTest.cpp
55-
relativePermeability/RelpermDriverVanGenuchtenBakerRunTest.cpp
56-
relativePermeability/RelpermDriverVanGenuchtenStone2RunTest.cpp
57-
relativePermeability/RelpermDriverTableRelativeRunTest.cpp
58-
relativePermeability/RelpermDriverTableRelativeHysteresisRunTest.cpp
5940
solid/TriaxialDriver.cpp
6041
)
6142

@@ -64,6 +45,24 @@ set( dependencyList ${parallelDeps} constitutive events )
6445
geos_decorate_link_dependencies( LIST decoratedDependencies
6546
DEPENDENCIES ${dependencyList} )
6647

48+
file( READ "${CMAKE_CURRENT_LIST_DIR}/kernelSpecs.json" kernelSpecs )
49+
set( kernelTemplateFileList
50+
fluid/multiFluid/PVTDriverRunTestFluid.cpp.template
51+
relativePermeability/RelpermDriverRunTestRelPerm.cpp.template)
52+
53+
foreach( kernelTemplateFile ${kernelTemplateFileList} )
54+
get_filename_component( jsonKey ${kernelTemplateFile} NAME_WE )
55+
generateKernels( TEMPLATE ${kernelTemplateFile}
56+
JSON kernelSpecs
57+
KEY ${jsonKey}
58+
HEADERS headerFiles
59+
SOURCES sourceFiles
60+
LIST_TEMPLATE ${CMAKE_CURRENT_LIST_DIR}/DriverDispatchTypeList.hpp.template )
61+
62+
list(APPEND constitutiveDrivers_headers ${headerFiles})
63+
list(APPEND constitutiveDrivers_sources ${sourceFiles})
64+
endforeach()
65+
6766
blt_add_library( NAME constitutiveDrivers
6867
SOURCES ${constitutiveDrivers_sources}
6968
HEADERS ${constitutiveDrivers_headers}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* ------------------------------------------------------------------------------------------------------------
3+
* SPDX-License-Identifier: LGPL-2.1-only
4+
*
5+
* Copyright (c) 2018-2019 Lawrence Livermore National Security LLC
6+
* Copyright (c) 2018-2019 The Board of Trustees of the Leland Stanford Junior University
7+
* Copyright (c) 2018-2019 Total, S.A
8+
* Copyright (c) 2019- GEOSX Contributors
9+
* All rights reserved
10+
*
11+
* See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12+
* ------------------------------------------------------------------------------------------------------------
13+
*/
14+
15+
/**
16+
* @file @KERNEL_GROUP_NAME@DispatchTypeList.hpp
17+
*/
18+
19+
#ifndef GEOS_@KERNEL_GROUP_NAME@_DISPATCHTYPELIST_HPP
20+
#define GEOS_@KERNEL_GROUP_NAME@_DISPATCHTYPELIST_HPP
21+
22+
#include "common/TypeDispatch.hpp"
23+
24+
namespace geos
25+
{
26+
27+
using namespace constitutive;
28+
29+
using @KERNEL_GROUP_NAME@DispatchTypeList = types::TypeList<
30+
@typeCombinationList@
31+
>;
32+
33+
} // namespace geos
34+
35+
#endif //GEOS_@KERNEL_GROUP_NAME@_DISPATCHTYPELIST_HPP

src/coreComponents/constitutiveDrivers/fluid/multiFluid/CO2Brine/PVTDriverRunTestCO2BrineEzrokhiThermalFluid.cpp

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/coreComponents/constitutiveDrivers/fluid/multiFluid/CO2Brine/PVTDriverRunTestCO2BrinePhillipsFluid.cpp

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/coreComponents/constitutiveDrivers/fluid/multiFluid/CO2Brine/PVTDriverRunTestCO2BrinePhillipsThermalFluid.cpp

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/coreComponents/constitutiveDrivers/fluid/multiFluid/CO2Brine/PVTDriverRunTestCO2BrineEzrokhiFluid.cpp renamed to src/coreComponents/constitutiveDrivers/fluid/multiFluid/PVTDriverRunTestFluid.cpp.template

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@
1313
* ------------------------------------------------------------------------------------------------------------
1414
*/
1515

16+
/*
17+
* PVTDriverRunTestFluid_@FLUID@.cpp
18+
*/
19+
1620
#include "constitutiveDrivers/fluid/multiFluid/PVTDriverRunTest.hpp"
17-
#include "constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp"
21+
#include "constitutive/fluid/multifluid/MultiFluidSelector.hpp"
1822

1923
namespace geos
2024
{
21-
template void PVTDriver::runTest< constitutive::CO2BrineEzrokhiFluid >( constitutive::CO2BrineEzrokhiFluid &, arrayView2d< real64 > const & );
25+
using namespace constitutive;
26+
template void PVTDriver::runTest< @FLUID@ >( @FLUID@ &, arrayView2d< real64 > const & );
2227
}

src/coreComponents/constitutiveDrivers/fluid/multiFluid/blackOil/PVTDriverRunTestDeadOilFluid.cpp

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/coreComponents/constitutiveDrivers/fluid/multiFluid/compositional/PVTDriverRunTestCompositionalKValueLohrenzBrayClarkViscosity.cpp

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/coreComponents/constitutiveDrivers/fluid/multiFluid/compositional/PVTDriverRunTestCompositionalKValuePhillipsBrine.cpp

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)