-
Couldn't load subscription status.
- Fork 97
feat: Adaptive multilinear interpolation for OBL solver #3391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
av-novikov
wants to merge
47
commits into
develop
Choose a base branch
from
feature/anovikov/adaptive_obl
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 36 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
db670c2
Initial commit: fix assembly of molecular diffusion
av-novikov 6833041
Reorganize MultivariableTableFunctionKernels, change name to Multilin…
av-novikov 9c9e28e
Introduce multilinear adaptive interpolation kernel
av-novikov 585337f
Draft of adaptive multilinear interpolator test
av-novikov 3d931f1
Introduce convergence test for multilinear adaptive interpolator
av-novikov 2dfae1a
Fix integer overflow - use __uint128_t for indexation
av-novikov d36873f
Add descriptions of some methods
av-novikov ada5e41
Use only two resolutions in convergence test of multilinear adaptive …
av-novikov 5d12ee9
Small fix of include declarations
av-novikov c8bed1a
Introduce OBLFluid constitutive
av-novikov 16542ba
Move hypercube and point data storage from adaptive interpolation ker…
av-novikov 4df5792
Initialize PythonFunction in OBLFluid, OBL axes parameters are moved …
av-novikov c06e8d8
Check if Python function actually assigned to wrapper before launchin…
av-novikov 39b2a3c
Expose PythonFunction interfaces to Python
av-novikov f6fa56d
Create a source file for PythonFunction
av-novikov e98dd33
Update OBL static models
av-novikov 052dee6
Add an example of Python-based model with interfaces from Makutu team
av-novikov c48636e
Use LvArray::python::PythonFunction
av-novikov c5c67f2
Recover adaptive interpolation test
av-novikov 28bfa6a
Suppress unused parameter error
av-novikov a6f9750
Merge branch develop into feature/anovikov/adaptive_obl
av-novikov 023ef96
Move Python interfaces to GEOS, merge obl example into a single script
av-novikov b5d8931
Update LvArray commit
av-novikov 583e6b6
Uncrustify formatting
av-novikov ed6c873
Move new Python interfaces to geosPythonPackages -> pygeos-tools
av-novikov 3d606c8
Merge branch 'develop' into feature/anovikov/adaptive_obl
av-novikov c3843fc
Create a base XML file for model example
av-novikov fc52d93
Applying changes from review
av-novikov 9e1ee77
Fix OBL solver according to changes in open-darts operators, fix asse…
av-novikov 4110b43
Introduce number of solid components and adjust chopping accordingly
av-novikov 612865d
PHREEQC-based limestone dissolution by carbonated water: 1D and 2D se…
av-novikov 88f4f71
Clean up OBL examples, they are moved to geosPythonPackages
av-novikov defed93
Merge branch develop into feature/anovikov/adaptive_obl
av-novikov ab1733f
Fix FunctionManager::createChild
av-novikov c6b8ad8
Fix dangling references in MultifluidTest.hpp
av-novikov b5d4dc0
Merge branch 'develop' into feature/anovikov/adaptive_obl
rrsettgast aeb36fa
Receive cycleNumber from Python in output/execute/collect calls
av-novikov 3c66fdc
Uncrustify formatting
av-novikov b4a296b
Update LvArray
av-novikov e16b427
Remove commented code from OBLFluid.cpp
av-novikov 5f95af0
Simplify logic for deducing m_intepolatorType as only multilinear one…
av-novikov 76559a8
Impose GEOS_USE_PYGEOSX/ENABLE_PYGEOSX guards for Python-dependent fu…
av-novikov afca323
Uncrustify check
av-novikov 3ea2b41
Merge develop
av-novikov de5e78a
Fix includes
av-novikov ffef26d
Merge branch 'develop' into feature/anovikov/adaptive_obl
av-novikov 6076912
Switch to True-IMPES reduction and Galerkin coarse grid method
av-novikov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| /* | ||
| * ------------------------------------------------------------------------------------------------------------ | ||
| * SPDX-License-Identifier: LGPL-2.1-only | ||
| * | ||
| * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC | ||
| * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University | ||
| * Copyright (c) 2018-2020 TotalEnergies | ||
| * Copyright (c) 2019- GEOSX Contributors | ||
| * All rights reserved | ||
| * | ||
| * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. | ||
| * ------------------------------------------------------------------------------------------------------------ | ||
| */ | ||
|
|
||
| /** | ||
| * @file OBLFluid.cpp | ||
| */ | ||
|
|
||
| #include "OBLFluid.hpp" | ||
| #include "functions/FunctionManager.hpp" | ||
| #include "dataRepository/InputFlags.hpp" | ||
| #include "dataRepository/RestartFlags.hpp" | ||
|
|
||
| namespace geos | ||
| { | ||
|
|
||
| using namespace dataRepository; | ||
|
|
||
| namespace constitutive | ||
| { | ||
|
|
||
| MultivariableTableFunction const * | ||
| makeOBLOperatorsTable( string const & OBLOperatorsTableFile, | ||
| string const & OBLFluidName, | ||
| FunctionManager & functionManager ) | ||
| { | ||
| string const tableName = OBLFluidName + "OBL_table"; | ||
| if( functionManager.hasGroup< MultivariableTableFunction >( tableName ) ) | ||
| { | ||
| return functionManager.getGroupPointer< MultivariableTableFunction >( tableName ); | ||
| } | ||
| else | ||
| { | ||
| MultivariableTableFunction * const table = dynamicCast< MultivariableTableFunction * >( functionManager.createChild( "MultivariableTableFunction", tableName ) ); | ||
| table->initializeFunctionFromFile ( OBLOperatorsTableFile ); | ||
| return table; | ||
| } | ||
| } | ||
|
|
||
| template< typename INDEX_T = __uint128_t > | ||
| PythonFunction< INDEX_T > * | ||
| makePythonFunction( string const & OBLFluidName, FunctionManager & functionManager ) | ||
| { | ||
| string const pythonFunctionName = OBLFluidName + "PythonFunction"; | ||
| if( functionManager.hasGroup< PythonFunction< INDEX_T > >( pythonFunctionName )) | ||
| { | ||
| return functionManager.getGroupPointer< PythonFunction< INDEX_T > >( pythonFunctionName ); | ||
| } | ||
| else | ||
| { | ||
| PythonFunction< INDEX_T > * function = dynamicCast< PythonFunction< INDEX_T > * >( functionManager.createChild( "PythonFunction", pythonFunctionName )); | ||
| return function; | ||
| } | ||
| } | ||
|
|
||
| OBLFluid::OBLFluid( string const & name, Group * const parent ) | ||
| : ConstitutiveBase( name, parent ), | ||
| m_OBLOperatorsTable( nullptr ), | ||
| m_pythonFunction( nullptr ) | ||
| { | ||
| this->registerWrapper( viewKeyStruct::interpolatorModeString(), &m_interpolatorModeString ). | ||
| setInputFlag( InputFlags::REQUIRED ). | ||
| setDescription( "OBL interpolator mode: static or adaptive" ); | ||
|
|
||
| this->registerWrapper( viewKeyStruct::interpolatorTypeString(), &m_interpolatorTypeString ). | ||
| setInputFlag( InputFlags::OPTIONAL ). | ||
| setDescription( "OBL interpolator type: multilinear or linear" ); | ||
|
|
||
| this->registerWrapper( viewKeyStruct::oblOperatorsTableFileString(), &m_OBLOperatorsTableFile ). | ||
| setInputFlag( InputFlags::OPTIONAL ). | ||
| setDescription( "File containing OBL operator values for static mode interpolation" ); | ||
| } | ||
|
|
||
| void OBLFluid::postInputInitialization() | ||
| { | ||
| ConstitutiveBase::postInputInitialization(); | ||
|
|
||
| // set interpolator mode | ||
| GEOS_THROW_IF( m_interpolatorModeString.empty(), | ||
| GEOS_FMT( "{}: Interpolator mode string is empty", | ||
| getFullName() ), | ||
| InputError ); | ||
| m_interpolatorMode = EnumStrings<OBLInterpolatorMode>::fromString( m_interpolatorModeString ); | ||
|
|
||
| // set interpolator type | ||
| /*GEOS_WARNING_IF( m_interpolatorTypeString.empty() || | ||
av-novikov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| (m_interpolatorTypeString != "multilinear" && | ||
| m_interpolatorTypeString != "linear"), | ||
| GEOS_FMT( "{}: Invalid interpolator type, using multilinear interpolator", | ||
| getFullName() ) );*/ | ||
|
|
||
| GEOS_WARNING_IF( m_interpolatorTypeString == "linear", | ||
av-novikov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| GEOS_FMT( "{}: Linear interpolator type is not supported yet, using multilinear interpolator", | ||
| getFullName()) ); | ||
|
|
||
| if( !m_interpolatorTypeString.empty()) | ||
| { | ||
| if( m_interpolatorTypeString == "multilinear" ) | ||
| m_interpolatorType = OBLInterpolatorType::Multilinear; | ||
| else if( m_interpolatorTypeString == "linear" ) | ||
| m_interpolatorType = OBLInterpolatorType::Multilinear; | ||
| else | ||
| m_interpolatorType = OBLInterpolatorType::Multilinear; | ||
| } | ||
| else | ||
| m_interpolatorType = OBLInterpolatorType::Multilinear; | ||
|
|
||
| // set table file | ||
| GEOS_THROW_IF( m_OBLOperatorsTableFile.empty() && | ||
| m_interpolatorMode == OBLInterpolatorMode::Static, | ||
| GEOS_FMT( "{}: Invalid operator table file", | ||
| getFullName() ), | ||
| InputError ); | ||
|
|
||
|
|
||
| if( m_interpolatorMode == OBLInterpolatorMode::Static ) | ||
| m_OBLOperatorsTable = makeOBLOperatorsTable( m_OBLOperatorsTableFile, getName(), FunctionManager::getInstance()); | ||
| else if( m_interpolatorMode == OBLInterpolatorMode::Adaptive ) | ||
| m_pythonFunction = makePythonFunction< longIndex >( getName(), FunctionManager::getInstance()); | ||
|
|
||
| // raise intialization flag | ||
| m_isInitialized = true; | ||
av-novikov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| REGISTER_CATALOG_ENTRY( ConstitutiveBase, OBLFluid, string const &, Group * const ) | ||
|
|
||
| } // namespace constitutive | ||
|
|
||
| } // namespace geos | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| /* | ||
| * ------------------------------------------------------------------------------------------------------------ | ||
| * SPDX-License-Identifier: LGPL-2.1-only | ||
| * | ||
| * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC | ||
| * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University | ||
| * Copyright (c) 2018-2020 TotalEnergies | ||
| * Copyright (c) 2019- GEOSX Contributors | ||
| * All rights reserved | ||
| * | ||
| * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. | ||
| * ------------------------------------------------------------------------------------------------------------ | ||
| */ | ||
|
|
||
| /** | ||
| * @file OBLFluid.hpp | ||
| */ | ||
|
|
||
| #ifndef GEOS_CONSTITUTIVE_FLUID_OBLFLUID_HPP_ | ||
| #define GEOS_CONSTITUTIVE_FLUID_OBLFLUID_HPP_ | ||
|
|
||
| #include "constitutive/ConstitutiveBase.hpp" | ||
| #include "functions/MultivariableTableFunction.hpp" | ||
| #include "functions/PythonFunction.hpp" | ||
|
|
||
| namespace geos | ||
| { | ||
| namespace constitutive | ||
| { | ||
|
|
||
| enum OBLInterpolatorMode : integer | ||
| { | ||
| Static = 0, ///< static interpolation from a given tabled data | ||
| Adaptive = 1 ///< adaptive interpolation from a given interface to function | ||
| }; | ||
|
|
||
| ENUM_STRINGS( OBLInterpolatorMode, | ||
| "static", | ||
| "adaptive" ); | ||
|
|
||
| enum OBLInterpolatorType : integer | ||
| { | ||
| Multilinear = 0, ///< multilinear interpolation | ||
| Linear = 1 ///< linear interpolation | ||
| }; | ||
|
|
||
| class OBLFluid : public ConstitutiveBase | ||
| { | ||
| public: | ||
| using longIndex = __uint128_t; | ||
|
|
||
| OBLFluid( string const & name, Group * const parent ); | ||
| /** | ||
| * @brief name of the constitutive in the object catalog | ||
| * @return string that contains the catalog name to generate a new object through the object catalog. | ||
| */ | ||
| static string catalogName() { return "OBLFluid"; } | ||
| /** | ||
| * @copydoc ConstitutiveBase::getCatalogName() | ||
| */ | ||
| virtual string getCatalogName() const override { return catalogName(); } | ||
| /** | ||
| * @struct viewKeyStruct holds char strings and viewKeys for fast lookup | ||
| */ | ||
| struct viewKeyStruct : ConstitutiveBase::viewKeyStruct | ||
| { | ||
| // input | ||
| static constexpr char const * interpolatorModeString() { return "interpolatorMode"; } | ||
| static constexpr char const * interpolatorTypeString() { return "interpolatorType"; } | ||
| static constexpr char const * oblOperatorsTableFileString() { return "oblOperatorsTableFile"; } | ||
| }; | ||
| /** | ||
| * @brief getter to the pointer to OBL operators table | ||
| * @return pointer to OBL operators table. | ||
| */ | ||
| MultivariableTableFunction const & getTable() const | ||
| { | ||
| GEOS_ERROR_IF( m_OBLOperatorsTable == nullptr, "m_OBLOperatorsTable is not initialized" ); | ||
| return *m_OBLOperatorsTable; | ||
| } | ||
| /** | ||
| * @brief getter to the Python-based evaluator | ||
| * @return pointer to the Python-based evaluator. | ||
| */ | ||
| template< typename INDEX_T = longIndex > | ||
| PythonFunction< INDEX_T > * getPythonFunction() | ||
| { | ||
| GEOS_ERROR_IF( m_pythonFunction == nullptr, "m_pythonFunction is not initialized" ); | ||
| return m_pythonFunction; | ||
| } | ||
| /** | ||
| * @brief initialize input | ||
| */ | ||
| void initialize() | ||
| { | ||
| if( !m_isInitialized ) | ||
| { | ||
| postInputInitialization(); | ||
| } | ||
| } | ||
| /** | ||
| * @brief Retrieves the current OBL interpolator mode. | ||
| * @return OBLInterpolatorMode The current interpolation mode (Static or Adaptive). | ||
| */ | ||
| OBLInterpolatorMode getInterpolatorMode() const { return m_interpolatorMode; }; | ||
| /** | ||
| * @brief Retrieves the current OBL interpolator type. | ||
| * @return OBLInterpolatorType The current interpolation type (Multilinear or Linear). | ||
| */ | ||
| OBLInterpolatorType getInterpolatorType() const { return m_interpolatorType; }; | ||
| private: | ||
| /// OBL interpolator mode | ||
| OBLInterpolatorMode m_interpolatorMode; | ||
|
|
||
| /// corresponding input string | ||
| string m_interpolatorModeString; | ||
|
|
||
| /// OBL interpolator type | ||
| OBLInterpolatorType m_interpolatorType; | ||
|
|
||
| /// corresponding input string | ||
| string m_interpolatorTypeString; | ||
|
|
||
| /// OBL operators table file (if OBL physics becomes consitutive, multiple regions will be supported ) | ||
| Path m_OBLOperatorsTableFile; | ||
|
|
||
| /// OBL operators table function tabulated vs all primary variables | ||
| MultivariableTableFunction const * m_OBLOperatorsTable; | ||
|
|
||
| /// OBL operators with access to Python-base exact evaluator | ||
| PythonFunction< longIndex > * m_pythonFunction; | ||
|
|
||
| /// Flag to check if contitutive is initialized or not | ||
| bool m_isInitialized = false; | ||
|
|
||
| /** | ||
| * @copydoc dataRepository::Group::postInputInitialization() | ||
| */ | ||
| virtual void postInputInitialization() override; | ||
| }; | ||
|
|
||
| } //namespace constitutive | ||
|
|
||
| } //namespace geos | ||
|
|
||
|
|
||
| #endif //GEOS_CONSTITUTIVE_FLUID_OBLFLUID_HPP_ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.