Exporting boundary value

Dear all

I want to export the boundary value of velocity, exact nodes on the boundary labrle 1 and 2. I wrote the following:
int Nbtriangle=th.nbe;
for (int k=0; k<Nbtriangle; k++)
{
int L=th.be(k).label;
if (L==1 || L==2)
{

		real xx=th.be(k)[1].x;
		real yy=th.be(k)[1].y;
		file1 << xx << " " << yy << " " << Cr(xx,yy)<< endl;
	}
}

when I compared the profile with the paper it was different. then I exported the vtk plot of my domain to tecplot and wanted to plot velocity profile at inlet (Labels 1 and 2) the plot was exactly the same as paper. how I can write it to give me the right value?

BR,

Zeinab

I would just use something like the following (based on this post):

fespace Vh(Th, [P2,P2,P2,P1]);
Vh [ux, uy, uz, p];
Vh [xx, xy, xz, xp] = [x,x,x,x];
Vh [yx, yy, yz, yp] = [y,y,y,y];
varf vBC1([u1, u2, u3, p], [v1, v2, v3, q])  = 
            on(1, u1 = 1.); // variational formulation to set the values corresponding to the velocity x at label1 to 1
real[int] bcLab1vec = vBC1(0,Vh,tgv=-1); 
for(int i=0; i< bcLab1vec .n; i++) {
    if(abs(bcLab1vec[i]-1)<1e-10)
         file1 << xx[][i]<< " " << yx[][i] << " " << ux[][i] << endl;
}

1 Like

Dear aszaboa

Thank you for your response. Sorry, I didn’t understand if(abs(bcLab1vec[i]-1)<1e-10) because its name presents the boundary label but when I use it is not that and doesn’t show me anything.

BR

The vector bcLab1vec just contains some arbitrary nonzero number at the gridpoints with a certain label. It could contain the label itself:

mesh Th = square(20, 20); 

fespace Vh(Th, [P2,P2,P2,P1]);
Vh [ux, uy, uz, p] = [sin(x*pi), 0, 0 ,0];
Vh [xx, xy, xz, xp] = [x,x,x,x];
Vh [yx, yy, yz, yp] = [y,y,y,y];

int lab = 2;
varf vBC1([u1, u2, u3, p], [v1, v2, v3, q])  = 
            on(lab, u1 = lab); // variational formulation to set the values corresponding to the velocity x at a certain label to the label value
real[int] bcLabvec = vBC1(0,Vh,tgv=-1); 

for(int i=0; i< bcLabvec .n; i++) {
    if(abs(bcLabvec[i]-lab)<1e-10)
         cout << xx[][i]<< " " << yx[][i] << " " << ux[][i] << endl;
}

If this was not your question, I am sorry, please try to explain it in more detail.

1 Like