API
Public APIs
FieldTracer.select_seeds
— Method select_seeds(x, y, z; nsegment=(5, 5, 5))
Generate uniform seeding points in the grid range x
, y
and z
in nsegment
.
FieldTracer.select_seeds
— Method select_seeds(x, y; nsegment=(5, 5))
Generate uniform seeding points in the grid range x
and y
in nsegment
. If nsegment
specified, use the keyword input, otherwise it will be overloaded by the 3D version seed generation function!
FieldTracer.trace
— Method trace(fieldx, fieldy, fieldz, startx, starty, startz, gridx, gridy, gridz;
alg=RK4(), kwargs...)
trace(fieldx, fieldy, fieldz, startx, starty, startz, grid::CartesianGrid;
alg=RK4(), maxstep=20000, ds=0.01, gridtype="ndgrid", direction="both")
Stream tracing on structured mesh with field in 3D array and grid in range.
FieldTracer.trace
— Method trace(mesh::SimpleMesh, vx, vy, xstart, ystart; maxIter=1000, maxLen=1000.)
2D stream tracing on unstructured quadrilateral and triangular mesh.
Private APIs
FieldTracer.DoBreak
— Method DoBreak(iloc, jloc, iSize, jSize)
Check to see if we should break out of an integration.
FieldTracer.bilin_reg
— Method bilin_reg(x, y, Q00, Q01, Q10, Q11)
Bilinear interpolation for x1,y1=(0,0) and x2,y2=(1,1) Q's are surrounding points such that Q00 = F[0,0], Q10 = F[1,0], etc.
FieldTracer.euler
— Function euler(maxstep, ds, startx, starty, xGrid, yGrid, ux, uy, precompute=false)
Fast 2D tracing using Euler's method. It takes at most maxstep
with step size ds
tracing the vector field given by ux,uy
starting from (startx,starty)
in the Cartesian grid specified by ranges xGrid
and yGrid
. Step size is in normalized coordinates within the range [0, 1]. Return footprints' coordinates in (x
, y
). If precompute=true
, fall back to the preallocation version.
FieldTracer.euler
— Method euler(maxstep, ds, startx, starty, startz, xGrid, yGrid, zGrid, ux, uy, uz, precompute=false)
Fast 3D tracing using Euler's method. It takes at most maxstep
with step size ds
tracing the vector field given by ux,uy,uz
starting from (startx,starty,startz)
in the Cartesian grid specified by ranges xGrid
, yGrid
and zGrid
. Return footprints' coordinates in (x
,y
,z
).
FieldTracer.getCellID
— MethodReturn cell ID on the unstructured mesh.
FieldTracer.getelement
— MethodReturn the cellID
th element of the mesh.
FieldTracer.grid_interp
— Method grid_interp(x, y, field, ix, iy)
Interpolate a value at (x,y) in a field. ix
and iy
are indexes for x,y locations (0-based).
FieldTracer.grid_interp
— Method grid_interp(x, y, z, ix, iy, iz, field)
Interpolate a value at (x,y,z) in a field. ix
,iy
and iz
are indexes for x, y and z locations (0-based).
FieldTracer.grid_interp_normalized
— Method grid_interp_normalized(x, y, z, ix, iy, iz, ux_field::Array, uy_field::Array, uz_field::Array, dx, dy, dz)
Interpolate a normalized vector value at (x,y,z) in a field. ix,iy,iz
are 0-based integer indices for the bottom-left corner of the cell containing (x,y,z). Normalization is performed on the fly for the corner points.
FieldTracer.grid_interp_normalized
— Method grid_interp_normalized(x, y, ix, iy, ux_field::Array, uy_field::Array, dx, dy)
Interpolate a normalized vector value at (x,y) in a field. ix
and iy
are 0-based integer indices for the bottom-left corner of the cell containing (x,y). Normalization is performed on the fly for the corner points.
FieldTracer.normalize_component
— Method normalize_component(ux, uy, dxInv, dyInv)
Normalizes a single vector component using inverse grid spacings.
FieldTracer.normalize_component
— Method normalize_component(ux, uy, uz, dxInv, dyInv, dzInv)
Normalizes a single vector component using inverse grid spacings.
FieldTracer.normalize_field
— MethodCreate unit vectors of field.
FieldTracer.normalize_field
— MethodCreate unit vectors of field in normalized coordinates.
FieldTracer.rk4
— Function rk4(maxstep, ds, startx, starty, xGrid, yGrid, ux, uy, precompute=false)
Fast and reasonably accurate 2D tracing with 4th order Runge-Kutta method and constant step size ds
. See also euler
.
FieldTracer.rk4
— Method rk4(maxstep, ds, startx, starty, startz, xGrid, yGrid, zGrid, ux, uy, uz, precompute=false)
Fast and reasonably accurate 3D tracing with 4th order Runge-Kutta method and constant step size ds
. See also euler
.
FieldTracer.trace2d_euler
— Method trace2d_euler(fieldx, fieldy, startx, starty, gridx, gridy;
maxstep=20000, ds=0.01, gridtype="ndgrid", direction="both")
Given a 2D vector field, trace a streamline from a given point to the edge of the vector field. The field is integrated using Euler's method, which is faster but less accurate than RK4. Only valid for regular grid with coordinates' range gridx
and gridy
. Step size is in normalized coordinates within the range [0,1]. The field can be in both meshgrid
or ndgrid
(default) format. Supporting direction
of {"both","forward","backward"}.
FieldTracer.trace2d_euler
— Method trace2d_euler(fieldx, fieldy, startx, starty, grid::CartesianGrid; kwargs...)
FieldTracer.trace2d_rk4
— Method trace2d_rk4(fieldx, fieldy, startx, starty, gridx, gridy;
maxstep=20000, ds=0.01, gridtype="ndgrid", direction="both")
Given a 2D vector field, trace a streamline from a given point to the edge of the vector field. The field is integrated using Runge Kutta 4. Slower than Euler, but more accurate. The higher accuracy allows for larger step sizes ds
. Step size is in normalized coordinates within the range [0,1]. See also trace2d_euler
.
FieldTracer.trace3d_euler
— Method trace3d_euler(fieldx, fieldy, fieldz, startx, starty, startz, gridx, gridy, gridz;
maxstep=20000, ds=0.01)
Given a 3D vector field, trace a streamline from a given point to the edge of the vector field. The field is integrated using Euler's method. Only valid for regular grid with coordinates gridx
, gridy
, gridz
. The field can be in both meshgrid
or ndgrid
(default) format. Supporting direction
of {"both","forward","backward"}.
FieldTracer.trace3d_euler
— Method trace3d_euler(fieldx, fieldy, fieldz, startx, starty, startz, grid::CartesianGrid;
maxstep=20000, ds=0.01, gridtype="ndgrid", direction="both")
See also trace3d_rk4
.
FieldTracer.trace3d_rk4
— Method trace3d_rk4(fieldx, fieldy, fieldz, startx, starty, startz, gridx, gridy, gridz;
maxstep=20000, ds=0.01)
Given a 3D vector field, trace a streamline from a given point to the edge of the vector field. The field is integrated using Euler's method. Only valid for regular grid with coordinates gridx
, gridy
, gridz
. The field can be in both meshgrid
or ndgrid
(default) format. See also trace3d_euler
.
FieldTracer.trace3d_rk4
— Method trace3d_rk4(fieldx, fieldy, fieldz, startx, starty, startz, grid::CartesianGrid;
maxstep=20000, ds=0.01, gridtype="ndgrid", direction="both")
See also trace3d_euler
.
FieldTracer.trilin_reg
— Method trilin_reg(x, y, z, Q)
Trilinear interpolation for x1,y1,z1=(0,0,0) and x2,y2,z2=(1,1,1) Q's are surrounding points such that Q000 = F[0,0,0], Q100 = F[1,0,0], etc.