From dc47c11daad57962034fc166c370a88cab712cca Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Tue, 5 Sep 2023 02:53:33 +0000 Subject: [PATCH] build based on b86ae14 --- dev/example/index.html | 2 +- dev/index.html | 2 +- dev/internal/index.html | 14 +++++++------- dev/log/index.html | 2 +- dev/search/index.html | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dev/example/index.html b/dev/example/index.html index cdb644f..f1f7528 100644 --- a/dev/example/index.html +++ b/dev/example/index.html @@ -30,4 +30,4 @@ lx, ly = trace(u, v, startx, starty, x, y, maxstep=20) linex[1:length(lx),i] = lx liney[1:length(ly),i] = ly -end

Arrow

When plotting, it is usually convenient to display an arrow along the line for showing the direction. Currently we provide a function add_arrow which acts on a Matplotlib Line2D object and adds an arrow for it.[3]

An example is shown for the 2D streamline tracing in the unstructured triangular mesh for the famous airfoil problem. The blue lines are the analytic stream functions derived from incompressible Euler equations which are calculated numerically. Three colored lines are displayed with dots representing the footprints inside each cell.

+end

Arrow

When plotting, it is usually convenient to display an arrow along the line for showing the direction. Currently we provide a function add_arrow which acts on a Matplotlib Line2D object and adds an arrow for it.[3]

An example is shown for the 2D streamline tracing in the unstructured triangular mesh for the famous airfoil problem. The blue lines are the analytic stream functions derived from incompressible Euler equations which are calculated numerically. Three colored lines are displayed with dots representing the footprints inside each cell.

diff --git a/dev/index.html b/dev/index.html index 4c81129..1af2bd8 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -Home · FieldTracer.jl

FieldTracer

Vector field tracing on common types of meshes.

This package supports 2nd and 4th order field line tracing on

  • 2D/3D regular Cartesian mesh
  • 2D unstructured quadrilateral mesh
  • 2D unstructured triangular mesh

It can be used for

  • generating streamlines and fieldlines;
  • checking field connectivity between spatial cells.
+Home · FieldTracer.jl

FieldTracer

Vector field tracing on common types of meshes.

This package supports 2nd and 4th order field line tracing on

  • 2D/3D regular Cartesian mesh
  • 2D unstructured quadrilateral mesh
  • 2D unstructured triangular mesh

It can be used for

  • generating streamlines and fieldlines;
  • checking field connectivity between spatial cells.
diff --git a/dev/internal/index.html b/dev/internal/index.html index 3697dde..436b8c5 100644 --- a/dev/internal/index.html +++ b/dev/internal/index.html @@ -1,11 +1,11 @@ -Internal · FieldTracer.jl

API

Public APIs

FieldTracer.select_seedsMethod
 select_seeds(x, y, z; nsegment=(5, 5, 5))

Generate uniform seeding points in the grid range x, y and z in nsegment.

source
FieldTracer.select_seedsMethod
 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!

source
FieldTracer.traceMethod
 trace(fieldx, fieldy, fieldz, startx, starty, startz, gridx, gridy, gridz;
+Internal · FieldTracer.jl

API

Public APIs

FieldTracer.select_seedsMethod
 select_seeds(x, y, z; nsegment=(5, 5, 5))

Generate uniform seeding points in the grid range x, y and z in nsegment.

source
FieldTracer.select_seedsMethod
 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!

source
FieldTracer.traceMethod
 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.

source
FieldTracer.traceMethod
 trace(mesh::SimpleMesh, vx, vy, xstart, ystart; maxIter=1000, maxLen=1000.)

2D stream tracing on unstructured quadrilateral and triangular mesh.

source

Private APIs

FieldTracer.bilin_regMethod
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.

source
FieldTracer.eulerMethod
euler(maxstep, ds, startx, starty, xGrid, yGrid, ux, uy)

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).

source
FieldTracer.eulerMethod
euler(maxstep, ds, startx, starty, startz, xGrid, yGrid, zGrid, ux, uy, uz)

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).

source
FieldTracer.grid_interpMethod
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).

source
FieldTracer.grid_interpMethod
grid_interp(x, y, z, field, ix, iy, iz, xsize, ysize)

Interpolate a value at (x,y,z) in a field. ix,iy and iz are indexes for x, y and z locations (0-based). xsize and ysize are the sizes of field in X and Y.

source
FieldTracer.rk4Method
rk4(maxstep, ds, startx, starty, xGrid, yGrid, ux, uy)

Fast and reasonably accurate 2D tracing with 4th order Runge-Kutta method and constant step size ds. See also euler.

source
FieldTracer.rk4Method
rk4(maxstep, ds, startx, starty, startz, xGrid, yGrid, zGrid, ux, uy, uz)

Fast and reasonably accurate 3D tracing with 4th order Runge-Kutta method and constant step size ds. See also euler.

source
FieldTracer.trace2d_eulerMethod
 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"}.

source
FieldTracer.trace2d_rk4Method
 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.

source
FieldTracer.trace3d_eulerMethod
 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"}.

source
FieldTracer.trace3d_rk4Method
 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.

source
FieldTracer.trilin_regMethod
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.

source
+ 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.

source
FieldTracer.traceMethod
 trace(mesh::SimpleMesh, vx, vy, xstart, ystart; maxIter=1000, maxLen=1000.)

2D stream tracing on unstructured quadrilateral and triangular mesh.

source

Private APIs

FieldTracer.bilin_regMethod
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.

source
FieldTracer.eulerMethod
euler(maxstep, ds, startx, starty, xGrid, yGrid, ux, uy)

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).

source
FieldTracer.eulerMethod
euler(maxstep, ds, startx, starty, startz, xGrid, yGrid, zGrid, ux, uy, uz)

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).

source
FieldTracer.grid_interpMethod
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).

source
FieldTracer.grid_interpMethod
grid_interp(x, y, z, field, ix, iy, iz, xsize, ysize)

Interpolate a value at (x,y,z) in a field. ix,iy and iz are indexes for x, y and z locations (0-based). xsize and ysize are the sizes of field in X and Y.

source
FieldTracer.rk4Method
rk4(maxstep, ds, startx, starty, xGrid, yGrid, ux, uy)

Fast and reasonably accurate 2D tracing with 4th order Runge-Kutta method and constant step size ds. See also euler.

source
FieldTracer.rk4Method
rk4(maxstep, ds, startx, starty, startz, xGrid, yGrid, zGrid, ux, uy, uz)

Fast and reasonably accurate 3D tracing with 4th order Runge-Kutta method and constant step size ds. See also euler.

source
FieldTracer.trace2d_eulerMethod
 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"}.

source
FieldTracer.trace2d_rk4Method
 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.

source
FieldTracer.trace3d_eulerMethod
 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"}.

source
FieldTracer.trace3d_rk4Method
 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.

source
FieldTracer.trilin_regMethod
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.

source
diff --git a/dev/log/index.html b/dev/log/index.html index 67fa45d..2e61583 100644 --- a/dev/log/index.html +++ b/dev/log/index.html @@ -1,2 +1,2 @@ -Log · FieldTracer.jl

Log

Streamline and trajectory are related topics in physical modeling, common seen in fluid and particle simulations.

First make it work, then make it better and fast.

One approach is called Pollock method.

Tracing in Unstructured Grid

Given an unstructured grid with node points and connectivity, how should you do the streamline tracing?

Brute force algorithm:

  1. find the grid cell you are currently in;
  2. move along the vector direction until you hit the boundary of that cell;
  3. find the neighbour who shares the same edge and the intersection point;
  4. use the vector direction in the next cell and move along that direction;
  5. repeat 2-4 until you reach any of the stopping criteria: hit the boundary, exceed MaxIteration, or exceed MaxLength.

Some questions during the process:

  • How to find the neighbouring cell?
  • How to determine which boundary edge will you cross?
  • How to improve the search speed?
  • How to improve accuracy?

MATLAB

There is an implementation of streamline tracing in Matlab called tristream. It requires nodal data.

Inside the function, there is an intrinsic function called pointLocation, which returns the index of cell where the point locates.

YT

There is another implementation in yt library, which has many similarities to the one I borrowed from SpacePy.

Streamlining through a volume is useful for a variety of analysis tasks. By specifying a set of starting positions, the user is returned a set of 3D positions that can, in turn, be used to visualize the 3D path of the streamlines. Additionally, individual streamlines can be converted into YTStreamline objects, and queried for all the available fields along the streamline.

The implementation of streamlining in yt is described below.

  1. Decompose the volume into a set of non-overlapping, fully domain tiling bricks, using the AMRKDTree homogenized volume.

  2. For every streamline starting position:

  • While the length of the streamline is less than the requested length:

    1. Find the brick that contains the current position.

    2. If not already present, generate vertex-centered data for the vector fields defining the streamline.

    3. While inside the brick:

    4. integrate the streamline path using a Runge-Kutta 4th order method and the vertex centered data.

    5. during the intermediate steps of each RK4 step, if the position is updated to outside the current brick, interrupt the integration and locate a new brick at the intermediate position.

  1. The set of streamline positions are stored in the Streamlines object.

VTK

In the VTK library, there is a class called vtkPointLocator. It is a spatial search object to quickly locate points in 3D. vtkPointLocator works by dividing a specified region of space into a regular array of "rectangular" buckets, and then keeping a list of points that lie in each bucket. Typical operation involves giving a position in 3D and finding the closest point. It supports both nodal data and cell data.

vtkPointLocator has two distinct methods of interaction. In the first method, you supply it with a dataset, and it operates on the points in the dataset. In the second method, you supply it with an array of points, and the object operates on the array.

Note

Many other types of spatial locators have been developed such as octrees and kd-trees. These are often more efficient for the operations described here.

+Log · FieldTracer.jl

Log

Streamline and trajectory are related topics in physical modeling, common seen in fluid and particle simulations.

First make it work, then make it better and fast.

One approach is called Pollock method.

Tracing in Unstructured Grid

Given an unstructured grid with node points and connectivity, how should you do the streamline tracing?

Brute force algorithm:

  1. find the grid cell you are currently in;
  2. move along the vector direction until you hit the boundary of that cell;
  3. find the neighbour who shares the same edge and the intersection point;
  4. use the vector direction in the next cell and move along that direction;
  5. repeat 2-4 until you reach any of the stopping criteria: hit the boundary, exceed MaxIteration, or exceed MaxLength.

Some questions during the process:

  • How to find the neighbouring cell?
  • How to determine which boundary edge will you cross?
  • How to improve the search speed?
  • How to improve accuracy?

MATLAB

There is an implementation of streamline tracing in Matlab called tristream. It requires nodal data.

Inside the function, there is an intrinsic function called pointLocation, which returns the index of cell where the point locates.

YT

There is another implementation in yt library, which has many similarities to the one I borrowed from SpacePy.

Streamlining through a volume is useful for a variety of analysis tasks. By specifying a set of starting positions, the user is returned a set of 3D positions that can, in turn, be used to visualize the 3D path of the streamlines. Additionally, individual streamlines can be converted into YTStreamline objects, and queried for all the available fields along the streamline.

The implementation of streamlining in yt is described below.

  1. Decompose the volume into a set of non-overlapping, fully domain tiling bricks, using the AMRKDTree homogenized volume.

  2. For every streamline starting position:

  • While the length of the streamline is less than the requested length:

    1. Find the brick that contains the current position.

    2. If not already present, generate vertex-centered data for the vector fields defining the streamline.

    3. While inside the brick:

    4. integrate the streamline path using a Runge-Kutta 4th order method and the vertex centered data.

    5. during the intermediate steps of each RK4 step, if the position is updated to outside the current brick, interrupt the integration and locate a new brick at the intermediate position.

  1. The set of streamline positions are stored in the Streamlines object.

VTK

In the VTK library, there is a class called vtkPointLocator. It is a spatial search object to quickly locate points in 3D. vtkPointLocator works by dividing a specified region of space into a regular array of "rectangular" buckets, and then keeping a list of points that lie in each bucket. Typical operation involves giving a position in 3D and finding the closest point. It supports both nodal data and cell data.

vtkPointLocator has two distinct methods of interaction. In the first method, you supply it with a dataset, and it operates on the points in the dataset. In the second method, you supply it with an array of points, and the object operates on the array.

Note

Many other types of spatial locators have been developed such as octrees and kd-trees. These are often more efficient for the operations described here.

diff --git a/dev/search/index.html b/dev/search/index.html index cf7845c..bf0ccf5 100644 --- a/dev/search/index.html +++ b/dev/search/index.html @@ -1,2 +1,2 @@ -Search · FieldTracer.jl

Loading search...

    +Search · FieldTracer.jl

    Loading search...