Chaste Commit::8b5d759ac2eb95e67ae57699734101efccb0a0a9
UniformGridRandomFieldGenerator< SPACE_DIM > Class Template Reference

#include <UniformGridRandomFieldGenerator.hpp>

+ Inheritance diagram for UniformGridRandomFieldGenerator< SPACE_DIM >:
+ Collaboration diagram for UniformGridRandomFieldGenerator< SPACE_DIM >:

Public Member Functions

 UniformGridRandomFieldGenerator (std::array< double, SPACE_DIM > lowerCorner, std::array< double, SPACE_DIM > upperCorner, std::array< unsigned, SPACE_DIM > numGridPts, std::array< bool, SPACE_DIM > periodicity, double lengthScale)
 
std::vector< doubleSampleRandomField ()
 
std::vector< doubleSampleRandomFieldAtTime (double time)
 
double Interpolate (const std::vector< double > &rRandomField, const c_vector< double, SPACE_DIM > &rLocation) const
 
void SetRandomSeed (const unsigned seed)
 

Private Member Functions

template<class Archive >
void serialize (Archive &archive, const unsigned int version)
 
long GetLinearIndex (std::array< long, SPACE_DIM > gridIndex) const
 
std::array< double, SPACE_DIM > GetPositionUsingGridIndex (std::array< long, SPACE_DIM > gridIndex) const
 

Private Attributes

std::array< double, SPACE_DIM > mLowerCorner
 
std::array< double, SPACE_DIM > mUpperCorner
 
std::array< unsigned, SPACE_DIM > mNumGridPts
 
std::array< bool, SPACE_DIM > mPeriodicity
 
double mLengthScale
 
unsigned mNumTotalGridPts
 
std::array< double, SPACE_DIM > mGridSpacing
 
std::array< double, SPACE_DIM > mOneOverGridSpacing
 
const std::string mCacheDir
 
unsigned mNumEigenvals
 
OpenSimplex2S mOpenSimplex
 

Friends

class boost::serialization::access
 
class TestSamplesFromCachedRandomField
 
class TestUniformGridRandomFieldGenerator
 

Detailed Description

template<unsigned SPACE_DIM>
class UniformGridRandomFieldGenerator< SPACE_DIM >

A UniformGridRandomFieldGenerator for adding spatially-correlated noise to a mesh.

Definition at line 51 of file UniformGridRandomFieldGenerator.hpp.

Constructor & Destructor Documentation

◆ UniformGridRandomFieldGenerator()

template<unsigned SPACE_DIM>
UniformGridRandomFieldGenerator< SPACE_DIM >::UniformGridRandomFieldGenerator ( std::array< double, SPACE_DIM >  lowerCorner,
std::array< double, SPACE_DIM >  upperCorner,
std::array< unsigned, SPACE_DIM >  numGridPts,
std::array< bool, SPACE_DIM >  periodicity,
double  lengthScale 
)

Constructor that takes all parameters as arguments.

Parameters
lowerCornerthe lower corner of the rectangular grid
upperCornerthe upper corner of the rectangular grid
numGridPtsthe number of grid points in each dimension
periodicitywhether the grid is periodic in each dimension
lengthScalethe length scale of the correlation when calculating the covariance matrix

Definition at line 51 of file UniformGridRandomFieldGenerator.cpp.

References UniformGridRandomFieldGenerator< SPACE_DIM >::mGridSpacing, UniformGridRandomFieldGenerator< SPACE_DIM >::mLengthScale, UniformGridRandomFieldGenerator< SPACE_DIM >::mLowerCorner, UniformGridRandomFieldGenerator< SPACE_DIM >::mNumGridPts, UniformGridRandomFieldGenerator< SPACE_DIM >::mNumTotalGridPts, UniformGridRandomFieldGenerator< SPACE_DIM >::mOneOverGridSpacing, UniformGridRandomFieldGenerator< SPACE_DIM >::mOpenSimplex, and UniformGridRandomFieldGenerator< SPACE_DIM >::mUpperCorner.

Member Function Documentation

◆ GetLinearIndex()

template<unsigned SPACE_DIM>
long UniformGridRandomFieldGenerator< SPACE_DIM >::GetLinearIndex ( std::array< long, SPACE_DIM >  gridIndex) const
private

Helper method for Interpolate(). Get the linear index (along the flat vector representing a random field instance) given the grid index (x,y,z).

Parameters
gridIndexthe (x,y,z) coordinate to translate into a linear index
Returns
the linear index along the flat vector representing the (x,y,z) grid coordinate

Definition at line 289 of file UniformGridRandomFieldGenerator.cpp.

References NEVER_REACHED.

◆ GetPositionUsingGridIndex()

template<unsigned SPACE_DIM>
std::array< double, SPACE_DIM > UniformGridRandomFieldGenerator< SPACE_DIM >::GetPositionUsingGridIndex ( std::array< long, SPACE_DIM >  gridIndex) const
private

Helper method for Interpolate(). Get the position in space of the grid point with (x,y,z) grid index gridIndex.

Parameters
gridIndexthe (x,y,z) coordinate to calculate the position of
Returns
the position in space of the (x,y,z) coordinate

Definition at line 321 of file UniformGridRandomFieldGenerator.cpp.

◆ Interpolate()

template<unsigned SPACE_DIM>
double UniformGridRandomFieldGenerator< SPACE_DIM >::Interpolate ( const std::vector< double > &  rRandomField,
const c_vector< double, SPACE_DIM > &  rLocation 
) const

Interpolate from the random field by returning the value at the node of the random field closest to the given location.

Parameters
rRandomFieldthe random field, assumed obtained from SampleRandomField()
rLocationthe location to which we identify the value at the closest node in the random field
Returns
the value of the random field closest to rLocation

Definition at line 149 of file UniformGridRandomFieldGenerator.cpp.

◆ SampleRandomField()

template<unsigned SPACE_DIM>
std::vector< double > UniformGridRandomFieldGenerator< SPACE_DIM >::SampleRandomField ( )

Sample an instance of the random field.

Calls SampleRandomFieldAtTime() at a time chosen uniformly at random from 0 to 1.

Returns
A vector representing an instance of the random field.

Definition at line 95 of file UniformGridRandomFieldGenerator.cpp.

◆ SampleRandomFieldAtTime()

template<unsigned SPACE_DIM>
std::vector< double > UniformGridRandomFieldGenerator< SPACE_DIM >::SampleRandomFieldAtTime ( double  time)

Sample an instance of the random field at a given time.

Parameters
timetime at which to sample the random field
Returns
A vector representing an instance of the random field.

Definition at line 101 of file UniformGridRandomFieldGenerator.cpp.

◆ serialize()

template<unsigned SPACE_DIM>
template<class Archive >
void UniformGridRandomFieldGenerator< SPACE_DIM >::serialize ( Archive &  archive,
const unsigned int  version 
)
inlineprivate

◆ SetRandomSeed()

template<unsigned SPACE_DIM>
void UniformGridRandomFieldGenerator< SPACE_DIM >::SetRandomSeed ( const unsigned  seed)

Set the random seed used for the generator.

Parameters
seedthe new seed

Definition at line 89 of file UniformGridRandomFieldGenerator.cpp.

Friends And Related Symbol Documentation

◆ boost::serialization::access

template<unsigned SPACE_DIM>
friend class boost::serialization::access
friend

Definition at line 55 of file UniformGridRandomFieldGenerator.hpp.

◆ TestSamplesFromCachedRandomField

template<unsigned SPACE_DIM>
friend class TestSamplesFromCachedRandomField
friend

Definition at line 56 of file UniformGridRandomFieldGenerator.hpp.

◆ TestUniformGridRandomFieldGenerator

template<unsigned SPACE_DIM>
friend class TestUniformGridRandomFieldGenerator
friend

Definition at line 57 of file UniformGridRandomFieldGenerator.hpp.

Member Data Documentation

◆ mCacheDir

template<unsigned SPACE_DIM>
const std::string UniformGridRandomFieldGenerator< SPACE_DIM >::mCacheDir
private

The directory name, relative to $CHASTE_TEST_OUTPUT, in which cached random fields will be saved.

Definition at line 96 of file UniformGridRandomFieldGenerator.hpp.

◆ mGridSpacing

template<unsigned SPACE_DIM>
std::array<double, SPACE_DIM> UniformGridRandomFieldGenerator< SPACE_DIM >::mGridSpacing
private

Store the calculated grid spacings to avoid recalculation during interpolation.

Definition at line 84 of file UniformGridRandomFieldGenerator.hpp.

Referenced by UniformGridRandomFieldGenerator< SPACE_DIM >::UniformGridRandomFieldGenerator().

◆ mLengthScale

template<unsigned SPACE_DIM>
double UniformGridRandomFieldGenerator< SPACE_DIM >::mLengthScale
private

◆ mLowerCorner

template<unsigned SPACE_DIM>
std::array<double, SPACE_DIM> UniformGridRandomFieldGenerator< SPACE_DIM >::mLowerCorner
private

◆ mNumEigenvals

template<unsigned SPACE_DIM>
unsigned UniformGridRandomFieldGenerator< SPACE_DIM >::mNumEigenvals
private

Number of eigenvalues calculated, such that their sum minimally exceeds mTraceProportion * mNumTotalGridPts.

Definition at line 102 of file UniformGridRandomFieldGenerator.hpp.

◆ mNumGridPts

template<unsigned SPACE_DIM>
std::array<unsigned, SPACE_DIM> UniformGridRandomFieldGenerator< SPACE_DIM >::mNumGridPts
private

◆ mNumTotalGridPts

template<unsigned SPACE_DIM>
unsigned UniformGridRandomFieldGenerator< SPACE_DIM >::mNumTotalGridPts
private

The product of mNumGridPts; the total number of grid points in the cuboid.

Definition at line 78 of file UniformGridRandomFieldGenerator.hpp.

Referenced by UniformGridRandomFieldGenerator< SPACE_DIM >::UniformGridRandomFieldGenerator().

◆ mOneOverGridSpacing

template<unsigned SPACE_DIM>
std::array<double, SPACE_DIM> UniformGridRandomFieldGenerator< SPACE_DIM >::mOneOverGridSpacing
private

Store the calculated one over grid spacings to avoid recalculation during interpolation.

Definition at line 90 of file UniformGridRandomFieldGenerator.hpp.

Referenced by UniformGridRandomFieldGenerator< SPACE_DIM >::UniformGridRandomFieldGenerator().

◆ mOpenSimplex

template<unsigned SPACE_DIM>
OpenSimplex2S UniformGridRandomFieldGenerator< SPACE_DIM >::mOpenSimplex
private

◆ mPeriodicity

template<unsigned SPACE_DIM>
std::array<bool, SPACE_DIM> UniformGridRandomFieldGenerator< SPACE_DIM >::mPeriodicity
private

Whether the grid is periodic in each dimension.

Definition at line 69 of file UniformGridRandomFieldGenerator.hpp.

Referenced by UniformGridRandomFieldGenerator< SPACE_DIM >::serialize().

◆ mUpperCorner

template<unsigned SPACE_DIM>
std::array<double, SPACE_DIM> UniformGridRandomFieldGenerator< SPACE_DIM >::mUpperCorner
private

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