I have a question about different methods of calculation of a relation.
my relation is
I have F and U from previous solutions of PDE equations and just want to add them together with weight alpha.
now, I am confused if I write it as follow, answers are different. I don’t know which one is correct.
Probably the easiest thing to do is try a small mesh with known data.
The both expressions are fairly literal - The first one is just as written scaled F + U.
The second one integrates of the test functions it is the RHS for a FEM
problem in form Ax=b . I guess you probably want the first expression.
I think you just need to add the functions together.
I think the most efficient way is the following
GradJ = F;
GradJ *= alpha;
GradJ += U;
This way you are just adding and multiplying the vectors. If you do
GradJ=alpha*F+U;, then the functions are interpolated.
Actually my case is axisymmetric and I do the optimization. I was not sure to compute gradients for descent direction, should I use variational form (1st method) and multiply it by r (radius) or just use the second method. In non axisymmetric models, I used the method you proposed and worked.
I am not sure about the answer. I think if the radius is in the variational form ,then you cannot multiply with R outside the varf, but I do not know about the precise problem you are solving.
I found that in the Stabfem repository, you can find the FreeFem implementation of various flow stability equations, which illustrate a lot of tricks. You might find the answer there; e.g., in SOURCES_FREEFEM/Newton_Axi.edp · master · StabFem / StabFem · GitLab