Пример #1
0
    def solve(self, h, v):
        # Update and solve full problem
        p = self.full.solve()

        # Obtain the reduced solution matrix and solve. First discretize
        # the eliminated problem (without intersections) to obtain flux
        # discretizations for backcalculation. These could in principle have
        # been obtained from the full discretization.
        self.el.solve()
        # Then get the Schur complement eliminated lhs and rhs from the
        # existing full discretization
        perform_condensation(self.full, self.el, 1)
        # And solve
        self.el.x = sps.linalg.spsolve(self.el.lhs, self.el.rhs)
        # Evaluate condition numbers
        self.full.cond = SC.sparse_condition_number(self.full.lhs)
        self.el.cond = SC.sparse_condition_number(self.el.lhs)
        return p, self.el.x
Пример #2
0
    )
    e = [
        global_error(gb, p1, p2[:p1.size]),
        global_error(gb, t[-1], t_mp[-1][:p1.size]),
    ]
    return e


if __name__ == "__main__":
    main_folder = "results"
    gb = define_grid()

    assign_data(gb, FlowData, "problem")
    edge_params(gb)
    gb_full = gb
    eldim = 0
    gb_el, el_data = gb.duplicate_without_dimension(eldim)

    Problems = BothProblems(gb)
    other = Problems.flow
    Problems_el = BothProblems(gb_el, "_el")
    p, t = Problems.solve_and_save()
    p_el, t_el = Problems_el.solve_and_save()
    cond_full = SC.sparse_condition_number(Problems.flow.lhs)
    cond_el = SC.sparse_condition_number(Problems_el.flow.lhs)
    print("Condition numbers", cond_full, cond_el, cond_full / cond_el)
    diff = t[-1][:p_el.size] - t_el[-1]
    print(np.amax(np.absolute(diff)), np.sum(np.absolute(diff)))
    errors = evaluate_errors(p_el, p, t_el, t, gb_el)
    print(errors)