Operators and Algebra

Base.:*Method
*(b::Number, A::ScalarField)

Performs multiplication of a ScalarField objects and a Number.

Return: ScalarField

Examples

C = 2.0 * A
source
Base.:*Method
*(A::ScalarField, b::Number)

Performs multiplication of a ScalarField objects and a Number.

Return: ScalarField

Examples

C = A * 2.0
source
Base.:*Method
*(A::ScalarField, B::ScalarField)

Performs element-wise multiplication of two ScalarField objects on the same set of elements.

Returns: ScalarField

Examples

C = A * B
source
Base.:*Method
*(A::ScalarField, B::VectorField)

Scales a VectorField by a ScalarField element-wise on matching elements.

Returns: VectorField

Examples

v2 = s .* v  # equivalent to s * v
source
Base.:*Method
*(A::SystemMatrix, c::Number)
*(c::Number, A::SystemMatrix)

Scalar multiplication of a system matrix.

source
Base.:*Method
*(A::TensorField, B::TensorField)

Tensor contraction (matrix multiplication) for each element/node: reshapes 9×1 blocks into 3×3, multiplies, then flattens back.

Returns: TensorField

source
Base.:*Method
*(A::Union{SystemMatrix,Matrix}, B::Union{ScalarField,VectorField,TensorField})

Matrix–vector multiplication between a system matrix and a nodal vector field.

If the vector field is defined elementwise, it is automatically converted to nodal representation before multiplication.

Returns

  • VectorField containing the nodal result with one time step.
source
Base.:*Method
*(B::VectorField, A::ScalarField)

Scales a VectorField by a ScalarField element-wise on matching elements.

Returns: VectorField

source
Base.:+Method
+(b::Number, A::ScalarField)

Add a constant offset to a scalar field.

The scalar b is added elementwise to each entry of every element-wise matrix of the scalar field.

If the field is nodal, it is first converted to elementwise form.

Returns

  • A new ScalarField containing the shifted values.
source
Base.:+Method
+(A::ScalarField, b::Number)

Add a constant offset to a scalar field.

The scalar b is added elementwise to each entry of every element-wise matrix of the scalar field.

If the field is nodal, it is first converted to elementwise form.

Returns

  • A new ScalarField containing the shifted values.
source
Base.:+Method
+(A::ScalarField, B::ScalarField)

Performs element-wise addition of two ScalarField objects on the same set of elements.

Returns: ScalarField

Examples

C = A + B
source
Base.:+Method
+(A::SystemMatrix, B::SystemMatrix)
-(A::SystemMatrix, B::SystemMatrix)

Addition and subtraction of system matrices.

source
Base.:-Method
-(b::Number, A::ScalarField)

Subtract a constant offset from a scalar field.

The scalar b is subtracted elementwise from each entry of every element-wise matrix of the scalar field.

If the field is nodal, it is first converted to elementwise form.

Returns

  • A new ScalarField containing the shifted values.
source
Base.:-Method
-(A::ScalarField, b::Number)

Subtract a constant offset from a scalar field.

The scalar b is subtracted elementwise from each entry of every element-wise matrix of the scalar field.

If the field is nodal, it is first converted to elementwise form.

Returns

  • A new ScalarField containing the shifted values.
source
Base.:-Method
-(A::ScalarField, B::ScalarField)

Performs element-wise subtraction of two ScalarField objects on the same set of elements.

Returns: ScalarField

Examples

C = A - B
source
Base.:/Method
/(b::Number, A::ScalarField)

Elementwise division of a constant by a scalar field.

Each element-wise matrix of the scalar field is used as the divisor of the constant b, i.e. b ./ A.

If the field is nodal, it is first converted to elementwise form.

Returns

  • A new ScalarField containing the elementwise divided values.
source
Base.:/Method
/(A::ScalarField, b::Number)

Elementwise division of a scalar field by a constant.

Each element-wise matrix of the scalar field is divided by the scalar b. If the field is nodal, it is first converted to elementwise form.

Returns

  • A new ScalarField containing the elementwise divided values.
source
Base.:/Method
/(A::ScalarField, B::ScalarField)

Performs element-wise division of two ScalarField objects on the same set of elements.

Returns: ScalarField

Examples

C = A / B
source
Base.:/Method
/(B::VectorField, A::ScalarField)

Divides a VectorField by a ScalarField element-wise on matching elements.

Returns: VectorField

source
Base.:\Method
\(A::Union{SystemMatrix,Matrix}, b::Union{ScalarField,VectorField,TensorField})

Solves the linear system A * x = b for a nodal scalar, vectoror tensor field right-hand side.

If the field is defined elementwise, it will be converted to nodal form before solving.

Returns

  • ScalarField or VectorField or TensorField containing the solution.
source
Base.:\Method
\(K::Union{SystemMatrix,SparseMatrixCSC}, F::SparseMatrixCSC)

Solves a sparse linear system with multiple right-hand sides.

Returns

  • Sparse matrix containing the solution.
source
Base.:∘Method
∘(D::Function, A::Union{ScalarField,VectorField})

Left application of differential operator D to field A.

  • If D == ∇ and A is ScalarField: returns grad(A).
  • If D == ∇ and A is VectorField: returns grad(A)' (transpose).

Returns: VectorField or TensorField

Examples

# 3D (assumes `problem` and a "body" physical group are defined)
V = vectorField(problem, [field("body", fx=x->x, fy=y->y, fz=z->z)])
T = ∇ ∘ V      # equals grad(V)'
source
Base.:∘Method
∘(A::Union{ScalarField,VectorField}, D::Function)

Right application of differential operator D to field A.

  • If D == ∇ and A is ScalarField: returns grad(A).
  • If D == ∇ and A is VectorField: returns grad(A).

Returns: VectorField or TensorField

Examples

# 3D (assumes `problem` and a "body" physical group are defined)
S = scalarField(problem, [field("body", f=(x,y,z)->x*y)])
G = S ∘ ∇      # grad of scalar field
V = vectorField(problem, [field("body", fx=x->x, fy=y->y, fz=z->z)])
H = V ∘ ∇      # grad of vector field (tensor)
source
Base.Math.cbrtMethod
cbrt(A::ScalarField)

Elementwise cubic root of a scalar field.

Applies the cubic root to each entry of every element-wise matrix of the scalar field.

If the field is nodal, it is first converted to elementwise form.

Returns

  • A new ScalarField containing the elementwise cubic-rooted values.
source
Base.absMethod
abs(A::ScalarField)

Elementwise absolute value of a scalar field.

Applies the absolute value to each entry of every element-wise matrix of the scalar field.

If the field is nodal, it is first converted to elementwise form.

Returns

  • A new ScalarField containing the elementwise absolute values.
source
Base.adjointMethod
adjoint(A::TensorField)

Adjoint (conjugate transpose) of each 3×3 tensor block.

Returns: TensorField

source
Base.axesMethod
axes(K::SystemMatrix)

Return the valid index ranges for the system matrix.

Equivalent to axes(K.A).

source
Base.copyMethod
copy(K::SystemMatrix)

Returns a deep copy of the system matrix.

source
Base.eltypeMethod
eltype(K::SystemMatrix)

Return the element type of the system matrix.

Equivalent to eltype(K.A).

source
Base.getindexMethod
getindex(K::SystemMatrix, I...)

Indexing operation for SystemMatrix.

Forwards all indexing operations to the underlying sparse matrix K.A, allowing a SystemMatrix to be indexed in the same way as a SparseMatrixCSC.

Examples include:

  • K[i, j]
  • K[:, j], K[i, :]
  • K[a:b, c:d]
  • K[v1, v2] where v1 and v2 are index vectors.
source
Base.invMethod
inv(A::TensorField)

Matrix inverse of each 3×3 tensor block.

Returns: TensorField

source
Base.logMethod
log(A::ScalarField)

Elementwise natural logarithm of a scalar field.

Applies the natural logarithm to each entry of every element-wise matrix of the scalar field.

If the field is nodal, it is first converted to elementwise form.

Returns

  • A new ScalarField containing the elementwise logarithmic values.
source
Base.setindex!Method
setindex!(K::SystemMatrix, v, I...)

In-place assignment for SystemMatrix.

Forwards indexed assignment to the underlying sparse matrix K.A, enabling modifications such as:

  • K[i, j] = v
  • K[a:b, c:d] .= v
  • K[v1, v2] .= submatrix

Note that assignment follows the semantics and performance characteristics of SparseMatrixCSC.

source
Base.sizeMethod
size(K::SystemMatrix)

Return the size of the system matrix.

Equivalent to size(K.A).

source
Base.sqrtMethod
sqrt(A::ScalarField)

Elementwise square root of a scalar field.

Applies the square root to each entry of every element-wise matrix of the scalar field.

If the field is nodal, it is first converted to elementwise form.

Returns

  • A new ScalarField containing the elementwise square-rooted values.
source
Base.transposeMethod
transpose(K::SystemMatrix)
adjoint(K::SystemMatrix)

Transpose / adjoint of a system matrix.

source
Base.transposeMethod
transpose(A::TensorField)

Transposes each 3×3 tensor block.

Returns: TensorField

source
LinearAlgebra.:×Method
×(D::Function, A::VectorField)

Left curl. With D == ∇, returns curl(A).

Returns: VectorField

Examples

# 3D (assumes `problem` and a "body" physical group are defined)
V = vectorField(problem, [field("body", fx=x->0, fy=x->x, fz=z->0)])
C = ∇ × V
source
LinearAlgebra.:×Method
×(A::VectorField, D::Function)

Right curl with sign convention. With D == ∇, returns -curl(A).

Returns: VectorField

Examples

# 3D (assumes `problem` and a "body" physical group are defined)
V = vectorField(problem, [field("body", fx=x->0, fy=x->x, fz=z->0)])
Cneg = V × ∇   # -curl(V)
source
LinearAlgebra.:×Method
×(a::VectorField, b::VectorField)

Element-wise 3D vector cross product on matching elements.

Returns: VectorField

Examples

w = u × v
source
LinearAlgebra.:⋅Method
⋅(D::Function, A::Union{VectorField,TensorField})

Left contraction with the differential operator. With D == ∇:

  • If A is VectorField: returns div(A).
  • If A is TensorField: returns div(A').

Returns: ScalarField or VectorField

Examples

# 3D (assumes `problem` and a "body" physical group are defined)
T = tensorField(problem, [field("body", fz=z->z)])
DV = ∇ ⋅ T     # VectorField (divergence of tensor)
source
LinearAlgebra.:⋅Method
⋅(A::TensorField, B::TensorField)

Element-wise (Hadamard) product followed by summation of all components, yielding a scalar per tensor (i.e., Frobenius inner product).

Returns: ScalarField

source
LinearAlgebra.:⋅Method
⋅(A::Union{VectorField,TensorField}, D::Function)

Right contraction with the differential operator. With D == ∇:

  • If A is VectorField: returns div(A) (scalar field).
  • If A is TensorField: returns div(A) (vector field).

Returns: ScalarField or VectorField

Examples

# 3D (assumes `problem` and a "body" physical group are defined)
V = vectorField(problem, [field("body", fx=x->x, fy=y->y, fz=z->z)])
divV = V ⋅ ∇   # ScalarField
source
LinearAlgebra.detMethod
det(A::TensorField)

Computes the determinant of each 3×3 tensor block.

Returns: ScalarField

source
LinearAlgebra.diagmMethod
diagm(A::VectorField)

Creates a diagonal TensorField from a VectorField (dim=3), i.e., places vector components on the tensor diagonal for each node/element.

Returns: TensorField

source
LinearAlgebra.normMethod
norm(A::VectorField)

Element-wise Euclidean norm of a VectorField.

Returns: ScalarField

source
LowLevelFEM.ldiv_sparse!Method
ldiv_sparse!(X, K, F)

Solves the sparse linear system K * X = F column-by-column, where F is a sparse matrix representing multiple right-hand sides.

Returns

  • Sparse matrix X containing the solution.
source
LowLevelFEM.mapScalarFieldMethod
mapScalarField(f, A::ScalarField)

Apply a function elementwise to a scalar field.

The function f is applied to each element-wise matrix of the scalar field. If the field is nodal, it is first converted to elementwise form.

This is a low-level helper used to implement elementwise scalar-field operations such as abs, +, -, log, sqrt, etc.

Returns

  • A new ScalarField containing the transformed values.
source
LowLevelFEM.traceMethod
trace(A::TensorField)

Computes the trace of each 3×3 tensor block.

Returns: ScalarField

source
LowLevelFEM.unitTensorMethod
unitTensor(A::TensorField)

Creates an identity tensor field (I) with the same element structure and time steps as A.

Returns: TensorField

source