queso-0.51.1
StdOneDGrid.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008,2009,2010,2011,2012,2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #include <queso/StdOneDGrid.h>
26 
27 namespace QUESO {
28 
29 template<class T>
31  const BaseEnvironment& env,
32  const char* prefix,
33  const std::vector<T>& points)
34  :
35  BaseOneDGrid<T>(env,prefix),
36  m_points (points)
37 {
38  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
39  *m_env.subDisplayFile() << "Entering StdOneDGrid<T>::constructor()"
40  << ": prefix = " << m_prefix
41  << std::endl;
42  }
43 
44  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
45  *m_env.subDisplayFile() << "Leaving StdOneDGrid<T>::constructor()"
46  << ": prefix = " << m_prefix
47  << std::endl;
48  }
49 }
50 
51 template<class T>
53 {
54 }
55 
56 template<class T>
57 unsigned int
59 {
60  return m_points.size();
61 }
62 
63 template<class T>
64 T
65 StdOneDGrid<T>::operator[](unsigned int i) const
66 {
67  UQ_FATAL_TEST_MACRO(i >= m_points.size(),
68  m_env.worldRank(),
69  "StdOneDGrid<V,M>::operator[]",
70  "too large i");
71 
72  return m_points[i];
73 }
74 
75 template<class T>
76 unsigned int
77 StdOneDGrid<T>::findIntervalId(const T& paramValue) const
78 {
79  UQ_FATAL_TEST_MACRO((paramValue < m_points[0]) || (m_points[m_points.size()-1] < paramValue),
80  m_env.worldRank(),
81  "StdOneDGrid<V,M>::findIntervalId[]",
82  "paramValue is out of domain");
83 
84  unsigned int iMax = m_points.size();
85  unsigned int i = 1; // Yes, '1'
86  for (i = 1; i < iMax; ++i) { // Yes, '1'
87  if (paramValue < m_points[i]) {
88  i--;
89  break;
90  }
91  }
92 
93  return i;
94 }
95 
96 } // End namespace QUESO
T operator[](unsigned int i) const
Returns the position of the i-th point in the grid.
Definition: StdOneDGrid.C:65
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
Base class for accommodating one-dimensional grids.
Definition: OneDGrid.h:46
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:187
unsigned int size() const
Grid size; the amount of points which defines the grid.
Definition: StdOneDGrid.C:58
unsigned int findIntervalId(const T &paramValue) const
Finds the ID of an interval. See template specialization.
Definition: StdOneDGrid.C:77
unsigned int displayVerbosity() const
Definition: Environment.C:436
std::string m_prefix
Definition: OneDGrid.h:83
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
~StdOneDGrid()
Destructor.
Definition: StdOneDGrid.C:52
const BaseEnvironment & m_env
Definition: OneDGrid.h:82
StdOneDGrid(const BaseEnvironment &env, const char *prefix, const std::vector< T > &points)
Default constructor.
Definition: StdOneDGrid.C:30

Generated on Thu Apr 23 2015 19:26:15 for queso-0.51.1 by  doxygen 1.8.5