コード例 #1
0
                       'maxiter': 300,
                       'disp': True
                   })

    # Results Of Minimization
    yh = Function(W)
    yh.vector()[:] = res.x
    uh = solve_supg(V, bcs, epsilon, b, c, f, yh)
    res_phi = phi(yh.vector())

    one = project(1., V)
    area = assemble(one * dx)
    h_average = assemble(h * dx) / area

    error_function = Function(V, assemble(abs(uh - u_exact) * v * dx))
    l2_norm_of_error = norm(error_function, 'l2')
    global_result = {
        'V_dofs': V.dofmap().global_dimension(),
        'W_dofs': W.dofmap().global_dimension(),
        'phi': res_phi,
        'phi_30': phi_30,
        'h': h_average,
        'error_l2': l2_norm_of_error
    }
    global_results.append(global_result)
    rs.make_results('RESULTS/' + str(SC_EXAMPLE) + 'indLim', NUM_CELL, V, W,
                    uh, u_exact, yh, res_phi, results)

# Global results
rs.make_global_results('RESULTS/' + str(SC_EXAMPLE) + 'indLim', global_results)
コード例 #2
0
ファイル: sold_simple.py プロジェクト: prklVIP/FEniCSopt
                        ])  # ! possible division by 0

    # Basic Definitions
    p = 1  # Constant(V.ufl_element().degree())
    tau = compute_tau(W, h, p, epsilon, b)
    uh = solve_supg(V, bcs, epsilon, b, c, f, tau)

    tau2 = compute_sold_tau_codina(uh, 0.7, W, h, epsilon, b, c, f)
    uh = solve_sold(V, bcs, epsilon, b, b_perp, c, f, tau, tau2)

    one = project(1., V)
    area = assemble(one * dx)
    h_average = assemble(h * dx) / area

    error_function = Function(V, assemble(abs(uh - u_exact) * v * dx))
    l2_norm_of_error = norm(error_function, 'l2')
    global_result = {
        'V_dofs': V.dofmap().global_dimension(),
        'W_dofs': W.dofmap().global_dimension(),
        'phi': 1.,
        'phi_30': 1.,
        'h': h_average,
        'error_l2': l2_norm_of_error
    }
    global_results.append(global_result)
    results = []
    rs.make_results(SC_EXAMPLE, NUM_CELL, V, W, uh, u_exact, tau, 1., results)

# Global results
rs.make_global_results(SC_EXAMPLE, global_results)