Skip to content

Conversation

@FrederikSchnack
Copy link
Contributor

@FrederikSchnack FrederikSchnack commented Jul 23, 2025

This PR deals with issue #515 .

By exposing the pads keyword to discretize_space in psydac/api/discretize.py, we can manually set its padding to match with the degree of the other space. This resolves the assertion error mentioned in the issue and seems to allow discretizing BilinearForms with spaces of different degree.

This change was proposed by @vcarlier in the branch maxwell_ssc.

A MWE is given by:

from sympde.topology import Square
from sympde.topology.analytical_mapping import IdentityMapping
from sympde.topology import Derham
from sympde.topology  import element_of

from sympde.expr.expr import BilinearForm
from sympde.expr.expr import integral

from psydac.api.discretization import discretize

ncells = [8, 8]
degree = [3, 3]
d_degree = [d - 1 for d in degree]

log_domain = Square('Omega', bounds1=(0, 1), bounds2=(0, 1))
mapping = IdentityMapping('M1', dim=2)
domain = mapping(log_domain)
derham = Derham(domain, sequence=['h1', 'hcurl', 'l2'])

domain_h = discretize(domain, ncells=ncells)

p_derham_h = discretize(derham, domain_h, degree=degree)
d_derham_h = discretize(derham, domain_h, degree=d_degree, pads=degree)

pV0h, pV1h, pV2h = p_derham_h.spaces
dV0h, dV1h, dV2h = d_derham_h.spaces

pV = pV0h.symbolic_space
dV = dV0h.symbolic_space

u = element_of(pV, name='u')
v = element_of(dV, name='v')

a = BilinearForm((u, v), integral(domain, u*v))
ah = discretize(a, domain_h, [pV0h, dV0h])
A = ah.assemble()

That this produces the correct solution has to be verified!

@codacy-production
Copy link

codacy-production bot commented Jul 23, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (42b214e) 30762 18640 60.59%
Head commit (8be6589) 61528 (+30766) 37282 (+18642) 60.59% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#517) 5 5 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants