Skip to content

Fix #351 #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 14, 2025
Merged

Fix #351 #353

merged 1 commit into from
Jun 14, 2025

Conversation

prj-
Copy link
Member

@prj- prj- commented Jun 12, 2025

No description provided.

@cmd8
Copy link
Contributor

cmd8 commented Jun 12, 2025

Thanks for the quick turnaround. I am having problems with this patch. Looks like they can be reproduced with newton-2d-PETSc.edp.

@prj-
Copy link
Member Author

prj- commented Jun 12, 2025

I knew this wasn't that easy to fix, otherwise I would have already fixed it...

@prj-
Copy link
Member Author

prj- commented Jun 12, 2025

I see what is happening, your varf was "easy" because there was no integration. Here, there is some integration, so we need to cache the values from before the assembly, do the assembly, and override the assembly by the cached values.

@cmd8
Copy link
Contributor

cmd8 commented Jun 12, 2025

If that all seems like too much to bury beneath a simple += operator, maybe that operator should be deprecated and eventually removed?

@prj-
Copy link
Member Author

prj- commented Jun 12, 2025

Yes, because it’s indeed really not clear what on combined with varf should do (should it apply BC after the summation or before the summation but after the assembly?)
I’ll see how easy it is to remove it, because at the same time, it’s functioning alright with no on.

@cmd8
Copy link
Contributor

cmd8 commented Jun 12, 2025

To me, it feels like on() should be interpreted as a part of the variational form. That is, it should apply the BC after assembly, but before summation. Otherwise, any natural BCs will be "enforced" before summation while any essential BCs will be enforced afterwards.

@prj-
Copy link
Member Author

prj- commented Jun 13, 2025

Not my finest work, but it should work now.

@cmd8
Copy link
Contributor

cmd8 commented Jun 13, 2025

Thanks, almost there. One last consideration for the complex case. The discrepancy there is smaller, but not irrelevant.

mesh Th = square(10,10);
fespace Vh(Th, P1);
Vh<complex> u;

varf varform(du, v) = int2d(Th)(x*y*(x-1)*(y-1)*(dx(v) + dy(v) + 1i*v)) + on(1, du = 0);

u[] = 1;
complex[int] temp = varform(0, Vh, tgv = -1);
u[] += temp;
cout << u[].l2 << endl;

u[] = 1;
u[] += varform(0, Vh, tgv = -1);
cout << u[].l2 << endl;
// These should be equal?

@prj-
Copy link
Member Author

prj- commented Jun 13, 2025

Of course... my bad, should be alright now.

@cmd8
Copy link
Contributor

cmd8 commented Jun 13, 2025

Looks good! So this operator will remain a part of FF and I can safely use it in my code (without fear of deprecation)?

@prj-
Copy link
Member Author

prj- commented Jun 13, 2025

It can stay, but it comes at a cost of three vectors instead of a single one (for now). So the user-facing code is maybe clearer, but slightly more memory-demanding under the hood (of course, these are merely vectors, so it should be in no way a bottleneck for most codes).

@cmd8
Copy link
Contributor

cmd8 commented Jun 13, 2025

Got it. Thanks for your quick work. 5-star service 😊

@prj- prj- merged commit 4bc1410 into develop Jun 14, 2025
38 checks passed
@prj- prj- deleted the fix-assembly branch June 14, 2025 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants