本文整理汇总了Python中sfepy.base.base.Struct.coffsets[ir]方法的典型用法代码示例。如果您正苦于以下问题:Python Struct.coffsets[ir]方法的具体用法?Python Struct.coffsets[ir]怎么用?Python Struct.coffsets[ir]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfepy.base.base.Struct
的用法示例。
在下文中一共展示了Struct.coffsets[ir]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: distribute_fields_dofs
# 需要导入模块: from sfepy.base.base import Struct [as 别名]
# 或者: from sfepy.base.base.Struct import coffsets[ir] [as 别名]
def distribute_fields_dofs(fields, cell_tasks, is_overlap=True,
use_expand_dofs=False, save_inter_regions=False,
output_dir=None, comm=None, verbose=False):
"""
Distribute the owned cells and DOFs of the given field to all tasks.
Uses interleaved PETSc numbering in each task, i.e., the PETSc DOFs of each
tasks are consecutive and correspond to the first field DOFs block followed
by the second etc.
Expand DOFs to equations if `use_expand_dofs` is True.
"""
if comm is None:
comm = PETSc.COMM_WORLD
size = comm.size
if comm.rank == 0:
gfds = []
inter_facets = get_inter_facets(fields[0].domain, cell_tasks)
for field in fields:
aux = create_task_dof_maps(field, cell_tasks, inter_facets,
is_overlap=is_overlap,
use_expand_dofs=use_expand_dofs,
save_inter_regions=save_inter_regions,
output_dir=output_dir)
cell_parts = aux[2]
n_cell_parts = [len(ii) for ii in cell_parts]
output('numbers of cells in tasks (without overlaps):',
n_cell_parts, verbose=verbose)
assert_(sum(n_cell_parts) == field.domain.mesh.n_el)
assert_(nm.all(n_cell_parts > 0))
gfd = Struct(name='global field %s distribution' % field.name,
dof_maps=aux[0], id_map=aux[1],
cell_parts=aux[2], overlap_cells=aux[3],
coffsets=nm.empty(size, dtype=nm.int32))
gfds.append(gfd)
# Initialize composite offsets of DOFs.
if len(fields) > 1:
# Renumber id_maps for field inter-leaving.
offset = 0
for ir in range(size):
for ii, gfd in enumerate(gfds):
dof_map = gfd.dof_maps[ir]
n_owned = dof_map[3]
off = dof_map[4]
iown = nm.concatenate([dof_map[0]] + dof_map[1])
gfd.id_map[iown] += offset - off
gfd.coffsets[ir] = offset
offset += n_owned
else:
gfd = gfds[0]
gfd.coffsets[:] = [gfd.dof_maps[ir][4] for ir in range(size)]
else:
gfds = [None] * len(fields)
lfds = []
for ii, field in enumerate(fields):
aux = distribute_field_dofs(field, gfds[ii],
use_expand_dofs=use_expand_dofs,
comm=comm, verbose=verbose)
lfd = Struct(name='local field %s distribution' % field.name,
cells=aux[0], petsc_dofs_range=aux[1],
petsc_dofs_conn=aux[2])
lfds.append(lfd)
return lfds, gfds