MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / F

Method F

python/dolfinx/fem/petsc.py:1511–1528  ·  view source on GitHub ↗

Assemble the residual F into the vector b. Args: x: The vector containing the latest solution b: Vector to assemble the residual into

(self, x: PETSc.Vec, b: PETSc.Vec)

Source from the content-addressed store, hash-verified

1509 x.ghostUpdate(addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD) # type: ignore[attr-defined]
1510
1511 def F(self, x: PETSc.Vec, b: PETSc.Vec) -> None: # type: ignore[name-defined]
1512 """Assemble the residual F into the vector b.
1513
1514 Args:
1515 x: The vector containing the latest solution
1516 b: Vector to assemble the residual into
1517 """
1518 # Reset the residual vector
1519 dolfinx.la.petsc._zero_vector(b)
1520 assemble_vector(b, self._L)
1521
1522 # Apply boundary condition
1523 if self.bcs is not None:
1524 apply_lifting(b, [self._a], bcs=[self.bcs], x0=[x], alpha=-1.0)
1525 b.ghostUpdate(addv=PETSc.InsertMode.ADD, mode=PETSc.ScatterMode.REVERSE) # type: ignore[attr-defined]
1526 set_bc(b, self.bcs, x, -1.0)
1527 else:
1528 b.ghostUpdate(addv=PETSc.InsertMode.ADD, mode=PETSc.ScatterMode.REVERSE) # type: ignore[attr-defined]
1529
1530 def J(self, x: PETSc.Vec, A: PETSc.Mat) -> None: # type: ignore[name-defined]
1531 """Assemble the Jacobian matrix.

Callers

nothing calls this directly

Calls 3

assemble_vectorFunction · 0.70
apply_liftingFunction · 0.70
set_bcFunction · 0.70

Tested by

no test coverage detected