Skip to content

pre.OpenSeesMatlabPre ¤

Bases: handle

OpenSeesMatlabPre Pre-processing utilities for OpenSeesMatlab.

OpenSeesMatlabPre groups helper tools used before and during model construction. It is created automatically by OpenSeesMatlab and is accessed through the pre property:

1
2
3
  opsmat = OpenSeesMatlab();
  pre = opsmat.pre;
  ops = opsmat.opensees;

The interface includes:

  • unitSystem for unit metadata and conversion helpers.
  • Gmsh2OPS for converting Gmsh meshes to OpenSees definitions.
  • section geometry recording for plotting fiber sections.
  • model-data utilities such as nodal mass and M/C/K matrix extraction.
  • load transformation helpers for gravity, beam, and surface loads.
Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
  opsmat = OpenSeesMatlab();
  ops = opsmat.opensees;

  ops.wipe();
  ops.model('basic', '-ndm', 2, '-ndf', 3);

  opsmat.pre.setSectionGeometryRecorder(true);
  ops.section('Fiber', 1, '-GJ', 1.0e6);
  ops.patch('rect', 1, 10, 10, -0.2, -0.3, 0.2, 0.3);
  opsmat.pre.plotSection(1);
  opsmat.pre.setSectionGeometryRecorder(false);

  nodeMass = opsmat.pre.getNodeMass();
  K = opsmat.pre.getMCK('k');

Methods:

Properties:

  • unitSystem (None) –

    Unit system information for the model, including length, force, time, etc. This can be used for unit conversions and ensuring consistency in model definitions and results interpretation. See pre.UnitSystem for details.

  • fiberSectionMesh (pre.FiberSectionMesh) –

    Stub instance of pre.FiberSectionMesh, pre-wired to this

unitSystem ¤

unitSystem

Unit system information for the model, including length, force, time, etc. This can be used for unit conversions and ensuring consistency in model definitions and results interpretation. See pre.UnitSystem for details.

fiberSectionMesh ¤

fiberSectionMesh: pre.FiberSectionMesh

Stub instance of pre.FiberSectionMesh, pre-wired to this model's OpenSees interface.

See pre.FiberSectionMesh for full documentation.

setSectionGeometryRecorder ¤

(sw: logical = true)

Enable or disable section geometry recording.

When enabled, fiber-section-related OpenSees commands issued through opsmat.opensees are recorded by a SectionGeometryRecorder. The recorded geometry can then be plotted with plotSection. This is useful because OpenSees itself does not retain enough section construction history for visualization in all workflows.

Syntax
1
2
3
pre.setSectionGeometryRecorder()
pre.setSectionGeometryRecorder(true)
pre.setSectionGeometryRecorder(false)

Input arguments:

  • sw (logical) –

    If true, enable section geometry recording. If false, disable it and clear the current recorder. Default is true.

Example
1
2
3
4
5
6
7
opsmat = OpenSeesMatlab();
ops = opsmat.opensees;

opsmat.pre.setSectionGeometryRecorder(true);
ops.section('Fiber', 1, '-GJ', 1.0e6);
ops.patch('rect', 1, 10, 10, -0.2, -0.3, 0.2, 0.3);
opsmat.pre.plotSection(1);

plotSection ¤

(secTag: double, ax=[])

Plot recorded fiber-section geometry.

plotSection visualizes a section previously recorded by setSectionGeometryRecorder(true). The recorder must be enabled before the corresponding OpenSees section, fiber, patch, and layer commands are issued.

Syntax
1
2
pre.plotSection(secTag)
pre.plotSection(secTag, ax)

Input arguments:

  • secTag (double) –

    Section tag to plot. It should match a section tag previously defined through ops.section while recording was enabled.

  • ax (axes handle) –

    Target axes for plotting. If empty or omitted, the recorder will create a suitable figure/axes.

Example
1
2
3
4
opsmat.pre.setSectionGeometryRecorder(true);
ops.section('Fiber', 1, '-GJ', 1.0e6);
ops.fiber(0.0, 0.0, 0.01, 1);
opsmat.pre.plotSection(1);

getNodeMass ¤

()

Get assembled nodal mass data from the current OpenSees model.

The returned map contains nodal mass contributions assembled from model definitions, element mass contributions, and mass matrix information supported by the underlying utility implementation.

Syntax
1
nodeMass = pre.getNodeMass()

Output arguments:

  • nodeMass ( containers.Map ) –

    Map of nodal masses.

    • Key : node tag
    • Value : row vector of nodal masses for each degree of freedom
Example
1
2
nodeMass = opsmat.pre.getNodeMass();
m1 = nodeMass(1);

getMCK ¤

(matrixType, constraintsArgs={"Penalty", 1e12, 1e12}, systemArgs={"FullGeneral"}, numbererArgs={"Plain"})

Assemble and return a global model matrix.

Syntax
1
2
3
out = pre.getMCK(matrixType)
out = pre.getMCK(matrixType, constraintsArgs=args)
out = pre.getMCK(matrixType, systemArgs=args, numbererArgs=args)

Input arguments:

  • matrixType (char or string) –

    Matrix type: 'm', 'c', 'k', or 'ki'.

  • constraintsArgs (char, string, or cell array) –

    Arguments passed to the OpenSees constraints command. Default: {'Penalty', 1e12, 1e12}.

  • systemArgs (char, string, or cell array) –

    Arguments passed to the OpenSees system command. Default: {'FullGeneral'}.

  • numbererArgs (char, string, or cell array) –

    Arguments passed to the OpenSees numberer command. Default: {'Plain'}.

createGravityLoad ¤

(excludeNodes: double = [], direction: string = "Z", factor: double = -9.81)

Create and apply gravity loads from assembled nodal masses.

This method obtains nodal mass information and converts it to equivalent nodal gravity loads. The generated loads are applied to the active OpenSees load pattern by calling the OpenSees load command through the parent command interface.

Syntax
1
2
3
nodeLoads = pre.createGravityLoad()
nodeLoads = pre.createGravityLoad(direction="Z", factor=-9.81)
nodeLoads = pre.createGravityLoad(excludeNodes=[1 2], direction="Y")

Input arguments:

  • excludeNodes (double array) –

    Node tags to exclude from gravity load application. Default is empty, meaning all nodes with assembled mass are included.

  • direction (string) –

    Gravity direction. Must be "X", "Y", "Z", "x", "y", or "z". Default is "Z".

  • factor (double) –

    Gravity/load scale factor. Default is -9.81.

Output arguments:

  • nodeLoads ( containers.Map ) –

    Applied nodal loads.

    • Key : node tag
    • Value : row vector nodal load
Example
1
2
3
ops.timeSeries('Linear', 1);
ops.pattern('Plain', 1, 1);
nodeLoads = opsmat.pre.createGravityLoad(direction="Z", factor=-9.81);

beamGlobalUniformLoad ¤

(eleTags: double, wx: double = 0.0, wy: double = 0.0, wz: double = 0.0)

Apply global uniform loads to beam elements.

The input load components are defined in the global coordinate system. They are transformed to each beam element's local coordinate system and then applied through ops.eleLoad(...).

Syntax
1
2
pre.beamGlobalUniformLoad(eleTags)
pre.beamGlobalUniformLoad(eleTags, wx=wx, wy=wy, wz=wz)

Input arguments:

  • eleTags (double array) –

    Element tags to which the uniform load will be applied.

  • wx (double) –

    Uniform load intensity in the global x direction. Default is 0.0.

  • wy (double) –

    Uniform load intensity in the global y direction. Default is 0.0.

  • wz (double) –

    Uniform load intensity in the global z direction. Default is 0.0.

Example
1
2
3
ops.timeSeries('Linear', 1);
ops.pattern('Plain', 1, 1);
opsmat.pre.beamGlobalUniformLoad([1 2 3], wx=0, wy=-10, wz=0);

beamGlobalPointLoad ¤

(eleTags: double, px: double = 0.0, py: double = 0.0, pz: double = 0.0, xl: double = 0.5)

Apply global point loads to beam elements.

The input load components are defined in the global coordinate system. They are transformed to each beam element's local coordinate system and then applied through ops.eleLoad(...).

Syntax
1
2
pre.beamGlobalPointLoad(eleTags)
pre.beamGlobalPointLoad(eleTags, px=px, py=py, pz=pz, xl=xl)

Input arguments:

  • eleTags (double array) –

    Element tags to which the point load will be applied.

  • px (double) –

    Point load magnitude in the global x direction. Default is 0.0.

  • py (double) –

    Point load magnitude in the global y direction. Default is 0.0.

  • pz (double) –

    Point load magnitude in the global z direction. Default is 0.0.

  • xl (double) –

    Location along each beam element as a fraction of the element length. Use 0.0 at the I end, 1.0 at the J end, and 0.5 for midspan. Default is 0.5.

Example
1
2
3
ops.timeSeries('Linear', 1);
ops.pattern('Plain', 1, 1);
opsmat.pre.beamGlobalPointLoad([1 2], py=-100, xl=0.5);

surfaceGlobalPressureLoad ¤

(eleTags: double, p: double = 0.0)

Apply uniform pressure loads to surface elements.

This method converts uniform pressure on surface elements to equivalent nodal loads in global coordinates. The positive surface normal follows the cross product of the I-J and J-K element edges.

Syntax
1
pre.surfaceGlobalPressureLoad(eleTags, p)

Input arguments:

  • eleTags (double array) –

    Surface element tags to which the pressure load will be applied.

  • p (double) –

    Uniform pressure magnitude per unit area. p can be scalar or a vector with one value per element tag.

Example
1
2
3
ops.timeSeries('Linear', 1);
ops.pattern('Plain', 1, 1);
opsmat.pre.surfaceGlobalPressureLoad([101 102 103], -5.0);

pre.UnitSystem ¤

Bases: handle

Fast unit conversion system for OpenSeesMatlab.

The unit system allows users to set their preferred basic units for length, force, and time. It then provides conversion factors for a wide range of units based on these basic units. Users can access unit conversion factors through properties (e.g., unit.mm, unit.kN, unit.MPa) or by using the unit system as a function with an expression (e.g., unit("N/mm^2")). unit.mm2 would return the conversion factor for mm^2 based on the current length unit, unit.mm3 would return the conversion factor for mm^3 based on the current length unit, and so on.

Supported units include:

  • lengthUnit, options: inch, ft, mm, cm, m, km
  • forceUnit, options: lb, lbf, kip, n, kn, mn, kgf, tonf
  • timeUnit, options: msec, sec, min, hour, day, year
  • massUnit, options: mg, g, kg, ton, t, slug, slinch
  • stressUnit, options: pa, kpa, mpa, gpa, bar, psi, ksi, psf, ksf
Example
1
2
3
4
5
6
7
unit = pre.unitSystem;
unit.setBasicUnits(lengthUnit, forceUnit, timeUnit);
a = unit.mm;
b = unit.kN;
c = unit.MPa;
d = unit.mm2;
e = unit("N/mm^2");

setBasicUnits ¤

(lengthUnit, forceUnit, timeUnit)

Set the basic units for length, force, and time. This will reset the unit system and update all conversion factors accordingly.

Input arguments:

  • lengthUnit

pre.Gmsh2OPS ¤

Bases: handle

GMSH2OPS Generate OpenSees-MATLAB commands from Gmsh .msh files.

This class reads ASCII Gmsh .msh files and converts mesh entities, nodes, elements, and physical groups into OpenSees-MATLAB commands.

The class supports:

  • parsing $PhysicalNames, $Entities, $Nodes, and $Elements
  • querying nodes/elements by dimension-entity tags or physical groups
  • creating OpenSees commands directly at runtime
  • writing MATLAB or Tcl command scripts

Input arguments:

  • ops (object) –

    OpenSees-MATLAB command object used by runtime command creation methods.

Notes
  1. This implementation is intended for ASCII Gmsh MSH 4.x files.
  2. Runtime Gmsh API access is intentionally not included here.
  3. The generated MATLAB commands assume an OpenSees-MATLAB interface such as:

    ops.node(...) ops.element(...) ops.fix(...)

Examples:

Create the converter and read a mesh file:

1
2
g2o = Gmsh2OPS(Ops=ops);
g2o.readGmshFile('model.msh');

Write node and element commands to a MATLAB script:

1
2
3
g2o.setOutputFile(FileName='gmsh_model.m');
g2o.writeNodeFile();
g2o.writeElementFile('truss', OpsEleArgs={0.01, 1});

Create commands directly at runtime:

1
2
3
4
opsMAT = OpenSeesMatlab();
ops = opsMAT.opensees;
g2o.createNodeCmds();
g2o.createElementCmds('truss', OpsEleArgs={0.01, 1});

reset ¤

()

readGmshFile ¤

(filePath: char, PrintInfo: logical = true)

READGMSHFILE Read an ASCII Gmsh .msh file.

Input arguments:

  • filePath (char) –

    Path to the .msh file.

  • PrintInfo (logical) –

    If true, print geometry, physical group, and mesh summary information. Default is true.

Notes

This method parses the following sections when present:

  • $PhysicalNames
  • $Entities
  • $Nodes
  • $Elements

The parsed data are stored in:

  • gmshEntities
  • gmshNodes
  • gmshEles
  • gmshPhysicalGroups

Examples:

1
2
g2o.readGmshFile('mesh.msh');
g2o.readGmshFile('mesh.msh', PrintInfo=false);

printInfo ¤

()

PRINTINFO Print geometry, physical group, and mesh summary information.

Notes

This method prints:

  • entity counts by dimension
  • physical group names
  • total node and element counts
  • minimum and maximum node/element tags

getDimEntityTags ¤

(Dim=[])

GETDIMENTITYTAGS Return dimension-entity tag pairs.

Input arguments:

  • Dim (double) –

    Dimension to filter. If empty, all dimension-entity tags are returned.

Output arguments:

  • dimEntityTags ( double array ) –

    N-by-2 array of [dim, entityTag].

getBoundaryDimTags ¤

(DimEntityTags=[], PhysicalGroupNames=[], IncludeSelf: logical = false)

GETBOUNDARYDIMTAGS Return all boundary dim-entity tags recursively.

Input arguments:

  • DimEntityTags (double array) –

    N-by-2 array of [dim, entityTag].

  • PhysicalGroupNames ((char, string, cellstr)) –

    Physical group name or names.

  • IncludeSelf (logical) –

    If true, the queried entities themselves are also included. Default is false.

Output arguments:

  • boundaryDimTags ( double array ) –

    Unique sorted boundary dim-entity tags.

Notes

The boundaries are collected recursively, so surfaces return their boundary curves and corner points, and volumes return their boundary surfaces, curves, and points.

getNodeTags ¤

(DimEntityTags=[], PhysicalGroupNames=[])

GETNODETAGS Return node tags from selected entities or groups.

Input arguments:

  • DimEntityTags (double array) –

    N-by-2 array of [dim, entityTag]. If provided, it takes priority over PhysicalGroupNames.

  • PhysicalGroupNames ((char, string, cellstr)) –

    Physical group name or list of names.

Output arguments:

  • nodeTags ( double column vector ) –

    Unique node tags in stable order.

Notes

If both DimEntityTags and PhysicalGroupNames are empty, all available mesh entities with nodes are used.

Examples:

1
2
3
tags = g2o.getNodeTags();
tags = g2o.getNodeTags(DimEntityTags=[2 1; 2 2]);
tags = g2o.getNodeTags(PhysicalGroupNames='Support');

getElementTags ¤

(DimEntityTags=[], PhysicalGroupNames=[])

GETELEMENTTAGS Return element tags from selected entities or groups.

Input arguments:

  • DimEntityTags (double array) –

    N-by-2 array of [dim, entityTag].

  • PhysicalGroupNames ((char, string, cellstr)) –

    Physical group name or list of names.

Output arguments:

  • eleTags ( double column vector ) –

    Unique element tags in stable order.

createNodeCmds ¤

(DimEntityTags=[], PhysicalGroupNames=[], StartNodeTag=[])

CREATENODECMDS Create OpenSees node commands at runtime.

Input arguments:

  • DimEntityTags (double array) –

    N-by-2 array of [dim, entityTag].

  • PhysicalGroupNames ((char, string, cellstr)) –

    Physical group name or list of names.

  • StartNodeTag (double) –

    Starting node tag. If empty, original Gmsh node tags are used.

Output arguments:

  • nodeTags ( double column vector ) –

    Generated OpenSees node tags.

Notes

If StartNodeTag is provided, node tags are reassigned in ascending order from that value.

createElementCmds ¤

(opsEleType, OpsEleArgs={}, DimEntityTags=[], PhysicalGroupNames=[], StartEleTag=[])

CREATEELEMENTCMDS Create OpenSees element commands at runtime.

Input arguments:

  • opsEleType (char or string) –

    OpenSees element type, such as "truss" or "quad".

  • OpsEleArgs (cell) –

    Additional arguments appended after tag and node tags.

  • DimEntityTags (double array) –

    N-by-2 array of [dim, entityTag].

  • PhysicalGroupNames ((char, string, cellstr)) –

    Physical group name or names.

  • StartEleTag (double) –

    Starting element tag. If empty, original Gmsh element tags are used.

Output arguments:

  • eleTags ( double column vector ) –

    Generated OpenSees element tags.

Notes

If StartEleTag is provided, element tags are reassigned in ascending order from that value.

Examples:

1
2
g2o.createElementCmds('truss', OpsEleArgs={0.01, 1});
g2o.createElementCmds('quad', OpsEleArgs={1, 'PlaneStress', 1}, PhysicalGroupNames='Slab');

createFixCmds ¤

(dofs, DimEntityTags=[], PhysicalGroupNames=[])

CREATEFIXCMDS Create OpenSees fix commands at runtime.

Input arguments:

  • dofs (cell or numeric array) –

    Constrained degrees of freedom flags, such as {1,1,1} or [1 1 1].

  • DimEntityTags (double array) –

    N-by-2 array of [dim, entityTag].

  • PhysicalGroupNames ((char, string, cellstr)) –

    Physical group name or names.

Output arguments:

  • fixedTags ( double column vector ) –

    Fixed node tags.

Notes

Duplicate node tags are removed automatically.

setOutputFile ¤

(FileName: char = 'src.m')

SETOUTPUTFILE Set the output script file.

Input arguments:

  • FileName (char) –

    Output file name. Must end with .m or .tcl. Default is 'src.m'.

Notes

If the file ends with .m, MATLAB/OpenSees commands are written. If the file ends with .tcl, Tcl/OpenSees commands are written.

A model header is automatically written to the file.

Examples:

1
2
g2o.setOutputFile(FileName='model_from_gmsh.m');
g2o.setOutputFile(FileName='model_from_gmsh.tcl');

writeNodeFile ¤

(DimEntityTags=[], PhysicalGroupNames=[], StartNodeTag=[])

WRITENODEFILE Write node commands to the output script.

Input arguments:

  • DimEntityTags (double array) –

    N-by-2 array of [dim, entityTag].

  • PhysicalGroupNames ((char, string, cellstr)) –

    Physical group name or list of names.

  • StartNodeTag (double) –

    Starting node tag. If empty, original Gmsh node tags are used.

Output arguments:

  • nodeTags ( double column vector ) –

    Written node tags.

Notes

setOutputFile must be called before using this method.

writeElementFile ¤

(opsEleType, OpsEleArgs={}, DimEntityTags=[], PhysicalGroupNames=[], StartEleTag=[])

WRITEELEMENTFILE Write element commands to the output script.

Input arguments:

  • opsEleType (char or string) –

    OpenSees element type.

  • OpsEleArgs (cell) –

    Additional arguments appended after tag and node tags.

  • DimEntityTags (double array) –

    N-by-2 array of [dim, entityTag].

  • PhysicalGroupNames ((char, string, cellstr)) –

    Physical group name or names.

  • StartEleTag (double) –

    Starting element tag. If empty, original Gmsh element tags are used.

Output arguments:

  • eleTags ( double column vector ) –

    Written element tags.

Notes

setOutputFile must be called before using this method.

writeFixFile ¤

(dofs, DimEntityTags=[], PhysicalGroupNames=[])

WRITEFIXFILE Write fix commands to the output script.

Input arguments:

  • dofs (cell or numeric array) –

    Constrained degrees of freedom flags.

  • DimEntityTags (double array) –

    N-by-2 array of [dim, entityTag].

  • PhysicalGroupNames ((char, string, cellstr)) –

    Physical group name or names.

Output arguments:

  • fixedTags ( double column vector ) –

    Written fixed node tags.

Notes

setOutputFile must be called before using this method.

pre.FiberSectionMesh ¤

Bases: handle

Cross-section meshing, geometric property computation, and OpenSees fiber section definition via the OpenSees MATLAB interface.

This class accepts an assembly of user-defined section parts, each described by a polyshape geometry object and an OpenSees material tag. Parts are independent and can represent distinct materials (e.g. confined core, unconfined cover, steel plate). The class meshes each part with a raster (rectangular grid) strategy, computes section properties from the resulting fiber discretisation, and writes the section definition directly into an OpenSees model through a shared OpenSees MATLAB interface object (ops).

1
2
3
4
5
% Access static helpers through the stub
ps = opsmat.pre.fiberSectionMesh.rectShape(400, 600);

% Construct a real section
sec = opsmat.pre.fiberSectionMesh.new(parts, rebars, secTag);

Rebar groups may also be registered. They contribute fiber calls to the build output but are excluded from all geometric property calculations; the caller is responsible for rebar geometry.

This class belongs to the pre package. Static utility methods must therefore be called as pre.FiberSectionMesh.<method>.

Input arguments:

  • parts (struct array) –

    Array of solid-region descriptors. Each element must contain the following fields:

    • name (char) – Human-readable label for the part.
    • matTag (int) – OpenSees uniaxial material tag.
    • geometry (polyshape) – Closed polygon defining the region boundary. Holes and multi-region shapes (created with subtract, intersect, etc.) are fully supported.
    • meshSize (double, optional) – Target raster cell size. Defaults to 20 when the field is absent or empty.
    • secTag (double, optional) – Per-part OpenSees section tag. Defaults to NaN; the class-level secTag property takes precedence when set.
  • rebars (struct array) –

    Array of rebar-group descriptors. Each element must contain:

    • name (char) – Human-readable label.
    • matTag (int) – OpenSees uniaxial material tag.
    • coords (N-by-2 double) – Bar centre coordinates; each row is [y, z].
    • area (double) – Cross-sectional area of one bar (scalar) or individual areas for each bar (N-by-1 vector).
  • secTag (double) –

    Global OpenSees section tag applied to the entire assembly. Overrides any secTag values stored in individual parts. Defaults to NaN (must be set before calling build).

Properties:

  • parts (struct array) –

    Solid-region descriptors as provided by the caller.

  • rebars (struct array) –

    Rebar-group descriptors as provided by the caller.

  • secTag (_Hx9U5) –

    Global OpenSees section tag.

  • meshFibers (struct array) –

    Fiber cells produced by the last call to mesh. Each element has fields y, z, area, hw, hh, matTag, and partName. Empty until mesh has been called.

  • sectionProps (_dXrgj) –

    Geometric properties produced by the last call to computeProps. Fields: A, Cy, Cz, Iy, Iz, Iyz, ry, rz, I1, I2, theta. Empty until computeProps has been called.

Examples:

Recommended workflow via the opsmat.pre.fiberSection stub::

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
opsmat = OpenSeesMatlab();
fs     = opsmat.pre.fiberSectionMesh;   % grab the stub once (optional)

% --- geometry via stub static helpers ---
outer = fs.rectShape(400, 600);     % same as pre.FiberSectionMesh.rectShape(...)
inner = fs.rectShape(340, 540);

parts(1).name     = 'Confined core';
parts(1).matTag   = 1;
parts(1).geometry = inner;
parts(1).meshSize = 30;

parts(2).name     = 'Cover concrete';
parts(2).matTag   = 2;
parts(2).geometry = subtract(outer, inner);
parts(2).meshSize = 30;

coords = fs.rectRebars(400, 600, 50, 'gap', 120);
rebars(1).name   = 'HRB400';
rebars(1).matTag = 3;
rebars(1).coords = coords;
rebars(1).area   = pi * 12^2;

% --- construct real section: ops injected automatically ---
sec = fs.new(parts, rebars=rebars, secTag=101);
sec.mesh();
sec.computeProps();
sec.printProps();
sec.build();               % calls ops.section / ops.fiber internally
Notes
  • The coordinate system follows the OpenSees convention: y is the horizontal axis and z is the vertical axis in the section plane.
  • Always create sections via opsmat.pre.fiberSection.new(...) rather than directly with pre.FiberSectionMesh(...); the former injects ops automatically so build works without extra steps.
  • The opsmat.pre.fiberSectionMesh stub is a shell instance with no parts or rebars. It is safe to call static helpers on it at any time; only new produces a real, usable section.
  • Rebar fibers are written last inside the section Fiber block but contribute nothing to sectionProps.
  • Calling mesh again after changing parts invalidates the previously computed sectionProps; computeProps must be re-called.
See Also

Polygonal Shapes

Methods:

  • new

    Create a fully configured FiberSectionMesh with ops injected.

  • mesh

    Discretise all section parts into triangular fiber cells.

  • computeProps

    Compute cross-section geometric properties.

  • printProps

    Print a formatted summary of section properties.

  • build

    Write the fiber section definition into the OpenSees model.

  • plot

    Visualize the triangular section mesh, rebars, and centroid.

  • polygonShape

    polygonShape Create an arbitrary closed polygon polyshape.

  • rectShape

    rectShape Create a solid rectangular polyshape.

  • hollowRectShape

    Create a hollow rectangular (box) polyshape.

  • circleShape

    circleShape Create a solid circular polyshape.

  • annulusShape

    annulusShape Create an annular (hollow circular) polyshape.

  • IShape

    IShape Create a doubly-symmetric I- or H-section polyshape.

  • TShape

    TShape Create a T-section (flange + web) polyshape.

  • LShape

    LShape Create an L-section (equal- or unequal-leg angle) polyshape.

  • lineRebars

    Generate rebar coordinates along a polyline or closed polygonal path.

  • rectRebars

    Bar centres around the perimeter of a rectangle.

  • circRebars

    circRebars Bar centres arranged on a full circle.

  • arcRebars

    arcRebars Bar centres along a circular arc.

  • polygonRebars

    polygonRebars Bar centres along an arbitrary polygon path.

new ¤

(parts: struct, rebars=[], secTag: double = NaN)

Create a fully configured FiberSectionMesh with ops injected.

Call this on the opsmat.pre.fiberSection stub rather than using the constructor directly. The ops object stored in the stub is automatically transferred to the new section so that build works without any extra setup.

Input arguments:

  • parts (struct array) –

    Solid-region descriptors. See class documentation for required fields (name, matTag, geometry).

  • rebars (struct array, optional keyword) –

    Rebar-group descriptors. Omit entirely when the section has no reinforcement. Default [].

  • secTag (double, optional keyword) –

    OpenSees section tag (positive integer). Can also be assigned later via sec.secTag = value before calling build. Default NaN.

Output arguments:

  • sec ( FiberSectionMesh ) –

    New section object with ops already injected. Ready for mesh, computeProps, and build.

mesh ¤

()

Discretise all section parts into triangular fiber cells.

This method must be called before computeProps or build. Calling mesh again discards the previous fiber set and resets isComputed.

Input arguments:

  • None

Output arguments:

  • None

    meshFibers is updated in place (handle semantics).

Notes

The Partial Differential Equation Toolbox - MATLAB is required.

computeProps ¤

()

Compute cross-section geometric properties.

Evaluates the following properties from the current fiber mesh using the standard fiber-integration formulas. Rebar fibers are not included.

mesh is called automatically if it has not yet been invoked.

Notes

Computed quantities stored in obj.sectionProps:

Field Description
A Total cross-sectional area.
Cy y-coordinate of the centroid.
Cz z-coordinate of the centroid.
Iy Second moment of area about the horizontal centroidal axis (integral of z^2 dA).
Iz Second moment of area about the vertical centroidal axis (integral of y^2 dA).
Iyz Product of inertia (integral of y*z dA).
ry Radius of gyration about the horizontal centroidal axis.
rz Radius of gyration about the vertical centroidal axis.
I1 Larger principal second moment of area.
I2 Smaller principal second moment of area.
theta Angle (degrees) from the z-axis to the principal axis corresponding to I1.

printProps ¤

()

Print a formatted summary of section properties.

build ¤

(secType='Fiber', GJ: double = 1.0e12)

Write the fiber section definition into the OpenSees model.

Input arguments:

  • secType (char or string) –

    OpenSees section type. Default is 'Fiber'. You can specify any valid OpenSees fiber section type, e.g, "FiberThermal".

  • GJ (double) –

    Torsional stiffness passed through the '-GJ' option. Default is 1.0e12. Only used for 3D case.

Examples:

1
2
3
4
5
6
% Default Fiber section with GJ = 1e12::
sec.build();
% Specify torsional stiffness::
sec.build(GJ=5.0e10);
% Specify section type and torsional stiffness::
sec.build(secType='Fiber', GJ=5.0e10);

plot ¤

(color: double = [], partColors: cell = {}, alpha: double = 0.92, fill: logical = false, showEdges: logical = true, showRebars: logical = true, showCentroid: logical = false, ax=[])

Visualize the triangular section mesh, rebars, and centroid.

Input arguments:

  • color (double array, shape (1, 3)) –

    Single RGB color applied to all parts. If empty, colors are assigned automatically from a colormap.

  • partColors (cell array) –

    One RGB or hex color per part. This overrides color and the colormap.

  • alpha (double) –

    Face transparency for filled mesh patches. Default is 0.92.

  • fill (logical) –

    If false, only colored mesh lines are shown. If true, filled triangular mesh patches are shown. Default is false.

  • showEdges (logical) –

    Show mesh edges when fill is true. Default is true.

  • showRebars (logical) –

    Show rebar groups. Default is true.

  • showCentroid (logical) –

    Show centroid marker if section properties have been computed. Default is false.

  • ax (axes) –

    Target axes. If empty, a new figure is created.

polygonShape Static ¤

(yVerts, zVerts)

polygonShape Create an arbitrary closed polygon polyshape.

Convenience wrapper around the polyshape constructor for user-supplied vertex lists. The polygon is automatically closed; do not repeat the first vertex at the end. Holes can be created afterwards with subtract.

Input arguments:

  • yVerts ((N,) double) –

    y-coordinates of the polygon vertices in order (CW or CCW).

  • zVerts ((N,) double) –

    z-coordinates of the polygon vertices in the same order. Must have the same length as yVerts.

Output arguments:

  • ps ( polyshape ) –

    Closed polygon built from the supplied vertices.

Examples:

1
2
3
4
5
6
7
8
9
% Trapezoidal section::
y = [-300, 300, 200, -200];
z = [   0,   0, 600,  600];
ps = pre.FiberSectionMesh.polygonShape(y, z);

% Diamond::
y = [0, 200, 0, -200];
z = [-300, 0, 300, 0];
ps = pre.FiberSectionMesh.polygonShape(y, z);

rectShape Static ¤

(b, h, cy, cz)

rectShape Create a solid rectangular polyshape.

Input arguments:

  • b (double) –

    Width in the y-direction.

  • h (double) –

    Height in the z-direction.

  • cy (double) –

    y-coordinate of the centroid. Default 0.

  • cz (double) –

    z-coordinate of the centroid. Default 0.

Output arguments:

  • ps ( polyshape ) –

    Axis-aligned solid rectangle.

Examples:

1
2
3
4
5
% Centred at origin::
ps = pre.FiberSectionMesh.rectShape(400, 600);

% Offset centroid::
ps = pre.FiberSectionMesh.rectShape(200, 300, 100, 0);

hollowRectShape Static ¤

(bo, ho, bi, hi, cy, cz)

Create a hollow rectangular (box) polyshape.

The inner rectangle is concentrically subtracted from the outer rectangle. Both rectangles share the same centroid. To model eccentric voids use subtract directly on two rectShape results.

Input arguments:

  • bo (double) –

    Outer width (y-direction).

  • ho (double) –

    Outer height (z-direction).

  • bi (double) –

    Inner (void) width (y-direction). Must be < bo.

  • hi (double) –

    Inner (void) height (z-direction). Must be < ho.

  • cy (double) –

    y-coordinate of the shared centroid. Default 0.

  • cz (double) –

    z-coordinate of the shared centroid. Default 0.

Output arguments:

  • ps ( polyshape ) –

    Hollow rectangular polygon (outer minus inner).

Examples:

1
2
3
4
5
% Steel box section 200 × 300, wall thickness 10::
ps = pre.FiberSectionMesh.hollowRectShape(200, 300, 180, 280);

% Concrete hollow pier 1200 × 1600, wall 200::
ps = pre.FiberSectionMesh.hollowRectShape(1200, 1600, 800, 1200);

circleShape Static ¤

(r, cy, cz, n)

circleShape Create a solid circular polyshape.

The circle is approximated by a regular n-gon. The default of 64 vertices is sufficient for typical section meshes; use 128 or higher for very fine meshes or large radii.

Input arguments:

  • r (double) –

    Radius of the circle.

  • cy (double) –

    y-coordinate of the centre. Default 0.

  • cz (double) –

    z-coordinate of the centre. Default 0.

  • n (int) –

    Number of polygon vertices. Default 64.

Output arguments:

  • ps ( polyshape ) –

    Regular n-gon approximating the circle.

Examples:

1
2
ps = pre.FiberSectionMesh.circleShape(250);
ps = pre.FiberSectionMesh.circleShape(250, 0, 0, 128);

annulusShape Static ¤

(Ro, Ri, cy, cz, n)

annulusShape Create an annular (hollow circular) polyshape.

Useful for circular steel tubes, pipe piles, or circular concrete sections with a central void.

Input arguments:

  • Ro (double) –

    Outer radius.

  • Ri (double) –

    Inner radius. Must satisfy 0 < Ri < Ro.

  • cy (double) –

    y-coordinate of the centre. Default 0.

  • cz (double) –

    z-coordinate of the centre. Default 0.

  • n (int) –

    Number of polygon vertices on each boundary circle. Default 64.

Output arguments:

  • ps ( polyshape ) –

    Annular polygon (outer circle minus inner circle).

Examples:

1
2
3
4
5
% Steel circular hollow section, outer diameter 600, thickness 20::
ps = pre.FiberSectionMesh.annulusShape(300, 280);

% Concrete annular pier, outer r = 1500, inner r = 1200::
ps = pre.FiberSectionMesh.annulusShape(1500, 1200);

IShape Static ¤

(bf, tf, hw, tw, cy, cz)

IShape Create a doubly-symmetric I- or H-section polyshape.

The section is assembled from three rectangles (top flange, web, bottom flange) combined with union. The centroid is placed at the intersection of the two axes of symmetry.

┌──────────────┐ ─ z = +H/2 (top of top flange)

│ top flange │

└───┬──────┬───┘ ─ z = +hw/2

1
  │  web │

┌───┴──────┴───┐ ─ z = -hw/2

│ bottom flange│

└──────────────┘ ─ z = -H/2

Input arguments:

  • bf (double) –

    Flange width (y-direction).

  • tf (double) –

    Flange thickness (z-direction, both flanges identical).

  • hw (double) –

    Clear web height (z-direction, between flanges).

  • tw (double) –

    Web thickness (y-direction).

  • cy (double) –

    y-coordinate of the section centroid. Default 0.

  • cz (double) –

    z-coordinate of the section centroid. Default 0.

Output arguments:

  • ps ( polyshape ) –

    I-section polygon. Total height = hw + 2*tf.

Examples:

1
2
3
4
5
% HN400 (approximate)::
ps = pre.FiberSectionMesh.IShape(200, 13, 374, 8);

% Steel H-pile 300 x 300::
ps = pre.FiberSectionMesh.IShape(300, 15, 270, 10);

TShape Static ¤

(bf, tf, hw, tw, cy, cz)

TShape Create a T-section (flange + web) polyshape.

The web hangs below the flange. The reference centroid (cy, cz) is placed at the centre of the flange's top face (i.e. z = 0 is the top of the section). The overall depth is tf + hw.

┌──────────────┐ z = 0 (top of flange / reference)

│ flange │

└───┬──────┬───┘ z = -tf

1
2
3
4
5
  │  web │

  │      │

  └──────┘      z = -(tf + hw)

Input arguments:

  • bf (double) –

    Flange width (y-direction).

  • tf (double) –

    Flange thickness (z-direction).

  • hw (double) –

    Web height below the flange (z-direction).

  • tw (double) –

    Web thickness (y-direction).

  • cy (double) –

    y-coordinate of the section centreline. Default 0.

  • cz (double) –

    z-coordinate of the top of the flange. Default 0.

Output arguments:

  • ps ( polyshape ) –

    T-section polygon. Total depth = tf + hw.

Examples:

T-beam 600 wide flange, 120 thick, 600 web height, 100 thick::

1
ps = pre.FiberSectionMesh.TShape(600, 120, 600, 100);

LShape Static ¤

(b, h, t, cy, cz)

LShape Create an L-section (equal- or unequal-leg angle) polyshape.

The horizontal leg extends in the +y direction and the vertical leg extends in the +z direction from the heel at (cy, cz).

┌──┐ z = cz + h (top of vertical leg)

│ │

│ ├────────┐ z = cz + t

└──┴────────┘ z = cz (bottom / heel)

cy cy + b

Input arguments:

  • b (double) –

    Total width of the horizontal leg (y-direction).

  • h (double) –

    Total height of the vertical leg (z-direction).

  • t (double) –

    Leg thickness (applied to both legs; for unequal thickness use polygonShape directly).

  • cy (double) –

    y-coordinate of the heel corner. Default 0.

  • cz (double) –

    z-coordinate of the heel corner. Default 0.

Output arguments:

Examples:

1
2
3
4
5
% Equal-leg angle L150 × 150 × 12::
ps = pre.FiberSectionMesh.LShape(150, 150, 12);

% Unequal-leg angle, heel at origin::
ps = pre.FiberSectionMesh.LShape(200, 100, 10, 0, 0);

lineRebars Static ¤

(yPath: double, zPath: double, n: double = [], gap: double = [], closed: logical = false, removeDuplicateEnd: logical = true, tol: double = 1.0e-10)

Generate rebar coordinates along a polyline or closed polygonal path.

Path vertices are always occupied by rebars. Each path segment is then independently interpolated using either a target spacing gap or an approximate total bar count n.

Input arguments:

  • yPath (double array, shape (n, 1)) –

    y-coordinates of the path vertices.

  • zPath (double array, shape (n, 1)) –

    z-coordinates of the path vertices.

  • n (double) –

    Approximate total number of bars along the whole path.

  • gap (double) –

    Target spacing along each segment.

  • closed (logical) –

    If true, connect the last point back to the first point.

  • removeDuplicateEnd (logical) –

    Remove repeated final point if identical to the first point.

  • tol (double) –

    Tolerance for duplicate and zero-length points.

Output arguments:

  • coords ( double array, shape (m, 2) ) –

    Rebar coordinates. Each row is [y, z].

rectRebars Static ¤

(b, h, cover, varargin)

Bar centres around the perimeter of a rectangle.

Distributes bars around all four faces of a rectangle. The spacing is controlled by nY + nZ (bars per face) or by a uniform centre-to-centre gap. Corner bars are always present and are counted only once.

Input arguments:

  • b (double) –

    Section width (y-direction).

  • h (double) –

    Section height (z-direction).

  • cover (double) –

    Distance from the face to the bar centre.

  • nY ((int, keyword)) –

    Number of bars along the top / bottom faces (corners included). Must be supplied together with nZ.

  • nZ ((int, keyword)) –

    Number of bars along the left / right faces (corners included). Must be supplied together with nY.

  • gap ((double, keyword)) –

    Uniform target spacing; the same gap is applied to all four faces independently. Cannot be combined with nY / nZ.

  • cy (double, optional keyword) –

    y-coordinate of the section centroid. Default 0.

  • cz (double, optional keyword) –

    z-coordinate of the section centroid. Default 0.

Output arguments:

  • coords ( (N, 2) double ) –

    Unique bar centre coordinates sorted by angle; each row is [y, z].

Examples:

1
2
3
4
5
6
7
8
% Specify bars per face::
c = pre.FiberSectionMesh.rectRebars(400, 600, 50, 'nY',4, 'nZ',5);

% Uniform gap::
c = pre.FiberSectionMesh.rectRebars(400, 600, 50, 'gap',120);

% Offset section centroid::
c = pre.FiberSectionMesh.rectRebars(400,600,50,'gap',120,'cy',100,'cz',0);

circRebars Static ¤

(R, varargin)

circRebars Bar centres arranged on a full circle.

Distributes bars uniformly on a circle of radius R. The spacing is controlled by n (number of bars) or by the target arc gap. The closed option selects whether the layout is treated as a closed loop (default) — spacing is 2*pi*R / n — or open, which has no practical difference for a full circle but is provided for API consistency.

Input arguments:

  • R (double) –

    Radius of the bar circle (to bar centres).

  • n ((int, keyword)) –

    Number of bars equally spaced around the full circle. Must be >= 2.

  • gap ((double, keyword)) –

    Target arc-length spacing between adjacent bar centres. n = round(2*pi*R / gap).

  • cy (double, optional keyword) –

    y-coordinate of the circle centre. Default 0.

  • cz (double, optional keyword) –

    z-coordinate of the circle centre. Default 0.

  • startAngle (double, optional keyword) –

    Angle (degrees) of the first bar, measured CCW from the +y axis. Default 90 (bar at the top).

Output arguments:

  • coords ( (N, 2) double ) –

    Bar centre coordinates; each row is [y, z].

Examples:

1
2
3
4
5
6
7
8
% bars on a 250 mm radius circle::
c = pre.FiberSectionMesh.circRebars(250, 'n', 8);

% Bars at 150 mm arc spacing::
c = pre.FiberSectionMesh.circRebars(250, 'gap', 150);

% Starting from the bottom (270 deg)::
c = pre.FiberSectionMesh.circRebars(250, 'n', 12, 'startAngle', 270);

arcRebars Static ¤

(R, angStart, angEnd, varargin)

arcRebars Bar centres along a circular arc.

Distributes bars from angle angStart to angEnd along an arc of radius R. By default the two end angles are included (closed = true). Set closed = false to place bars strictly between the end angles.

Input arguments:

  • R (double) –

    Arc radius (to bar centres).

  • angStart (double) –

    Start angle in degrees, measured CCW from the +y axis.

  • angEnd (double) –

    End angle in degrees, measured CCW from the +y axis. May be less than angStart to sweep CW.

  • n ((int, keyword)) –

    Number of bars including end bars (when closed = true) or excluding them (when closed = false). Must be >= 2 when closed = true, >= 1 otherwise.

  • gap ((double, keyword)) –

    Target arc-length spacing. The actual bar count is determined from the arc length and the gap.

  • closed (logical, optional keyword) –

    true (default) – bars placed at angStart and angEnd as well as in between. false – bars placed strictly between the two angles, evenly spaced.

  • cy (double, optional keyword) –

    y-coordinate of the arc centre. Default 0.

  • cz (double, optional keyword) –

    z-coordinate of the arc centre. Default 0.

Output arguments:

  • coords ( (N, 2) double ) –

    Bar centre coordinates; each row is [y, z].

Examples:

1
2
3
4
5
% 6 bars over the top half (0° to 180°)::
c = pre.FiberSectionMesh.arcRebars(250, 0, 180, 'n', 6);

% Bars at 100 mm spacing over bottom 180°, open ends::
c = pre.FiberSectionMesh.arcRebars(250, 180, 360, 'gap', 100, 'closed', false);

polygonRebars Static ¤

(yPath, zPath, varargin)

polygonRebars Bar centres along an arbitrary polygon path.

Traverses the edges of a polygon (given as an ordered vertex list) and places bars at uniform arc-length spacing along the path. The polygon can be treated as open (a poly-line) or closed (the last vertex connects back to the first).

This is useful for non-rectangular or non-circular cages, such as hexagonal columns, wall boundary elements, or custom shapes.

Input arguments:

  • yPath ((M,) double) –

    y-coordinates of the polygon vertices in traversal order.

  • zPath ((M,) double) –

    z-coordinates of the polygon vertices in traversal order.

  • n ((int, keyword)) –

    Total number of bars distributed along the full path (including the start point; end point included only if closed = true).

  • gap ((double, keyword)) –

    Target arc-length spacing between adjacent bars.

  • closed (logical, optional keyword) –

    true (default) – the last vertex connects back to the first vertex, forming a closed loop. false – the path is open; bars run from the first to the last vertex only.

Output arguments:

  • coords ( (N, 2) double ) –

    Bar centre coordinates; each row is [y, z].

Notes

Bar positions are determined by uniform arc-length parameterisation of the polyline. Vertices of the path are not necessarily bar positions.

Examples:

Hexagonal cage, 18 bars, closed::

1
2
3
4
ang   = (0:5) * 60;
yHex  = 250 * cosd(ang);
zHex  = 250 * sind(ang);
c = pre.FiberSectionMesh.polygonRebars(yHex, zHex, 'n', 18);

Open poly-line, bars at 80 mm::

1
2
c = pre.FiberSectionMesh.polygonRebars( ...
        [-200,0,200], [0,300,0], 'gap', 80, 'closed', false);