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::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
*(B::VectorField, A::ScalarField)

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

Returns: VectorField

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::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
/(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
∘(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.adjointMethod
adjoint(A::TensorField)

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

Returns: TensorField

source
Base.invMethod
inv(A::TensorField)

Matrix inverse of each 3×3 tensor block.

Returns: TensorField

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