SyntheticFields
VortexPasta.SyntheticFields Module
SyntheticFieldsProvides implementations of synthetic vector fields.
These can be used to represent a "normal" fluid velocity field which influences the motion of vortex lines.
sourceUniform vector fields
VortexPasta.SyntheticFields.UniformVectorField Type
UniformVectorField{T, N} <: SyntheticVectorField{T, N}
UniformVectorField(u⃗)Represents a uniform (constant) vector field with no spatial fluctuations.
This can be used for instance to represent a uniform counterflow.
The input u⃗ can be an SVector{N, T} or a tuple.
Fourier vector fields
VortexPasta.SyntheticFields.FourierBandVectorField Type
FourierBandVectorField{T, N} <: FourierSyntheticVectorField{T, N}
FourierBandVectorField(undef, Ls::NTuple; [kmin], [kmax])Implements a synthetic vector field in Fourier space.
This type is adapted for vector fields described by a relatively small number of non-zero Fourier modes. The non-zero modes are within a "band" given by
One should initialise the Fourier coefficients of the vector field before performing any evaluations. For this one can call SyntheticFields.init_coefficients! after creating the vector field. After that, one can evaluate the field as described in SyntheticVectorField.
Moreover the state can be saved to an HDF5 file with SyntheticFields.save_coefficients and loaded back with SyntheticFields.load_coefficients!.
Positional arguments
undef: this is Julia'sundefvariable, used here to explicitly indicate that Fourier coefficients are not initialised by this function (but only allocated).Ls: domain period in each direction. For example,Ls = (2π, 2π, 2π)for a-periodic cubic domain.
Optional keyword arguments
kmin: minimum forcing wavenumber (magnitude);kmax: maximum forcing wavenumber (magnitude).
These should satisfy 0 ≤ kmin ≤ kmax. Moreover, one usually wants 0 < kmin to ensure that the generated field has zero mean value.
If these are not passed, an empty FourierBandVectorField will be returned (with no wavevectors). It can be initialised later using set_wavevector_band!.
VortexPasta.SyntheticFields.set_wavevector_band! Function
SyntheticFields.set_wavevector_band!(field::FourierBandVectorField; kmin::Real, kmax::Real)Set active wavevectors of field within a Fourier band.
This will set the normalised wavevectors fields.qs and resize the coefficients fields.cs.
VortexPasta.SyntheticFields.init_coefficients! Function
SyntheticFields.init_coefficients!([rng::AbstractRNG,] f::FourierBandVectorField, u_rms::Real)Initialise Fourier coefficients of vector field.
The "active" Fourier modes are chosen randomly following a normal distribution such that the resulting velocity components have an rms value given by u_rms (on average). The generated field is divergence-free (in 3D).
Positional arguments
rng(optional): random number generator for determining Fourier coefficients of the forcing velocity field. Default value isRandom.default_rng().f: field to be initialised (of typeFourierBandVectorField).u_rms: typical magnitude (rms value) of each vector component.
The total rms value of the vector field is N * u_rms where N is the number of dimensions. Note that the rms value of a single component may slightly differ from u_rms.
VortexPasta.SyntheticFields.from_fourier_grid! Function
SyntheticFields.from_fourier_grid!(
[op::Function], field::FourierBandVectorField{T, N},
ûs_grid::NTuple{N, AbstractArray}, ks_grid::NTuple{N, AbstractVector},
)Copy values from vector field ûs_grid in Fourier space onto a FourierBandVectorField.
Only the wavenumbers within the band [kmin, kmax] in which field is defined are copied.
The ks_grid argument should contain the wavevectors associated to the grid where ûs_grid is defined.
By default, old values in field are discarded and are simply replaced by the values in ûs_grid. One can use the optional op argument to change this behaviour, which should be a function op(old, new, k⃗) taking 3 SVector{N}. For example, passing op(old, new, k⃗) = old - new * sum(abs2, k⃗) means that new values are first multiplied by field.
VortexPasta.SyntheticFields.remove_zeros! Function
SyntheticFields.remove_zeros!(field::FourierBandVectorField) -> IntRemove entries associated to Fourier coefficients which are currently equal to zero.
Returns the number of removed coefficients. Coefficients and their associated wavevectors are removed.
This can help avoid useless computations when evaluating the Fourier sum in physical space.
sourceSaving and loading data
VortexPasta.SyntheticFields.save_coefficients Function
SyntheticFields.save_coefficients(fname::AbstractString, field::FourierBandVectorField)
SyntheticFields.save_coefficients(g::Union{HDF5.File, HDF5.Group}, field::FourierBandVectorField)Save Fourier coefficients to HDF5 file.
This can be useful for restarting a simulation keeping the same synthetic field.
See also SyntheticFields.load_coefficients!.
VortexPasta.SyntheticFields.load_coefficients! Function
SyntheticFields.load_coefficients!(fname::AbstractString, field::FourierBandVectorField)
SyntheticFields.load_coefficients!(g::Union{HDF5.File, HDF5.Group}, field::FourierBandVectorField)Load Fourier coefficients from HDF5 file.
This can be useful for restarting a simulation keeping the same synthetic field.
See also SyntheticFields.save_coefficients.
Abstract types
VortexPasta.SyntheticFields.SyntheticVectorField Type
SyntheticVectorField{T, N} <: FunctionAbstract type representing a synthetic vector field in
Here T <: AbstractFloat is the type of the returned values when evaluating the field at a position.
A field can be evaluated using the f(x⃗) syntax, where f is a SyntheticVectorField and x⃗ is a physical location, returning an SVector{N, T}. Here x⃗ can be an N-element tuple or SVector.
VortexPasta.SyntheticFields.FourierSyntheticVectorField Type
FourierSyntheticVectorField{T, N} <: SyntheticVectorField{T, N}Abstract type representing a synthetic vector field implemented in Fourier space.
See also SyntheticVectorField.