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
| Function | What 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
- Solving.
applyBoundaryCondition,specifyCoefficients,setInitialConditions,solvepdeandsolvepdeeigexist onPDEModeland raise an error; the model'sEquationCoefficients,BoundaryConditions,InitialConditionsandSolverOptionsstay empty. The legacy solvers (assempde,adaptmesh,parabolic,hyperbolic,pdeeig,pdenonlin) and the assembly helpers are not provided. - 3-D and imported geometry.
importGeometry,geometryFromMesh,multicuboid,multicylinder,multisphere, STL and mesh import. - Structural, thermal and electromagnetic models
(
createpde('structural', ...)and friends,femodel,fegeometry). - Geometry functions as input to
geometryFromEdges,initmeshorrefinemesh, ellipse segments,csgchk,csgdel,wgeom,pdecircand the other shape helpers, and the interactivepdetoolapplication. - Other legacy functions:
jigglemesh,pdetriq,pdeintrp,pdeprtni,pdeent,pdesdt,pdecont,pdesurf; theFlowData,Contour,ZDataand relatedpdeplotoptions; plotting a solution withpdemesh; the subdomain-list argument ofpdegrad.
Differences to be aware of
- Region numbers in
dlandt, and the order of the columns ofdl, are deterministic but not the numbering another implementation would produce. Address regions through the Boolean tablebt, as the examples do, rather than by number. - Node and element counts differ from other meshers, as the
documentation of
generateMeshitself warns. The defaultHmaxis a fifteenth of the larger bounding-box side; circles are resolved with at least 24 chords. - For a quadratic mesh the
ematrix frommeshToPetlists the corner nodes of each boundary segment only. Mid-side nodes are at half distance between corners, as documented, so they do not lie on curved edges. refinemeshaccepts linear meshes only.- Shapes may touch at a point (tangent conductors, a circle resting on a line). The mesher keeps the boundary exact there; the few elements wedged into such a cusp stay thin, as they must.
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.