Weak formulations
Derive a variational equation before translating it into finite element code.
A weak formulation specifies the spaces in which an equation is tested, the derivatives that must exist, and the way boundary data enter. The purpose of this guide is the derivation. The variational formulations guide then explains how those objects are represented in Rodin.
Begin with scalar diffusion
Let be a bounded Lipschitz domain. Split its boundary into a Dirichlet part and a Neumann part , ignoring their measure-zero interface. Consider
For nonzero prescribed values, the admissible fields and test functions belong to different sets.
Traces are understood in the Sobolev sense. The data must admit the required trace and load functionals. In particular, a lifting of is assumed to exist in .
Integrate by parts
Multiplying by and integrating by parts gives
The test function vanishes on , while the normal derivative is prescribed on . Thus the weak problem seeks such that
with
The second derivative in the strong equation has become first derivatives in the weak equation. This permits continuous piecewise affine functions, whose gradients may jump between cells, to be used as conforming approximations.
Check uniqueness
On a connected domain with a Dirichlet part of positive boundary measure, the Poincaré inequality supplies coercivity of the diffusion form on . With a bounded load functional, the standard Lax–Milgram argument gives a unique weak solution after lifting the prescribed values.
For a pure-Neumann problem, constants remain in the kernel. Compatibility requires
A mean constraint or another valid normalization is then needed. A solver cannot compensate for incompatible data or an unresolved nullspace.
Connect the terms to code
The mixed-boundary example takes , fixes the left side of the unit square, and prescribes a unit normal derivative on the right.
P1 vh(mesh); TrialFunction u(vh); TestFunction v(vh); RealFunction flux = 1.0; Problem diffusion(u, v); diffusion = Integral(Grad(u), Grad(v)) - BoundaryIntegral(flux, v).over(loaded) + DirichletBC(u, Zero()).on(fixed);
The minus sign on the load expresses . Boundary selection and the complete runnable program are explained in that guide. For zero values on the entire boundary and a nonzero source, see the Poisson tutorial.
Extend to elasticity
The unknown displacement is . Define
Equilibrium is , with prescribed displacement on and traction on . Testing against a vector field that vanishes on the fixed boundary gives
Symmetry of the stress removes its contraction with the skew part of . Expanding the constitutive law gives
The factor is essential with this definition of strain.
Interpret the material model
Positive elastic energy requires and . The displacement constraints must also remove rigid motions; Korn's inequality then supplies the relevant coercivity statement.
For three-dimensional isotropic elasticity, Young's modulus and Poisson's ratio give
A two-dimensional reduction must state whether plane strain or plane stress is intended. The beam tutorial uses plane strain and shows the corresponding vector-valued finite element problem.
Finite-strain models
Linearized strain assumes small deformation. Finite-strain mechanics uses the deformation gradient and a constitutive energy, from which an internal virtual-work residual and consistent tangent are obtained. The solid mechanics guide explains that construction; the residual and its consistent tangent must represent the chosen nonlinear model.
Complex and mixed formulations
Over complex fields, the usual finite element convention is trial-linear and test-conjugate-linear. For Helmholtz, this gives
Positive definiteness is checked from the coefficients, boundary conditions and spectrum of the form. The Helmholtz tutorial uses an indefinite system and checks a manufactured solution.
Mixed equations introduce coupled unknowns and constraints. In Stokes flow, velocity and pressure form a saddle-point system; compatible spaces and a pressure gauge are needed. In Navier–Stokes, convection adds a nonlinear dependence that must be discretized in time and linearized explicitly.
Discretize the weak problem
Choose a finite-dimensional test space and a discrete representation of the prescribed trace. For homogeneous essential data, trial and test spaces can coincide. With trial basis functions and test basis functions , the Galerkin equations have entries
For a nonzero discrete lifting , the unknown homogeneous part instead has load entries . If the prescribed trace is not exactly representable, its approximation introduces a boundary-data error. Periodic identifications or multiplier equations add their corresponding algebraic constraints. Numerical quadrature and approximated geometry can introduce additional errors beyond the field approximation.
A small algebraic residual establishes that the assembled system was solved accurately. Model accuracy and spatial discretization error are assessed separately. See the form-language guide for assembly, solvers for algebraic checks, and numerical contracts for implementation rules.