Muscat.LinAlg.ConstraintsHolder module

class Ainsworth[source]

Bases: object

Method from https://doi.org/10.1016/S0045-7825(01)00236-5 Because the CleanConstraint(C) matrix is orthonormal then C.dot(C.T) = I this make the P Q R expression simpler

GetCOp(op)[source]
GetCRhs(op, rhs)[source]
GetNumberOfDofs()[source]
RestoreSolution(op, rhs, arg)[source]
RestrictSolution(op, rhs, arg)[source]
UpdateSystem(CH)[source]
matvec(op, arg)[source]
CheckIntegrity(GUI: bool = False)[source]
CheckIntegrityMasterSlaveDetection(GUI: bool = False)[source]
CheckIntegrityTTC(ttc, GUI=False)[source]
class ConstraintsHolder[source]

Bases: object

Constrained linear problem: Class to store and to enforce constraints for a quadratic system of the form:

minimize 1/2 u.K.u - u.f subject to: A.u = b

This class can store, and manipulate the system Au=b and enforce the constraints by different methods (penalization, substitution, lagrange multiplier)

the first set of function is used to fill this class with the system Au=b:

NextEquation must be called after the call of a set of : AddFactor, AddConstant One per constraint

AddEquationSparse, AddEquation, AddEquationsFromIJV to add a full constraint at once

Compact will clean (zeros, and duplicated) entries

AddConstant(constant)[source]
AddConstraint(constraints)[source]
AddEquation(vals, const=0)[source]
AddEquationSparse(index, vals, const)[source]
AddEquationsFromIJV(ei, ej, ev)[source]
AddEquationsFromOperatorAAndb(A, b=None)[source]
AddFactor(ddl, factor)[source]
CleanEmptyColumns(mat)[source]

Function to clean empty columns for a matrix,

this function returns:

res : a sparse matrix with only non zero columns of mat (the last column is always present, event if it is full of zeros) usedDofs : the indices of the columns prensent in res

Compact()[source]
ComputeConstraintsEquations(mesh, unknownFields, solutionFields=None, reactionFields=None)[source]
GetCOp()[source]
GetCRhs(rhs=None)[source]
GetCleanConstraintBase(purePython=False)[source]

This function compute the QR decomposition of the augmented system [A|b] Il will use the self.tol value to detect redundant constraints (rank revealing)

this functions returns:

res : a parse matrix q’ with only the relevant part of the QR decomposition. Q’ constraint only the non zero columns of [A|b] and always the last column (the b) usedDofs : the indices of the columns present in Q

option:

purePython: to force scipy for computing the QR decomposition

GetNumberOfConstraints()[source]
GetNumberOfDofsOnCSystem()[source]
GetNumberOfDofsOnOriginalSystem()[source]
NextEquation()[source]
Reset()[source]
Residual(u: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Tuple[ndarray, ndarray][source]

Recover A.u and b

Parameters:

u (ArrayLike) – Vector of unknowns

Returns:

se result of

Return type:

Tuple[np.ndarray,np.ndarray]

RestoreSolution(arg)[source]
RestrictSolution(arg)[source]
SetConstraintsMethod(method: str)[source]
SetNumberOfDofs(nbdof)[source]
SetOp(op, rhs=None)[source]
ToSparse()[source]

Function to convert to the constraints system Ax=B to a sparse matrix

this function returns:
  • res : a sparse matrix of [A’|B] , A’ has only the non zero columns of A

  • usedDofs : the indices of the columns present in A’

ToSparseFull()[source]

Function to convert to the constraints system Ax=B to a sparse matrix

this function returns:

res : a sparse matrix of [A|B] ,

UpdateCSystem()[source]
matvec(arg)[source]
rmatvec(arg)[source]
ExpandMatrix(op, mattoglobal, nbdofs, treatrows=True, treatcols=True)[source]
class Lagrange[source]

Bases: object

GetCOp(op)[source]
GetCRhs(op, rhs)[source]
GetNumberOfDofs()[source]
RestoreSolution(op, rhs, arg)[source]
RestrictSolution(op, rhs, arg)[source]
UpdateSystem(CH)[source]
matvec(op, arg)[source]
class Penalisation[source]

Bases: object

GetCOp(op)[source]
GetCRhs(op, rhs)[source]
GetNumberOfDofs()[source]
RestoreSolution(op, rhs, arg)[source]
RestrictSolution(op, rhs, arg)[source]
UpdateSystem(CH)[source]
matvec(op, arg)[source]
class Projection[source]

Bases: object

GetCOp(op)[source]
GetCRhs(op, rhs)[source]
GetNumberOfDofs()[source]
RestoreSolution(op, rhs, arg)[source]
RestrictSolution(op, rhs, arg)[source]
UpdateSystem(CH)[source]
matvec(op, arg)[source]