Beispiel #1
0
    def create_friction_bcs(self, dof_name):
        """
        Fix friction DOFs on surface boundary edges, i.e. that are not
        shared by two friction surface faces.
        """
        bcs = []
        for ig, dual_surface in self.dual_surfaces.iteritems():
            e_id = dual_surface.conn[:, 0]
            ii = nm.where(nm.bincount(e_id) == 1)

            region = Region('__friction_%d' % ig, '', self, '')
            region.set_vertices(ii)
            region.is_complete = True

            dofs = {'%s.all' % dof_name: 0.0}

            bc = EssentialBC('__friction_%d' % ig, region, dofs)
            bcs.append(bc)

        return bcs
Beispiel #2
0
def eval_in_els_and_qp(expression, ig, iels, coors,
                       fields, materials, variables,
                       functions=None, mode='eval', term_mode=None,
                       extra_args=None, verbose=True, kwargs=None):
    """
    Evaluate an expression in given elements and points.

    Parameters
    ----------
    expression : str
        The expression to evaluate.
    fields : dict
        The dictionary of fields used in `variables`.
    materials : Materials instance
        The materials used in the expression.
    variables : Variables instance
        The variables used in the expression.
    functions : Functions instance, optional
        The user functions for materials etc.
    mode : one of 'eval', 'el_avg', 'qp'
        The evaluation mode - 'qp' requests the values in quadrature points,
        'el_avg' element averages and 'eval' means integration over
        each term region.
    term_mode : str
        The term call mode - some terms support different call modes
        and depending on the call mode different values are
        returned.
    extra_args : dict, optional
        Extra arguments to be passed to terms in the expression.
    verbose : bool
        If False, reduce verbosity.
    kwargs : dict, optional
        The variables (dictionary of (variable name) : (Variable
        instance)) to be used in the expression.

    Returns
    -------
    out : array
        The result of the evaluation.
    """
    weights = nm.ones_like(coors[:, 0])
    integral = Integral('ie', coors=coors, weights=weights)

    domain = fields.values()[0].domain

    region = Region('Elements', 'given elements', domain, '')
    region.cells = iels + domain.mesh.el_offsets[ig]
    region.update_shape()
    domain.regions.append(region)

    for field in fields.itervalues():
        field.clear_mappings(clear_all=True)
        for ap in field.aps.itervalues():
            ap.clear_qp_base()

    aux = create_evaluable(expression, fields, materials,
                           variables.itervalues(), Integrals([integral]),
                           functions=functions,
                           mode=mode, extra_args=extra_args, verbose=verbose,
                           kwargs=kwargs)
    equations, variables = aux

    out = eval_equations(equations, variables,
                         preserve_caches=False,
                         mode=mode, term_mode=term_mode)
    domain.regions.pop()

    return out