Basis projection operators#

class struphy.feec.basis_projection_ops.BasisProjectionOperators(derham, domain, verbose=True, **weights)[source]#

Bases: object

Collection of pre-defined struphy.feec.basis_projection_ops.BasisProjectionOperator.

Parameters:
  • derham (struphy.feec.psydac_derham.Derham) – Discrete de Rham sequence on the logical unit cube.

  • domain (Geometry) – Mapping from logical unit cube to physical domain and corresponding metric coefficients.

  • verbose (bool) – Show info on screen.

  • **weights (dict) – Objects to access callables that can serve as weight functions.

Note

Possible choices for key-value pairs in **weights are, at the moment:

property derham#

Discrete de Rham sequence on the logical unit cube.

property domain#

Mapping from the logical unit cube to the physical domain with corresponding metric coefficients.

property weights#

Dictionary of objects that provide access to callables that can serve as weight functions.

property rank#

MPI rank, is 0 if no communicator.

property verbose#

show info on screen.

Type:

Bool

DF(e1, e2, e3)[source]#

Jacobian callable.

DFT(e1, e2, e3)[source]#

Jacobain transpose callable.

DFinv(e1, e2, e3)[source]#

Jacobain inverse callable.

DFinvT(e1, e2, e3)[source]#

Jacobian inverse transpose callable.

G(e1, e2, e3)[source]#

Metric tensor callable.

Ginv(e1, e2, e3)[source]#

Inverse metric tensor callable.

sqrt_g(e1, e2, e3)[source]#

Jacobian determinant callable.

property K0#

Basis projection operator

\[\mathcal{K}^{0}_{ijk,mno} := \hat{\Pi}^0_{ijk} \left[ \hat{p}^0_{\text{eq}} \mathbf{\Lambda}^0_{mno} \right] \,.\]
property K3#

Basis projection operator

\[\mathcal{K}^3_{ijk,mno} := \hat{\Pi}^3_{ijk} \left[ \frac{\hat{p}^3_{\text{eq}}}{\sqrt{g}}\Lambda^3_{mno} \right] \,.\]
property Qv#

Basis projection operator

\[\mathcal{Q}^v_{(\mu,ijk),(\nu,mno)} := \hat{\Pi}^2_{(\mu, ijk)} \left[\hat{\rho}^3_{\text{eq}} \Lambda^{0,\nu}_{mno} \right] \,.\]
property Q1#

Basis projection operator

\[\mathcal{Q}^1_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^2_{(\mu, ijk)} \left[\hat{\rho}^3_{\text{eq}}G^{-1}_{\mu,\nu}\Lambda^1_{(\nu, mno)} \right] \,.\]
property Q2#

Basis projection operator

\[\mathcal{Q}^2_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^2_{(\mu, ijk)} \left[\frac{\hat{\rho}^3_{\text{eq}}}{\sqrt{g}}\Lambda^2_{(\nu, mno)} \right] \,.\]
property Q3#

Basis projection operator

\[\mathcal{Q}^3_{ijk,mno} := \hat{\Pi}^3_{ijk} \left[ \frac{\hat{\rho}^3_{\text{eq}}}{\sqrt{g}}\Lambda^3_{mno} \right] \,.\]
property Tv#

Basis projection operator

\[\mathcal{T}^v_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^1_{(\mu, ijk)} \left[\mathcal R^B_{\mu,\nu} \Lambda^0_{(\nu, mno)} \right] \,.\]

with the rotation matrix

\[\mathcal R^B_{\mu, \nu} := \epsilon_{\mu \alpha \nu}\, B^2_{\textnormal{eq}, \alpha}\,,\qquad s.t. \qquad \mathcal R^B \vec v = \vec B^2_{\textnormal{eq}} \times \vec v\,,\]

where \(\epsilon_{\mu \alpha \nu}\) stands for the Levi-Civita tensor and \(B^2_{\textnormal{eq}, \alpha}\) is the \(\alpha\)-component of the MHD equilibrium magnetic field (2-form).

property T1#

Basis projection operator

\[\mathcal{T}^1_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^1_{(\mu, ijk)} \left[\mathcal R^B_{\mu, \beta}G^{-1}_{\beta, \nu}\Lambda^1_{(\nu, mno)} \right] \,,\]

with the rotation matrix

\[\mathcal R^B_{\mu, \beta} := \epsilon_{\mu \alpha \beta}\, B^2_{\textnormal{eq}, \alpha}\,,\qquad s.t. \qquad \mathcal R^B \vec v = \vec B^2_{\textnormal{eq}} \times \vec v\,,\]

where \(\epsilon_{\mu \alpha \beta}\) stands for the Levi-Civita tensor and \(B^2_{\textnormal{eq}, \alpha}\) is the \(\alpha\)-component of the MHD equilibrium magnetic field (2-form).

property T2#

Basis projection operator

\[\mathcal{T}^2_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^1_{(\mu, ijk)} \left[\frac{\mathcal R^B_{\mu, \nu}}{\sqrt{g}}\Lambda^2_{(\nu, mno)} \right] \,.\]

with the rotation matrix

\[\mathcal R^B_{\mu, \nu} := \epsilon_{\mu \alpha \nu}\, B^2_{\textnormal{eq}, \alpha}\,,\qquad s.t. \qquad \mathcal R^B \vec v = \vec B^2_{\textnormal{eq}} \times \vec v\,,\]

where \(\epsilon_{\mu \alpha \nu}\) stands for the Levi-Civita tensor and \(B^2_{\textnormal{eq}, \alpha}\) is the \(\alpha\)-component of the MHD equilibrium magnetic field (2-form).

property Sv#

Basis projection operator

\[\mathcal{S}^v_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^2_{(\mu, ijk)} \left[\hat{p}^3_{\text{eq}} \Lambda^{0,\nu}_{mno} \right] \,.\]
property S1#

Basis projection operator

\[\mathcal{S}^1_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^2_{(\mu, ijk)} \left[\hat{p}^3_{\text{eq}}G^{-1}_{\mu,\nu}\Lambda^1_{(\nu, mno)} \right] \,.\]
property S2#

Basis projection operator

\[\mathcal{S}^2_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^2_{(\mu, ijk)} \left[\frac{\hat{p}^3_{\text{eq}}}{\sqrt{g}}\Lambda^2_{(\nu, mno)} \right] \,.\]
property S11#

Basis projection operator

\[\mathcal{S}^{11}_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^1_{(\mu, ijk)} \left[ \hat{p}^0_{\text{eq}} \Lambda^1_{(\nu, mno)} \right] \,.\]
property S21#

Basis projection operator

\[\mathcal{S}^{21}_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^1_{(\mu, ijk)} \left[ \frac{G_{\mu, \nu}}{\sqrt{g}} \Lambda^2_{(\nu, mno)} \right] \,.\]
property S21p#

Basis projection operator

\[\mathcal{S}^{21p}_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^1_{(\mu, ijk)} \left[ \frac{G_{\mu, \nu}}{\sqrt{g}} \Lambda^2_{(\nu, mno)} \right] \,.\]
property Uv#

Basis projection operator

\[\mathcal{U}^v_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^2_{(\mu, ijk)} \left[\sqrt{g} \, \Lambda^{0, \nu}_{mno} \right] \,.\]
property U1#

Basis projection operator

\[\mathcal{U}^1_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^2_{(\mu, ijk)} \left[ \sqrt{g} \, G^{-1}_{\mu, \nu} \Lambda^1_{(\nu, mno)} \right] \,.\]
property Xv#

Basis projection operator

\[\mathcal{X}^v_{(\mu,ijk),(\nu,mno)} := \hat{\Pi}^{0, \mu}_{ijk} \left[ DF_{\mu, \nu}\Lambda^{0, \nu}_{mno} \right] \,.\]
property X1#

Basis projection operator

\[\mathcal{X}^1_{(\mu, ijk),(\nu, mno)} := \hat{\Pi}^{0, \mu}_{ijk} \left[ DF^{-\top}_{\mu, \nu}\Lambda^1_{(\nu, mno)} \right] \,.\]
property X2#

Basis projection operator

\[\mathcal{X}^2_{(\mu, ijk),(\nu, mno)} := \hat{\Pi}^{0, \mu}_{ijk} \left[ \frac{DF_{\mu, \nu}}{\sqrt{g}} \Lambda^2_{(\nu, mno)} \right] \,.\]
property W1#

Basis projection operator

\[\mathcal{W}^1_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^1_{(\mu, ijk)} \left[\frac{\hat{\rho}^3_{\text{eq}}}{\sqrt{g}}\Lambda^1_{(\nu, mno)} \right] \,.\]
property R1#

Basis projection operator

\[\mathcal{R}^1_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^1_{(\mu, ijk)} \left[\frac{\mathcal R^J_{\mu, \nu}}{\sqrt{g}}\Lambda^2_{(\nu, mno)} \right] \,.\]

with the rotation matrix

\[\mathcal R^J_{\mu, \nu} := \epsilon_{\mu \alpha \nu}\, J^2_{\textnormal{eq}, \alpha}\,,\qquad s.t. \qquad \mathcal R^J \vec v = \vec J^2_{\textnormal{eq}} \times \vec v\,,\]

where \(\epsilon_{\mu \alpha \nu}\) stands for the Levi-Civita tensor and \(J^2_{\textnormal{eq}, \alpha}\) is the \(\alpha\)-component of the MHD equilibrium current density (2-form).

property R2#

Basis projection operator

\[\mathcal{R}^2_{(\mu, ijk), (\nu, mno)} := \hat{\Pi}^2_{(\mu, ijk)} \left[\mathcal R^J_{\mu, \beta} G^{-1}_{\beta, \nu} \Lambda^2_{(\nu, mno)} \right] \,.\]

with the rotation matrix

\[\mathcal R^J_{\mu, \beta} := \epsilon_{\mu \alpha \beta}\, J^2_{\textnormal{eq}, \alpha}\,,\qquad s.t. \qquad \mathcal R^J \vec v = \vec J^2_{\textnormal{eq}} \times \vec v\,,\]

where \(\epsilon_{\mu \alpha \beta}\) stands for the Levi-Civita tensor and \(J^2_{\textnormal{eq}, \alpha}\) is the \(\alpha\)-component of the MHD equilibrium current density (2-form).

property PB#

Basis projection operator

\[\mathcal P^b_{ijk, (\mu, mno)} := \hat \Pi^0_{ijk} \left[\frac{1}{\sqrt g} \hat{b}^1_{\text{eq},\mu} \cdot \Lambda^2_{\mu, mno}\right]\,.\]
create_basis_op(fun: list, V_id: str, W_id: str, assemble: bool = False, name: str | None = None)[source]#

Basis projection operator \(V^\alpha_h \to V^\beta_h\) with given (rank 0, 1 or 2) weight function \(A(\boldsymbol \eta)\):

\[\mathcal P_{(\mu, ijk),(\nu, mno)} = \hat \Pi^\beta_{\mu, ijk} \left( A_{\mu,\nu}\,\Lambda^\alpha_{\nu, mno} \right)\,.\]

Here, \(\alpha \in \{0, 1, 2, 3, v\}\) indicates the domain and \(\beta \in \{0, 1, 2, 3, v\}\) indicates the co-domain of the operator.

Parameters:
  • fun (list[list[callable | ndarray]]) – 2d list of either all 3d arrays or all scalar functions of eta1, eta2, eta3 (must allow matrix evaluations). 3d arrays must have shape corresponding to the 1d quad_grids of V1-VectorFemSpace.

  • V_id (str) – Specifier for the domain of the operator (‘H1’, ‘Hcurl’, ‘Hdiv’, ‘L2’ or ‘H1vec’).

  • W_id (str) – Specifier for the co-domain of the operator (‘H1’, ‘Hcurl’, ‘Hdiv’, ‘L2’ or ‘H1vec’).

  • assemble (bool) – Whether to assemble the DOF matrix.

  • name (bstr) – Name of the operator.

Returns:

out

Return type:

A BasisProjectionOperator object.

class struphy.feec.basis_projection_ops.BasisProjectionOperatorLocal(P: CommutingProjectorLocal, V: FemSpace, weights: list, V_extraction_op: PolarExtractionOperator | IdentityOperator | None = None, V_boundary_op: BoundaryOperator | IdentityOperator | None = None, P_extraction_op: PolarExtractionOperator | IdentityOperator | None = None, P_boundary_op: BoundaryOperator | IdentityOperator | None = None, transposed: bool = False)[source]#

Bases: LinOpWithTransp

Class for assembling basis projection operators in 3d, based on local projectors.

A basis projection operator \(\mathcal P: \mathbb R^{N_\alpha} \to \mathbb R^{N_\beta}\) is defined by the matrix

\[\mathcal P_{(\mu, ijk),(\nu, mno)} = \hat \Pi^\beta_{\mu, ijk} \left( A_{\mu,\nu}\,\Lambda^\alpha_{\nu, mno} \right)\,,\]

where the weight fuction \(A\) is a tensor of rank 0, 1 or 2, depending on domain and co-domain of the operator, and \(\Lambda^\alpha_{\nu, mno}\) is the B-spline basis function with tensor-product index \(mno\) of the \(\nu\)-th component in the space \(V^\alpha_h\). The operator \(\hat \Pi^\beta: V^\beta \to \mathbb R^{N_\beta}\) is a local commuting projector from the continuous space into the space of coefficients.

Finally, extraction and boundary operators can be applied to the basis projection operator matrix, \(B_P * E_P * \mathcal P * E_V^T * B_V^T\).

Parameters:
  • P (struphy.feec.projectors.CommutingProjectorLocal) – Local commuting projector mapping into TensorFemSpace/VectorFemSpace W = P.space (codomain of operator).

  • V (psydac.fem.basic.FemSpace) – Finite element spline space (domain, input space).

  • weights (list) – Weight function(s) (callables) in a 2d list of shape corresponding to number of components of domain/codomain.

  • V_extraction_op (PolarExtractionOperator | IdentityOperator) – Extraction operator to polar sub-space of V.

  • V_boundary_op (BoundaryOperator | IdentityOperator) – Boundary operator that sets essential boundary conditions on V.

  • P_extraction_op (PolarExtractionOperator | IdentityOperator) – Extraction operator to polar sub-space of the domain of P.

  • P_boundary_op (BoundaryOperator | IdentityOperator) – Boundary operator that sets essential boundary conditions on the domain of P.

  • transposed (bool) – Whether to assemble the transposed operator.

property domain#

Domain vector space (input) of the operator.

property codomain#

Codomain vector space (input) of the operator.

property dtype#

Datatype of the operator.

property tosparse#

Convert to a sparse matrix in any of the formats supported by scipy.sparse.

property toarray#

Convert to Numpy 2D array.

property transposed#

If the transposed operator is in play.

dot(v, out=None)[source]#

Applies the basis projection operator to the FE coefficients v.

Parameters:
  • v (psydac.linalg.basic.Vector) – Vector the operator shall be applied to.

  • out (psydac.linalg.basic.Vector, optional) – If given, the output will be written in-place into this vector.

Returns:

out – The output (codomain) vector.

Return type:

psydac.linalg.basic.Vector

transpose()[source]#

Returns the transposed operator.

update_weights(weights)[source]#

Updates self.weights and computes new BasisProjectionOperatorLocal matrix.

Parameters:

weights (list) – Weight function(s) (callables) in a 2d list of shape corresponding to number of components of domain/codomain.

assemble(verbose=False)[source]#

Assembles the BasisProjectionOperatorLocal. And store it in self._mat.

class struphy.feec.basis_projection_ops.BasisProjectionOperator(P: CommutingProjector, V: FemSpace, weights: list, *, V_extraction_op: PolarExtractionOperator | IdentityOperator | None = None, V_boundary_op: BoundaryOperator | IdentityOperator | None = None, P_extraction_op: PolarExtractionOperator | IdentityOperator | None = None, P_boundary_op: BoundaryOperator | IdentityOperator | None = None, transposed: bool = False, polar_shift: bool = False, use_cache: bool = False)[source]#

Bases: LinOpWithTransp

Class for assembling basis projection operators in 3d.

A basis projection operator \(\mathcal P: \mathbb R^{N_\alpha} \to \mathbb R^{N_\beta}\) is defined by the matrix

\[\mathcal P_{(\mu, ijk),(\nu, mno)} = \hat \Pi^\beta_{\mu, ijk} \left( A_{\mu,\nu}\,\Lambda^\alpha_{\nu, mno} \right)\,,\]

where the weight fuction \(A\) is a tensor of rank 0, 1 or 2, depending on domain and co-domain of the operator, and \(\Lambda^\alpha_{\nu, mno}\) is the B-spline basis function with tensor-product index \(mno\) of the \(\nu\)-th component in the space \(V^\alpha_h\). The operator \(\hat \Pi^\beta: V^\beta \to \mathbb R^{N_\beta}\) is a commuting projector from the continuous space into the space of coefficients; it can be decomposed into computation of degrees of freedom (DOFs) \(\sigma^\beta: V^\beta \to \mathbb R^{N_\beta}\) and inversion of the inter/-histopolation matrix \(\mathcal (I^\beta)^{-1}: \mathbb R^{N_\beta} \to \mathbb R^{N_\beta}\):

\[\hat \Pi^\beta = (I^\beta)^{-1} \sigma^\beta\,.\]

\(I^\beta\) is usually a Kronecker product and thus fast to invert; this inversion is performed when calling the dot-product of the BasisProjectionOperator. The DOFs are precomputed and stored in StencilVector format, because the local support of each \(\Lambda^\alpha_{\nu, mno}\).

Finally, extraction and boundary operators can be applied to the DOFs, \(B_P * P * \sigma * E_V^T * B_V^T\).

Parameters:
  • P (struphy.feec.projectors.Projector) – Global commuting projector mapping into TensorFemSpace/VectorFemSpace W = P.space (codomain of operator).

  • V (psydac.fem.basic.FemSpace) – Finite element spline space (domain, input space).

  • weights (list) – Weight function(s) (callables or xp.ndarrays) in a 2d list of shape corresponding to number of components of domain/codomain.

  • V_extraction_op (PolarExtractionOperator | IdentityOperator) – Extraction operator to polar sub-space of V.

  • V_boundary_op (BoundaryOperator | IdentityOperator) – Boundary operator that sets essential boundary conditions on V.

  • P_extraction_op (PolarExtractionOperator | IdentityOperator) – Extraction operator to polar sub-space of the domain of P.

  • P_boundary_op (BoundaryOperator | IdentityOperator) – Boundary operator that sets essential boundary conditions on the domain of P.

  • transposed (bool) – Whether to assemble the transposed operator.

  • polar_shift (bool) – Whether there are metric coefficients contained in “weights” which are singular at eta1=0. If True, interpolation points at eta1=0 are shifted away from the singularity by 1e-5.

  • use_cache (bool) – Whether to store some information computed in self.assemble for reuse. Set it to true if planned to update the weights later.

property domain#

Domain vector space (input) of the operator.

property codomain#

Codomain vector space (input) of the operator.

property dtype#

Datatype of the operator.

property tosparse#

Convert to a sparse matrix in any of the formats supported by scipy.sparse.

property toarray#

Convert to Numpy 2D array.

property transposed#

If the transposed operator is in play.

property dof_operator#

The degrees of freedom operator as composite linear operator containing polar extraction and boundary operators.

dot(v, out=None, tol=1e-14, maxiter=1000, verbose=False)[source]#

Applies the basis projection operator to the FE coefficients v.

Parameters:
  • v (psydac.linalg.basic.Vector) – Vector the operator shall be applied to.

  • out (psydac.linalg.basic.Vector, optional) – If given, the output will be written in-place into this vector.

  • tol (float, optional) – Stop tolerance in iterative solve (only used in polar case).

  • maxiter (int, optional) – Maximum number of iterations in iterative solve (only used in polar case).

  • verbose (bool, optional) – Whether to print some information in each iteration in iterative solve (only used in polar case).

Returns:

out – The output (codomain) vector.

Return type:

psydac.linalg.basic.Vector

transpose(conjugate=False)[source]#

Returns the transposed operator.

update_weights(weights)[source]#

Updates self.weights and computes new DOF matrix.

Parameters:

weights (list) – Weight function(s) (callables or xp.ndarrays) in a 2d list of shape corresponding to number of components of domain/codomain.

assemble(weights=None, verbose=False)[source]#

Assembles the tensor-product DOF matrix sigma_i(weights[i,j]*Lambda_j), where i=(i1, i2, …) and j=(j1, j2, …) depending on the number of spatial dimensions (1d, 2d or 3d). And store it in self._dof_mat.

struphy.feec.basis_projection_ops.prepare_projection_of_basis(V1d, W1d, starts_out, ends_out, n_quad=None, polar_shift=False)[source]#

Obtain knot span indices and basis functions evaluated at projection point sets of a given space.

Parameters:
  • V1d (3-list) – Three SplineSpace objects from Psydac from the input space (to be projected).

  • W1d (3-list) – Three SplineSpace objects from Psydac from the output space (projected onto).

  • starts_out (3-list) – Global starting indices of process.

  • ends_out (3-list) – Global ending indices of process.

  • n_quad (3_list) – Number of quadrature points per histpolation interval. If not given, is set to V1d.degree + 1.

Returns:

  • ptsG (3-tuple of 2d float arrays) – Quadrature points (or Greville points for interpolation) in each dimension in format (interval, quadrature point).

  • wtsG (3-tuple of 2d float arrays) – Quadrature weights (or ones for interpolation) in each dimension in format (interval, quadrature point).

  • spans (3-tuple of 2d int arrays) – Knot span indices in each direction in format (n, nq).

  • bases (3-tuple of 3d float arrays) – Values of p + 1 non-zero eta basis functions at quadrature points in format (n, nq, basis).

  • subs (3-tuple of 1f int arrays) – Sub-interval indices (either 0 or 1). This index is 1 if an element has to be split for exact integration (even spline degree).

class struphy.feec.basis_projection_ops.CoordinateProjector(mu: int, V: BlockVectorSpace | PolarDerhamSpace, Vmu: StencilVectorSpace | PolarDerhamSpace)[source]#

Bases: LinearOperator

Class of projectors on one component of a BlockVectorSpace. Represent the projection on the \(\mu\)-th component :

\[\begin{split}\begin{align} P_\mu : \ & V_1 \times \ldots \times V_\mu \times \ldots \times V_n \longrightarrow V_\mu \,, \\[2mm] &\vec{x} = (x_1,\ldots,x_\mu,\ldots ,x_n) \mapsto x_\mu \,. \end{align}\end{split}\]
Parameters:
  • mu (int) – The component on which to project.

  • V (BlockVectorSpace | PolarDerhamSpace) – Domain, input space.

  • Vmu (StencilVectorSpace | PolarDerhamSpace) – Codomain, out space, must be \(\mu\)-th space of V.

property domain#

Domain vector space (input) of the operator.

property codomain#

Codomain vector space (input) of the operator.

property dtype#

Datatype of the operator.

property tosparse#

Convert to a sparse matrix in any of the formats supported by scipy.sparse.

property toarray#

Convert to Numpy 2D array.

transpose(conjugate=False)[source]#

Transpose the LinearOperator .

If conjugate is True, return the Hermitian transpose.

dot(v: BlockVector | PolarVector, out=None)[source]#

Apply the LinearOperator self to the Vector v.

The result is written to the Vector out, if provided.

Parameters:
  • v (Vector) – The vector to which the linear operator (self) is applied. It must belong to the domain of self.

  • out (Vector) – The vector in which the result of the operation is stored. It must belong to the codomain of self. If out is None, a new vector is created and returned.

Returns:

The result of the operation. If out is None, a new vector is returned. Otherwise, the result is stored in out and out is returned.

Return type:

Vector

idot(v: BlockVector | PolarVector, out: StencilVector | PolarVector)[source]#

Implements out += self @ v with a temporary. Subclasses should provide an implementation without a temporary.

class struphy.feec.basis_projection_ops.CoordinateInclusion(mu: int, V: BlockVectorSpace | PolarDerhamSpace, Vmu: StencilVectorSpace | PolarDerhamSpace)[source]#

Bases: LinearOperator

Class of inclusion operator from one component of a BlockVectorSpace. Represent the canonical inclusion on the \(\mu\)-th component :

\[\begin{split}\begin{align} I_\mu : \ &V_\mu \longrightarrow V_1 \times \ldots \times V_\mu \times \ldots \times V_n \,, \\[2mm] &x_\mu \mapsto \vec{x} = (0,\ldots,x_\mu,\ldots , 0) \,. \end{align}\end{split}\]
Parameters:
  • mu (int) – The component on which to project.

  • V (BlockVectorSpace | PolarDerhamSpace) – Codomain, out space.

  • Vmu (StencilVectorSpace | PolarDerhamSpace) – Domain, in space, must be \(\mu\)-th space of V.

property domain#

Domain vector space (input) of the operator.

property codomain#

Codomain vector space (input) of the operator.

property dtype#

Datatype of the operator.

property tosparse#

Convert to a sparse matrix in any of the formats supported by scipy.sparse.

property toarray#

Convert to Numpy 2D array.

transpose(conjugate=False)[source]#

Transpose the LinearOperator .

If conjugate is True, return the Hermitian transpose.

dot(v: StencilVector | PolarVector, out=None)[source]#

Apply the LinearOperator self to the Vector v.

The result is written to the Vector out, if provided.

Parameters:
  • v (Vector) – The vector to which the linear operator (self) is applied. It must belong to the domain of self.

  • out (Vector) – The vector in which the result of the operation is stored. It must belong to the codomain of self. If out is None, a new vector is created and returned.

Returns:

The result of the operation. If out is None, a new vector is returned. Otherwise, the result is stored in out and out is returned.

Return type:

Vector

idot(v: StencilVector | PolarVector, out: BlockVector | PolarVector)[source]#

Implements out += self @ v with a temporary. Subclasses should provide an implementation without a temporary.

struphy.feec.basis_projection_ops.find_relative_col(col, row, Nbasis, periodic)[source]#

Compute the relative row position of a StencilMatrix from the global column and row positions.

Parameters:
  • col (int) – Global column index.

  • row (int) – Global row index.

  • Nbasis (int) – Number of B(or D)-splines for this particular dimension.

  • periodic (bool) – True if we have periodic boundary conditions in this direction, otherwise False.

Returns:

relativecol – The relative column position of col with respect to the the current row of the StencilMatrix.

Return type:

int