# How is Sommerfeld boundary condition applied in this model problem

**URL:** <https://community.freefem.org/t/how-is-sommerfeld-boundary-condition-applied-in-this-model-problem/2601>\
**Category:** General Discussion\
**Created:** [July 13, 2023, 2:50am UTC](https://community.freefem.org/t/how-is-sommerfeld-boundary-condition-applied-in-this-model-problem/2601 "2023-07-13T02:50:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jawahar264](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/jawahar264/32/1783_2.png) [@jawahar264](https://community.freefem.org/u/jawahar264)\
**Post date:** [July 13, 2023, 2:50am UTC](https://community.freefem.org/t/how-is-sommerfeld-boundary-condition-applied-in-this-model-problem/2601/1 "2023-07-13T02:50:20Z")

</div>

load “bem”  
real k = 10;  
int n = 100;  
border circle(t = 0, 2_pi){x=cos(t); y=sin(t);}  
meshL ThL = buildmeshL(circle(n));  
ThL = OrientNormal(ThL,unbounded=1);  
varf vbem(u,v) = int1dx1d(ThL)(ThL)(BEM(BemKernel(“SL”,k=k),u,v));  
fespace Uh(ThL,P1);  
HMatrix H = vbem(Uh,Uh);  
func uinc = exp(1i_k_x);  
Uh p, b;  
varf vrhs(u,v) = -int1d(ThL)(uinc_v);  
b = vrhs(0,Uh);  
p = H^-1_b[];  
varf vpot(u,v) = int1d(ThL)(POT(BemPotential(“SL”,k=k),u,v));  
int np = 200;  
int R = 4;  
border b1(t=-R, R){x=t; y=-R;}  
border b2(t=-R, R){x=R; y=t;}  
border b3(t=-R, R){x=-t; y=R;}  
border b4(t=-R, R){x=-R; y=-t;}  
mesh ThOut = buildmesh(b1(np)+b2(np)+b3(np)+b4(np)+circle(-n));  
fespace UhOut(ThOut,P1);  
HMatrix HP = vpot(Uh,UhOut);  
UhOut u, utot;  
u[] = HP_p;  
utot = u + uinc;  
plot(utot,fill=1,value=1,cmm=“u\_total”);

---

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [July 13, 2023, 8:23am UTC](https://community.freefem.org/t/how-is-sommerfeld-boundary-condition-applied-in-this-model-problem/2601/2 "2023-07-13T08:23:01Z")

</div>

I can’t get it to compiles on 4.12 its stumbling at OrientNormal,

```auto
ff-mpirun -np 1 forumrad.edp -wg 
'/usr/bin/mpiexec' --oversubscribe -np 1 /home/ubuntu/dev/freefem/install/bin/FreeFem++-mpi -nw 'forumrad.edp' -wg
-- FreeFem++ v4.12 (Sat 20 May 2023 07:29:03 PM EDT - git no git)
   file : forumrad.edp
 Load: lg_fem lg_mesh lg_mesh3 eigenvalue parallelempi 
    1 : load "bem"
Init_Bem

    2 : real k = 10;
    3 : int n = 100;
    4 : border circle(t = 0, 2*pi){x=cos(t); y=sin(t);}
    5 : meshL ThL = buildmeshL(circle(n));
    6 : ThL=OrientNormal The Identifier OrientNormal does not exist 

 Error line number 6, in file forumrad.edp, before token OrientNormal

```

and it looks ok as per this page,

[https://doc.freefem.org/documentation/BEM.html](https://doc.freefem.org/documentation/BEM.html)

---

<div class="post-metadata">

**Author:** ![jawahar264](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/jawahar264/32/1783_2.png) [@jawahar264](https://community.freefem.org/u/jawahar264)\
**Post date:** [July 13, 2023, 8:35am UTC](https://community.freefem.org/t/how-is-sommerfeld-boundary-condition-applied-in-this-model-problem/2601/3 "2023-07-13T08:35:38Z")

</div>

yes we have to load msh3 that is missing if you add msh3 and run it in mpi it will work fine .My doubt is how is Sommerfeld boundary condition applied here. Do you know how to make a dynamic mesh in freefem?

---

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [July 13, 2023, 12:01pm UTC](https://community.freefem.org/t/how-is-sommerfeld-boundary-condition-applied-in-this-model-problem/2601/4 "2023-07-13T12:01:25Z")

</div>

Thanks.  
Directly relevant to your question sources of information include the documentation,  
the BEM source code, and dumping the matrix and RHS that BEM generates.

I haven’t actually used it myself but was going to dig into it some time anyway.  
The documentation claims this  
for single layer,  
[https://doc.freefem.org/documentation/BEM.html#bemintrobio](https://doc.freefem.org/documentation/BEM.html#bemintrobio)

I had to make several changes to the code including adding “complex” and the  
browser mangles asterisks and quotes. It compiles but I don’t have enough memory  
for np=200 and 50 didn’t converge.
