How to use the petsc.PETSc.Section 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
"""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():
            for p in plex.getTransitiveClosure(cell)[0]:
                if p in seen:
                    continue

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