petsc4py.PETSc.Section#

class petsc4py.PETSc.Section#

Bases: Object

Mapping from integers in a range to unstructured set of integers.

Methods Summary

addConstraintDof(point, numDof)

Increment the number of constrained DOFs for a given point.

addDof(point, numDof)

Add numDof degrees of freedom associated with a given point.

addFieldConstraintDof(point, field, numDof)

Add numDof constrained DOFs for a given field on a point.

addFieldDof(point, field, numDof)

Add numDof DOFs associated with a field on a given point.

clone()

Return a copy of the section.

create([comm])

Allocate a section and set the map contents to the default.

createGlobalSection(sf)

Create a section describing the global field layout.

destroy()

Destroy a section.

getChart()

Return the range in which points (indices) lie for this section.

getConstrainedStorageSize()

Return the size capable of holding all unconstrained DOFs in a section.

getConstraintDof(point)

Return the number of constrained DOFs associated with a given point.

getConstraintIndices(point)

Return the point DOFs numbers which are constrained for a given point.

getDof(point)

Return the number of degrees of freedom for a given point.

getFieldComponents(field)

Return the number of field components for the given field.

getFieldConstraintDof(point, field)

Return the number of constrained DOFs for a given field on a point.

getFieldConstraintIndices(point, field)

Return the field DOFs numbers, in [0, DOFs), which are constrained.

getFieldDof(point, field)

Return the number of DOFs associated with a field on a given point.

getFieldName(field)

Return the name of a field in the section.

getFieldOffset(point, field)

Return the offset for the field DOFs on the given point.

getMaxDof()

Return the maximum number of DOFs for any point in the section.

getNumFields()

Return the number of fields in a section.

getOffset(point)

Return the offset for the DOFs associated with the given point.

getOffsetRange()

Return the full range of offsets, [start, end), for a section.

getPermutation()

Return the permutation that was set with setPermutation.

getStorageSize()

Return the size capable of holding all the DOFs defined in a section.

reset()

Free all section data.

setChart(pStart, pEnd)

Set the range in which points (indices) lie for this section.

setConstraintDof(point, numDof)

Set the number of constrained DOFs associated with a given point.

setConstraintIndices(point, indices)

Set the point DOFs numbers, in [0, DOFs), which are constrained.

setDof(point, numDof)

Set the number of degrees of freedom associated with a given point.

setFieldComponents(field, numComp)

Set the number of field components for the given field.

setFieldConstraintDof(point, field, numDof)

Set the number of constrained DOFs for a given field on a point.

setFieldConstraintIndices(point, field, indices)

Set the field DOFs numbers, in [0, DOFs), which are constrained.

setFieldDof(point, field, numDof)

Set the number of DOFs associated with a field on a given point.

setFieldName(field, fieldName)

Set the name of a field in the section.

setFieldOffset(point, field, offset)

Set the offset for the DOFs on the given field at a point.

setNumFields(numFields)

Set the number of fields in a section.

setOffset(point, offset)

Set the offset for the DOFs associated with the given point.

setPermutation(perm)

Set the permutation for [0, pEnd - pStart).

setUp()

Calculate offsets.

view([viewer])

View the section.

Methods Documentation

addConstraintDof(point, numDof)#

Increment the number of constrained DOFs for a given point.

Not collective.

Parameters:
  • point (int) – The point.

  • numDof (int) – The number of additional DOFs which are fixed by constraints.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:485

addDof(point, numDof)#

Add numDof degrees of freedom associated with a given point.

Not collective.

Parameters:
  • point (int) – The point.

  • numDof (int) – The number of additional DOFs.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:354

addFieldConstraintDof(point, field, numDof)#

Add numDof constrained DOFs for a given field on a point.

Not collective.

Parameters:
  • point (int) – The point.

  • field (int) – The field.

  • numDof (int) – The number of additional DOFs which are fixed by constraints.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:557

addFieldDof(point, field, numDof)#

Add numDof DOFs associated with a field on a given point.

Not collective.

Parameters:
  • point (int) – The point.

  • field (int) – The field.

  • numDof (int) – The number of additional DOFs.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:421

clone()#

Return a copy of the section.

Collective.

The copy is shallow, if possible.

Source code at petsc4py/PETSc/Section.pyx:80

Return type:

Section

create(comm=None)#

Allocate a section and set the map contents to the default.

Collective.

Typical calling sequence: - create - setNumFields - setChart - setDof - setUp - getOffset - destroy

The Section object and methods are intended to be used in the PETSc Vec and Mat implementations. The indices returned by the Section are appropriate for the kind of Vec it is associated with. For example, if the vector being indexed is a local vector, we call the section a local section. If the section indexes a global vector, we call it a global section. For parallel vectors, like global vectors, we use negative indices to indicate DOFs owned by other processes.

Parameters:

comm (Comm | None) – MPI communicator, defaults to Sys.getDefaultComm.

Return type:

Self

Source code at petsc4py/PETSc/Section.pyx:42

createGlobalSection(sf)#

Create a section describing the global field layout.

Collective.

The section describes the global field layout using the local section and an SF describing the section point overlap.

If we have a set of local sections defining the layout of a set of local vectors, and also an SF to determine which section points are shared and the ownership, we can calculate a global section defining the parallel data layout, and the associated global vector.

This gives negative sizes and offsets to points not owned by this process.

includeConstraints and localOffsets parameters of the C API are always set to False.

Parameters:

sf (SF) – The SF describing the parallel layout of the section points (leaves are unowned local points).

Return type:

Section

Source code at petsc4py/PETSc/Section.pyx:846

destroy()#

Destroy a section.

Not collective.

Source code at petsc4py/PETSc/Section.pyx:29

Return type:

Self

getChart()#

Return the range in which points (indices) lie for this section.

Not collective.

The range is [pStart, pEnd), i.e., from the first point to one past the last point.

Source code at petsc4py/PETSc/Section.pyx:238

Return type:

tuple[int, int]

getConstrainedStorageSize()#

Return the size capable of holding all unconstrained DOFs in a section.

Not collective.

Source code at petsc4py/PETSc/Section.pyx:720

Return type:

int

getConstraintDof(point)#

Return the number of constrained DOFs associated with a given point.

Not collective.

Parameters:

point (int) – The point.

Return type:

int

Source code at petsc4py/PETSc/Section.pyx:445

getConstraintIndices(point)#

Return the point DOFs numbers which are constrained for a given point.

Not collective.

The range is in [0, DOFs).

Parameters:

point (int) – The point.

Return type:

ArrayInt

Source code at petsc4py/PETSc/Section.pyx:586

getDof(point)#

Return the number of degrees of freedom for a given point.

Not collective.

In a global section, this value will be negative for points not owned by this process.

Parameters:

point (int) – The point.

Return type:

int

Source code at petsc4py/PETSc/Section.pyx:311

getFieldComponents(field)#

Return the number of field components for the given field.

Not collective.

Parameters:

field (int) – The field number.

Return type:

int

Source code at petsc4py/PETSc/Section.pyx:198

getFieldConstraintDof(point, field)#

Return the number of constrained DOFs for a given field on a point.

Not collective.

Parameters:
  • point (int) – The point.

  • field (int) – The field.

Return type:

int

Source code at petsc4py/PETSc/Section.pyx:506

getFieldConstraintIndices(point, field)#

Return the field DOFs numbers, in [0, DOFs), which are constrained.

Not collective.

The constrained DOFs are sorted in ascending order.

Parameters:
  • field (int) – The field number.

  • point (int) – The point.

Return type:

ArrayInt

Source code at petsc4py/PETSc/Section.pyx:634

getFieldDof(point, field)#

Return the number of DOFs associated with a field on a given point.

Not collective.

Parameters:
  • point (int) – The point.

  • field (int) – The field.

Return type:

int

Source code at petsc4py/PETSc/Section.pyx:375

getFieldName(field)#

Return the name of a field in the section.

Not collective.

Parameters:

field (int) – The field number.

Return type:

str

Source code at petsc4py/PETSc/Section.pyx:156

getFieldOffset(point, field)#

Return the offset for the field DOFs on the given point.

Not collective.

In a global section, this offset will be negative for points not owned by this process.

Parameters:
  • point (int) – The point.

  • field (int) – The field.

Return type:

int

Source code at petsc4py/PETSc/Section.pyx:779

getMaxDof()#

Return the maximum number of DOFs for any point in the section.

Not collective.

Source code at petsc4py/PETSc/Section.pyx:692

Return type:

int

getNumFields()#

Return the number of fields in a section.

Not collective.

Returns 0 if no fields were defined.

Source code at petsc4py/PETSc/Section.pyx:122

Return type:

int

getOffset(point)#

Return the offset for the DOFs associated with the given point.

Not collective.

In a global section, this offset will be negative for points not owned by this process.

Parameters:

point (int) – The point.

Return type:

int

Source code at petsc4py/PETSc/Section.pyx:734

getOffsetRange()#

Return the full range of offsets, [start, end), for a section.

Not collective.

Source code at petsc4py/PETSc/Section.pyx:831

Return type:

tuple[int, int]

getPermutation()#

Return the permutation that was set with setPermutation.

Not collective.

Source code at petsc4py/PETSc/Section.pyx:279

Return type:

IS

getStorageSize()#

Return the size capable of holding all the DOFs defined in a section.

Not collective.

Source code at petsc4py/PETSc/Section.pyx:706

Return type:

int

reset()#

Free all section data.

Not collective.

Source code at petsc4py/PETSc/Section.pyx:110

Return type:

None

setChart(pStart, pEnd)#

Set the range in which points (indices) lie for this section.

Not collective.

The range is [pStart, pEnd), i.e., from the first point to one past the last point.

Parameters:
  • pStart (int) – The first point.

  • pEnd (int) – One past the last point.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:255

setConstraintDof(point, numDof)#

Set the number of constrained DOFs associated with a given point.

Not collective.

Parameters:
  • point (int) – The point.

  • numDof (int) – The number of DOFs which are fixed by constraints.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:464

setConstraintIndices(point, indices)#

Set the point DOFs numbers, in [0, DOFs), which are constrained.

Not collective.

Parameters:
  • point (int) – The point.

  • indices (Sequence[int]) – The constrained DOFs.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:610

setDof(point, numDof)#

Set the number of degrees of freedom associated with a given point.

Not collective.

Parameters:
  • point (int) – The point.

  • numDof (int) – The number of DOFs.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:333

setFieldComponents(field, numComp)#

Set the number of field components for the given field.

Not collective.

Parameters:
  • field (int) – The field number.

  • numComp (int) – The number of field components.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:217

setFieldConstraintDof(point, field, numDof)#

Set the number of constrained DOFs for a given field on a point.

Not collective.

Parameters:
  • point (int) – The point.

  • field (int) – The field.

  • numDof (int) – The number of DOFs which are fixed by constraints.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:528

setFieldConstraintIndices(point, field, indices)#

Set the field DOFs numbers, in [0, DOFs), which are constrained.

Not collective.

Parameters:
  • point (int) – The point.

  • field (int) – The field number.

  • indices (Sequence[int]) – The constrained DOFs.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:661

setFieldDof(point, field, numDof)#

Set the number of DOFs associated with a field on a given point.

Not collective.

Parameters:
  • point (int) – The point.

  • field (int) – The field.

  • numDof (int) – The number of DOFs.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:397

setFieldName(field, fieldName)#

Set the name of a field in the section.

Not collective.

Parameters:
  • field (int) – The field number.

  • fieldName (str) – The field name.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:176

setFieldOffset(point, field, offset)#

Set the offset for the DOFs on the given field at a point.

Not collective.

The user usually does not call this function, but uses setUp.

Parameters:
  • point (int) – The point.

  • field (int) – The field.

  • offset (int) – The offset.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:805

setNumFields(numFields)#

Set the number of fields in a section.

Not collective.

Parameters:

numFields (int) – The number of fields.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:138

setOffset(point, offset)#

Set the offset for the DOFs associated with the given point.

Not collective.

The user usually does not call this function, but uses setUp.

Parameters:
  • point (int) – The point.

  • offset (int) – The offset.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:756

setPermutation(perm)#

Set the permutation for [0, pEnd - pStart).

Not collective.

Parameters:

perm (IS) – The permutation of points.

Return type:

None

Source code at petsc4py/PETSc/Section.pyx:294

setUp()#

Calculate offsets.

Not collective.

Offsets are based on the number of degrees of freedom for each point.

Source code at petsc4py/PETSc/Section.pyx:96

Return type:

None

view(viewer=None)#

View the section.

Collective.

Parameters:

viewer (Viewer | None) – A Viewer to display the section.

Return type:

None

See also

PetscSectionView

Source code at petsc4py/PETSc/Section.pyx:10