queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::UniformOneDGrid< T > Class Template Reference

Class for accommodating uniform one-dimensional grids. More...

#include <UniformOneDGrid.h>

Inheritance diagram for QUESO::UniformOneDGrid< T >:
QUESO::BaseOneDGrid< T >

Public Member Functions

Constructor/Destructor methods
 UniformOneDGrid (const BaseEnvironment &env, const char *prefix, unsigned int size, T minPosition, T maxPosition)
 Default constructor. More...
 
 ~UniformOneDGrid ()
 Destructor. More...
 
Accessor methods
operator[] (unsigned int i) const
 Returns the position of the i-th point in the grid. More...
 
Mathematical methods
unsigned int size () const
 Grid size; the amount of points that defines the grid. More...
 
unsigned int findIntervalId (const T &paramValue) const
 Finds the ID of an interval. See template specialization. More...
 
- Public Member Functions inherited from QUESO::BaseOneDGrid< T >
 BaseOneDGrid (const BaseEnvironment &env, const char *prefix)
 Default constructor. More...
 
virtual ~BaseOneDGrid ()
 Virtual destructor. More...
 
void print (std::ostream &ofsvar) const
 Prints the values of the grid points. More...
 

Protected Attributes

unsigned int m_size
 
m_minPosition
 
m_maxPosition
 
- Protected Attributes inherited from QUESO::BaseOneDGrid< T >
const BaseEnvironmentm_env
 
std::string m_prefix
 

Detailed Description

template<class T>
class QUESO::UniformOneDGrid< T >

Class for accommodating uniform one-dimensional grids.

Definition at line 41 of file UniformOneDGrid.h.

Constructor & Destructor Documentation

template<class T >
QUESO::UniformOneDGrid< T >::UniformOneDGrid ( const BaseEnvironment env,
const char *  prefix,
unsigned int  size,
minPosition,
maxPosition 
)

Default constructor.

Constructs a uniform 1D grid between minPosition and maxPosition, with size points.

Definition at line 31 of file UniformOneDGrid.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::BaseOneDGrid< T >::m_env, QUESO::BaseOneDGrid< T >::m_prefix, and QUESO::BaseEnvironment::subDisplayFile().

37  :
38  BaseOneDGrid<T>(env,prefix),
39  m_size (size),
40  m_minPosition(minPosition),
41  m_maxPosition(maxPosition)
42 {
43  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
44  *m_env.subDisplayFile() << "Entering UniformOneDGrid<T>::constructor()"
45  << ": prefix = " << m_prefix
46  << std::endl;
47  }
48 
49  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
50  *m_env.subDisplayFile() << "Leaving UniformOneDGrid<T>::constructor()"
51  << ": prefix = " << m_prefix
52  << std::endl;
53  }
54 }
std::string m_prefix
Definition: OneDGrid.h:83
const BaseEnvironment & m_env
Definition: OneDGrid.h:82
unsigned int size() const
Grid size; the amount of points that defines the grid.
unsigned int displayVerbosity() const
Definition: Environment.C:450
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class T >
QUESO::UniformOneDGrid< T >::~UniformOneDGrid ( )

Destructor.

Definition at line 57 of file UniformOneDGrid.C.

58 {
59 }

Member Function Documentation

template<class T >
unsigned int QUESO::UniformOneDGrid< T >::findIntervalId ( const T &  paramValue) const
virtual

Finds the ID of an interval. See template specialization.

This function finds to which interval the parameter value belongs to.

Implements QUESO::BaseOneDGrid< T >.

Definition at line 81 of file UniformOneDGrid.C.

82 {
83  queso_require_msg(!((paramValue < m_minPosition) || (m_maxPosition < paramValue)), "paramValue is out of domain");
84 
85  T ratio = (paramValue - m_minPosition)/(m_maxPosition - m_minPosition);
86  unsigned int i = (unsigned int) (ratio*(m_size-1.));
87  if ((i > 0 ) &&
88  ((*this)[i] > paramValue)) {
89  i--;
90  }
91 
92  return i;
93 }
template<class T >
T QUESO::UniformOneDGrid< T >::operator[] ( unsigned int  i) const
virtual

Returns the position of the i-th point in the grid.

Implements QUESO::BaseOneDGrid< T >.

Definition at line 70 of file UniformOneDGrid.C.

71 {
72  queso_require_less_msg(i, m_size, "too large i");
73 
74  T ratio = ((T) i)/(((T)m_size)-1.); // IMPORTANT: Yes, '-1.'
75  T position = (1.-ratio)*m_minPosition + ratio*m_maxPosition;
76  return position;
77 }
template<class T >
unsigned int QUESO::UniformOneDGrid< T >::size ( ) const
virtual

Grid size; the amount of points that defines the grid.

Implements QUESO::BaseOneDGrid< T >.

Definition at line 63 of file UniformOneDGrid.C.

64 {
65  return m_size;
66 }

Member Data Documentation

template<class T>
T QUESO::UniformOneDGrid< T >::m_maxPosition
protected

Definition at line 78 of file UniformOneDGrid.h.

template<class T>
T QUESO::UniformOneDGrid< T >::m_minPosition
protected

Definition at line 77 of file UniformOneDGrid.h.

template<class T>
unsigned int QUESO::UniformOneDGrid< T >::m_size
protected

Definition at line 76 of file UniformOneDGrid.h.


The documentation for this class was generated from the following files:

Generated on Tue Jun 5 2018 19:49:21 for queso-0.57.1 by  doxygen 1.8.5