utils#
- fenics_optim.utils.add_zeros(x, npad: int, pos: int = 0)#
Vector padding with zeros.
- Parameters
x (UFL vector) – the intial vector
npad (int) – number of padding zeros
pos (int, optional) – position at which zeros are added, by default 0 (start), -1 to add at the end
- Returns
the new vector with zeros
- Return type
UFL vector
- fenics_optim.utils.block_matrix(M)#
Horizontal stack of vectors.
- fenics_optim.utils.cell_project(v, V, dx)#
Project a UFL expression to a FunctionSpace V.
- Parameters
v (UFL expression, list) – expression to project, if v is a list, then dx must be a list and each element of the list will be projected against the corresponding measure
V (dolfin.Functionspace) – the FunctionSpace on which to project
dx (dolfin.Measure, list) – must be a list if v is a list
- Returns
a function on V corresponding to the projection
- Return type
dolfin.Function
- fenics_optim.utils.concatenate(vectors)#
Concatenate vectors.
- fenics_optim.utils.dummy_variable(d, mesh)#
Create a dummy variable of size d.
- fenics_optim.utils.facet_project(v, V, dS)#
Project a UFL expression to a facet FunctionSpace V.
- Parameters
v (UFL expression, list) – expression to project, if v is a list, then dS must be a list and each element of the list will be projected against the corresponding measure
V (dolfin.Functionspace) – the FunctionSpace on which to project
dS (dolfin.Measure, list) – must be a list if v is a list
- Returns
a function on V corresponding to the projection
- Return type
dolfin.Function
- fenics_optim.utils.get_slice(x, start=0, end=None, step=None)#
Get a slice x[start:end:step].
- fenics_optim.utils.half_vect2subk(index_list, d)#
Return the subk index for a d-dimensional SDP variable half vector.
- fenics_optim.utils.half_vect2subl(index_list, d)#
Return the subl index for a d-dimensional SDP variable half vector.
- fenics_optim.utils.hstack(arrays)#
Vertical stack of vectors/matrix.
- fenics_optim.utils.local_frame(n)#
Compute projector on facet local frame (n, t1, t2).
- fenics_optim.utils.local_project(v, V)#
Perform projection on discontinuous or Quadrature spaces.
- fenics_optim.utils.subk_list(d)#
Generate list of subk indices for block triplet format for dimension d.
- fenics_optim.utils.subl_list(d)#
Generate list of subl indices for block triplet format for dimension d.
- fenics_optim.utils.tail(x)#
Get the tail x[1:] of a vector.
- fenics_optim.utils.to_list(a, n=1)#
Transform a to list of length n.
- fenics_optim.utils.to_mat(X, symmetric=True)#
Transform vector of components (diagonal spanning) into tensor.
- Parameters
X (UFL vector expression) – a d*(d+1)/2 vector if the d x d tensor is symmetric, a d**2 vector otherwise
symmetric (bool) – indicates if the returned tensor is symmetric or not
- Returns
a d x d tensor
- Return type
UFL tensor expression
- fenics_optim.utils.to_vect(X, symmetric=True)#
Transform a tensor into vector by spanning diagonals.
- Parameters
symmetric (bool) – indicates if the tensor X must be considered as symmetric or not
- Returns
a d*(d+1)/2 vector if the d x d tensor is symmetric, a d**2 vector otherwise
- Return type
UFL vector expression
- fenics_optim.utils.vstack(arrays)#
Vertical stack of vectors/matrix.