13#include "libmesh/utility.h"
23 "Wavelength cut off (set to about twice the interfacial width)");
26 "Number of random fourier series terms (this will result in non-periodic noise). Omit this "
27 "parameter to obtain a periodic noise distribution.");
28 params.
addParam<
unsigned int>(
"seed", 12455,
"Random number generator seed");
34 _lambda(getParam<Real>(
"lambda")),
35 _fe_problem(*getCheckedPointerParam<
FEProblemBase *>(
"_fe_problem_base"))
38 rng.
seed(0, getParam<unsigned int>(
"seed"));
43 _series.resize(getParam<unsigned int>(
"num_terms"));
49 "If specifying the number of terms, supply a number greater than zero.");
58 const Real
x = rng.
rand(0) - 0.5;
59 const Real
y = rng.
rand(0) - 0.5;
60 f.k = RealVectorValue(
x,
y, 0.0);
75 if (!
mesh.isRegularOrthogonal())
76 mooseError(
"Periodic Fourier Noise requires a regular orthogonal mesh.");
82 const int xmax = rmax / dx;
83 const int ymax = rmax / dy;
85 const Real rmax2 = rmax * rmax;
86 for (
int x = 0;
x < xmax; ++
x)
87 for (
int y = -ymax;
y < ymax; ++
y)
91 f.
k = RealVectorValue(
x * dx,
y * dy, 0.0);
92 if (
f.k.norm_sq() <= rmax2)
109 v +=
f.s * std::sin(
p *
f.k) +
f.c * std::cos(
p *
f.k);
116 using std::sin, std::cos;
120 v +=
f.s * sin(
p *
f.k) +
f.c * cos(
p *
f.k);
DualNumber< Real, DNDerivativeType, true > ADReal
Real f(Real x)
Test function for Brents method.
const std::vector< double > y
const std::vector< double > x
registerMooseObject("PhaseFieldApp", FourierNoise)
virtual MooseMesh & mesh() override
Generate noise using random fourier series coefficients.
Real _scale
amplitude factor
virtual Real value(Real, const Point &p) const override
static InputParameters validParams()
const Real _lambda
selected lower lengthscale for the noise cut-off
FourierNoise(const InputParameters ¶meters)
std::vector< SeriesItem > _series
Fourier series terms.
FEProblemBase & _fe_problem
FEProblem pointer for obtaining the current mesh.
static InputParameters validParams()
void paramError(const std::string ¶m, Args... args) const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
void seed(std::size_t i, unsigned int seed)
Real randNormal(std::size_t i, Real mean, Real sigma)
RealVectorValue k
k-vector