Grid.md
FaADE.Grid
— ModuleGrid
Submodule containing the grid data structure and functions.
One thing to note if editing code is that the Grid.jl
module has its own internal copy of first derivative operators for constructing curvilinear coordinates.
1D Problems
FaADE.Grid.Grid1D
— TypeGrid1D{TT<:Real,MET<:MetricType,GT<:Vector{TT},DT<:Union{Real,Vector{TT}}} <: LocalGridType{TT,1,MET}
Grid data structure for 1 dimensional problems.
Constructors:
Grid1D(𝒟::Vector{TT},n::Integer) where TT
Grid1D(𝒟::Vector{TT}) where TT
Grid points can be accessed as if the grid object is an array;
G = Grid2D([0.0,0.5],[0.0,1.0],5,5)
G[1]
Inputs:
- Vector of domain boundaries
[x_0,x_N]
- Number of grid points.
Returns:
- Struct for 1D grid object containing vector of grid points, $\Delta x$ and $n$.
2D
FaADE.Grid.Grid2D
— TypeGrid2D{TT,MET<:MetricType,GT<:AbstractArray{TT}} <: LocalGridType{TT,2,MET}
Grid data structure for 2 dimensional problems.
Grid points can be accessed as if the grid object is an array;
G = Grid2D([0.0,0.5],[0.0,1.0],5,5)
G[1,1]
Inputs:
- Domain boundaries in $x$
- Domain boundaries in $y$
- Number of nodes in $x$
- Number of nodes in $y$
Returns:
- Struct for 2D grid object containing grid points in $x$ and $y$, $\Delta x$ and $\Delta y$, and $n_x$ and $n_y$.
Multiblock grids
Solvers for these methods are not implemented yet (SATs required)
The following is used for constructing multiblock problems.
FaADE.Grid.GridMultiBlock
— TypeGridMultiBlock{TT,DIM,MET,TG,TJ,IT} <: GridType{TT,DIM,MET}
Grid data for multiblock problems
Grabbing a particular subgrid can be done by G.Grids[i]
which indexes in the order the grids are given. Indexing can be performed by G[i]
for 1D or G[i,j]
for 2D multiblock problems. GridMultiBlock.Joint
contains the information on how to connect grids. If periodic boundary conditions are being used, do not specify the joint across that boundary.
Example grid creation,
D1 = Grid2D([0.0,0.5],[0.0,1.0],5,5)
D2 = Grid2D([0.5,1.0],[0.0,1.0],5,5)
D3 = Grid2D([1.0,1.5],[0.0,1.0],5,5)
glayout = ([(2,Right)],
[(1,Left),(3,Right)],
[(2,Left)])
G = GridMultiBlock((D1,D2,D3),glayout)
Curvilinear grid generation
The meshgrid
function can be used to generate domains in curvilinear coordinates.
FaADE.Grid.meshgrid
— FunctionGenerates the 2D grid of nx
and ny
points in a domain given a set of functions which bound a domain.
meshgrid(cbottom::Function,cleft::Function,cright::Function,ctop::Function,nx::Int,ny::Int)
Construct a grid of nx
by ny
points in a domain bounded by the functions cbottom
, cleft
, cright
, and ctop
.
meshgrid(𝒟x::Vector{TT},𝒟y::Vector{TT}) where TT
Generate matrix of coordinates from vectors of coordinates this is useful for packed grids.
meshgrid(cinner::Function,couter::Function,nx,ny)
Meshgrid for annular domains where the inner and outer boundaries are parameterised boundaries
meshgrid(inner::Torus,outer::Torus,ζ,nr,nθ)
Take two tori and generate a meshgrid between them at a given toroidal angle ζ
with nr
radial points and nθ
poloidal points.
See also: Torus
Toroidal surfaces
For generating meshgrid functions in an annulus one can use the following commands to generate two torii.
FaADE.Grid.Torus
— TypeTorus{TT}
Represents a torus in boundary using Fourier series in R
and Z
coordinates as,
$R(\theta,\zeta) = \sum_{i,j} R_{i,j} cos(m_j\theta - n_i\zeta), \qquad Z(\theta,\zeta) = \sum_{i,j} Z_{i,j} sin(m_j\theta - n_i\zeta)$
where Rᵢⱼ
and Zᵢⱼ
are the Fourier coefficients and mⱼ
and nᵢ
are the Fourier modes.
Example:
Rin = [3e-1]; Zin=[-3e-1]
Rout = [6e-1]; Zout=[-6e-1]
inner = Torus(Rout,Zout,[1],[0])
outer = Torus(Rout,Zout,[1],[0])
meshgrid(inner,outer,0.0,11,21)
Coordinates at a given $\theta\in[0,R]$ and $\zeta\in[0,2\pi)$ can be computed using the call syntax
inner(θ,ζ)