Preprocessing API
Set up the current Gmsh mesh, material groups, and unknown-field descriptors. Field is an alias of Problem; a descriptor defines interpolation and DOFs, while ScalarField/VectorField/TensorField contain values.
Materials and unknowns
LowLevelFEM.Material — TypeMaterial(phName; type=:Hooke, E=nothing, ν=nothing, λ=nothing,
μ=nothing, κ=nothing, ρ=7.85e-9, k=45.0, c=4.2e8,
α=1.2e-5, η=1e-7, p₀=0.1, A=1.0)Material parameters assigned to a physical group.
This structure stores mechanical, thermal and fluid-related material properties used during assembly. The material is associated with a Gmsh physical group via phName.
Arguments
phName::StringName of the physical group where the material is applied.
Keyword Arguments
Elastic properties
With no elastic constants, use E=2e5 and ν=0.3. Supplying only E keeps ν=0.3; supplying only κ keeps E=2e5. Supported pairs are (E,ν), (μ,ν), (λ,μ), and (κ,μ). Other combinations are rejected; missing elastic constants are computed from the selected combination.
type selects :Hooke, :StVenantKirchhoff, :NeoHookeCompressible, or :JFO. It is material metadata; the selected assembly or constitutive routine must support that material law. Parameters use the user's consistent unit system; the defaults are not converted automatically.
E::Float64Young's modulusν::Float64Poisson's ratioλ::Float64First Lamé parameterμ::Float64Second Lamé parameter (shear modulus)κ::Float64Bulk modulus
Density
ρ::Float64Mass density
Thermal properties
k::Float64Thermal conductivityc::Float64Specific heat capacityα::Float64Thermal expansion coefficient
Fluid / tribology-related properties
η::Float64Dynamic viscosityp₀::Float64Cavitation pressure
Structural property
A::Float64Cross-sectional area (used e.g. in truss elements)
Notes
- Elastic constants are internally completed to a consistent set using
elastic_constants. - Default values are provided for all optional parameters.
- The material definition is independent of the field type (scalar, vector, tensor) and can be used in multifield problems.
Examples
mat = Material("solid", E=210e3, ν=0.3)
mat = Material("fluid",
η=1e-6,
p₀=0.1
)
mat = Material("truss",
E=210e3,
A=1.0
)LowLevelFEM.material — Functionmaterial(phName::String; kwargs...) -> MaterialCompatibility spelling of Material, forwarding all material keywords and defaults unchanged. Prefer Material in new models.
LowLevelFEM.Problem — TypeProblem(materials; kwargs...)Defines a finite element problem on the current Gmsh model.
The Problem structure collects all information required for assembly, including geometry, discretization, unknown field structure and associated materials. It serves as the central object for operator-based formulations.
Arguments
materials::Vector{Material}List of materials assigned to physical groups in the mesh.
Keyword Arguments
Geometry and discretization
dim::IntSpatial dimension of the problem (1, 2 or 3).thickness::Float64Thickness parameter for 2D formulations.
Field definition
fieldName::SymbolName of the unknown field (e.g.:u,:T,:p).rhsName::SymbolName of the right-hand side field.reducedOrder::BoolIf
true, the active approximation order is reduced fromptop - 1, while assembly and field storage remain on the original order-pmesh. This option is independent of the solver basis. Default:false.basis::SymbolSolver-space basis. Currently
:lagrangeand:spectralare supported. The global LowLevelFEM/Gmsh storage representation remains Lagrange in both cases. Default::lagrange.
Problem configuration
type::SymbolPredefined problem setup. Supported values::Solid:PlaneStress:PlaneStrain:AxiSymmetric:HeatConduction:PlaneHeatConduction:AxiSymmetricHeatConduction:Truss:ScalarField:VectorField:TensorField:Reynolds
These presets define default values for:
- spatial dimension (
dim) - number of unknown components (
pdim) - field naming (
field,rhs_field)
bandwidth::SymbolOptional node renumbering strategy for bandwidth reduction. Options::RCMK,:Hilbert,:Metis,:none(default).
Geometry names (used in special cases)
nameTopSurface::StringName of the top surface (used e.g. in Reynolds-type problems)nameVolume::StringName of the volume region
Internal Fields
dim::IntSpatial dimension of the meshpdim::IntNumber of unknown components per node (e.g. 1 = scalar, 2/3 = vector, 9 = tensor)non::IntNumber of mesh nodesgeometry::GeometryGeometry information extracted from Gmshmaterial::Vector{Material}Material definitions assigned to physical groupsapproximation::ApproximationDataCached solver-space transformation and basis-specific auxiliary data.
Notes
- The problem is defined on the currently active Gmsh model.
- The total number of degrees of freedom is
non * pdim. - The structure is compatible with scalar, vector and tensor fields, and supports multifield formulations.
Examples
```julia
3D elasticity
mat = Material("solid", E=210e3, ν=0.3) P = Problem([mat], type=:Solid)
Scalar field in 2D
P = Problem([mat], type=:ScalarField, dim=2)
Vector field in 3D
P = Problem([mat], type=:VectorField, dim=3)
Tensor field
P = Problem([mat], type=:TensorField, dim=3)
Reynolds-type problem
P = Problem([mat], type=:Reynolds, nameTopSurface="top", nameVolume="fluid" )
LowLevelFEM.Field — TypeFieldAlias for Problem.
Field can be used instead of Problem when defining unknown fields in multifield formulations. Both names refer to exactly the same type.
Mesh and geometry
The structured mesh helpers create named physical groups; see their individual lists before selecting Ω, Γ, or a boundary condition.
LowLevelFEM.line_mesh — Functionline_mesh(; lx=1.0,
n=10,
dx=lx/n,
order=1)Create a structured 1D mesh of a line domain using Gmsh.
The domain is defined on the interval [0, lx]. A transfinite structured mesh is generated along the line.
Keyword Arguments
lx: Length of the domain.n: Default subdivision parameter (used to definedx).dx: Target element size along the line.order: Polynomial order of the finite elements.
Physical Groups
The following physical groups are created:
- 0D boundary points:
"left","right" - 1D domain:
"body"
Notes
- A transfinite structured mesh is enforced.
- The number of nodes is determined from
ceil(lx/dx) + 1. - The mesh is generated but not written to file.
- Initialize Gmsh automatically if needed, clear existing models with
gmsh.clear(), and set Gmsh verbosity to zero. Existing geometry, meshes and views are discarded; reconstruct descriptors after remeshing.
Returns nothing.
Note: These helper functions are primarily intended for rapid prototyping, testing and educational examples in LowLevelFEM workflows.
LowLevelFEM.structured_rect_mesh — Functionstructured_rect_mesh(; x0=0.0, y0=0.0,
lx=1.0, ly=1.0,
n=10,
dx=lx/n, dy=ly/n,
order=1, nx=nothing, ny=nothing)Create a structured quadrilateral mesh of a rectangular 2D domain using Gmsh.
The domain is defined by its lower-left corner (x0, y0) and its dimensions lx × ly. A transfinite structured mesh is generated and recombined into quadrilateral elements.
Keyword Arguments
x0, y0: Coordinates of the lower-left corner.lx, ly: Domain dimensions.n: Default subdivision parameter (used to definedx,dy).dx, dy: Target element sizes in x and y directions.order: Polynomial order of the finite elements.nx, ny: Optional positive integer element counts in the x/y directions. Each supplied count overrides the size-based subdivision in that direction. With neither supplied, the historical common sizemin(dx,dy)is retained.
For a slender rectangle, nx=25, ny=3 gives 25 longitudinal elements and 3 transverse layers without also refining the long direction. By contrast, n=3 retains the common-size rule and can produce many more elements along an elongated domain.
Physical Groups
The following physical groups are created:
- 1D boundaries:
"bottom","right","top","left" - 2D domain:
"body" - 0D corner points:
"leftbottom","rightbottom","righttop","lefttop"
Notes
- A transfinite structured mesh is enforced.
- Elements are recombined into quadrilaterals.
- The mesh is generated but not written to file.
- Initialize Gmsh automatically if needed, clear existing models with
gmsh.clear(), and set Gmsh verbosity to zero. Existing geometry, meshes and views are discarded; reconstruct descriptors after remeshing.
Returns nothing.
Note: These helper functions are primarily intended for rapid prototyping, testing and educational examples in LowLevelFEM workflows.
Optional remote points
leftRemote=false and rightRemote=false optionally create extra point physical groups "leftremote" and "rightremote" at the end-section centers. These provide reference nodes for MPC construction; enabling them alone creates no rigid coupling or boundary condition.
LowLevelFEM.structured_box_mesh — Functionstructured_box_mesh(; x0=0.0, y0=0.0, z0=0.0,
lx=1.0, ly=1.0, lz=1.0,
n=10,
dx=lx/n, dy=ly/n, dz=lz/n,
order=1)Create a structured hexahedral mesh of a rectangular 3D domain using Gmsh.
The domain is defined by its lower-front-left corner (x0, y0, z0) and its dimensions lx × ly × lz. A fully transfinite structured mesh is generated and recombined into hexahedral elements.
Keyword Arguments
x0, y0, z0: Coordinates of the origin corner.lx, ly, lz: Domain dimensions.n: Default subdivision parameter.dx, dy, dz: Target element sizes in each direction.order: Polynomial order of the finite elements.
Physical Groups
The following physical groups are created:
- 2D boundary faces:
"left","right","front","rear","bottom","top" - 3D domain:
"body"
Notes
- A transfinite structured mesh is enforced in all directions.
- Elements are recombined into hexahedra.
- The mesh is generated but not written to file.
- Initialize Gmsh automatically if needed, clear existing models with
gmsh.clear(), and set Gmsh verbosity to zero. Existing geometry, meshes and views are discarded; reconstruct descriptors after remeshing.
Returns nothing.
Note: These helper functions are primarily intended for rapid prototyping, testing and educational examples in LowLevelFEM workflows.
Optional remote points
leftRemote=false and rightRemote=false optionally create extra point physical groups "leftremote" and "rightremote" at the end-section centers. These provide reference nodes for MPC construction; enabling them alone creates no rigid coupling or boundary condition.
LowLevelFEM.renumberNodes! — FunctionrenumberNodes!(material::Material; method::Symbol=:RCMK)
renumberNodes!(materials::Vector{Material}; method::Symbol=:RCMK)Renumber the Gmsh mesh nodes associated with the given material domain(s).
The renumbering is computed from the finite elements belonging to the physical groups referenced by the supplied Material objects. The supported methods are :RCMK, :Hilbert, and :Metis.
If several material domains belong to the same finite-element problem, it is recommended to pass all of them together in a vector so that the renumbering is computed from the complete element connectivity of the problem.
Warning
Node renumbering modifies the node tags of the Gmsh mesh and must therefore be performed before creating any Problem or Field objects that use the mesh.
Do not call renumberNodes! after a Problem or Field has already been created, because existing node/DoF mappings may then become inconsistent with the modified Gmsh mesh.
Examples
mat = Material("body")
renumberNodes!(mat; method=:RCMK)
u = Field([mat], type=:VectorField, dim=3, field=:u)For a problem containing several material domains:
mat1 = Material("body1")
mat2 = Material("body2")
renumberNodes!([mat1, mat2]; method=:RCMK)
u = Field([mat1, mat2], type=:VectorField, dim=3, field=:u)LowLevelFEM.openGeometry — FunctionopenGeometry(name::String; verbose::Int=0)Open a geometry or mesh file in the current Gmsh session.
If Gmsh is not yet initialized, the function calls gmsh.initialize(). If the file name does not exist and has extension .geo, a new geometry file is created and initialized with a minimal header. Otherwise an error is thrown. verbose sets the verbosity level of Gmsh.
Before opening the file the current Gmsh model is cleared with gmsh.clear(), so any previously loaded geometry or mesh is removed.
Arguments
name::String: Path to a geometry (.geo) or mesh file (.msh,.step,.brep, etc.) that should be opened in Gmsh.
Behavior
- Existing files are opened directly.
- Missing
.geofiles are automatically created. - Missing files with other extensions result in an error.
Notes
This function only loads the geometry into Gmsh. The model name used later by Problem is obtained from gmsh.model.getCurrent().
Examples
openGeometry("beam.geo") # create if missing and open
openGeometry("mesh.msh") # open existing meshParameters and interactive geometry
LowLevelFEM.setParameter — FunctionsetParameter(name, value)Defines a parameter name and sets its value to value.
Returns: nothing
Types:
name: Stringvalue: Float64
LowLevelFEM.setParameters — FunctionsetParameters(name, value)Defines a parameter name and sets its value to value, which is a Vector{Float64}.
Returns: nothing
Types:
name: Stringvalue: Vector{Float64}
LowLevelFEM.getParameter — FunctiongetParameter(name)Gets the value of the parameter name.
Returns: value
Types:
name: Stringvalue: Float64
LowLevelFEM.openPreProcessor — FunctionopenPreProcessor(; openGL=true)Launches the Gmsh preprocessor window with OpenGL disabled by default.
Returns: nothing
Types:
openGL: Boolean