-
Notifications
You must be signed in to change notification settings - Fork 8
Add function to return reasonable upper and lower bounds of field values. #351
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
258f67e
Add bounds checking to the interstitial aerosol number calculations.
overfelt 20321be
Add bounds checking to the interstitial aerosol number calculations.
overfelt 9800a61
Revert back to main.
overfelt 56acf1e
Add function to return reasonable upper and lower bounds of field val…
overfelt a5affba
Clang format.
overfelt a1f77d8
Losen tolerance so scream tests pass.
overfelt 63b7d99
Expand range of valid values in order for Scream tests to pass.
overfelt 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| // mam4xx: Copyright (c) 2022, | ||
| // Battelle Memorial Institute and | ||
| // National Technology & Engineering Solutions of Sandia, LLC (NTESS) | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| #ifndef PHYSICAL_LIMITS_HPP | ||
| #define PHYSICAL_LIMITS_HPP | ||
| #include <map> | ||
| #include <string> | ||
| #include <utility> | ||
|
|
||
| namespace mam4 { | ||
|
|
||
| #if 0 | ||
| // If a device callable version of physical_min and physical_max is needed along | ||
| // with the CPU only version, somthing like this would work. Strings do not do | ||
| // well on device but enums are fast. | ||
|
|
||
| enum FieldNameIndex { T_mid, qv, qc, qi, nc, nr, ni, nmr, mmr, NUMFIELD}; | ||
| struct min_max {const Real min; const Real max;}; | ||
|
|
||
| KOKKOS_INLINE_FUNCTION constexpr min_max physical_min_max(const FieldNameIndex ind) { | ||
| const min_max field_min_max[NUMFIELD] = { | ||
| {100, 500}, // T_mid | ||
| {1e-13, 0.2}, // qv | ||
| {0, 0.1}, // qc | ||
| {0, 0.1}, // qi | ||
| {0, 0.1e11}, // nc | ||
| {0, 0.1e10}, // nr | ||
| {0, 0.1e10}, // ni | ||
| {0, 1e13}, // nmr | ||
| {-1e-20, 1e-2} // mmr | ||
| }; | ||
| return field_min_max[ind]; | ||
| } | ||
|
|
||
| KOKKOS_INLINE_FUNCTION constexpr Real physical_min(const FieldNameIndex ind) { | ||
| return physical_min_max(ind).min; | ||
| } | ||
|
|
||
| KOKKOS_INLINE_FUNCTION constexpr Real physical_max(const FieldNameIndex ind) { | ||
| return physical_min_max(ind).max; | ||
| } | ||
|
|
||
| inline const std::pair<Real,Real>& physical_min_max(const std::string &field_name) { | ||
| static const std::map<std::string, std::pair<Real,Real>> | ||
| limits = { | ||
| {"T_mid", {physical_min(T_mid), physical_max(T_mid)} }, | ||
| {"qv", {physical_min(qv), physical_max(qv)} }, | ||
| {"qc", {physical_min(qc), physical_max(qc)} }, | ||
| {"qi", {physical_min(qi), physical_max(qi)} }, | ||
| {"nc", {physical_min(nc), physical_max(nc)} }, | ||
| {"nr", {physical_min(nr), physical_max(nr)} }, | ||
| {"ni", {physical_min(ni), physical_max(ni)} }, | ||
| {"nmr", {physical_min(nmr), physical_max(nmr)} }, | ||
| {"mmr", {physical_min(mmr), physical_max(mmr)} } | ||
| }; | ||
| return limits.at(field_name); | ||
| } | ||
| #endif | ||
| inline const std::pair<Real, Real> & | ||
| physical_min_max(const std::string &field_name) { | ||
| static const std::map<std::string, std::pair<Real, Real>> limits = { | ||
| {"T_mid", {100, 500}}, {"qv", {1e-13, 0.2}}, {"qc", {0, 0.1}}, | ||
| {"qi", {0, 0.1}}, {"nc", {0, 0.1e11}}, {"nr", {0, 0.1e10}}, | ||
| {"ni", {0, 0.1e10}}, {"nmr", {0, 1e13}}, {"mmr", {-1e-20, 1e-2}}}; | ||
| return limits.at(field_name); | ||
| } | ||
| inline Real physical_min(const std::string &field_name) { | ||
| return physical_min_max(field_name).first; | ||
| } | ||
| inline Real physical_max(const std::string &field_name) { | ||
| return physical_min_max(field_name).second; | ||
| } | ||
| } // namespace mam4 | ||
|
|
||
| #endif | ||
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.
Might this be better-named
MinMax?