Skip to content

Commit 8422ab2

Browse files
committed
Better bounds checking for interpolation datasets
We now throw an exception when the user tries to construct an interpolation surrogate on an unbounded domain.
1 parent 0f815f4 commit 8422ab2

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/surrogates/inc/InterpolationSurrogateData.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ namespace QUESO
103103
//! Helper function for sizing m_values
104104
void init_values( const std::vector<unsigned int>& n_points );
105105

106+
//! Helper function for checking domain extent
107+
void check_domain_bounds() const;
108+
106109
//! Parameter domain over which we use surrogate
107110
const BoxSubset<V,M>& m_domain;
108111

src/surrogates/src/InterpolationSurrogateData.C

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <queso/MpiComm.h>
3030
#include <queso/GslVector.h>
3131
#include <queso/GslMatrix.h>
32+
#include <queso/math_macros.h>
3233

3334
// C++
3435
#include <sstream>
@@ -46,6 +47,9 @@ namespace QUESO
4647

4748
// Size m_values
4849
this->init_values(this->m_n_points);
50+
51+
// Check the domain is bounded
52+
this->check_domain_bounds();
4953
}
5054

5155
template<class V, class M>
@@ -80,6 +84,17 @@ namespace QUESO
8084
this->m_values.resize(n_total_points);
8185
}
8286

87+
template<class V, class M>
88+
void InterpolationSurrogateData<V,M>::check_domain_bounds() const
89+
{
90+
for (unsigned int i = 0; i < m_domain.vectorSpace().dimLocal(); i++) {
91+
queso_require_msg(queso_isfinite(m_domain.minValues()[i]),
92+
"Interpolation with an unbounded domain is unsupported");
93+
queso_require_msg(queso_isfinite(m_domain.maxValues()[i]),
94+
"Interpolation with an unbounded domain is unsupported");
95+
}
96+
}
97+
8398
template<class V, class M>
8499
void InterpolationSurrogateData<V,M>::set_values( std::vector<double>& values )
85100
{

0 commit comments

Comments
 (0)