Save Boundary Condition

Hello!
I’m working with several files, and the solution I obtain in one of them I need to use ir as the boundary condtion in the other. Is there a way to save and read the boundary condition in a .txt? I know I can save the whole solution, but I don’t need most of that data and that creares big files.
Thanks!

The idea is to save the interpolation of the boundary condition.

an ideas:

save-bc.edp (423 Bytes)

You can evaluate the solution anywhere with automatic interpolation. I just output on
a regular grid which includes the boundaries I seem to recall however something in libmesh
about some way of handling these or related problems but I dont remember the
name. - there may be a function to do this. Anyway, for example I just looked at this
in R and it seems to work,

int onmesh=0;
{
ofstream ff("peri.txt");
if (onmesh==1)
{
for (int ii = 0; ii < Th.nv; ii++)
//for (int ii = 0; ii < Th.nt; ii++)
{
// I guess these are verticies? 
real x=Th[ii][0].x;
real y=Th[ii][0].y;
real z=Th[ii][0].z;
real uhi=uh(x,y,z);
//if (Th[ii].region==888) hx[ii]=volume/1.4; 
//if (Th[ii].region==999) hx[ii]=volume;
//cout<<" point "<< x<<" "<<y<<" "<<z <<" "<< Th[ii].region << " "<<uhi << endl;
ff<<" point "<< x<<" "<<y<<" "<<z <<" "<< Th[ii].region << " "<<uhi << endl;
} 
} // onmesh
else
{
int npts=1e2;
int px=npts^3;
int px2=npts^2;
int ip=0,iq=0,ir=0;
real delc=2*dim/npts; 
for (int ii = 0; ii < px; ii++)
{
++ip; if (ip==npts) { ip=0; ++iq;
if (iq==npts) { iq=0; ++ir; } }
real x=x0+delc*ip;;
real y=x0+delc*iq;;
real z=x0+delc*ir;;
real uhi=uh(x,y,z);
ff<<" point "<< x<<" "<<y<<" "<<z <<" "<<uhi << endl;

} // ii 

} // !onmesh 
} // scope

Be careful with the previous comment, this ok for P1 Finite element ; not for all finite element because the interpolation operator is not only the value a vertices.

use varf with on like

varf vonPb(u,v) = on(1,2,3,4,u=g);
Vh g=vonPb(0,Vh,tgv=1);// tgv=1 is important because other without you get the value multiply by tgv value (1e30)

Interpolating the solution will pick up the tgv to enforce the diriclet bc?
In any case, it looks like you can just iterate over the
boundary just as you would any other component. Thbounds is part of the overall
mesh and AFAICT this generates the right result. This is the example I happen
to have, there is no BC enforced although it is using periodic BC
on this surface.

meshS Thbounds = mycube(x0,x1,yy0,yy1,z0,z1,-1,1);
real vol=volumetet;
meshS Thsrc=Thx0;
//nx=8; ny=8; nz=8;
meshS Thdense = mycube(x0+sx,x1-sx,yy0+sx,yy1-sx,z0+sx,z1-sx,-1,100);
meshS Thtotal= Thdense+Thbounds;

for (int ii = 0; ii < Thbounds.nv; ii++)
//for (int ii = 0; ii < Th.nt; ii++)
{
// I guess these are verticies? 
real x=Thbounds[ii][0].x;
real y=Thbounds[ii][0].y;
real z=Thbounds[ii][0].z;
real uhi=uh(x,y,z);
//if (Th[ii].region==888) hx[ii]=volume/1.4; 
//if (Th[ii].region==999) hx[ii]=volume;
//cout<<" point "<< x<<" "<<y<<" "<<z <<" "<< Th[ii].region << " "<<uhi << endl;
ff<<" point "<< x<<" "<<y<<" "<<z <<" "<< Thbounds[ii].region << " "<<uhi << endl;