DOLFIN
DOLFIN C++ interface
Public Types | Public Member Functions | List of all members
dolfin::LocalSolver Class Reference

Solve problems cell-wise. More...

#include <LocalSolver.h>

Public Types

enum  SolverType { LU, Cholesky }
 SolverType.
 

Public Member Functions

 LocalSolver (std::shared_ptr< const Form > a, std::shared_ptr< const Form > L, SolverType solver_type=SolverType::LU)
 
 LocalSolver (std::shared_ptr< const Form > a, SolverType solver_type=SolverType::LU)
 
void solve_global_rhs (Function &u) const
 
void solve_local_rhs (Function &u) const
 
void solve_local (GenericVector &x, const GenericVector &b, const GenericDofMap &dofmap_b) const
 
void factorize ()
 Factorise the local LHS matrices for all cells and store in cache.
 
void clear_factorization ()
 Reset (clear) any stored factorizations.
 

Detailed Description

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 & Destructor Documentation

◆ LocalSolver() [1/2]

LocalSolver::LocalSolver ( std::shared_ptr< const Form a,
std::shared_ptr< const Form L,
SolverType  solver_type = SolverType::LU 
)

Constructor (shared pointer version)

Parameters
a(Form) input LHS form
L(Form) input RHS form
solver_type(SolverType)

◆ LocalSolver() [2/2]

LocalSolver::LocalSolver ( std::shared_ptr< const Form a,
SolverType  solver_type = SolverType::LU 
)

Constructor (shared pointer version)

Parameters
a(Form) input LHS form
solver_type(SolverType)

Member Function Documentation

◆ solve_global_rhs()

void LocalSolver::solve_global_rhs ( Function u) const

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

◆ solve_local()

void LocalSolver::solve_local ( GenericVector x,
const GenericVector b,
const GenericDofMap dofmap_b 
) const

Solve local problems for given RHS and corresponding dofmap for RHS

Parameters
x(GenericVector)
b(GenericVector)
dofmap_b(GenericDofMap)

◆ solve_local_rhs()

void LocalSolver::solve_local_rhs ( Function u) const

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

The documentation for this class was generated from the following files: