Cantera
Install
User Guide
Examples
Reference
Develop
Community
4.0.0a2
Toggle main menu visibility
Loading...
Searching...
No Matches
checkFinite.cpp
Go to the documentation of this file.
1
/**
2
* @file checkFinite.cpp Declarations for routines that check for the
3
* presence of NaNs in the code.
4
*/
5
6
// This file is part of Cantera. See License.txt in the top-level directory or
7
// at https://cantera.org/license.txt for license and copyright information.
8
9
#include "
cantera/base/ct_defs.h
"
10
#include "
cantera/base/stringUtils.h
"
11
#include "
cantera/base/ctexceptions.h
"
12
13
namespace
Cantera
{
14
15
void
checkFinite
(
const
double
tmp)
16
{
17
if
(!std::isfinite(tmp)) {
18
if
(std::isnan(tmp)) {
19
throw
CanteraError
(
"checkFinite"
,
"found NaN"
);
20
}
else
if
(tmp > 0) {
21
throw
CanteraError
(
"checkFinite"
,
"found +Inf"
);
22
}
else
{
23
throw
CanteraError
(
"checkFinite"
,
"found -Inf"
);
24
}
25
}
26
}
27
28
void
checkFinite
(
const
string
& name, span<const double> values)
29
{
30
for
(
size_t
i = 0; i < values.size(); i++) {
31
if
(!std::isfinite(values[i])) {
32
string
message = name +
" contains non-finite elements:\n\n"
;
33
for
(
size_t
j = 0; j < values.size(); j++) {
34
if
(!std::isfinite(values[j])) {
35
message += fmt::format(
"{}[{}] = {}\n"
, name, j, values[j]);
36
}
37
}
38
throw
CanteraError
(
"checkFinite"
, message);
39
}
40
}
41
}
42
43
}
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition
ctexceptions.h:66
ct_defs.h
This file contains definitions of constants, types and terms that are used in internal routines and a...
ctexceptions.h
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
Cantera
Namespace for the Cantera kernel.
Definition
AnyMap.cpp:595
Cantera::checkFinite
void checkFinite(const double tmp)
Check to see that a number is finite (not NaN, +Inf or -Inf).
Definition
checkFinite.cpp:15
stringUtils.h
Contains declarations for string manipulation functions within Cantera.
src
base
checkFinite.cpp
Generated by
1.17.0