API
Nmrc.Incident
Nmrc.Incident
Nmrc.PML
Nmrc.allocate_matrices
Nmrc.allocate_stiff_matrix
Nmrc.apply_all_bds!
Nmrc.assemble_A
Nmrc.assemble_A0
Nmrc.assemble_A1
Nmrc.assemble_A2
Nmrc.assemble_load
Nmrc.assemble_pml_A0
Nmrc.assemble_pml_A1
Nmrc.assemble_pml_A2
Nmrc.assemble_tbc
Nmrc.beta_n
Nmrc.compute_coef!
Nmrc.compute_scaling
Nmrc.coord_transform
Nmrc.dofs_on_dtn
Nmrc.get_width
Nmrc.periodic_cell
Nmrc.setup_bcs
Nmrc.setup_bdcs
Nmrc.setup_dofs
Nmrc.setup_fevs
Nmrc.setup_grid
Nmrc.setup_vals
Nmrc.sub_preserve_structure
Nmrc.Incident
— TypeIncident
Some parameters related to the incident field.
Parameters
k
: the wave numberθ
: the incident fieldα
: α = k * sin(θ)β
: β = k * cos(θ)
Nmrc.Incident
— MethodIncident(k::Float64, θ::Float64)
Define the incident field with the wavenumber k
and the incident field θ
.
Nmrc.PML
— TypePML
Information on PML layer and coordinate transformation.
Nmrc.allocate_matrices
— Methodallocate_matrices(dof::DofHandler, cst::ConstraintHandler)
Allocate the complex-valued stiffness matrices.
Nmrc.allocate_stiff_matrix
— Methodallocate_stiff_matrix(dofhandler::DofHandler, csthandler::ConstraintHandler, dofs)
Create a sparse pattern for the stiffness matrix. We need to add extra entries due to the DtN map by hand.
Nmrc.apply_all_bds!
— Methodapply_all_bds!(K::Union{SparseMatrixCSC, Symmetric}, ch::ConstraintHandler)
apply_all_bds!(KK::Union{SparseMatrixCSC, Symmetric}, f::AbstractVector, ch::ConstraintHandler, applyzero::Bool = false)
Impose the periodic boundary condition and the Dirichlet boundary condition on the matrices.
Nmrc.assemble_A
— Methodassemble_A(cv::CellValues, dh::DofHandler, A::SparseMatrixCSC, inc::Incident)
Nmrc.assemble_A0
— Methodassemble_A0(cv::CellValues, dh::DofHandler, A₀::SparseMatrixCSC, medium::Function, k)
Assemble the zero order term $\mathbf{A}_{0}$ in the Nonlinear eigenvalue problem.
$A_{0}(u, v) = \int \nabla u \cdot \nabla \bar{v} - k^{2}n(x_{1}, x_{2}) u \bar{v} d x.$
Argument
cv
: CellValuesdh
: DofHandlerA₀
: an empty sparse pattern preallocated for A₀medium
: refractive index function which describes the properties of the mediumk
: the wavenumber
See also assemble_A1
, assemble_A2
.
Nmrc.assemble_A1
— Methodassemble_A1(cv::CellValues, dh::DofHandler, A₁::SparseMatrixCSC)
Assemble the first order term $\mathbf{A}_{1}$ in the Nonlinear eigenvalue problem.
$A_{1}(u, v) = -\int 2i \partial_{1} u \bar{v} d x.$
See also assemble_A0
, assemble_A2
.
Nmrc.assemble_A2
— Methodassemble_A2(cv::CellValues, dh::DofHandler, A₂::SparseMatrixCSC)
Assemble the second order term in the Nonlinear eigenvalue problem.
$A_{2}(u, v) = \int u \bar{v} d x.$
See also assemble_A0
, assemble_A1
.
Nmrc.assemble_load
— Methodassemble_load(fv::FacetValues, dh::DofHandler, facetset, f, inc::Incident, height)
Assemble the load vector due to the incident field.
Nmrc.assemble_pml_A0
— Methodassemble_pml_A0(cv::CellValues, dh::DofHandler, A₀::SparseMatrixCSC, medium::Function, p::PML, k)
Assemble the zero order term in the quadratic eigenvalue problem constructed by PML-FEM.
$A_{0}(u, v) = \int s(x_{2}) \frac{\partial u}{\partial x_{1}} \frac{\partial \bar{v}}{\partial x_{1}} + \frac{1}{s(x_{2})} \frac{\partial u}{\partial x_{2}} \frac{\partial \bar{v}}{\partial x_{2}} - k^{2} n(x_{1}, x_{2}) s(x_{2}) u \bar{v} dx.$
Arguments
cv
: CellValuesdh
: DofHandlerA₀
: Sparse matix preallocated for A₀medium
: the refractive indexp
: the information about PML, seePML
k
: the wavenumber
See also assemble_pml_A1
, assemble_pml_A2
.
Nmrc.assemble_pml_A1
— Methodassemble_pml_A1(cv::CellValues, dh::DofHandler, A₁::SparseMatrixCSC, p::PML)
Assemble the first order term in the quadratic eigenvalue problem constructed by PML-FEM.
$A_{1}(u, v) = -\int 2i s(x_{2}) \frac{\partial u}{\partial x_{1}} \bar{v} dx.$
Arguments
cv
: CellValuesdh
: DofHandlerA₁
: Sparse matix preallocated for A₁p
: the information about PML, seePML
See also assemble_pml_A0
, assemble_pml_A2
.
Nmrc.assemble_pml_A2
— Methodassemble_pml_A2(cv::CellValues, dh::DofHandler, A₂::SparseMatrixCSC, p::PML)
Assemble the second order term in the quadratic eigenvalue problem from the PML-FEM method.
$A_{2}(u, v) = \int s(x_{2}) u \bar{v} dx.$
Arguments
cv
: CellValuesdh
: DofHandlerA₂
: Sparse matix preallocated for A₂p
: the information about PML, seePML
See also assemble_pml_A0
, assemble_pml_A1
.
Nmrc.assemble_tbc
— Methodassemble_tbc(fv::FacetValues, dh::DofHandler, inc::Incident, F::SparseMatrixCSC, facetset, N, dofsDtN)
Assemble the TBC matrix.
Nmrc.beta_n
— Methodbeta_n(inc::Incident, n)
Compute the βₙ
.
Nmrc.compute_coef!
— Methodcompute_coef!(fv::FacetValues, dh::DofHandler, θ::SparseVector, facetset, n)
Compute Θⁿ on the facetset
. Actually the computation of the TBC matrix reduces to the computation of the vector Θⁿ.
Nmrc.compute_scaling
— Methodcompute_scaling(A₀::M, A₁::M, A₂::M; scaling=:nothing::Symbol) where {T,M<:AbstractMatrix{T}}
TBW
Nmrc.coord_transform
— Methodcoord_transform(x₂, p::PML)
Coordinate transformation of PML method.
Nmrc.dofs_on_dtn
— Methoddofs_on_dtn(dh::DofHandler, field::Symbol, facetset)
Extract the global indices of Dofs associated to the artificial boundary.
Nmrc.get_width
— Methodget_width(p::PML)
Get the width of the PML layer.
Nmrc.periodic_cell
— Methodperiodic_cell(;lc=0.5, period=2π, height=2.0)
Generate a mesh for the periodic cell.
Arguments
lc
: the mesh size near pointsperiod
: the period of the periodic cellheight
: the height of the periodic cell
Points
4 ------------ 3
| |
| |
1 ------------ 2
Lines
. ---- l3 ---- .
l4 l2
. ---- l1 ---- .
Nmrc.setup_bcs
— Methodsetup_bcs(dh::DofHandler; period=2π)
Set the periodic boundary condition ("left" and "right") and Dirichelt boundary condition ("bottom").
Arguments
dh
: DofHandlerperiod
: the period of the periodic cell, seeperiodic_cell
Nmrc.setup_bdcs
— Methodsetup_bdcs(dof::DofHandler, d)
Set the periodic boundary condition ("left" and "right") and Dirichelt boundary condition ("bottom" and "top").
Nmrc.setup_dofs
— Methodsetup_dofs(grid::Grid, ip)
Setup degree of freedoms.
Nmrc.setup_fevs
— Methodsetup_fevs(ip)
Define quadrature rules on Reference triangle and setup FE values.
Nmrc.setup_grid
— Methodsetup_grid(;d=2π, ĥ=1.5, δ=2.0, lc=0.5, lp=0.5, vtk=false)
Generate a mesh by julia interface for Gmsh and read the .msh
file by FerriteGmsh
.
Arguments
d
: the period of the periodic layerĥ
: the start of the PML layerδ
: the height of the PML layerlc
: mesh size near the periodic layerlp
: mesh size in the PML layervtk
: write.vtk
file, default isfalse
Points
5 ------------- 4
| |
6 3
| |
1 ------------- 2
Lines
. ----- l4 ----- .
l5 l3
. .
l6 l2
. ----- l1 ----- .
Misc
- We can generate a
*.vtk
file by replace thedo end
block withgmsh.write(*.vtk)
Nmrc.setup_vals
— Methodsetup_vals(ip)
Set up CellValues and FacetValues by using interpolation ip
. Here we need to define FacetValues because the load vector and the TBC matrix contains integral on the boundary.
Nmrc.sub_preserve_structure
— Methodsub_preserve_structure(A::SparseMatrixCSC, B::SparseMatrixCSC)
Subtract two sparse matrix without changing the sparse pattern. A
and B
should have the same sparse pattern.