Beispiel #1
0
def avg(q: CoefficientFunction) -> CoefficientFunction:
    """
    Returns the average of a scalar field.

    Args:
        q (CoefficientFunction): The scalar field.

    Returns:
        ~ (CoefficientFunction): The average of q at every facet of the mesh.
    """

    return 0.5 * (q + q.Other())
Beispiel #2
0
def jump(q: CoefficientFunction) -> CoefficientFunction:
    """
    Returns the jump of a field.

    Args:
        q: The  field.

    Returns:
        ~: The jump of q at every facet of the mesh.
    """

    return q - q.Other()
Beispiel #3
0
def grad_avg(q: CoefficientFunction) -> CoefficientFunction:
    """
    Returns the average of the gradient of a field.

    Args:
        q: The field.

    Returns:
        ~: The average of the gradient of q at every facet of the mesh.
    """

    # Grad must be called differently if q is a trial or testfunction instead of a coefficientfunction/gridfunction.
    if isinstance(q, ProxyFunction):
        return 0.5 * (Grad(q) + Grad(q.Other()))
    else:
        return 0.5 * (Grad(q) + Grad(q).Other())