OGS
ClampingStats.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "ClampingStats.h"
5
6#include "BaseLib/Logging.h"
7
8namespace ChemistryLib
9{
10namespace PhreeqcIOData
11{
12double ClampingStats::clamp(double const c, double const warning_threshold,
13 std::string_view const name)
14{
15 if (c >= 0.0)
16 {
17 return c;
18 }
19 if (c < warning_threshold)
20 {
23 {
26 }
27 }
28 ++n_values;
30 return 0.0;
31}
32
47
48void ClampingStats::report(double const warning_threshold) const
49{
50 if (n_severe_values > 0)
51 {
52 WARN(
53 "Clamped {:d} concentration value(s) more negative than the "
54 "warning threshold ({:g} mol/kgw) to zero across {:d} chemical "
55 "system(s) before speciation; worst: '{:s}' = {:g} mol/kgw.",
56 n_severe_values, warning_threshold, n_severe_cells,
58 }
59 if (n_values > 0)
60 {
61 DBUG(
62 "PhreeqcIO: clamped {:d} negative concentration value(s) to zero "
63 "across {:d} chemical system(s) before speciation (total clamped: "
64 "{:g} mol/kgw).",
66 }
67}
68} // namespace PhreeqcIOData
69} // namespace ChemistryLib
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:34
std::string_view worst_component_name
aliases Component::name
std::size_t n_severe_values
total severe values clamped
std::size_t n_severe_cells
cells with a severe clamp
double clamp(double c, double warning_threshold, std::string_view name)
ClampingStats & operator+=(ClampingStats const &other)
Folds another stats object into this accumulator (identity = {}).
void report(double warning_threshold) const
WARN for severe clamps, DBUG for silent noise clamps. No-op when empty.
std::size_t n_values
total values clamped
std::size_t n_cells
cells with any clamping