Exemple #1
0
    def error_norm(self, N):
        "Return the infinity norm of errors for the u and v components (as a tuple)."
        geometry, enthalpy, yield_stress = self.inputs(N)

        grid = enthalpy.grid()

        u_exact = self.exact_solution(grid)

        # no variation in the Z direction, so it's OK to use 2 vertical levels
        blatter_Mz = 2
        coarsening_factor = 1

        model = PISM.BlatterTestXY(grid, blatter_Mz, coarsening_factor)

        model.init()

        inputs = PISM.StressBalanceInputs()

        inputs.geometry = geometry
        inputs.basal_yield_stress = yield_stress
        inputs.enthalpy = enthalpy

        # run the solver
        model.update(inputs, True)

        # compute the error
        error = PISM.IceModelVec2V(grid, "error", PISM.WITHOUT_GHOSTS)
        error.copy_from(u_exact)
        error.add(-1.0, model.velocity())

        return error.norm(PISM.PETSc.NormType.NORM_INFINITY)