# Problem in defining penalty parameters locally

**URL:** <https://community.freefem.org/t/problem-in-defining-penalty-parameters-locally/4250>\
**Category:** General Discussion\
**Created:** [April 8, 2026, 6:02pm UTC](https://community.freefem.org/t/problem-in-defining-penalty-parameters-locally/4250 "2026-04-08T18:02:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pratyay](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@pratyay](https://community.freefem.org/u/pratyay)\
**Post date:** [April 8, 2026, 6:02pm UTC](https://community.freefem.org/t/problem-in-defining-penalty-parameters-locally/4250/1 "2026-04-08T18:02:03Z")

</div>

How to define the penalty parameter for the local Lux Friedrich flux? The value of the penalty parameter will depend on the exterior and interior edge for every edge and so it will be changed accordingly. How can we implement this type of parameter in free fem ++? I have also attached the flux. Please help me.

Thank you in advance.

 ![IMG_20260408_232708](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/8/8b979d73ef5135d4999a49ffbd3b5e7ecf84c4d8.jpeg)

---

<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:** [April 9, 2026, 8:15am UTC](https://community.freefem.org/t/problem-in-defining-penalty-parameters-locally/4250/2 "2026-04-09T08:15:08Z")

</div>

I understand that by “penalty parameter” you mean the numerical viscosity coefficient \Lambda\_{K,e}. Since there is one coefficient for each edge, you could consider a function the the finite element space P0edge. If you want to compute this coefficient prior to using it, you have to make a loop over the triangles and their edges.  
Or your can use a variational formulation as

```auto
int nx=12;
mesh Th=square(nx,nx);

fespace Vh(Th,P0);
fespace Vhe(Th,P0edge);

Vh ux,uy;
ux=x;uy=y;//example
Vhe lambda;

varf numvisc(unused,lamt)=intalledges(Th)(max(abs(ux*N.x+uy*N.y),otherside(abs(ux*N.x+uy*N.y)))*lamt/lenEdge/nTonEdge);
lambda[]=numvisc(0,Vhe);

```
