Skip to content

PDE toolbox

Nexus ships the start of a partial-differential-equation toolbox: the 2-D geometry and meshing path that finite-element scripts use when they assemble and solve their own systems. It is a clean-room implementation of the documented public behaviour. Everything not listed as supported below is absent or raises a clear not supported in this release error.

Supported

FunctionWhat works
createpde(), createpde(N) Returns a PDEModel handle object with PDESystemSize N. The analysis-type forms ('structural', 'thermal', 'electromagnetic') raise an error.
[dl, bt] = decsg(gd, sf, ns) Circles (type 1), polygons (type 2) and rectangles (type 3, any vertex count in row 2). Set formulas with +, *, - and parentheses; names as a character matrix (one name per column), a cell array or a string array; repeated names are allowed. Returns the decomposed geometry (7 rows, or 10 with circle arcs) and the Boolean table. Ellipses (type 4) raise an error.
geometryFromEdges(model, dl) Attaches the geometry as an AnalyticGeometry (NumEdges, NumFaces, NumVertices, Vertices). Geometry functions and handles raise an error.
generateMesh(model, ...) Delaunay-refinement triangular mesh stored in model.Mesh as an FEMesh (Nodes, Elements, MaxElementSize, MinElementSize, MeshGradation, GeometricOrder). Options Hmax, Hmin, Hgrad, GeometricOrder ('quadratic' by default, or 'linear'), Hedge, Hvertex, Hface; Jiggle, JiggleIter and MesherVersion are accepted and ignored.
[p, e, t] = meshToPet(mesh) The mesh matrices: nodes, 7-row boundary segment matrix (nodes, edge parameters, geometry edge, left and right subdomain), elements with the subdomain number in the last row.
refinemesh(g, p, e, t, [u], [it], [method]) Regular (1 to 4) and longest-edge refinement with the documented closure rule, subdomain or triangle selection, solution interpolation. New boundary nodes are placed on the geometry (on the arc for circle segments).
[p, e, t] = initmesh(g, ...) The legacy entry to the same mesher, with Hmax and Hgrad.
findNodes, findElements, area On an FEMesh: 'region' ('Face', and 'Edge' for nodes), 'box', 'radius', 'nearest'. An element is inside a box or circle when all its nodes are.
pdegplot, pdemesh, pdeplot Geometry plot with edge, face and vertex labels; mesh plot with node and element labels; mesh or nodal/element XYData colouring with Mesh, ColorMap, ColorBar and Title.
pdegrad(p, t, u) Element gradients of a linear solution, scalar or system.

Not supported

Differences to be aware of

Example: mesh for a finite-element script

model = createpde (1);
gd = zeros (10, 2);
gd(:, 1)   = [3; 4; -1; 1; 1; -1; -1; -1; 1; 1];   % square
gd(1:4, 2) = [1; 0; 0; 0.4];                      % circle inside it
[dl, bt] = decsg (gd, 'S', ['S' 'C']');            % keep the square, split by the circle
geometryFromEdges (model, dl);
generateMesh (model, 'Hmax', 0.1, 'GeometricOrder', 'linear');
[p, e, t] = meshToPet (model.Mesh);
[p, e, t] = refinemesh (dl, p, e, t);
circle_region = find (bt(:, 2));
in_circle = find (t(4, :) == circle_region);      % elements of the circle

The implementation lives in scripts/pde with its tests.