# Need a border cube but it looks like flags in msh3.cpp commented out

**URL:** <https://community.freefem.org/t/need-a-border-cube-but-it-looks-like-flags-in-msh3-cpp-commented-out/2214>\
**Category:** General Discussion\
**Created:** [January 11, 2023, 2:21pm UTC](https://community.freefem.org/t/need-a-border-cube-but-it-looks-like-flags-in-msh3-cpp-commented-out/2214 "2023-01-11T14:21:47Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [January 11, 2023, 2:21pm UTC](https://community.freefem.org/t/need-a-border-cube-but-it-looks-like-flags-in-msh3-cpp-commented-out/2214/1 "2023-01-11T14:21:47Z")

</div>

I could not ifind a way to make cube “holes” in a cubes mesh. I thought bcube may  
do that but looking here, plugin/seq/msh3.cpp, it looks like there may be  
flag bits for that but none seem to be coded in. Is there some simple way to do this?

Before getting to the Dirac Eqn, I thought I would play with this, lol,

> **[Mythbusters: drafting 10 feet behind a big rig will improve mileage 39 percent...](https://www.autoblog.com/2007/10/28/mythbusters-drafting-10-feet-behind-a-big-rig-will-improve-mile/)**
>
> Warning: Don't try this! The safest distance to drive behind a big rig at 55 miles per hour is 150 feet. Driving any closer is insane because it puts you in the driver's blind spot and also does not give you enough time to respond if the big rig's...

This code sort of runs except it seems to add the BC to each cube and solve inside  
each one. And the adaptive thing does not work but I can probably figure that out.  
Thanks.

load “msh3”  
load “medit”  
real h=.25;  
real s1=.25;  
real s2=.25;  
real cen=1;  
real first=1.5;  
real d=.6;  
mesh3 Th3 = cube(20,20,20,[2_x,2_y,2\*z]);  
mesh3 Th4 = bcube(10,10,10, [s1\*x+first,s1\*y+cen,s1\*z+h]);  
mesh3 Th5 = bcube(10,10,10, [s2\*x+first-d,s2\*y+cen,s2\*z+h]);  
mesh3 Thx=Th3+Th4+Th5;  
mesh3 Tsb=buildBdMesh(Th3);  
//meshS surface=Tsb.Gamma;  
int[int] labs = [1];  
//meshS Thl = extract(Th3.Gamma, label=labs);  
meshS Thl = extract(Th3, label=labs);

//plot(Thx,wait=true);

real tol=.5;  
real cut=.01;

for(int i=0; i\<1; ++i)  
{

fespace Xh(Thx,P13d);  
Xh psi, wx;  
macro grad(u) [dx(u),dy(u),dz(u)]// def of grad operator  
// Solve  
solve potential(psi, wx)  
= int3d(Thx)(  
grad(psi)'\*grad(wx)) // scalar product  
//+on(Thl,psi=1)  
+on(2,psi=2)  
+on(1,psi=1)  
+on(3,psi=1)  
+on(4,psi=1)  
+on(5,psi=1)  
+on(6,psi=1)  
;  
plot(psi, value=true, wait=1);  
medit(“asdf”,Thx);

//Thx = adaptmesh(Thx, [dx(psi), dy(psi),dz(psi)], splitpbedge=1, nbvx=1e5, abserror=1, cutoff=cut, err=tol, inquire=0, ratio=1.5, hmin=1./100);  
tol=tol/2;  
cut=cut/2;

} // i

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [January 12, 2023, 9:01pm UTC](https://community.freefem.org/t/need-a-border-cube-but-it-looks-like-flags-in-msh3-cpp-commented-out/2214/2 "2023-01-12T21:01:12Z")

</div>

in include file MeshSurface.idp

like in file example/3d/Poisson-cube-ballon.edp or pluton  
see:

> <https://github.com/FreeFem/FreeFem-sources/blob/master/examples/3d/Period-Poisson-cube-ballon.edp>

> <https://github.com/FreeFem/FreeFem-sources/blob/master/examples/3d/Poisson-cube-ballon.edp>

---

<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:** [January 12, 2023, 9:12pm UTC](https://community.freefem.org/t/need-a-border-cube-but-it-looks-like-flags-in-msh3-cpp-commented-out/2214/3 "2023-01-12T21:12:48Z")

</div>

Thanks, I will take another look through the examples but that is difficult without  
some uncommon key words 🙂 I did get code to run using, SurfaceHex that I found  
in the manual but the orientation flag does not seem to do anything and I have  
yet to look at the cpp source code.  
The code I have is below but let me look at those examples before doing anything  
else. Thanks.

real h=-.5;  
real s1=.5;  
real s2=.5;  
real cen=1;  
real first=1.;  
real d=.6;  
int[int,int] label1=[[101,102],[103,104],[105,106]];  
int[int] NX1=[20,20,20];  
int[int,int] label2=[[201,202],[203,204],[205,206]];  
int[int] NX2=[20,20,20];  
real [int,int] BX1=[[first,s1+first],[cen,cen+s1],[h,h+s1]];  
real [int,int] BX2=[[first-d,s2+first-d],[cen,cen+s2],[h,h+s2]];  
cout\<\<BX1;  
int[int] NX3=[20,20,20];  
real [int,int] BX3=[[0,2],[0,2],[-1,1]];  
int[int,int] label3=[[1,2],[3,4],[5,6]];  
meshS Th5=SurfaceHex(NX1,BX1,label1,1);  
meshS Th3=SurfaceHex(NX2,BX2,label2,1);  
meshS Th4=SurfaceHex(NX3,BX3,label3,-1);  
meshS Thxs=Th3+Th4+Th5;  
mesh3 Thx = tetg(Thxs, switch=“pqaAAYYQ”); // , nbofregions=1);
