Spaces
Bramble.BrambleGridSpaceFunction
— Typestruct BrambleGridSpaceFunction{S,T}
f_tuple::FunctionWrapper{T, Tuple{VectorElement{S,T}}}
end
Structure to wrap around functions defined on gridspaces to make them more type agnostic. It uses FunctionWrappers
to provide functions calculated on VectorElement.
Bramble.GridSpace
— Typestruct GridSpace{MType,D,T}
mesh::MType
innerh_weights::Vector{T}
innerplus_weights::NTuple{D,Vector{T}}}
cache::SpaceCacheType
end
Structure for a gridspace defined on a mesh.
The vector innerh_weights
has the weights for the standard discrete $L^2$ inner product on the space of grid functions defined as follows
- 1D case
\[(u_h, v_h)_h = \sum_{i=1}^{N_x} |\square_{i}| u_h(x_i) v_h(x_i)\]
- 2D case
\[(u_h, v_h)_h = \sum_{i=1}^{N_x}\sum_{j=1}^{N_y} |\square_{i,j}| u_h(x_i,y_j) v_h(x_i,y_j)\]
- 3D case
\[(u_h, v_h)_h = \sum_{i=1}^{N_x}\sum_{j=1}^{N_y}\sum_{l=1}^{N_z} |\square_{i,j,l}| u_h(x_i,y_j,z_l) v_h(x_i,y_j,z_l).\]
Here, $|\cdot|$ denotes the measure of the set and all details on the definition of $\square_{i}$, $\square_{i,j}$ and $\square_{i,j,l}$ can be found in functions cell_measure (for the 1
-dimensional case) and cell_measure (for the n
-dimensional cases).
The tuple of vectors innerplus_weights
has the weights for the modified discrete $L^2$ inner product on the space of grid functions, for each component (x, y, z).
- 1D case
\[(u_h, v_h)_+ = \sum_{i=1}^{N_x} h_{i} u_h(x_i) v_h(x_i)\]
- 2D case
\[(u_h, v_h)_{+x} = \sum_{i=1}^{N_x}\sum_{j=1}^{N_y} h_{x,i} h_{y,j+1/2} u_h(x_i,y_j) v_h(x_i,y_j)\]
\[(u_h, v_h)_{+y} = \sum_{i=1}^{N_x}\sum_{j=1}^{N_y} h_{x,i} h_{y,j+1/2} u_h(x_i,y_j) v_h(x_i,y_j)\]
- 3D case
\[(u_h, v_h)_{+x} = \sum_{i=1}^{N_x}\sum_{j=1}^{N_y}\sum_{l=1}^{N_z} h_{x,i} h_{y,j+1/2} h_{z,l+1/2} u_h(x_i,y_j,z_l) v_h(x_i,y_j,z_l)\]
\[(u_h, v_h)_{+y} = \sum_{i=1}^{N_x}\sum_{j=1}^{N_y}\sum_{l=1}^{N_z} h_{x,i+1/2} h_{y,j} h_{z,l+1/2} u_h(x_i,y_j,z_l) v_h(x_i,y_j,z_l)\]
\[(u_h, v_h)_{+z} = \sum_{i=1}^{N_x}\sum_{j=1}^{N_y}\sum_{l=1}^{N_z} h_{x,i+1/2} h_{y,j+1/2} h_{z,l} u_h(x_i,y_j,z_l) v_h(x_i,y_j,z_l).\]
Bramble.MatrixElement
— TypeMatrixElement{S, T}
A MatrixElement
is a container with a sparse matrix where each entry is a T
. the container also has a space S
to retain the information to which this special element belongs to. Its purpose is to represent discretization matrices from finite difference methods.
Bramble.SpaceType
— TypeSpaceType
Abstract type for grid spaces defined on meshes of type MeshType.
Bramble.VectorElement
— Typestruct VectorElement{S,T}
space::S
values::Vector{T}
end
Vector element of space S
with coefficients of type T
.
Base.eltype
— Methodeltype(Wₕ::SpaceType)
eltype(::Type{<:SpaceType{MType}})
Returns the element type of the mesh associated with GridSpace Wₕ
. If the input argument is a type derived from SpaceType then the function returns the element type of the MeshType associated with it.
Bramble.__innerplus_weights!
— Method__innerplus_weights!(v, innerplus_per_component)
Builds the weights for the modified discrete $L^2$ inner product on the space of grid functions GridSpace. The result is stored in vector v
.
Bramble._innerplus_mean_weights!
— Method_innerplus_mean_weights!(u::Vector{T}, Ωₕ::MeshType, component::Int = 1)
Builds a set of weights based on the half spacings, associated with the component
-th direction, for the modified discrete $L^2$ inner product on the space of grid functions, following the order of the points. The values are stored in vector u
. for each component.
Bramble._innerplus_weights!
— Method_innerplus_weights!(u::Vector{T}, Ωₕ::MeshType, component::Int = 1)
Builds a set of weights based on the spacings, associated with the component
-th direction, for the modified discrete $L^2$ inner product on the space of grid functions, following the order of the points provided by indices(Ωₕ)
. The values are stored in vector u
.
Bramble.build_innerh_weights!
— Methodbuild_innerh_weights!(u, Ωₕ::MeshType)
Builds the weights for the standard discrete $L^2$ inner product, $inner_h(\cdot, \cdot)$, on the space of grid functions, following the order of the points provided by indices(Ωₕ)
. The values are stored in vector u
.
Bramble.get_diff_matrix
— Methodget_diff_matrix(Wₕ::SpaceType, i)
Returns the i
-th cached differentiation matrix of GridSpace Wₕ
.
Bramble.ndofs
— Methodndofs(Wₕ::SpaceType)
Returns the number of degrees of freedom of the GridSpace Wₕ
.
Base.:*
— Method*(uₕ::VectorElement, vₕ::VectorElement)
Returns a new VectorElement with coefficients given by the elementwise evaluation of uₕ
*vₕ
.
Base.:*
— Method*(uₕ::VectorElement, α::Number)
Returns a new VectorElement with coefficients given by the elementwise evaluation ofuₕ
*α
.
Base.:*
— Method*(α::Number, uₕ::VectorElement)
Returns a new VectorElement with coefficients given by the elementwise evaluation ofα
*uₕ
.
Base.:+
— Method+(uₕ::VectorElement, vₕ::VectorElement)
Returns a new VectorElement with coefficients given by the elementwise evaluation of uₕ
+vₕ
.
Base.:+
— Method+(uₕ::VectorElement, α::Number)
Returns a new VectorElement with coefficients given by the elementwise evaluation ofuₕ
+α
.
Base.:+
— Method+(α::Number, uₕ::VectorElement)
Returns a new VectorElement with coefficients given by the elementwise evaluation ofα
+uₕ
.
Base.:-
— Method-(uₕ::VectorElement, vₕ::VectorElement)
Returns a new VectorElement with coefficients given by the elementwise evaluation of uₕ
-vₕ
.
Base.:-
— Method-(uₕ::VectorElement, α::Number)
Returns a new VectorElement with coefficients given by the elementwise evaluation ofuₕ
-α
.
Base.:-
— Method-(α::Number, uₕ::VectorElement)
Returns a new VectorElement with coefficients given by the elementwise evaluation ofα
-uₕ
.
Base.:/
— Method/(uₕ::VectorElement, vₕ::VectorElement)
Returns a new VectorElement with coefficients given by the elementwise evaluation of uₕ
/vₕ
.
Base.:/
— Method/(uₕ::VectorElement, α::Number)
Returns a new VectorElement with coefficients given by the elementwise evaluation ofuₕ
/α
.
Base.:/
— Method/(α::Number, uₕ::VectorElement)
Returns a new VectorElement with coefficients given by the elementwise evaluation ofα
/uₕ
.
Base.:^
— Method^(uₕ::VectorElement, vₕ::VectorElement)
Returns a new VectorElement with coefficients given by the elementwise evaluation of uₕ
^vₕ
.
Base.:^
— Method^(uₕ::VectorElement, α::Number)
Returns a new VectorElement with coefficients given by the elementwise evaluation ofuₕ
^α
.
Base.:^
— Method^(α::Number, uₕ::VectorElement)
Returns a new VectorElement with coefficients given by the elementwise evaluation ofα
^uₕ
.
Base.copyto!
— Methodcopyto!(uₕ::VectorElement, vₕ::VectorElement)
copyto!(uₕ::VectorElement, v::AbstractVector)
copyto!(uₕ::VectorElement, α::Number)
Copies the coefficients of VectorElement vₕ
into VectorElement uₕ
. The second argument can also be a regular Vector
or a Number
`.
Base.eltype
— Methodeltype(uₕ::VectorElement{S,T})
eltype(::Type{<:VectorElement{S,T}})
Returns the element type of a VectorElement uₕ
, T
`.
Base.similar
— Methodsimilar(uh::VectorElement)
Returns a new VectorElement belonging to the same GridSpace as uh
, with uninitialized components.
Bramble.__integrand1d
— Method__integrand1d(y, t, p)
Implements the integrand function needed in the calculation of avgₕ. In this function, y
denotes the return values, t
denotes the integration variable and p
denotes the parameters (integrand function f
, points x
, spacing h
and indices idxs
).
For efficiency, each integral in avgₕ is rewritten as an integral over [0,1]
following
\[\int_{a}^{b} f(x) dx = (b-a) \int_{0}^{1} f(a + t (b-a)) dt\]
Bramble.__integrandnd
— Method__integrandnd(y, t, p)
Implements the integrand function needed in the calculation of avgₕ. In this function, y
denotes the return values, t
denotes the integration variable and p
denotes the parameters (integrand function f
, points x
, measures meas
and indices idxs
).
For efficiency, each integral is calculated on $[0,1]^D$, where $D$ is the dimension of the integration domain. This is done through a similar change of variable as in __integrand1d(y, t, p).
Bramble.space
— Methodspace(uₕ::VectorElement)
Returns the space associated with VectorElement uₕ
.
Base.:*
— Method*(Uₕ::MatrixElement, Vₕ::MatrixElement)
Returns a new MatrixElement given by multiplying the matrix of MatrixElement Uₕ
by the matrix of MatrixElement Vₕ
.
Base.:*
— Method*(Uₕ::MatrixElement, vₕ::VectorElement)
Returns a new MatrixElement calculated by multiplying each coefficient of VectorElement vₕ
with the corresponding column of Uₕ
.
Base.:*
— Method*(Uₕ::MatrixElement, α::Number)
Returns a new MatrixElement with coefficients given by the elementwise evaluation ofUₕ
*α
.
Base.:*
— Method*(uₕ::VectorElement, Vₕ::MatrixElement)
Returns a new MatrixElement calculated by multiplying each coefficient of VectorElement uₕ
with the corresponding row of Vₕ
.
Base.:*
— Method*(α::Number, Uₕ::MatrixElement)
Returns a new MatrixElement with coefficients given by the elementwise evaluation ofα
*Uₕ
.
Base.:+
— Method+(Uₕ::MatrixElement, Vₕ::MatrixElement)
Returns a new MatrixElement given by adding the matrix of MatrixElement Uₕ
to the matrix of MatrixElement Vₕ
.
Base.:+
— Method+(Uₕ::MatrixElement, α::Number)
Returns a new MatrixElement with coefficients given by the elementwise evaluation ofUₕ
+α
.
Base.:+
— Method+(α::Number, Uₕ::MatrixElement)
Returns a new MatrixElement with coefficients given by the elementwise evaluation ofα
+Uₕ
.
Base.:-
— Method-(Uₕ::MatrixElement, Vₕ::MatrixElement)
Returns a new MatrixElement given by subtracting the matrix of MatrixElement Vₕ
to the matrix of MatrixElement Uₕ
.
Base.:-
— Method-(Uₕ::MatrixElement, α::Number)
Returns a new MatrixElement with coefficients given by the elementwise evaluation ofUₕ
-α
.
Base.:-
— Method-(α::Number, Uₕ::MatrixElement)
Returns a new MatrixElement with coefficients given by the elementwise evaluation ofα
-Uₕ
.
Base.:/
— Method/(Uₕ::MatrixElement, α::Number)
Returns a new MatrixElement with coefficients given by the elementwise evaluation ofUₕ
/α
.
Base.:/
— Method/(α::Number, Uₕ::MatrixElement)
Returns a new MatrixElement with coefficients given by the elementwise evaluation ofα
/Uₕ
.
Base.:^
— Method^(Uₕ::MatrixElement, α::Number)
Returns a new MatrixElement with coefficients given by the elementwise evaluation ofUₕ
^α
.
Base.:^
— Method^(α::Number, Uₕ::MatrixElement)
Returns a new MatrixElement with coefficients given by the elementwise evaluation ofα
^Uₕ
.
Base.copyto!
— Methodcopyto!(Uₕ::MatrixElement, Vₕ::MatrixElement)
Copies the coefficients of MatrixElement Vₕ
into MatrixElement Uₕ
.
Base.eltype
— Methodeltype(Uₕ::MatrixElement{S,T})
eltype(::Type{MatrixElement{S,T}})
Returns the element type of a MatrixElement, T
`.
Base.length
— Methodlength(Uₕ::MatrixElement)
Returns the length of a MatrixElement.
Base.similar
— Methodsimilar(Uₕ::MatrixElement)
Returns a similar MatrixElement to Uₕ
.
Bramble.elements
— Methodelements(Wₕ::SpaceType, A::SparseMatrixCSC)
Returns a MatrixElement from a given SpaceType, initialized with the sparse matrix A
.
Bramble.elements
— Methodelements(Wₕ::SpaceType)
Returns a MatrixElement from a given SpaceType, initialized with the identity matrix.
Bramble.space
— Methodspace(Uₕ::MatrixElement)
Returns the space associated with the MatrixElement Uₕ
.
Bramble._backward_differencex!
— Method_backward_differencex!(out, in, dims::NTuple{1,Int})
In-place computation of the backward difference in the x
direction of vector in
for a 1
-dimensional element. The result is stored in out
. Allows for in
and out
to be the same vector.
Bramble._backward_differencex!
— Method_backward_differencex!(out, in, dims::NTuple{D,Int}, ::Val{D})
In-place computation of the backward difference in the x
direction of vector in
for a D
-dimensional ($D>1$) element. The result is stored in out
. Allows for in
and out
to be the same vector.
Bramble._backward_differencey!
— Method_backward_differencey!(out, in, dims::NTuple{3,Int})
In-place computation of the backward difference in the y
direction of vector in
for a 3
-dimensional element. The result is stored in out
. Allows for in
and out
to be the same vector.
Bramble._backward_differencey!
— Method_backward_differencey!(out, in, dims::NTuple{2,Int})
In-place computation of the difference in the y
direction of vector in
for a 2
-dimensional element. The result is stored in out
. Allows for in
and out
to be the same vector.
Bramble._backward_differencez!
— Method_backward_differencez!(out, in, dims::NTuple{3,Int})
In-place computation of the backward difference in the z
direction of vector in
for a 3
-dimensional element. The result is stored in out
. Allows for in
and out
to be the same vector.
Bramble._backward_finite_differencex!
— Method_backward_finite_differencex!(out, in, hx, dims::NTuple{1,Int})
In-place computation of the backward finite difference in the x
direction of vector in
for a 1
-dimensional element. The spacings are encoded in hx
. The result is stored in out
. Allows for in
and out
to be the same vector.
Bramble._backward_finite_differencex!
— Method_backward_finite_differencex!(out, in, hx, dims::NTuple{D,Int})
In-place computation of the backward finite difference in the x
direction of vector in
for a D
-dimensional element. The spacings are encoded in hx
. The result is stored in out
. Allows for in
and out
to be the same vector.
Bramble._backward_finite_differencey!
— Method_backward_finite_differencey!(out, in, hy, dims::NTuple{3,Int})
In-place computation of the backward finite difference in the y
direction of vector in
for a 3
-dimensional element. The spacings are encoded in hy
. The result is stored in out
. Allows for in
and out
to be the same vector.
Bramble._backward_finite_differencey!
— Method_backward_finite_differencey!(out, in, hy, dims::NTuple{2,Int})
In-place computation of the backward finite difference in the y
direction of vector in
for a 2
-dimensional element. The spacings are encoded in hy
. The result is stored in out
. Allows for in
and out
to be the same vector.
Bramble._backward_finite_differencez!
— Method_backward_finite_differencez!(out, in, hz, dims::NTuple{3,Int})
In-place computation of the backward finite difference in the z
direction of vector in
for a 3
-dimensional element. The spacings are encoded in hz
. The result is stored in out
. Allows for in
and out
to be the same vector.
Bramble.weights_D₋ᵧ!
— Methodweights_D₋ᵧ!(v, Ωₕ::MeshType, ::Val{2})
Sets v
to the inverse of the spacing of Ωₕ
on the y
component, $h_{y,j}$ .
Bramble.weights_D₋ᵧ!
— Methodweights_D₋ᵧ!(v, Ωₕ::MeshType, ::Val{3})
Sets v
to the inverse of the spacing of Ωₕ
on the y
component, $h_{y,j}$ .
Bramble.weights_D₋₂!
— Methodweights_D₋₂!(v, Ωₕ::MeshType, ::Val{3})
Sets v
to the inverse of the spacing of Ωₕ
on the z
component, $h_{z,l}$ .
Bramble.weights_D₋ₓ!
— Methodweights_D₋ₓ!(v, Ωₕ::MeshType, ::Val{1})
Sets v
to the inverse of the spacing of Ωₕ
on the x
component, $h_{i}$ .
Bramble.weights_D₋ₓ!
— Methodweights_D₋ₓ!(v, Ωₕ::MeshType, ::Val{D})
Sets v
to the inverse of the spacing of Ωₕ
on the x
component, $h_{x,i}$ .
Bramble.innerh_weights
— Methodinnerh_weights(Wₕ::SpaceType)
Returns the weights to be used in the calculation of innerₕ.
Bramble.innerplus_weights
— Methodinnerplus_weights(Wₕ::SpaceType, ::Val{D})
Returns the weights to be used in the calculation of inner₊
.