Skip to content

Postprocessing

fenics-constitutive: Interfaces for postprocessing routines with dolfinx

norm

norm(f, dx, comm=MPI.COMM_WORLD, norm_type='l2')
Source code in src/fenics_constitutive/postprocessing/error_estimation.py
def norm(f, dx, comm=MPI.COMM_WORLD, norm_type="l2"):
    match norm_type:
        case "l2":
            norm_squared = df.fem.assemble_scalar(df.fem.form(ufl.inner(f, f) * dx))
            return np.sqrt(comm.allreduce(norm_squared, op=MPI.SUM))
        case "inf":
            norm_max = np.linalg.norm(f.x.array, ord=np.inf)
            return comm.allreduce(norm_max, op=MPI.MAX)
        case _:
            msg = f"Unknown norm type: {type}"
            raise ValueError(msg)