Quite often it looked like some boundary conditions were ignored.
So, I went back to a simple example trying to generate a sine wave
in 1D starting at arbitrary phase and amplitude ( value and slope on left ).
I could not find a combination of terms to do that and inevitably the result
had a value of slope of zero on the other end of the mesh. Also, I could not figure
out how to plot the things in FreeFEM so I just exported to txt files and used R.
Looking at the matrix and RHS, it appeared in many cases that “+on” had no
effect. I guess I could try to “do the math” and figure out what entries I expect
in “A” and b or see why it is not possible but thought someone may know offhand.
In 1D with P1 elements and a uniform mesh it shouldn’t be that difficult, the laplacian
looks like a scaled FD expression.

cat sinephase.edp
load "msh3"
load "medit"
int nx=100;
//int nx=5;
int[int] lbe=[100,200]; // begin and end point labels
meshL Th=Sline(nx, [1.5*x],label=lbe);
fespace Vh(Th,P1);
Vh u,v;
Vh w=x;
// the tgv is ignored here...
varf sinewave(u,v,tgv=-1)
= int1d(Th)(dx(u)*dx(v)) + int1d(Th)(-4*pi*pi*u*v)
+int0d(Th,100)(-11230*v)
+on(100,u=10) // value on 100
;
matrix A=sinewave(Vh,Vh,tgv=-1);
real[int] b= sinewave(0,Vh,tgv=-1);
real[int] sm=A^-1 * b;
if (false)
{
cout<<" solution axb : "; cout<<sm;
cout.flush;
{ofstream outf("sinea.txt");
outf<<A<<endl;
cout<<A<<endl;
outf.flush;
}
{ofstream outf("sineb.txt");
outf<<b<<endl;
cout<<b<<endl;
outf.flush;
}
//if (nx<50)
{ofstream outf("sine.txt");
for(int i=0; i<sm.n; ++i) outf<<i<<" "<<w[][i]<<" "<<sm[i]<<endl;
outf.flush;
}
}
u[]=sm;
// how to plot?
//plot(u,wait=1, fill=1);
//plot(1:10,sm,wait=1, fill=1);
//medit("asdf", [sm,sm]);

Thanks. I may have gotten a bit confused at some point ( I deleted all the things
I tried that did not seem to work ). Sure, most of the time I can get either Neumann
or Difichlet to work, the problem was trying to speciify both on the same
boundary region. How do I specify the initial phase of the sinewave on the
initial point? I’m sure this is going to turn out to be something similarly simple

What is the origin of that restriction?
This becomes an issue when one dimension of the mesh is time and I want
to continue a function from one iterations’ last value and derivative to
use as the initial conditions in the next iteration.

If you use on, it will overwrite whatever you have in the rest of your varf (this is not specific to FreeFEM, whenever you use Dirichlet boundary conditions, you somehow need to enforce it algebraically on your system). So if you want to have a combination of both kind of boundary conditions, you should simply use Robin boundary conditions instead of on.

Well, if you set the value setting the derivative is effectively fixing
the adjacent node value isn’t it?
I’m thinking in FD or maybe P0 terms but AFAICT its not much differnet
for the others although I haven’t worked it through.
Thanks.

For the u’’ +u case just splitting iit up into two vars seems to add enough dof’s
to make it workout.
I guess this is cheating and may have other issues but it looks like it works
although I have not yet tried to extend the “z” results from one run to another using
this ( final “z” and dz as init conitions for next run ). Creating 2 vars sounds bad
except that the nuymber of non-zero matrix elements may not even be all that much
worse.