How to use the petsc.PETSc function in petsc

To help you get started, we’ve selected a few petsc 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 firedrakeproject / firedrake / firedrake / dmplex.py View on Github external
def _from_cell_list(dim, cells, coords, comm=None):
    """
    Create a DMPlex from a list of cells and coords.

    :arg dim: The topological dimension of the mesh
    :arg cells: The vertices of each cell
    :arg coords: The coordinates of each vertex
    :arg comm: An optional communicator to build the plex on (defaults to COMM_WORLD)
    """

    if comm is None:
        comm = MPI.comm
    if comm.rank == 0:
        # Provide the actual data on rank 0.
        return PETSc.DMPlex().createFromCellList(dim, cells, coords, comm=comm)

    # Provide empty plex on other ranks
    # A subsequent call to plex.distribute() takes care of parallel partitioning
    return PETSc.DMPlex().createFromCellList(dim,
                                             np.zeros((0, 0), dtype=np.int32),
                                             np.zeros((0, 0), dtype=np.int32),
                                             comm=comm)
github firedrakeproject / firedrake / firedrake / dmplex.py View on Github external
def permute_global_numbering(plex):
    """Permute the global/universal DoF numbering according to a
    depth-first traversal of the Plex graph."""
    dim = plex.getDimension()
    glbl = plex.getDefaultSection()
    univ = plex.getDefaultGlobalSection()
    pStart, pEnd = glbl.getChart()

    entity_classes = [0, 0, 0, 0]
    permutation = -1 * np.ones(pEnd-pStart, dtype=np.int)
    glbl_num = 0

    # Create new numbering sections
    glbl_new = PETSc.Section().create()
    glbl_new.setChart(pStart, pEnd)
    glbl_new.setUp()
    univ_new = PETSc.Section().create()
    univ_new.setChart(pStart, pEnd)
    univ_new.setUp()

    # Get a list of current universal DoFs
    universal_dofs = []
    for p in range(pStart, pEnd):
        for c in range(univ.getDof(p)):
            universal_dofs.append(univ.getOffset(p)+c)

    # Renumber core DoFs
    seen = set()
    if plex.getStratumSize("op2_core", dim) > 0:
        for cell in plex.getStratumIS("op2_core", dim).getIndices():

petsc

PETSc: Portable, Extensible Toolkit for Scientific Computation

BSD-2-Clause
Latest version published 8 days ago

Package Health Score

60 / 100
Full package analysis