<commit_before>import dolfin as df

def amr(mesh, m, DirichletBoundary, g, d):
    V = df.FunctionSpace(mesh, "CG", 1)

    # Define boundary condition
    bc = df.DirichletBC(V, g, DirichletBoundary())

    # Define variational problem
    u = df.Function(V)
    v = df.TestFunction(V)
    E = df.grad(u)
    costheta = df.dot(m, E)
    sigma = 1/(1 + costheta**2)
    F = df.inner(sigma*df.grad(u), df.grad(v))*df.dx

    # Compute solution
    df.solve(F == 0, u, bc, solver_parameters={"newton_solver":
                                               {"relative_tolerance": 1e-6}})

    # Plot solution and solution gradient
    df.plot(u, title="Solution")
    df.plot(sigma*df.grad(u), title="Solution gradient")
    df.interactive()<commit_msg>Add sigma0 and alpha AMR parameters to the function.<commit_after>import dolfin as df

def amr(mesh, m, DirichletBoundary, g, d, s0=1, alpha=1):
    V = df.FunctionSpace(mesh, "CG", 1)

    # Define boundary condition
    bc = df.DirichletBC(V, g, DirichletBoundary())

    # Define variational problem
    u = df.Function(V)
    v = df.TestFunction(V)
    E = -df.grad(u)
    costheta = df.dot(m, E)
    sigma = s0/(1 + alpha*costheta**2)
    F = df.inner(sigma*df.grad(u), df.grad(v))*df.dx

    # Compute solution
    df.solve(F == 0, u, bc, solver_parameters={"newton_solver":
                                               {"relative_tolerance": 1e-6}})

    # Plot solution and solution gradient
    df.plot(u, title="Solution")
    df.plot(sigma*df.grad(u), title="Solution gradient")
    df.interactive()
{'fraction_non_alphanumeric': 0.1440460947503201, 'fraction_numerical': 0.011523687580025609, 'mean_word_length': 2.6950354609929077, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1909650', 'n_tokens_mistral': 566, 'n_tokens_neox': 521, 'n_words': 127}