# LocalSolver¶

class dolfin.cpp.fem.LocalSolver(*args)

Bases: object

Solve problems cell-wise. This class solves problems cell-wise. It computes the local left-hand side A_local which must be square locally but not globally. The right-hand side b_local is either computed locally for one cell or globally for all cells depending on which of the solve_local_rhs or solve_global_rhs methods which are called. You can optionally assemble the right-hand side vector yourself and use the solve_local method. You must then provide the DofMap of the right-hand side. The local solver solves A_local x_local = b_local. The result x_local is copied into the global vector x of the provided Function u. You can optionally call the factorize method to pre-calculate the local left-hand side factorizations to speed up repeated applications of the LocalSolver with the same LHS. The solve_xxx methods will factorise the LHS A_local matrices each time if they are not cached by a previous call to factorize. You can chose upon initialization whether you want Cholesky or LU (default) factorisations. For forms with no coupling across cell edges, this function is identical to a global solve. For problems with coupling across cells it is not. This class can be used for post-processing solutions, e.g. computing stress fields for visualisation, far more cheaply that using global projections.

Constructor (shared pointer version)

Parameters: const Form > a (std::shared_ptr<) – (Form ) input LHS form solver_type (SolverType) – (SolverType)
SolverType_Cholesky = 1
SolverType_LU = 0
clear_factorization()

Reset (clear) any stored factorizations.

Return type: void
factorize()

Factorise the local LHS matrices for all cells and store in cache.

Return type: void
solve_global_rhs()

Solve local (cell-wise) problems A_e x_e = b_e, where A_e is the cell matrix LHS and b_e is the global RHS vector b restricted to the cell, i.e. b_e may contain contributions from neighbouring cells. The solution is exact for the case in which there is no coupling between cell contributions to the global matrix A, e.g. the discontinuous Galerkin matrix. The result is copied into x.

Parameters: & u (Function) – (Function &) Function void
solve_local()

Solve local problems for given RHS and corresponding dofmap for RHS

Parameters: & x (GenericVector) – (GenericVector ) GenericVector & b (const) – (GenericVector ) GenericDofMap & dofmap_b (const) – (GenericDofMap ) void
solve_local_rhs()

Solve local (cell-wise) problems A_e x_e = b_e where A_e and b_e are the cell element tensors. Compared to solve_global_rhs this function calculates local RHS vectors for each cell and hence does not include contributions from neighbouring cells. This function is useful for computing (approximate) cell-wise projections, for example for post-processing. It much more efficient than computing global projections.

Parameters: & u (Function) – (Function &) Function void
thisown

The membership flag