Procedures

Preprocessing

sigmaepsilon.solid.fem.preproc.assemble_load_vector(values: ndarray, gnum: ndarray, N: int = -1)[source]

Returns global dof numbering based on element topology data.

Parameters
  • values (numpy.ndarray) – 3d numpy float array of shape (nE, nEVAB, nRHS), representing element data. The length of the second axis matches the the number of degrees of freedom per cell.

  • gnum (int) – Global indices of local degrees of freedoms of elements.

  • N (int, Optional) – The number of total unknowns in the system. Must be specified correcly, to get a vector the same size of the global system. If not specified, it is inherited from ‘gnum’ (as ‘gnum.max() + 1’), but this can lead to a chopped array.

Returns

2d numpy array of integers with a shape of (N, nRHS), where nRHS is the number if right hand sizes (load cases).

Return type

numpy.ndarray

sigmaepsilon.solid.fem.preproc.assert_min_diagonals_bulk(K: ndarray, minval: float = 1e-12)[source]

Guarantees, that the values in the diagonal are larger a prescribed minimum value.

Parameters
  • A (numpy.ndarray) – The coefficient matrix of several elements as a 3d array, where elements run along the first axis.

  • minval (float, Optional) – The minimum value. Default is 1e-12.

Returns

The modified coefficient matrix, with the same shape as ‘K’.

Return type

numpy.ndarray

sigmaepsilon.solid.fem.preproc.box_fem_data_bulk(Kp_coo: coo_matrix, gnum: ndarray, f: ndarray)[source]

Notes:

If the load vector ‘f’ is dense, it must contain values for all nodes, even the passive ones.

sigmaepsilon.solid.fem.preproc.box_fem_data_sparse(K_coo: coo_matrix, Kp_coo: coo_matrix, f: ndarray)[source]

Notes:

If the load vector ‘f’ is dense, it must contain values for all nodes, even the passive ones.

sigmaepsilon.solid.fem.preproc.condensate_Kf_bulk(K: ndarray, f: ndarray, fixity: ndarray) Tuple[ndarray, ndarray][source]

Returns the condensed coefficient matrices representing constraints on the internal forces of the elements (eg. hinges).

Currently this solution is only able to handle two states, being totally free and being fully constrained. The fixity values are expected to be numbers between 0 and 1, where dofs with a factor > 0.5 are assumed to be the constrained ones.

Parameters
  • K (numpy.ndarray) – 3d float array, the stiffness matrices of several elements of the same kind.

  • factors (numpy.ndarray) – 2d boolean array of connectivity factors for each dof of several elements.

Returns

  • numpy.ndarray – The condensed stiffness matrices with the same shape as K.

  • numpy.ndarray – The condensed load vectors with the same shape as f.

sigmaepsilon.solid.fem.preproc.condensate_M_bulk(M: ndarray, fixity: ndarray) ndarray[source]

Returns the condensed coefficient matrices representing constraints on the internal forces of the elements (eg. hinges).

Parameters
  • M (numpy.ndarray) – 3d float array, the mass matrices of several elements of the same kind.

  • fixity (numpy.ndarray) – 2d float boolean of connectivity factors for each dof of several elements.

Returns

The condensed mass matrices with the same shape as M.

Return type

numpy.ndarray

sigmaepsilon.solid.fem.preproc.essential_penalty_factor_matrix(fixity: Optional[ndarray] = None, *, inds: Optional[ndarray] = None, N: Optional[int] = None, eliminate_zeros: bool = True, sum_duplicates: bool = True) coo_matrix[source]

Returns the penalty factor matrix. This matrix is the basis of several penalty matrices used to enforce constraints on the primary variables.

At all times, the function must be informed about the total number of nodes in the model, to return an output with a correct shape. If ‘inds’ is None, it is assumed that ‘fixity’ contains data for each node in the model, and therefore the length of ‘fixity’ is the number of nodes in the model. You can also use ‘N’ to indicate the number of nodes, in which case entries according to ‘inds’ are marked as constrained.

Parameters
  • fixity (numpy.ndarray, Optional) – Fixity information as a 2d boolean array.

  • inds (numpy.ndarray, Optional) – 1d numpy integer array specifying node indices.

  • N (int, Optional) – The overall number of nodes in the model. If not provided, we assume that it equals the highest index in ‘inds’ + 1 (this assumes zero-based indexing).

sigmaepsilon.solid.fem.preproc.essential_penalty_matrix(fixity: Optional[ndarray] = None, *, inds: Optional[ndarray] = None, pfix: float = 1000000000000.0, eliminate_zeros: bool = True, sum_duplicates: bool = True) coo_matrix[source]

Returns the sparse, COO format penalty matrix, equivalent of a Courant-type penalization of the essential boundary conditions.

Parameters
  • fixity (numpy.ndarray, Optional) – Fixity information as a 2d float or boolean array.

  • inds (numpy.ndarray, Optional) – 1d integer array specifying global indices for the rows of ‘values’.

  • pfix (float, Optional) – Penalty value for fixed dofs. It is used to transform boolean penalty data, or to make up for missing values (e.g. only indices are provided). Default is sigmaepsilon.solid.fem.constants.DEFAULT_DIRICHLET_PENALTY.

  • eliminate_zeros (bool, Optional) – Eliminates zeros from the matrix. Default is True.

  • eliminate_zeros – Summs duplicate entries in the matrix. Default is True.

Returns

The penalty matrix in sparse COO format.

Return type

scipy.sparse.coo_matrix

sigmaepsilon.solid.fem.preproc.estimate_stiffness_penalty(K: Union[ndarray, spmatrix], fixity: ndarray, N: int)[source]

Returns a sugegsted value for the stiffness penalty, to account for essential boundary conditions.

\(\mathbf{M}\)

\begin{equation} \mathbf{A} \mathbf{x} = \lambda \mathbf{x}, \end{equation}
Parameters
  • K (Union[ndarray, spmatrix]) – The stiffness matrix as a dense or a sparse array.

  • N (int) – The number of degrees of freedom in the model.

References

1

B. Nour-Omid, P. Wriggers “A two-level iteration method for solution of contact problems.” Computer Methods in Applied Mechanics and Engineering, vol. 54, pp. 131-144, 1986.

sigmaepsilon.solid.fem.preproc.fem_coeff_matrix_coo(A: ndarray, *args, inds: Optional[ndarray] = None, rows: Optional[ndarray] = None, cols: Optional[ndarray] = None, N: Optional[int] = None)[source]

Returns the coefficient matrix in sparse ‘coo’ format. Index mapping is either specified with inds or with both rows and cols.

If lower or upper is provided as a positional argument, the result is returned as a lower- or upper-triangular matrix, respectively.

Parameters
  • A (np.ndarray) – Element coefficient matrices as a 3d array. The lengths if the last two axes must be the same.

  • inds (np.ndarray, Optional) – Global indices of all quantities of an element as a 2d integer array. Length of the second axis must match the lengths of the 2nd and 3rd axes of ‘A’. Default is None.

  • rows (np.ndarray, Optional) – Global numbering of the rows as an 1d integer array. Length must equal the flattened length of ‘A’. Default is None.

  • cols (np.ndarray, Optional) – Global numbering of the columns as an 1d integer array. Length must equal the flattened length of ‘A’. Default is None.

  • N (int, Optional) – Total number of coefficients in the system. If not provided, it is inferred from index data.

Returns

Coefficient matrix in sparse coo format (see scipy doc for the details).

Return type

scipy.sparse.coo_matrix

sigmaepsilon.solid.fem.preproc.nodal_mass_matrix(*args, values: Optional[ndarray] = None, eliminate_zeros: bool = True, sum_duplicates: bool = True, ndof: int = 6, **kwargs) coo_matrix[source]

Returns the diagonal mass matrix resulting form nodal masses in scipy COO format.

Parameters
  • discription (See the documentation of 'build_fem_ebc_data' for the) –

  • arguments. (of the possible) –

Returns

The mass matrix in sparse COO format.

Return type

scipy.sparse.coo_matrix

Miscellaneous

sigmaepsilon.solid.fem.utils.approximation_matrix(ndf: ndarray, NDOFN: int)[source]

Returns a matrix of approximation coefficients for all elements.

sigmaepsilon.solid.fem.utils.compatibility_factors(ncf: dict, nreg: dict, NDOFN: int)[source]

ncf : nodal_compatibility_factors

sigmaepsilon.solid.fem.utils.compatibility_factors_to_coo(ncf: dict, nreg: dict)[source]

ncf : nodal_compatibility_factors

sigmaepsilon.solid.fem.utils.expand_coeff_matrix_bulk(A_in: ndarray, A_out: ndarray, dofmap: ndarray) ndarray[source]

Expands the local coefficient matrices into a standard form. It is used for instance when the total matrix is built up of smaller parts.

sigmaepsilon.solid.fem.utils.expand_load_vector_bulk(v_in: ndarray, v_out: ndarray, dofmap: ndarray) ndarray[source]

Expands the local load vectors into a standard form.

sigmaepsilon.solid.fem.utils.fixity2d_to_dofs1d(fixity2d: ndarray, inds: ndarray = None)[source]

Returns the indices of the degrees of freedoms being supressed.

Optionally, global indices of the rows in ‘fixity2d’ array can be provided by the optional argument ‘inds’.

Parameters
  • fixity2d (numpy.ndarray) – 2d numpy array of booleans. It has as many rows as nodes, and as many columns as derees of freedom per node in the model. A True value means that the corresponding dof is fully supressed.

  • inds (numpy.ndarray, Optional) – 1d numpy array of integers, default is None. If provided, it should list the global indices of the nodes, for which the data is provided by the array ‘fixity2d’.

Returns

dofinds – 1d numpy array of integers.

Return type

np.ndarray

sigmaepsilon.solid.fem.utils.irows_icols_bulk(edofs: ndarray)[source]

Returns row and column index data for several finite elements.

Parameters

edofs (numpy.ndarray) – 2d numpy array. Each row has the meaning of global degree of freedom numbering for a given finite element.

Returns

  • irows (numpy.ndarray) – Global indices of the rows of the entries of stiffness matrices of the elements.

  • icols (numpy.ndarray) – Global indices of the columns of the entries of stiffness matrices of the elements.

Notes

The implementation assumes that every cell has the same number of degrees of freedom.

sigmaepsilon.solid.fem.utils.irows_icols_bulk_filtered(edofs: ndarray, inds: ndarray)[source]

Returns row and column index data for finite elements specified by the index array inds.

Parameters
  • edofs (numpy.ndarray) – 2d numpy array. Each row has the meaning of global degree of freedom numbering for a given finite element.

  • inds (numpy.ndarray) – 1d numpy array of integers specifying active elements in an assembly.

Returns

  • irows (numpy.ndarray) – Global indices of the rows of the entries of stiffness matrices of the elements.

  • icols (numpy.ndarray) – Global indices of the columns of the entries of stiffness matrices of the elements.

Notes

The implementation assumes that every cell has the same number of degrees of freedom.

sigmaepsilon.solid.fem.utils.min_stiffness_diagonal(K: Union[ndarray, spmatrix]) float[source]

Returns the minimum diagonal entry of the stiffness matrix.

Parameters

K (Union[ndarray, spmatrix]) – The stiffness matrix as a dense or a sparse array.

sigmaepsilon.solid.fem.utils.nodal_approximation_matrix(ndf: ndarray)[source]

Returns a matrix of nodal approximation coefficients for all elements.

sigmaepsilon.solid.fem.utils.nodes2d_to_dofs1d(inds: ndarray, values: ndarray)[source]

Returns a tuple of degree of freedom indices and data, based on a nodal definition.

Parameters
  • inds (numpy.ndarray) – 1d numpy array of integers, listing global node indices.

  • values (numpy.ndarray) – 3d numpy float array of shape (nN, nDOF, nX), listing values for each node in ‘inds’. nX is the number of datasets.

Returns

  • dofinds (numpy.ndarray) – 1d numpy array of integers, denoting global dof indices.

  • dofvals (numpy.ndarray) – 2d numpy float array of shape (nN * nDOF, nX), denoting values on dofs in ‘dofinds’.

sigmaepsilon.solid.fem.utils.topo_to_gnum(topo: ndarray, ndofn: int)[source]

Returns global dof numbering based on element topology data.

Parameters
  • topo (numpy.ndarray) – 2d numpy array of integers. Topology array listing global node numbers for several elements.

  • ndofn (int) – Number of degrees of freedoms per node.

Returns

gnum – 2d numpy array of integers.

Return type

numpy.ndarray

sigmaepsilon.solid.fem.utils.topo_to_gnum_jagged(topo, gnum, ndofn: int)[source]

Returns global dof numbering based on element topology data.

Parameters
  • topo (numpy.ndarray) – 2d array of integers. Topology array listing global node numbers for several elements.

  • gnum (numpy.ndarray) – 2d buffer array for the results.

  • ndofn (int) – Number of degrees of freedoms per node.

Returns

gnum – 2d numpy array of integers.

Return type

numpy.ndarray

sigmaepsilon.solid.fem.utils.weighted_stiffness_bulk(K: ndarray, weights: ndarray)[source]

Returns a weighted stiffness matrix.

Parameters
  • K (numpy.ndarray) – 2d numpy array of floats, where the first axis of K runs along the elements.

  • weights (numpy.ndarray) – 1d numpy array of floats.

Returns

Kw – 2d numpy array of floats with the same shape as ‘K’.

Return type

numpy.ndarray