Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
|
#include <UniformGridRandomFieldGenerator.hpp>
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< double > | SampleRandomField () |
std::vector< double > | SampleRandomFieldAtTime (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 |
A UniformGridRandomFieldGenerator for adding spatially-correlated noise to a mesh.
Definition at line 51 of file UniformGridRandomFieldGenerator.hpp.
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.
lowerCorner | the lower corner of the rectangular grid |
upperCorner | the upper corner of the rectangular grid |
numGridPts | the number of grid points in each dimension |
periodicity | whether the grid is periodic in each dimension |
lengthScale | the 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.
|
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).
gridIndex | the (x,y,z) coordinate to translate into a linear index |
Definition at line 289 of file UniformGridRandomFieldGenerator.cpp.
References NEVER_REACHED.
|
private |
Helper method for Interpolate(). Get the position in space of the grid point with (x,y,z) grid index gridIndex.
gridIndex | the (x,y,z) coordinate to calculate the position of |
Definition at line 321 of file UniformGridRandomFieldGenerator.cpp.
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.
rRandomField | the random field, assumed obtained from SampleRandomField() |
rLocation | the location to which we identify the value at the closest node in the random field |
Definition at line 149 of file UniformGridRandomFieldGenerator.cpp.
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.
Definition at line 95 of file UniformGridRandomFieldGenerator.cpp.
std::vector< double > UniformGridRandomFieldGenerator< SPACE_DIM >::SampleRandomFieldAtTime | ( | double | time | ) |
Sample an instance of the random field at a given time.
time | time at which to sample the random field |
Definition at line 101 of file UniformGridRandomFieldGenerator.cpp.
|
inlineprivate |
Archive the member variables.
archive | the archive |
version | the current version of this class |
Definition at line 111 of file UniformGridRandomFieldGenerator.hpp.
References UniformGridRandomFieldGenerator< SPACE_DIM >::mLengthScale, UniformGridRandomFieldGenerator< SPACE_DIM >::mLowerCorner, UniformGridRandomFieldGenerator< SPACE_DIM >::mNumGridPts, UniformGridRandomFieldGenerator< SPACE_DIM >::mPeriodicity, and UniformGridRandomFieldGenerator< SPACE_DIM >::mUpperCorner.
void UniformGridRandomFieldGenerator< SPACE_DIM >::SetRandomSeed | ( | const unsigned | seed | ) |
Set the random seed used for the generator.
seed | the new seed |
Definition at line 89 of file UniformGridRandomFieldGenerator.cpp.
|
friend |
Definition at line 55 of file UniformGridRandomFieldGenerator.hpp.
|
friend |
Definition at line 56 of file UniformGridRandomFieldGenerator.hpp.
|
friend |
Definition at line 57 of file UniformGridRandomFieldGenerator.hpp.
|
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.
|
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().
|
private |
Length scale over which the noise is to be correlated.
Definition at line 72 of file UniformGridRandomFieldGenerator.hpp.
Referenced by UniformGridRandomFieldGenerator< SPACE_DIM >::UniformGridRandomFieldGenerator(), and UniformGridRandomFieldGenerator< SPACE_DIM >::serialize().
|
private |
Coordinates of the lower corner of the grid.
Definition at line 60 of file UniformGridRandomFieldGenerator.hpp.
Referenced by UniformGridRandomFieldGenerator< SPACE_DIM >::UniformGridRandomFieldGenerator(), and UniformGridRandomFieldGenerator< SPACE_DIM >::serialize().
|
private |
Number of eigenvalues calculated, such that their sum minimally exceeds mTraceProportion * mNumTotalGridPts.
Definition at line 102 of file UniformGridRandomFieldGenerator.hpp.
|
private |
Number of grid points required in each dimension.
Definition at line 66 of file UniformGridRandomFieldGenerator.hpp.
Referenced by UniformGridRandomFieldGenerator< SPACE_DIM >::UniformGridRandomFieldGenerator(), and UniformGridRandomFieldGenerator< SPACE_DIM >::serialize().
|
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().
|
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().
|
private |
Noise generator
Definition at line 145 of file UniformGridRandomFieldGenerator.hpp.
Referenced by UniformGridRandomFieldGenerator< SPACE_DIM >::UniformGridRandomFieldGenerator().
|
private |
Whether the grid is periodic in each dimension.
Definition at line 69 of file UniformGridRandomFieldGenerator.hpp.
Referenced by UniformGridRandomFieldGenerator< SPACE_DIM >::serialize().
|
private |
Coordinates of the upper corner of the grid.
Definition at line 63 of file UniformGridRandomFieldGenerator.hpp.
Referenced by UniformGridRandomFieldGenerator< SPACE_DIM >::UniformGridRandomFieldGenerator(), and UniformGridRandomFieldGenerator< SPACE_DIM >::serialize().