-
Notifications
You must be signed in to change notification settings - Fork 122
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
Separate keyword validation for fully supported keywords #5866
Open
vkip
wants to merge
3
commits into
OPM:master
Choose a base branch
from
vkip:fully_supported_validation
base: master
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 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 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 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 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,80 @@ | ||
/* | ||
Copyright 2021 Equinor. | ||
|
||
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/>. | ||
*/ | ||
|
||
#if HAVE_CONFIG_H | ||
#include "config.h" | ||
#endif // HAVE_CONFIG_H | ||
|
||
#include <opm/simulators/utils/FullySupportedFlowKeywords.hpp> | ||
|
||
using namespace Opm::KeywordValidation; | ||
namespace Opm::FlowKeywordValidation | ||
{ | ||
|
||
template <> | ||
const SupportedKeywords<std::string>& | ||
fullySupported() | ||
{ | ||
static const SupportedKeywords<std::string> fully_supported_keywords_strings = { | ||
{ | ||
"NEXTSTEP", | ||
{ | ||
{2,{true, is_bool_convertible {}, "NEXTSTEP(NSTEP2): String value must be convertible to bool."}}, // APPLY_TO_FUTURE_REPORT_STEPS | ||
}, | ||
}, | ||
{ | ||
"WCONHIST", | ||
{ | ||
{3,{true, allow_values<std::string> {"ORAT", "WRAT", "GRAT", "LRAT", "RESV", "BHP"}, "WCONHIST(TARGET): should be set to ORAT/WRAT/GRAT/LRAT/RESV or BHP"}}, // CMODE | ||
}, | ||
}, | ||
}; | ||
|
||
return fully_supported_keywords_strings; | ||
} | ||
|
||
|
||
|
||
template <> | ||
const SupportedKeywords<int>& | ||
fullySupported() | ||
{ | ||
static const SupportedKeywords<int> fully_supported_keywords_int = { | ||
}; | ||
|
||
return fully_supported_keywords_int; | ||
} | ||
|
||
template <> | ||
const SupportedKeywords<double>& | ||
fullySupported() | ||
{ | ||
static const SupportedKeywords<double> fully_supported_keywords_double = { | ||
{ | ||
"WPIMULT", | ||
{ | ||
{2,{true, [](double x) { return x > 0; }, "WPIMULT(PIMULT): Well PI multiplier must be a positive number."}}, // PI_MULTIPLIER | ||
}, | ||
}, | ||
}; | ||
|
||
return fully_supported_keywords_double; | ||
} | ||
|
||
} // namespace Opm::FlowKeywordValidation |
This file contains 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,55 @@ | ||
/* | ||
Copyright 2024 Equinor. | ||
|
||
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_FULLYSUPPORTEDFLOWKEYWORDS_HEADER_INCLUDED | ||
#define OPM_FULLYSUPPORTEDFLOWKEYWORDS_HEADER_INCLUDED | ||
|
||
|
||
#include <opm/simulators/flow/KeywordValidation.hpp> | ||
|
||
#include <string> | ||
|
||
/* | ||
Here keywords are defined that are fully supported by flow, but nevertheless | ||
can benefit from a preliminary high-level non-contextual verification. | ||
|
||
The keywords are specified in a mapping with the keyword names as keys, and | ||
values that describe the set of supported items. These are described by a | ||
mapping from the item name to a struct of properties, defined in KeywordValidation.hpp. | ||
|
||
This struct has the following fields: | ||
|
||
critical (bool) : if this is a critical error. | ||
validator (function wrapper) : A function wrapper object that is used to test values. | ||
message (itemal string): an optional message to add to the error reported by flow. | ||
|
||
For convenience there is a small class KeywordValidation::allow_values which | ||
can be initialized with a list of permitted values, and used as a validator. | ||
*/ | ||
|
||
namespace Opm::FlowKeywordValidation | ||
{ | ||
|
||
template <typename T> | ||
const KeywordValidation::SupportedKeywords<T>& fullySupported(); | ||
|
||
} // namespace Opm::FlowKeywordValidation | ||
|
||
|
||
#endif |
This file contains 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imho this is getting out of hand. I'd introduce some struct, e.g.
and adjust constructor to
KeywordValidator(unsupported, partially_supported, fully_supported, special)
and adjust getters accordingly.