fenapack package¶
Submodules¶
fenapack.assembling module¶
This module provides wrappers for assembling systems of linear algebraic equations to be solved with the use of PCD preconditioning strategy. These wrappers naturally provide routines for assembling preconditioning operators themselves.
-
class
fenapack.assembling.PCDAssembler(a, L, bcs, a_pc=None, mp=None, mu=None, ap=None, fp=None, kp=None, gp=None, bcs_pcd=[])[source]¶ Bases:
objectBase class for creating linear problems to be solved by application of the PCD preconditioning strategy. Users are encouraged to use this class for interfacing with
fenapack.field_split.PCDKrylovSolver. On request it assembles not only the individual PCD operators but also the system matrix and the right hand side vector defining the linear problem.-
__init__(a, L, bcs, a_pc=None, mp=None, mu=None, ap=None, fp=None, kp=None, gp=None, bcs_pcd=[])[source]¶ Collect individual variational forms and boundary conditions defining a linear problem (system matrix + RHS vector) on the one side and preconditioning operators on the other side.
- Arguments
- a (
dolfin.Formorufl.Form) - Bilinear form representing a system matrix.
- L (
dolfin.Formorufl.Form) - Linear form representing a right hand side vector.
- bcs (
listofdolfin.DirichletBC) - Boundary conditions applied to
a,L, anda_pc. - a_pc (
dolfin.Formorufl.Form) - Bilinear form representing a matrix optionally passed to
preconditioner instead of
a. In case of PCD, stabilized 00-block can be passed to 00-KSP solver. - mp, mu, ap, fp, kp, gp (
dolfin.Formorufl.Form) - Bilinear forms which (some of them) might be used by a particular PCD(R) preconditioner. Typically they represent “mass matrix” on pressure, “mass matrix” on velocity, minus Laplacian operator on pressure, pressure convection-diffusion operator, pressure convection operator and pressure gradient respectively.
- bcs_pcd (
listofdolfin.DirichletBC) - Artificial boundary conditions used by PCD preconditioner.
- a (
All the arguments should be given on the common mixed function space.
All the forms are wrapped using
PCDFormso that each of them can be endowed with additional set of properties.By default,
mp,mu,apandgpare assumed to be constant if the preconditioner is used repeatedly in some outer iterative process (e.g Newton-Raphson method, time-stepping). As such, the corresponding operators are assembled only once. On the other hand,fpandkpare updated in every outer iteration.Also note that
gpis the only form that is by default in a phantom mode. It means that the corresponding operator (if needed) is not obtained by assembling the form, but it is extracted as the 01-block of the system matrix.The default setting can be modified by accessing a
PCDForminstance viaPCDAssembler.get_pcd_form()and changing the properties directly.
-
__weakref__¶ list of weak references to the object (if defined)
-
gp(Bt)[source]¶ Assemble discrete pressure gradient. It is crucial to respect any constraints placed on the velocity test space by Dirichlet boundary conditions.
-
pc_matrix(P)[source]¶ Assemble preconditioning matrix
Pwhose relevant blocks can be passed to actual parts of theKSPsolver.
-
-
class
fenapack.assembling.PCDForm(form, const=False, phantom=False)[source]¶ Bases:
objectWrapper for PCD operators represented by
dolfin.Formorufl.Form. This class allows to record specific properties of the form that can be utilized later while setting up the preconditioner.For example, we can specify which matrices remain constant during the outer iterative algorithm (e.g. Newton-Raphson method, time-stepping) and which matrices need to be updated in every outer iteration.
-
__init__(form, const=False, phantom=False)[source]¶ The class is initialized by a single form with default properties.
- Arguments
- form (
dolfin.Formorufl.Form) - A form to be wrapped.
- const (bool)
- Whether the form remains constant in outer iterations.
- phantom (bool)
- If True, then the corresponding operator will be obtained not by assembling the form, but in some different way. (For example, pressure gradient may be extracted directly from the system matrix.)
- form (
-
__weakref__¶ list of weak references to the object (if defined)
-
fenapack.field_split module¶
This module provides subclasses of DOLFIN and petsc4py Krylov solvers implementing PCD fieldsplit preconditioned GMRES
fenapack.field_split_backend module¶
Tools for extraction and management of fieldsplit submatrices, subvectors, subbcs, subksps intended to be hidden from user interface
-
class
fenapack.field_split_backend.PCDInterface(pcd_assembler, A, is_u, is_p, deep_submats=False)[source]¶ Bases:
objectWrapper of PCDAssembler for interfacing with PCD PC fieldsplit implementation. Convection fieldsplit submatrices are extracted as shallow or deep submatrices according to
deep_submatsparameter.-
__init__(pcd_assembler, A, is_u, is_p, deep_submats=False)[source]¶ Create PCDInterface instance given PCDAssembler instance, system matrix and velocity and pressure index sets
-
__weakref__¶ list of weak references to the object (if defined)
-
apply_bcs(vec, bcs_getter, iset)[source]¶ Transform dolfin bcs obtained using
bcs_getterfunction into fieldsplit subBCs and apply them to fieldsplit vector. SubBCs are cached.
-
get_work_dolfin_mat(key, comm, can_be_destroyed=None, can_be_shared=None)[source]¶ Get working DOLFIN matrix by key.
can_be_destroyed=Truetells that it is probably favourable to not store the matrix unless it is shared as it will not be used ever again,Nonemeans that it can be destroyed but it is not probably favourable andFalseforbids the destruction.can_be_sharedtells if a work matrix can be the same with work matrices for other keys.
-
get_work_vecs_from_square_mat(M, num)[source]¶ Return
numof work vecs initially created from a square matrixM.
-
setup_ksp(ksp, assemble_func, iset, spd=False, const=False)[source]¶ Assemble into operator of given ksp if not yet assembled
-
setup_ksp_Rp(ksp, Mu, Bt)[source]¶ Setup pressure Laplacian ksp based on velocity mass matrix
Muand discrete gradientBtand assemble matrix
-
fenapack.nonlinear_solvers module¶
This module provides subclasses of DOLFIN interface for solving non-linear problems suitable for use with fieldsplit preconditioned Krylov methods
fenapack.preconditioners module¶
-
class
fenapack.preconditioners.BasePCDPC[source]¶ Bases:
objectBase python context for pressure convection diffusion (PCD) preconditioners.
-
__weakref__¶ list of weak references to the object (if defined)
-
-
class
fenapack.preconditioners.BasePCDRPC[source]¶ Bases:
fenapack.preconditioners.BasePCDPCBase python context for pressure convection diffusion reaction (PCDR) preconditioners.
-
class
fenapack.preconditioners.PCDPC_BRM1[source]¶ Bases:
fenapack.preconditioners.BasePCDPCThis class implements a modification of PCD variant similar to one by [1].
[1] Olshanskii M. A., Vassilevski Y. V., Pressure Schur complement preconditioners for the discrete Oseen problem. SIAM J. Sci. Comput., 29(6), 2686-2704. 2007.
-
class
fenapack.preconditioners.PCDPC_BRM2[source]¶ Bases:
fenapack.preconditioners.BasePCDPCThis class implements a modification of steady variant of PCD described in [2].
[2] Elman H. C., Silvester D. J., Wathen A. J., Finite Elements and Fast Iterative Solvers: With Application in Incompressible Fluid Dynamics. Oxford University Press 2005. 2nd edition 2014.
-
class
fenapack.preconditioners.PCDRPC_BRM1[source]¶ Bases:
fenapack.preconditioners.BasePCDRPCThis class implements an extension of
PCDPC_BRM1. Here we add a reaction term into the preconditioner, so that is becomes PCDR (pressure-convection-diffusion-reaction) preconditioner. This particular variant is suitable for time-dependent problems, where the reaction term arises from the time derivative in the balance of momentum.
-
class
fenapack.preconditioners.PCDRPC_BRM2[source]¶ Bases:
fenapack.preconditioners.BasePCDRPCThis class implements an extension of
PCDPC_BRM2. Here we add a reaction term into the preconditioner, so that is becomes PCDR (pressure-convection-diffusion-reaction) preconditioner. This particular variant is suitable for time-dependent problems, where the reaction term arises from the time derivative in the balance of momentum.
fenapack.stabilization module¶
-
fenapack.stabilization.StabilizationParameterSD(wind, viscosity, density=None)[source]¶ Returns a subclass of
dolfin.Expressionrepresenting streamline diffusion stabilization parameter.This kind of stabilization is convenient when a multigrid method is used for the convection term in the Navier-Stokes equation. The idea of the stabilization involves adding an additional term of the form:
delta_sd*inner(dot(grad(u), w), dot(grad(v), w))*dx
into the Navier-Stokes equation. Here
uis a trial function,vis a test function andwdefines so-called “wind” which is a known vector function. Regularization parameterdelta_sdis determined by the local mesh Peclet number (PE), see the implementation below.- Arguments
- wind (
dolfin.GenericFunction) - A vector field determining convective velocity.
- viscosity (
dolfin.GenericFunction) - A scalar field determining dynamic viscosity.
- density (
dolfin.GenericFunction) - A scalar field determining density (optional).
- wind (
fenapack.utils module¶
Module contents¶
This is FENaPack, FEniCS Navier-Stokes preconditioning package.