Main Content

discreteGeometry

Discrete 2-D or 3-D geometry description

    Description

    DiscreteGeometry describes a 2-D or 3-D geometry in the form of a discrete geometry object. PDEModel, StructuralModel, and ThermalModel objects have a Geometry property, which can be an AnalyticGeometry or DiscreteGeometry object.

    Creation

    Description

    Create a discrete geometry for your model by using one of the following approaches:

    • Use importGeometry to import a 2-D or 3-D geometry from an STL file or a 3-D geometry from a STEP file and attach it to the model.

    • Use geometryFromMesh to reconstruct a 2-D or 3-D geometry from mesh and attach it to the model.

    • Use multicuboid, multicylinder, or multisphere to create a 3-D geometry. Then assign the resulting geometry to the Geometry property of the model. For example, create a PDE model and add the following geometry formed by three spheres to the model.

      model = createpde;
      gm = multisphere([1,2,3]);
      model.Geometry = gm;
    • Use extrude to create a 3-D geometry by vertically extruding a 2-D geometry.

    In R2026a: gm = discreteGeometry(fegeom) converts an fegeometry object to a Discretegeometry object.

    example

    Input Arguments

    expand all

    Since R2026a

    Geometry to convert, specified as an fegeometry object. The geometry must not be empty.

    Properties

    expand all

    Number of geometry cells, specified as a nonnegative integer.

    Data Types: double

    Number of geometry faces, specified as a positive integer.

    Data Types: double

    Number of geometry edges, specified as a nonnegative integer.

    Data Types: double

    Number of geometry vertices, specified as a nonnegative integer.

    Data Types: double

    Coordinates of geometry vertices, specified as an N-by-2 or N-by-3 numeric matrix for a 2-D or 3-D geometry, respectively. Here, N is the number of vertices.

    Data Types: double

    Object Functions

    addCellCombine two geometries by adding one inside a cell of another
    addFaceFill void regions in 2-D and split cells in 3-D geometry
    addVertexAdd vertex on geometry boundary
    addVoidCreate void regions inside 3-D geometry
    cellEdgesFind edges belonging to boundaries of specified cells
    cellFacesFind faces belonging to specified cells
    extrudeVertically extrude 2-D geometry or specified faces of 3-D geometry
    faceEdgesFind edges belonging to specified faces
    facesAttachedToEdgesFind faces attached to specified edges
    mergeCellsMerge geometry cells
    nearestEdgeFind edges nearest to specified point
    nearestFaceFind faces nearest to specified point
    rotateRotate geometry
    scaleScale geometry
    translateTranslate geometry

    Examples

    collapse all

    Create the geometry consisting of three cylinders of the same height by using the multicylinder function.

    gm = multicylinder([5 10 15],20)
    gm = 
      DiscreteGeometry with properties:
    
           NumCells: 3
           NumFaces: 9
           NumEdges: 6
        NumVertices: 6
           Vertices: [6×3 double]
    
    

    Plot the geometry.

    pdegplot(gm,FaceAlpha=0.5)

    Figure contains an axes object. The axes object contains 6 objects of type quiver, text, patch, line.

    Import a geometry from an STL geometry file.

    gm = importGeometry("ForearmLink.stl")
    gm = 
      DiscreteGeometry with properties:
    
           NumCells: 1
           NumFaces: 147
           NumEdges: 329
        NumVertices: 213
           Vertices: [213×3 double]
    
    

    Plot the geometry,

    pdegplot(gm)

    Figure contains an axes object. The axes object contains 6 objects of type quiver, text, patch, line.

    Since R2026a

    Create a geometry by cutting out multiple cubes from a cylinder.

    First, create geometries representing a cylinder and a unit cube.

    gmcyl = fegeometry(multicylinder(1,1));
    gmcube = fegeometry(multicuboid(1,1,1));

    Create a vector of geometries by rotating the cube by 30 and 60 degrees.

    angle = [0 30 60];
    for k = 1:numel(angle)
        gv(k) = rotate(gmcube,angle(k));
    end

    Subtract the resulting vector of geometries from the cylinder.

    gm = subtract(gmcyl,gv)
    gm = 
      fegeometry with properties:
    
           NumCells: 1
           NumFaces: 27
           NumEdges: 74
        NumVertices: 50
           Vertices: [50×3 double]
               Mesh: []
    
    

    Plot the resulting geometry.

    pdegplot(gm)

    Figure contains an axes object. The axes object contains 6 objects of type quiver, text, patch, line.

    The resulting geometry is an fegeometry object. You can use this object to define a geometry for an femodel object or batteryP2DModel object. To use this geometry with a PDEModel object for solving general PDEs, convert the geometry to a DiscreteGeometry object.

    gm = discreteGeometry(gm)
    gm = 
      DiscreteGeometry with properties:
    
           NumCells: 1
           NumFaces: 27
           NumEdges: 74
        NumVertices: 50
           Vertices: [50×3 double]
    
    

    Create a PDE model and include the geometry in the model.

    model = createpde;
    model.Geometry = gm
    model = 
      PDEModel with properties:
    
               PDESystemSize: 1
             IsTimeDependent: 0
                    Geometry: [1×1 DiscreteGeometry]
        EquationCoefficients: []
          BoundaryConditions: []
           InitialConditions: []
                        Mesh: []
               SolverOptions: [1×1 pde.PDESolverOptions]
    
    

    Version History

    Introduced in R2015a

    expand all