本文整理汇总了Python中sfepy.discrete.Variables.get_matrix_shape方法的典型用法代码示例。如果您正苦于以下问题:Python Variables.get_matrix_shape方法的具体用法?Python Variables.get_matrix_shape怎么用?Python Variables.get_matrix_shape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfepy.discrete.Variables
的用法示例。
在下文中一共展示了Variables.get_matrix_shape方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Equations
# 需要导入模块: from sfepy.discrete import Variables [as 别名]
# 或者: from sfepy.discrete.Variables import get_matrix_shape [as 别名]
#.........这里部分代码省略.........
Create tangent matrix graph, i.e. preallocate and initialize the
sparse storage needed for the tangent matrix. Order of DOF
connectivities is not important.
Parameters
----------
any_dof_conn : bool
By default, only volume DOF connectivities are used, with
the exception of trace surface DOF connectivities. If True,
any kind of DOF connectivities is allowed.
rdcs, cdcs : arrays, optional
Additional row and column DOF connectivities, corresponding
to the variables used in the equations.
shape : tuple, optional
The required shape, if it is different from the shape
determined by the equations variables. This may be needed if
additional row and column DOF connectivities are passed in.
active_only : bool
If True, the matrix graph has reduced size and is created with the
reduced (active DOFs only) numbering.
verbose : bool
If False, reduce verbosity.
Returns
-------
matrix : csr_matrix
The matrix graph in the form of a CSR matrix with
preallocated structure and zero data.
"""
if not self.variables.has_virtuals():
output('no matrix (no test variables)!')
return None
shape = get_default(shape, self.variables.get_matrix_shape())
output('matrix shape:', shape, verbose=verbose)
if nm.prod(shape) == 0:
output('no matrix (zero size)!')
return None
rdcs, cdcs = self.get_graph_conns(any_dof_conn=any_dof_conn,
rdcs=rdcs, cdcs=cdcs,
active_only=active_only)
if not len(rdcs):
output('no matrix (empty dof connectivities)!')
return None
output('assembling matrix graph...', verbose=verbose)
tt = time.clock()
nnz, prow, icol = create_mesh_graph(shape[0], shape[1],
len(rdcs), rdcs, cdcs)
output('...done in %.2f s' % (time.clock() - tt), verbose=verbose)
output('matrix structural nonzeros: %d (%.2e%% fill)' \
% (nnz, float(nnz) / nm.prod(shape)), verbose=verbose)
data = nm.zeros((nnz,), dtype=self.variables.dtype)
matrix = sp.csr_matrix((data, icol, prow), shape)
return matrix
def init_time(self, ts):
pass