Skip to content

Introduce MeshSequence + handle restrictions on MeshSequence #264

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ksagiyam
Copy link
Contributor

@ksagiyam ksagiyam commented Mar 27, 2024

Depend on #382 (small).

In multi-domain (submesh) problems, there are situations where, say, an exterior-facet integration of domainA is an interior-facet integration of domainB. In this PR we extend the Measure class to correctly represent such integration. Specifically, in the above example, if we choose domainA as the "primal" integration domain, we define the interested measure as:

meas = Measure(
    "ds", domainA,
    extra_measures=(
        Measure("dS", domainB),
    )
)

. This required changing:

  • integral sorting (form.py),
  • IntegralData grouping (algorithms/domain_analysis.py),
  • signature (algorithms/signature.py),

accordingly.

We also modified RestrictionPropagator class and apply_restrictions() function. apply_restriction() function now takes default_restrictions kwarg, so that we can specify the default restrictions domain-wise. In the above case, we will have something like:

apply_restrictions(
    integral,
    default_restrictions={
        domainA: None,
        domainB: "+",
    }
)

.

@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch from e07f9fa to d574909 Compare July 20, 2024 14:30
@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch 8 times, most recently from e66d41d to d3e72fb Compare August 20, 2024 22:31
@ksagiyam ksagiyam changed the title Introduce MixedMesh Introduce MixedMesh + handle restrictions on MixedMesh Aug 21, 2024
@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch 2 times, most recently from 23696eb to ae55b3b Compare November 20, 2024 13:38
@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch from ae55b3b to 4ced3a7 Compare December 10, 2024 15:53
@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch 5 times, most recently from 7e4dd44 to ef8fd99 Compare January 10, 2025 21:23
restriction = t._side
t, = t.ufl_operands
elif t._ufl_terminal_modifiers_:
raise ValueError("Missing handler for terminal modifier type %s, object is %s." % (type(t), repr(t)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for not using f-strings here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I will fix it when I tidy this up. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

# Only split mixed coefficients
return o
# Reference value expected
assert reference_value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this throw a run-time error instead of an assertion, as something has clearly gone wrong if you have gotten here without t being a Coefficient and ReferenceValue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed.

@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch 2 times, most recently from 988189f to 36559fc Compare January 17, 2025 21:33
@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch from 36559fc to 9317b5b Compare February 6, 2025 23:48
@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch from 9317b5b to 883ee0b Compare February 20, 2025 13:38
@mscroggs
Copy link
Member

Should this PR be closed in favour of #303? Or this a different feature?

@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch from 883ee0b to 2d76a5e Compare March 7, 2025 12:55
@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch 6 times, most recently from 3f5f1ea to b2f2fec Compare June 17, 2025 16:33
@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch 10 times, most recently from f55fd36 to 5882239 Compare June 25, 2025 01:15
@dham dham changed the title Introduce MixedMesh + handle restrictions on MixedMesh Introduce MeshSequence + handle restrictions on MeshSequence Jun 25, 2025
Copy link
Collaborator

@dham dham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm basically happy with this.

ufl/measure.py Outdated
@@ -122,6 +130,8 @@ def __init__(
affecting how code is generated, including parameters
for optimization or debugging of generated code
subdomain_data: object representing data to interpret subdomain_id with
extra_measures: additional domain-integral_type map
for multi-domain problems
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs serious documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -143,6 +143,9 @@ def compute_form_signature(form, renumbering): # FIXME: Fix callers
integrand_hashdata = compute_expression_hashdata(integral.integrand(), terminal_hashdata)

domain_hashdata = integral.ufl_domain()._ufl_signature_data_(renumbering)
extra_measures_hash_data = tuple(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
extra_measures_hash_data = tuple(
extra_measures_hashdata = tuple(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -153,6 +156,7 @@ def compute_form_signature(form, renumbering): # FIXME: Fix callers
integrand_hashdata,
domain_hashdata,
integral.integral_type(),
extra_measures_hash_data,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
extra_measures_hash_data,
extra_measures_hashdata,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ksagiyam
Copy link
Contributor Author

@jorgensd I will touch up slightly more today, but could you have a look at this PR?

@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch 3 times, most recently from fb5f4a4 to abc62d6 Compare June 27, 2025 17:20
@ksagiyam
Copy link
Contributor Author

Updated the description.

@ksagiyam ksagiyam marked this pull request as ready for review June 27, 2025 22:56
@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch from 5350b9f to 1b26a8f Compare July 7, 2025 01:18
@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch from 1b26a8f to 5650c45 Compare July 17, 2025 16:03
@ksagiyam ksagiyam force-pushed the ksagiyam/introduce_mixed_map branch from 5650c45 to 6ec0d57 Compare July 18, 2025 08:05
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.

4 participants