# Plus and negative side of an internal facet

**URL:** <https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663>\
**Category:** variational formulation\
**Created:** [May 15, 2024, 1:05am UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663 "2024-05-15T01:05:23Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![leshinka](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/leshinka/32/5789_2.png) [@leshinka](https://fenicsproject.discourse.group/u/leshinka)\
**Post date:** [May 15, 2024, 1:05am UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/1 "2024-05-15T01:05:23Z")

</div>

I am a solving a problem using symmetric interior penalty discontinuous Galerkin and I am running into convergence issues that I am attributing to labeling of internal facets.

 ![Screenshot from 2024-05-14 20-39-09](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/8/873f55b578a12bef0ef971b377c26a2a8aff72d8.png)  
I need to impose a flux expression on the internal boundary between the pink and the turquoise colored subdomains.

The expression for flux that I need to impose is:  
-\kappa \nabla u \cdot n\_{\mathrm{turquoise}} = \gamma (u\_{\mathrm{turquoise}} - u\_{\mathrm{pink}} - \mathrm{constant})

I obtain convergence when the boundary between the pink and turquoise domains is a straight line.

My solution involves replacing the jump of u [\![u]\!] in the internal facet integral with (\mathrm{constant} - \frac{\kappa}{\gamma}\nabla u \cdot n\_{\mathrm{turquoise}})n\_{\mathrm{turqoise}} .

In such a boundary, is there a way to know which is the subdomain that provides u(``+") and n(``+"), and which subdomain provides u(``-") and n(``-")?

I am basically enforcing the flux condition according to [Imposing a discontinuity at interface using DG method - #19 by smesc](https://fenicsproject.discourse.group/t/imposing-a-discontinuity-at-interface-using-dg-method/11780/19)

---

<div class="post-metadata">

**Author:** ![leshinka](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/leshinka/32/5789_2.png) [@leshinka](https://fenicsproject.discourse.group/u/leshinka)\
**Post date:** [May 15, 2024, 2:43am UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/2 "2024-05-15T02:43:42Z")

</div>

Further investigation shows that it is related to [Facets orientation in inner surface with fenicsX - #3 by RaphaelC](https://fenicsproject.discourse.group/t/facets-orientation-in-inner-surface-with-fenicsx/8034/3), but I cannot figure out what the solution is. At the interface between the subdomains, the orientation needs to be definite. For example, I may want the turquoise domain to be “+” and the pink domain to be “-”.

---

<div class="post-metadata">

**Author:** ![francesco-ballarin](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@francesco-ballarin](https://fenicsproject.discourse.group/u/francesco-ballarin)\
**Post date:** [May 15, 2024, 5:06am UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/3 "2024-05-15T05:06:52Z")

</div>

You may want to have a look at [dolfinx/python/test/unit/fem/test\_assemble\_domains.py at b16ef8abc20d70c28d8f1850fe42a0ee0bcf5106 · FEniCS/dolfinx · GitHub](https://github.com/FEniCS/dolfinx/blob/b16ef8abc20d70c28d8f1850fe42a0ee0bcf5106/python/test/unit/fem/test_assemble_domains.py#L241) . Rather than say + and -, it allows to choose yourself which faces to integrate on.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [May 15, 2024, 2:41pm UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/4 "2024-05-15T14:41:24Z")

</div>

Another example can be found here: [Add one-sided integration example as example of custom integration · Issue #158 · jorgensd/dolfinx-tutorial · GitHub](https://github.com/jorgensd/dolfinx-tutorial/issues/158)

---

<div class="post-metadata">

**Author:** ![leshinka](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/leshinka/32/5789_2.png) [@leshinka](https://fenicsproject.discourse.group/u/leshinka)\
**Post date:** [May 15, 2024, 7:23pm UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/5 "2024-05-15T19:23:31Z")

</div>

This is what I needed.

---

<div class="post-metadata">

**Author:** ![leshinka](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/leshinka/32/5789_2.png) [@leshinka](https://fenicsproject.discourse.group/u/leshinka)\
**Post date:** [May 16, 2024, 1:47am UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/6 "2024-05-16T01:47:37Z")

</div>

Given now that I have control over direction of ordering, how do I express a function such as  
ufl.sqrt([\![u]\!]) where [\![u]\!] is a jump that is non-zero? I am unclear how to combine the labeling that I have made according to [Add one-sided integration example as example of custom integration · Issue #158 · jorgensd/dolfinx-tutorial · GitHub](https://github.com/jorgensd/dolfinx-tutorial/issues/158) to generate a function that takes the square root of the local jump and integrates once over the shared interface.

---

<div class="post-metadata">

**Author:** ![francesco-ballarin](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@francesco-ballarin](https://fenicsproject.discourse.group/u/francesco-ballarin)\
**Post date:** [May 16, 2024, 5:12am UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/7 "2024-05-16T05:12:04Z")

</div>

what’s wrong with defining your own jump function that reads n[+] - n[-], or the other way around?

---

<div class="post-metadata">

**Author:** ![leshinka](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/leshinka/32/5789_2.png) [@leshinka](https://fenicsproject.discourse.group/u/leshinka)\
**Post date:** [May 16, 2024, 8:22pm UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/8 "2024-05-16T20:22:05Z")

</div>

Nothing wrong with that. I am trying to figure that out from the ufl library, but it’s a slow process and any tips you provide is greatly appreciated. What I need is for “+” side to be on the side of domain with higher cell tag and “-” to be on the side of domain with lower cell tag if the facet is an internal boundary shared by two subdomains. For facets not at the internal boundary between two subdomains, I can use default behavior of “+” and “-” sides.

---

<div class="post-metadata">

**Author:** ![leshinka](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/leshinka/32/5789_2.png) [@leshinka](https://fenicsproject.discourse.group/u/leshinka)\
**Post date:** [May 17, 2024, 3:15am UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/9 "2024-05-17T03:15:41Z")

</div>

I have checked [ufl/ufl/algorithms/apply\_restrictions.py at main · FEniCS/ufl · GitHub](https://github.com/FEniCS/ufl/blob/main/ufl/algorithms/apply_restrictions.py) but cannot figure out how the “+” and “-” sides get selected and whether at the point of that selection, there is access to information about which subdomains lie on each side of the facet.

Basically, what I require is the old fix [Fix consistent restriction of one-sided interior facet integrals by jorgensd · Pull Request #2127 · FEniCS/dolfinx · GitHub](https://github.com/FEniCS/dolfinx/pull/2127). I feel that the PR introducing that change was prematurely closed. Situations where one needs to integrate a function whose input values is the jump of a value in a specified direction across the interface cannot be solved by the one-sided integral fix.

Though the fix by Dokken was deemed implicit, I believe it would be tremendously useful for folks whose problem required such a feature and would not have negatively impacted anyone who did not need it. Therefore, both Dokken’s fix and the alternate one-sided integration can both exist. By the description of the test at [dolfinx/python/test/unit/fem/test\_assemble\_domains.py at b3cb5c8127274aaeec2ddea88340651b6068df7e · FEniCS/dolfinx · GitHub](https://github.com/FEniCS/dolfinx/blob/b3cb5c8127274aaeec2ddea88340651b6068df7e/python/test/unit/fem/test_assemble_domains.py#L229), I believe this would solve my problem.

---

<div class="post-metadata">

**Author:** ![francesco-ballarin](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@francesco-ballarin](https://fenicsproject.discourse.group/u/francesco-ballarin)\
**Post date:** [May 17, 2024, 6:12am UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/10 "2024-05-17T06:12:30Z")

</div>

I wouldn’t necessarily rely on us resurrecting a fix that was dismissed years ago. OK, so since indeed you can’t rely on + and -, can’t you expand the definition of jump, use its linearity, and write the two integrals separately?

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [May 17, 2024, 7:41am UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/11 "2024-05-17T07:41:31Z")

</div>

In the integral tuple we create with integration entities, (cell\_0, local\_ facet\_index\_ cell\_0, cell\_1, local\_facet\_index\_cell\_1) the plus restriction is the first cell (0), while the negative restriction is cell 1. thus by manually packing them in that order you can get a directional jump

---

<div class="post-metadata">

**Author:** ![leshinka](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/leshinka/32/5789_2.png) [@leshinka](https://fenicsproject.discourse.group/u/leshinka)\
**Post date:** [May 17, 2024, 10:00pm UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/12 "2024-05-17T22:00:12Z")

</div>

Thanks, I think I’ve gotten it now. I noticed that I can mark only one boundary with such a method. For example, I can do:

```auto
int_facet_domains = [(3, int_facet_domain)]
dS_manual = ufl.Measure("dS", subdomain_data=int_facet_domains, domain=msh)

```

but cannot do

```auto
int_facet_domains = [(3, int_facet_domain), (5, other_int_facet_domain)]
dS_manual = ufl.Measure("dS", subdomain_data=int_facet_domains, domain=msh)

```

Marking only 1 internal boundary where I want deterministic “+” and “-” sides is sufficient for my current problem, but it’d be great to learn if it possible (if so how) to label multiple internal boundaries for deterministic “+” and “-” sides.

I appreciate both of you for your help and patience.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [May 28, 2024, 5:12pm UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/13 "2024-05-28T17:12:18Z")

</div>

What you sketch out here should work, could you comment on what is not working, and post an acompanying reproducible example

---

<div class="post-metadata">

**Author:** ![Jim\_Husman](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/jim_husman/32/8377_2.png) [@Jim\_Husman](https://fenicsproject.discourse.group/u/Jim_Husman)\
**Post date:** [April 11, 2025, 11:55am UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/14 "2025-04-11T11:55:00Z")

</div>

Hi there , I am facing the same problem as you indicated here before. Could you please share you final code for the solution?

---

<div class="post-metadata">

**Author:** ![leshinka](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/leshinka/32/5789_2.png) [@leshinka](https://fenicsproject.discourse.group/u/leshinka)\
**Post date:** [April 21, 2025, 5:10pm UTC](https://fenicsproject.discourse.group/t/plus-and-negative-side-of-an-internal-facet/14663/15 "2025-04-21T17:10:58Z")

</div>

My specific usage required me to reorder facets at only one boundary and it was not necessary to add more than one tag to dS. [Poisson submesh DG coupling · GitHub](https://gist.github.com/jorgensd/8a5c32f491195e838f5863ca88b27bce#file-problem-py-L389) has some utility functions that you may find helpful.
