How to use the pygmsh.Geometry function in pygmsh

To help you get started, we’ve selected a few pygmsh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / pygmsh / test / examples / flow_around_airfoil.py View on Github external
# Scale airfoil to input coord
    airfoilCoordinates *= coord
    
    # Dat-file dimensions
    numPoints = airfoilCoordinates.shape[0]
    dimPoints = airfoilCoordinates.shape[1]
    
    # Move points from 1D or 2D space to 3D space
    if 0 < dimPoints < 3:
        airfoilCoordinates = np.hstack((airfoilCoordinates, np.zeros([numPoints, 3-dimPoints])))
    else:
        sys.exit('The airfoil dat-file should contain either 1, 2 or 3 columns.')
    
    # Instantiate geometry object
    geom = pg.Geometry()
    
    # Create line loop for airfoil
    airfoil = [geom.add_polygon_loop(airfoilCoordinates, charLength)]

    # Create line loop for numerical domain
    if domainShape == 'rectangular':
        domainCoordinates = np.zeros([4, 3])
        domainCoordinates[0, 0] = airfoilCoordinates[:, 0].min() - leftDist*coord
        domainCoordinates[0, 1] = airfoilCoordinates[:, 1].min() - bottomDist*coord
        domainCoordinates[1, 0] = airfoilCoordinates[:, 0].max() + rightDist*coord
        domainCoordinates[1, 1] = airfoilCoordinates[:, 1].min() - bottomDist*coord
        domainCoordinates[2, 0] = airfoilCoordinates[:, 0].max() + rightDist*coord
        domainCoordinates[2, 1] = airfoilCoordinates[:, 1].max() + topDist*coord
        domainCoordinates[3, 0] = airfoilCoordinates[:, 0].min() - leftDist*coord
        domainCoordinates[3, 1] = airfoilCoordinates[:, 1].max() + topDist*coord
    elif domainShape == 'elliptic':
github nschloe / pygmsh / test / examples / cube.py View on Github external
def generate():
    geom = pg.Geometry()
    geom.add_box(0, 1, 0, 1, 0, 1, 0.05)
    return geom
github nschloe / pygmsh / test / examples / boolean.py View on Github external
def generate():
    geom = pg.Geometry()
    lcar = 0.1
    rectangle = geom.add_rectangle(
            -1.0, 1.0,
            -1.0, 1.0,
            0.0,
            lcar
            )

    if geom.get_gmsh_major() == 2:
        # boolean operations are not supported in gmsh 2
        return geom, 4.0

    circle_w = geom.add_circle(
            [-1.0, 0.0, 0.0],
            0.5,
            lcar,
github nschloe / pygmsh / test / examples / boolean.py View on Github external
def generate():
    geom = pg.Geometry()
    lcar = 0.1

    rectangle = geom.add_rectangle(
            -1.0, 1.0,
            -1.0, 1.0,
            0.0,
            lcar
            )

    if geom.get_gmsh_major() == 2:
        # boolean operations are not supported in gmsh 2
        return geom, 4.0

    circle_w = geom.add_circle(
            [-1.0, 0.0, 0.0],
            0.5,
github nschloe / pygmsh / test / examples / factory.py View on Github external
def generate():
    if pg.get_gmsh_major_version() == 3:
        # factories are supported only in gmsh 3
        geom = pg.Geometry(factory_type='OpenCASCADE')
    else:
        geom = pg.Geometry()

    geom.add_box(0, 1, 0, 1, 0, 1, 1.0)
    return geom, 1.0
github pmgbergen / porepy / gmsh / fractured_domain_2d.py View on Github external
-------
    g - triangular grid that conforms to the fratures. In addition to the
        standard fields, g has a variable face_info (dictionary),
        with elements tagcols (an explanation of the tags), and tags,
        telling which faces lies on the fractures (numbering corresponding
        to the columns in fracs['edges'])
    """

    # Filename for gmsh i/o, if none is specified
    if filename is None:
        filename = tempfile.mkstemp
    geofile = filename + '.geo'
    mshfile = filename + '.msh'

    # Initialize pygmsh geometry object, this is used for generating .geo file
    geom = pg.Geometry()

    # Pick out fracture points, and their connections
    pts = fracs['points']
    edges = fracs['edges']

    # If no tags are provided for the fractures, we assign increasing value
    # for each column
    if edges.shape[0] == 2:
        edges = np.vstack((edges, np.arange(edges.shape[1])))

    # Bounding box for the domain.
    domain = np.array([[box['xmax'] - box['xmin']],
                       [box['ymax'] - box['ymin']],
                       ])
    # Remove intersections before passing to gmsh.
    pts, edges = basics.remove_edge_crossings(pts, edges, domain)