Projection Utilities and Diagnostics

Specialized field projection and volume operations.

LowLevelFEM.projectScalarField — Function
projectScalarField(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:

  1. Collecting all 2D finite elements belonging to the physical group from.
  2. Assigning each source element to all spatial bins intersected by its axis-aligned bounding box (AABB) in the (x,y) plane.
  3. Assigning target nodes (from the physical group to) to spatial bins based on their (x,y) coordinates.
  4. 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::ScalarField Scalar field defined on the source surface (from). In the Reynolds context, this typically represents the pressure field.

Keyword Arguments

  • from::String Name of the physical group defining the source 2D surface on which the scalar field p is defined.

  • to::String Name of the physical group defining the target mesh (surface or volume) whose nodes receive the projected values.

  • gap::Bool = false If true, 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.7 Controls 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

  • ScalarField or Vector{ScalarField} A new scalar field(s) defined on the target mesh nodes, containing the interpolated values of p.

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 field p.
  • Project the pressure field onto a surrounding 3D mesh (to) for use in structural, thermal, or multiphysics coupling.

source
LowLevelFEM.fieldsToVolume — Function
fieldsToVolume(p0::Union{ScalarField,Vector{ScalarField}})

Project lubricant-surface scalar field(s) to the configured lubricant volume.

Arguments

  • p0: One ScalarField or a vector of ScalarFields defined on the source surface.

Returns

  • Vector{ScalarField}: Elementwise scalar fields on model.geometry.nameVolume.

Example

pv = fieldsToVolume(p_surface)
source

Interactive diagnostics

LowLevelFEM.DebugTools.@showfields — Macro
@showfields expr

Evaluate expr once and print its type, field names and current field values. Return nothing; the value must support structural field access.

source
LowLevelFEM.DebugTools.@showdef — Macro
@showdef expr

Evaluate expr once and print a structural summary of its type: field names and declared field types, without current values. Return nothing.

source
LowLevelFEM.DebugTools.@showtype — Macro
@showtype expr

Evaluate expr once and print its type and total reachable object size from Base.summarysize when available. Return nothing; this is not array shape.

source
LowLevelFEM.DebugTools.@showmem — Macro
@showmem expr

Evaluate expr with @timed, print elapsed milliseconds and allocated bytes, and return the expression result. First-call compilation is included; this single sample is not a statistical benchmark.

source
LowLevelFEM.DebugTools.@disp — Macro
@disp expr

Evaluate expr once and display its source text followed by its string value. The macro returns the result of display (normally nothing).

source
LowLevelFEM.DebugTools.@showsize — Macro
@showsize expr

Evaluate expr once and print its total reachable memory from Base.summarysize, using B/kB/MB/GB with factors of 1024. Return nothing. This reports object storage, not allocations during evaluation.

source

Bundled Gmsh module

The re-exported module provides access to the bundled Gmsh API. The full external API is maintained in the Gmsh documentation, rather than duplicated in this package's reference.

See the Gmsh reference manual for the external API.