Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute the norm of an expression with multiple fields #377

Open
alex-m-h opened this issue Feb 12, 2024 · 1 comment
Open

Compute the norm of an expression with multiple fields #377

alex-m-h opened this issue Feb 12, 2024 · 1 comment
Assignees
Labels
bug Something isn't working codegen Automatic code generation FEM API Objects describing finite element concepts

Comments

@alex-m-h
Copy link

When computing the L2-norm of an expression, I am not sure how the discretization should work in this case.
Minimal code example:

domain = Cube(name='Cube')
derham = Derham(domain, ['H1', 'Hcurl', 'Hdiv', 'L2'])
B = element_of(derham.V1, name='B')
u = element_of(derham.V0, name='u')
J = Norm(dot(B - grad(u), B - grad(u)), domain)

domain_h = discretize(domain, ncells=[5,5,5], periodic=[False, False, False])
derham_h = discretize(derham, domain_h, degree=[2,2,2])
J_h = discretize(J, domain_h, derham_h.V0)

which results in the following traceback:

Traceback (most recent call last):
  File "functional_issue.py", line 26, in <module>
    main()
  File "functional_issue.py", line 22, in main
    J_h = discretize(J, domain_h, derham_h.V0)
  File "/home/alex/repos/psydac/psydac/api/discretization.py", line 513, in discretize
    return DiscreteFunctional(a, kernel_expr, *args, **kwargs)
  File "/home/alex/repos/psydac/psydac/api/fem.py", line 1426, in __init__
    BasicDiscrete.__init__(self, expr, kernel_expr, comm=comm, root=0, discrete_space=discrete_space,
  File "/home/alex/repos/psydac/psydac/api/basic.py", line 298, in __init__
    BasicCodeGen.__init__(self, expr, folder=folder, comm=comm, root=root, discrete_space=discrete_space,
  File "/home/alex/repos/psydac/psydac/api/basic.py", line 108, in __init__
    ast = self._create_ast( expr=expr, tag=tag, discrete_space=discrete_space,
  File "/home/alex/repos/psydac/psydac/api/basic.py", line 339, in _create_ast
    return AST(expr, kernel_expr, discrete_space, mapping_space=mapping_space,
  File "/home/alex/repos/psydac/psydac/api/ast/fem.py", line 334, in __init__
    fields_degrees      = get_degrees(fields, spaces)
  File "/home/alex/repos/psydac/psydac/api/ast/fem.py", line 226, in get_degrees
    assert len(funcs) == len(degrees)
AssertionError

Maybe I have misunderstood, how this is supposed to be discretized. In the examples there is only one space used, but we need two spaces for the two fields. It might be good to have an option as for the BilinearForm where the variables are specified and then the spaces, as in

ac = BilinearForm((u, v), integral(domain, gc * u * v))
ach = discretize(ac, domain_h, [Vh, Vh], **kwargs)

(taken from test_assemble_complex_parallel in psydac/api/tests/test_assembly.py)

@yguclu yguclu added bug Something isn't working FEM API Objects describing finite element concepts codegen Automatic code generation labels Feb 20, 2024
@yguclu
Copy link
Member

yguclu commented Feb 21, 2024

I feel that this issue should be solved after #332.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working codegen Automatic code generation FEM API Objects describing finite element concepts
Projects
None yet
Development

No branches or pull requests

2 participants