Extra API
Auxiliary utilities and project-specific helper functionality.
LowLevelFEM.projectScalarField — FunctionprojectScalarField(pp::Union{ScalarField,Vector{ScalarField}}; from="", to="", gap=false, binSize=0.7)
projectScalarField(p::Union{ScalarField,Vector{ScalarField}}; from="", to="", gap=false, binSize=0.7)Projects a scalar field defined on a 2D surface onto the nodes of another mesh (typically a 3D volume or a parallel surface), using a robust AABB-based spatial binning algorithm.
This function is primarily intended for use in the Reynolds equation solver, where a pressure field defined on a lubricating surface must be transferred to another surface or to the surrounding 3D mesh.
Functionality
The projection is performed by:
- Collecting all 2D finite elements belonging to the physical group
from. - Assigning each source element to all spatial bins intersected by its axis-aligned bounding box (AABB) in the (x,y) plane.
- Assigning target nodes (from the physical group
to) to spatial bins based on their (x,y) coordinates. - For each target node, testing candidate source elements from the same bin:
- computing local coordinates using Gmsh,
- performing an inside-element test (triangular or quadrilateral),
- interpolating the scalar field using Gmsh-provided Lagrange basis functions.
The algorithm is deterministic, robust with respect to bin size, and works for arbitrary element order supported by Gmsh.
Arguments
p::ScalarFieldScalar field defined on the source surface (from). In the Reynolds context, this typically represents the pressure field.
Keyword Arguments
from::StringName of the physical group defining the source 2D surface on which the scalar fieldpis defined.to::StringName of the physical group defining the target mesh (surface or volume) whose nodes receive the projected values.gap::Bool = falseIftrue, the source surface nodes are temporarily projected onto the z = 0 plane during the projection.This option is useful in Reynolds-type lubrication problems, where:
- the height of the lubricat is defined on a geometrically curved upper surface,
- but the projection should be performed purely in (x,y) coordinates.
After the projection, the original node coordinates are restored.
binSize::Real = 0.7Controls the spatial bin size relative to the smallest source element size.Smaller values increase the number of bins (finer spatial partitioning), potentially improving performance for large meshes.
Due to the AABB-based binning strategy, correctness does not depend on the bin size; this parameter only affects performance.
Returns
ScalarFieldorVector{ScalarField}A new scalar field(s) defined on the target mesh nodes, containing the interpolated values ofp.
Notes
- This function relies exclusively on the Gmsh API for element localization and basis function evaluation; no custom shape functions are implemented.
- Both triangular and quadrilateral elements are supported, for arbitrary polynomial order.
- The AABB-based binning guarantees that no valid node–element associations are missed, even for small bin sizes or highly distorted elements.
- The function is optimized for single-threaded execution; parallel scaling may be limited by Gmsh API overhead.
Typical Use Case (Reynolds Equation)
- Solve the Reynolds equation on a lubricating surface (
from), obtaining a pressure fieldp. - Project the pressure field onto a surrounding 3D mesh (
to) for use in structural, thermal, or multiphysics coupling.
LowLevelFEM.fieldsToVolume — FunctionfieldsToVolume(p0::Union{ScalarField,Vector{ScalarField}})Project lubricant-surface scalar field(s) to the configured lubricant volume.
Arguments
p0: OneScalarFieldor a vector ofScalarFields defined on the source surface.
Returns
Vector{ScalarField}: Elementwise scalar fields onmodel.geometry.nameVolume.
Example
pv = fieldsToVolume(p_surface)