Forms

Bramble._dirichlet_bc_indices!Method
_dirichlet_bc_indices!(A, marker_indices)

Internal helper to apply Dirichlet boundary conditions to matrix A for a given set of indices.

source
Bramble._dirichlet_bc_indices!Method

dirichletbcindices!(A::SparseMatrixCSC, indexin_marker::BitVector)

Applies Dirichlet boundary conditions to a sparse matrix A by directly manipulating its CSC data structure for high performance.

source
Bramble._function_in_linear_indicesMethod
_function_in_linear_indices(func, Ωₕ, i)

Internal helper to evaluate a function at a grid point given its linear index.

Converts linear index i to Cartesian indices and evaluates func at the corresponding physical point in mesh Ωₕ.

Arguments

  • func: Function to evaluate (typically a boundary condition function)
  • Ωₕ: The mesh
  • i: Linear index into the mesh points

Returns

The value of func at the i-th mesh point.

source
Bramble._get_eltype_and_domainMethod
_get_eltype_and_domain(cartesian_product)

Internal helper to extract element type and spatial domain from either a CartesianProduct or ScalarGridSpace.

Arguments

  • cartesian_product: Either a CartesianProduct domain or a ScalarGridSpace

Returns

  • (T, domain) where T is the element type and domain is the CartesianProduct

This helper enables a unified interface for dirichlet_constraints that accepts both mesh domains and grid spaces.

source
Bramble._validate_dirichlet_labelsMethod
_validate_dirichlet_labels(labels)

Internal helper to validate dirichlet_labels parameter.

Ensures that labels is either nothing, a Symbol, or a Tuple of Symbols. Throws an error if the validation fails.

This function is used by both bilinear_form.jl and linear_form.jl to validate the dirichlet_labels keyword argument before applying boundary conditions.

source
Bramble.dirichlet_bc!Method
dirichlet_bc!(A::AbstractMatrix, Ωₕ::AbstractMeshType, labels::Symbol...)

Applies Dirichlet boundary conditions to matrix A based on marked regions in the mesh Ωₕ.

For each index i associated with the given Dirichlet labels, this function:

  1. Sets all elements in the i-th row of A to zero.
  2. Sets the diagonal element A[i, i] to one.
source
Bramble.dirichlet_bc!Method
dirichlet_bc!(v::AbstractVector, Ωₕ::AbstractMeshType, bcs::DirichletConstraint, labels::Symbol...)

Apply Dirichlet boundary conditions to vector v using the DirichletConstraint object bcs and the mesh Ωₕ.

source
Bramble.symmetrize!Method
symmetrize!(A, F, Ωₕ, labels)

Modifies the linear system Ax = F to make A symmetric after applying Dirichlet conditions. It updates the vector F and zeros out the columns of A corresponding to Dirichlet nodes.

The algorithm goes as follows: for any given row i where Dirichlet boundary conditions have been applied

- calculate `dᵢ = cᵢ .* F`, where `cᵢ` is the `i`-th column of `A`;
- replace `F` by substracting `dᵢ` to `F` (except for the `i`-th component)
- replace all elements in the `i`-th column of `A` (except the `i`-th by zero).
source
Bramble.AutoDetectType
AutoDetect

Automatic detection of the most appropriate assembly strategy based on the form expression signature. Currently not fully implemented.

See also: DefaultAssembly

source
Bramble.InPlaceAssemblyType
InPlaceAssembly

Assembly strategy for in-place computation. The form expression should accept two arguments: (output_vector, operator) and modify output_vector directly.

This strategy is useful for reducing allocations in iterative solvers.

See also: DefaultAssembly, assemble!

source
Bramble.LinearFormType
struct LinearForm{TestType,F} <: LinearFormType
	test_space::TestType
	form_expr::F
end

Structure to store the data associated with a linear form

\[\begin{array}{rcll} l \colon & W_h &\longrightarrow &\mathbb{R} \\ & v &\longmapsto & l(v). \end{array}\]

The field form_expr has the expression of the form and the remaining field stores the test space $W_h$.

source
Bramble._assemble!Method
_assemble!(x::AbstractVector, l::LinearForm)

In-place assemble of a linear form into a given vector.

source
Bramble._form_expr2fwrapperMethod
_form_expr2fwrapper(f, S, strategy)

Internal helper to wrap form expressions in FunctionWrappers for type stability.

Converts the user-provided function f into a type-stable FunctionWrapper based on the selected assembly strategy. This eliminates dynamic dispatch and improves performance.

Arguments

  • f: The form expression function
  • S: The test space
  • strategy: The assembly strategy (determines wrapper signature)

Returns

A FunctionWrapper with appropriate type signature for the given strategy.

source
Bramble.BilinearFormType
struct BilinearForm{TrialType,TestType,F} <: BilinearFormType
	trial_space::TrialType
	test_space::TestType
	form_expression::F
end

Structure to store the data associated with a bilinear form

\[\begin{array}{rcll} a \colon & W_h \times V_h &\longrightarrow &\mathbb{R} \\ & (u,v) &\longmapsto & a(u,v). \end{array}\]

The field form_expression has the expression of the form and the remaining fields store the trial and test spaces $W_h$ and $V_h$.

Fields

  • trial_space::TrialType - The trial space W_h
  • test_space::TestType - The test space V_h
  • form_expression::F - Function defining a(u,v)

Example

# Stiffness matrix for Poisson equation
Wₕ = gridspace(Ωₕ)
a = form(Wₕ, Wₕ, (u, v) -> inner₊(∇₋ₕ(u), ∇₋ₕ(v)))

# Assemble
A = assemble(a)

# With Dirichlet boundary conditions
A = assemble(a, dirichlet_labels = :boundary)

# Evaluate form on specific functions
uₕ = element(Wₕ)
vₕ = element(Wₕ)
result = a(uₕ, vₕ)  # Returns scalar

See also: form, assemble, trial_space, test_space

source
Bramble.BilinearFormMethod
(a::BilinearForm)(u, v)

Callable interface for evaluating a bilinear form on given functions.

Returns the scalar value a(u,v) where u and v are elements from the trial and test spaces respectively.

source
Bramble._assemble!Method
_assemble!(A::AbstractMatrix, a::BilinearForm)

Helper function. Copies the assembled matrix of a bilinear form to a given matrix.

source
Bramble._assembleMethod
_assemble(a::BilinearForm)

Helper function. Returns the assembled matrix of a bilinear form.

source