# Question about dual- P1DCP\_1^{DC} DG formulation in FreeFem++ documentation (nTonEdge logic & parameter al)

**URL:** <https://community.freefem.org/t/question-about-dual-p1dcp-1-dc-dg-formulation-in-freefem-documentation-ntonedge-logic-parameter-al/4035>\
**Category:** General Discussion\
**Created:** [August 8, 2025, 4:46am UTC](https://community.freefem.org/t/question-about-dual-p1dcp-1-dc-dg-formulation-in-freefem-documentation-ntonedge-logic-parameter-al/4035 "2025-08-08T04:46:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tan](https://avatars.discourse-cdn.com/v4/letter/t/f07891/32.png) [@Tan](https://community.freefem.org/u/Tan)\
**Post date:** [August 8, 2025, 4:46am UTC](https://community.freefem.org/t/question-about-dual-p1dcp-1-dc-dg-formulation-in-freefem-documentation-ntonedge-logic-parameter-al/4035/1 "2025-08-08T04:46:48Z")

</div>

I am currently studying the section _“Solution by Discontinuous-Galerkin FEM”_ in the FreeFem++ documentation, which presents a dual-P1DCP\_1^{DC} formulation for solving a scalar advection problem.

The weak formulation presented is:

∫Ω(cn+1−cnδt+u⋅∇c)w+∫E(α∣n⋅u∣−12n⋅u)[c]w=∫EΓ−∣n⋅u∣cw∀w\int\_{\Omega}\left(\frac{c^{n+1}-c^n}{\delta t} + u \cdot \nabla c \right) w + \int\_E \left(\alpha |n \cdot u| - \frac{1}{2} n \cdot u \right) [c] w = \int\_{E\_{\Gamma}^{-}} |n \cdot u| c w \quad \forall w

In the associated code, the problem is defined as:

```auto
// Problem
problem Adual(cc, w)
    = int2d(Th)(
        (cc/dt + (v1*dx(cc) + v2*dy(cc)))*w
    )
    + intalledges(Th)(
        (1 - nTonEdge)*w*(al*abs(n) - n/2)*jump(cc)
    )
    - int2d(Th)(
        ccold*w/dt
    );

```

I have two questions regarding this implementation:

* * *

### 1️⃣ About `(1 - nTonEdge)`:

From the documentation and `nTonEdge` behavior, it seems that:

- `nTonEdge = 1` if the triangle has a boundary edge,

- `nTonEdge = 2` otherwise (i.e., internal edge with two adjacent elements).

In this case, the term `(1 - nTonEdge)` becomes:

- `0` on boundary edges,

- `-1` on interior edges.

This seems counterintuitive to me, as it introduces a **negative sign** on interior edges. Could someone please explain **why this negative sign is necessary** , and how it fits into the weak formulation?

* * *

### 2️⃣ About the parameter `al`:

The formulation involves a parameter `al` in the numerical flux:

(α∣n⋅u∣−12n⋅u)\left(\alpha |n \cdot u| - \frac{1}{2} n \cdot u\right)

Could you please clarify:

- What is the **typical choice** for `al`?

- What is the **theoretical rationale** behind it?

- Should `al = 1` always be used for full upwinding, or can it vary?

* * *

Any insights or references would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [August 8, 2025, 10:51am UTC](https://community.freefem.org/t/question-about-dual-p1dcp-1-dc-dg-formulation-in-freefem-documentation-ntonedge-logic-parameter-al/4035/2 "2025-08-08T10:51:08Z")

</div>

Dear Tan,

You are right about the sign: there is a problem.

Indeed there is a mistake in the documentation: there should be a minus sign in front of the integral over E.

But the code is correct.

About the choice of alpha I don’t know.

---

<div class="post-metadata">

**Author:** ![math](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@math](https://community.freefem.org/u/math)\
**Post date:** [September 13, 2025, 8:03am UTC](https://community.freefem.org/t/question-about-dual-p1dcp-1-dc-dg-formulation-in-freefem-documentation-ntonedge-logic-parameter-al/4035/3 "2025-09-13T08:03:55Z")

</div>

> [@Tan](#):
>
> ```auto
> + intalledges(Th)(
> (1 - nTonEdge)*w*(al*abs(n) - n/2)*jump(cc)
> 
> ```

why not /nTonEdge in + intalledges(Th)( (1 - nTonEdge)\*w\*(al\*abs(n) - n/2)\*jump(cc)? Do you know. I think the interior edges are computed twice, so should /nTonEdge. Am I right?

---

<div class="post-metadata">

**Author:** ![math](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@math](https://community.freefem.org/u/math)\
**Post date:** [September 13, 2025, 8:18am UTC](https://community.freefem.org/t/question-about-dual-p1dcp-1-dc-dg-formulation-in-freefem-documentation-ntonedge-logic-parameter-al/4035/4 "2025-09-13T08:18:54Z")

</div>

Dear Professor, why not /nTonEdge in + intalledges(Th)( (1 - nTonEdge)\*w\*(al\*abs(n) - n/2)\*jump(cc)? Do you know. I think the interior edges are computed twice, so should /nTonEdge. Am I right?

---

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [September 15, 2025, 9:30am UTC](https://community.freefem.org/t/question-about-dual-p1dcp-1-dc-dg-formulation-in-freefem-documentation-ntonedge-logic-parameter-al/4035/5 "2025-09-15T09:30:46Z")

</div>

Dear Tan,

I agree that there is a mismatch between the formula and the code (factor 2). To fix the problem you should look at the mentioned reference :

ERN, A. and GUERMOND, J. L. Discontinuous Galerkin methods for Friedrichs’ symmetric systems. I. General theory. SIAM J. Numer. Anal., 2006

in particular section 5.2

---

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [September 15, 2025, 12:18pm UTC](https://community.freefem.org/t/question-about-dual-p1dcp-1-dc-dg-formulation-in-freefem-documentation-ntonedge-logic-parameter-al/4035/6 "2025-09-15T12:18:34Z")

</div>

I checked the reference, I find that the code is right. Indeed the correct formula is that there are two integrals for each internal edge: one for each of the two adjacent triangles.

For the choice of \alpha, according to the theory any positive value works, but there is a particularly interesting choice \alpha=1/2.
