Forms
Bramble.DirichletConstraint — Typestruct DomainMarkers{FType}Alias for storage of Dirichlet constraints.
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.
Bramble._dirichlet_bc_indices! — Methoddirichletbcindices!(A::SparseMatrixCSC, indexin_marker::BitVector)
Applies Dirichlet boundary conditions to a sparse matrix A by directly manipulating its CSC data structure for high performance.
Bramble._function_in_linear_indices — Method_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 meshi: Linear index into the mesh points
Returns
The value of func at the i-th mesh point.
Bramble._get_eltype_and_domain — Method_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 aCartesianProductdomain or aScalarGridSpace
Returns
(T, domain)whereTis the element type anddomainis theCartesianProduct
This helper enables a unified interface for dirichlet_constraints that accepts both mesh domains and grid spaces.
Bramble._validate_dirichlet_labels — Method_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.
Bramble.dirichlet_bc! — Methoddirichlet_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:
- Sets all elements in the
i-th row ofAto zero. - Sets the diagonal element
A[i, i]to one.
Bramble.dirichlet_bc! — Methoddirichlet_bc!(v::AbstractVector, Ωₕ::AbstractMeshType, bcs::DirichletConstraint, labels::Symbol...)Apply Dirichlet boundary conditions to vector v using the DirichletConstraint object bcs and the mesh Ωₕ.
Bramble.symmetrize! — Methodsymmetrize!(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).Bramble.AutoDetect — TypeAutoDetectAutomatic detection of the most appropriate assembly strategy based on the form expression signature. Currently not fully implemented.
See also: DefaultAssembly
Bramble.DefaultAssembly — TypeDefaultAssemblyAssembly strategy that evaluates the linear form by passing a VectorElement to the form expression. This is the standard and most flexible approach.
Example
l = form(Wₕ, v -> innerₕ(f, v), strategy = DefaultAssembly())See also: InPlaceAssembly, OperatorsAssembly, AutoDetect
Bramble.InPlaceAssembly — TypeInPlaceAssemblyAssembly 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!
Bramble.LinearForm — Typestruct LinearForm{TestType,F} <: LinearFormType
test_space::TestType
form_expr::F
endStructure 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$.
Bramble.LinearFormType — TypeLinearFormTypeAbstract type for linear forms.
Bramble.OperatorsAssembly — TypeOperatorsAssemblyAssembly strategy that passes an IdentityOperator to the form expression instead of a VectorElement. Useful for operator-based formulations.
See also: DefaultAssembly, IdentityOperator
Bramble._assemble! — Method_assemble!(x::AbstractVector, l::LinearForm)In-place assemble of a linear form into a given vector.
Bramble._assemble! — Method_assemble!(uₕ::VectorElement, l::LinearForm)In-place assemble of a linear form into a given VectorElement.
Bramble._form_expr2fwrapper — Method_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 functionS: The test spacestrategy: The assembly strategy (determines wrapper signature)
Returns
A FunctionWrapper with appropriate type signature for the given strategy.
Bramble.test_space — Methodtest_space(a::LinearForm)Returns the test space of a linear form.
Bramble.BilinearForm — Typestruct BilinearForm{TrialType,TestType,F} <: BilinearFormType
trial_space::TrialType
test_space::TestType
form_expression::F
endStructure 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_htest_space::TestType- The test space V_hform_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 scalarSee also: form, assemble, trial_space, test_space
Bramble.BilinearForm — Method(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.
Bramble.BilinearFormType — TypeBilinearFormTypeAbstract type for bilinear forms.
Bramble._assemble! — Method_assemble!(A::AbstractMatrix, a::BilinearForm)Helper function. Copies the assembled matrix of a bilinear form to a given matrix.
Bramble._assemble — Method_assemble(a::BilinearForm)Helper function. Returns the assembled matrix of a bilinear form.
Bramble.test_space — Methodtest_space(a::BilinearForm)Returns the test space of a bilinear form.
Bramble.trial_space — Methodtrial_space(a::BilinearForm)Returns the trial space of a bilinear form.