Ejemplo n.º 1
0
def group_add_group_elements(group: FieldGroup,
                             other_group: FieldGroup,
                             only_dimension=None):
    '''
    Add to group elements and/or nodes from other_group.
    :param only_dimension: If set, only add objects of this dimension.
    '''
    fieldmodule = group.getFieldmodule()
    with ChangeManager(fieldmodule):
        for dimension in [only_dimension] if only_dimension else range(4):
            if dimension > 0:
                mesh = fieldmodule.findMeshByDimension(dimension)
                element_group = group.getFieldElementGroup(mesh)
                if not element_group.isValid():
                    element_group = group.createFieldElementGroup(mesh)
                mesh_group = element_group.getMeshGroup()
                mesh_group.addElementsConditional(
                    other_group.getFieldElementGroup(mesh))
            elif dimension == 0:
                nodeset = fieldmodule.findNodesetByFieldDomainType(
                    Field.DOMAIN_TYPE_NODES)
                node_group = group.getFieldNodeGroup(nodeset)
                if not node_group.isValid():
                    node_group = group.createFieldNodeGroup(nodeset)
                nodeset_group = node_group.getNodesetGroup()
                nodeset_group.addNodesConditional(
                    other_group.getFieldNodeGroup(nodeset))
Ejemplo n.º 2
0
def find_or_create_field_node_group(group: FieldGroup, nodeset: Nodeset) -> FieldNodeGroup:
    """
    Gets or creates the node group field for the supplied nodeset in group.
    Field is managed by its parent group field.

    :param group:  Zinc group field that manages child node group field.
    :param nodeset:  A nodeset from group region to get or create subgroup of.
    :return: Zinc FieldNodeGroup.
    """
    node_group = group.getFieldNodeGroup(nodeset)
    if not node_group.isValid():
        node_group = group.createFieldNodeGroup(nodeset)
    return node_group
Ejemplo n.º 3
0
def group_add_group_nodes(group: FieldGroup, other_group: FieldGroup,
                          nodeset: Nodeset):
    """
    Add to group elements and/or nodes from other_group.
    :param nodeset: Nodeset to add nodes from.
    """
    other_node_group = other_group.getFieldNodeGroup(nodeset)
    if other_node_group.isValid() and (
            other_node_group.getNodesetGroup().getSize() > 0):
        node_group = group.getFieldNodeGroup(nodeset)
        if not node_group.isValid():
            node_group = group.createFieldNodeGroup(nodeset)
        nodeset_group = node_group.getNodesetGroup()
        nodeset_group.addNodesConditional(
            other_group.getFieldNodeGroup(nodeset))