B-Spline Constraints: Fully Funded! Thanks everybody!

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: B-Spline Constraints: Fully Funded! Thanks everybody!

Post by adrianinsaval »

jnxd wrote: Wed Jan 11, 2023 4:22 pm @adrianinsaval what is the behaviour on your end now?
I tested yesterday and endpoint tangent to knot worked well, creating first tangent at knot constraint and then adding a coincidence constraint still failed to converge, it would be ideal if it was auto replaced by end point tangent as it happens with normal tangent constraints.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: B-Spline Constraints: Fully Funded! Thanks everybody!

Post by abdullah »

jnxd wrote: Tue Jan 17, 2023 7:16 pm
abdullah wrote: Tue Jan 17, 2023 3:18 pm
jnxd wrote: Thu Dec 29, 2022 4:26 am However if it does result in a dense matrix (albeit with most elements within it set to zero) the performance penalty is indeed significant.
It should not. Diagnosis is run at the beginning, with the parameter value as initialised by OCC. If the constraint uses this value to calculate gradients (Jacobian), all but the intervening ones will be zero. This will keep the matrix sparse. If a point can move in a segment of BSpline, it will move on any to other. So the fact that diagnosis is restricted to the relevant segment appears to me an advantage...
Note that the sparsity of a matrix in the data structure may be different than the actual sparsity of the matrix: it is possible that elements that are actually zero are stored explicitly in the data structure, eating up resources during computations. This may not be a bad thing all the time (e.g. in GPU matrix operations, which we don't do here), but just something to keep in mind.
This should not be the case if a zero is an actual zero (not e.g. 1e-15), as the system is created as a dense matrix and only then it is converted to a sparse one. But, hey! you have already implemented it so we will take a look :D
jnxd wrote: Tue Jan 17, 2023 7:16 pm Definitely don't have anything against your heart's health. It's in everyone's (including Sketcher's) interest that it keeps working fine ;).

I think most of the actual "tests" will eventually only happen in the wild. Anyone who wanted to test it pre-merge seems to have already done so.
From previous experiences, the amount of people testing during pre-merge is limited. The moment something is announced as a new feature in master, many more users will try it out. Some power users may well abuse the poor feature to test its limits. :lol:
jnxd wrote: Wed Jan 18, 2023 5:23 pm 1) The variable is now just a non-array double.
3) I added the dynamic segment hopping, at least as a prototype. It's not particularly difficult to implement, but we need to know the performance hit. Here I just update the piece in error.
Thank you!
adrianinsaval wrote: Wed Jan 18, 2023 6:01 pm tested yesterday and endpoint tangent to knot worked well, creating first tangent at knot constraint and then adding a coincidence constraint still failed to converge, it would be ideal if it was auto replaced by end point tangent as it happens with normal tangent constraints.
Yes, we are missing the constraint substitution part. Do you want to give it a go Ajinkya?
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: B-Spline Constraints: Fully Funded! Thanks everybody!

Post by jnxd »

abdullah wrote: Thu Jan 19, 2023 2:53 pm
adrianinsaval wrote: Wed Jan 18, 2023 6:01 pm tested yesterday and endpoint tangent to knot worked well, creating first tangent at knot constraint and then adding a coincidence constraint still failed to converge, it would be ideal if it was auto replaced by end point tangent as it happens with normal tangent constraints.
Yes, we are missing the constraint substitution part. Do you want to give it a go Ajinkya?
Could try. Where to start?
My latest (or last) project: B-spline Construction Project.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: B-Spline Constraints: Fully Funded! Thanks everybody!

Post by abdullah »

jnxd wrote: Thu Jan 19, 2023 3:31 pm Could try. Where to start?
When adding a coincident, this checks what should do instead in particular cases:
https://github.com/FreeCAD/FreeCAD/blob ... .cpp#L2027
https://github.com/FreeCAD/FreeCAD/blob ... .cpp#L1909
https://github.com/FreeCAD/FreeCAD/blob ... s.cpp#L485

That is for coincident, there are others for when, for example, a PoO is added:
https://github.com/FreeCAD/FreeCAD/blob ... .cpp#L2465

or tangencies:
https://github.com/FreeCAD/FreeCAD/blob ... .cpp#L4031

It is rather rudimentary...
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: B-Spline Constraints: Fully Funded! Thanks everybody!

Post by adrianinsaval »

is it expected the the solver fails to converge when I add first the tangent and then the coincidence then? If I first add the coincidence and then the tangent it says it's partially redundant but it works, it converges and I can drag stuff around
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: B-Spline Constraints: Fully Funded! Thanks everybody!

Post by jnxd »

adrianinsaval wrote: Thu Jan 19, 2023 5:40 pm is it expected the the solver fails to converge when I add first the tangent and then the coincidence then?
That's not my own experience with recent builds, but apparently abdullah said it's unrelated.
My latest (or last) project: B-spline Construction Project.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: B-Spline Constraints: Fully Funded! Thanks everybody!

Post by abdullah »

adrianinsaval wrote: Thu Jan 19, 2023 5:40 pm is it expected the the solver fails to converge when I add first the tangent and then the coincidence then? If I first add the coincidence and then the tangent it says it's partially redundant but it works, it converges and I can drag stuff around
It is not expected that the solver fails to converge. However, the tangent constraint is not, IMO, what makes it fail to converge. The fact that the other way around it works buts some weight on this position.

It would be great to find the real culprit. However, finding the real culprit is not relevant for this specific case, as the constraint should be the other one (endpoint to endpoint tangency). When constraint substitution is implemented this issue won't arise for this case. However, it may appear in another combination of constraints, where the problem is not that the "wrong" constraint was selected.

But that we will see when people start using it and report issues... and maybe those issues help us find that sneaky culprit... ;)
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: B-Spline Constraints: Fully Funded! Thanks everybody!

Post by abdullah »

Point on B-Spline is merged.

@jnxd
Do you feel like AngleViaPoint next?
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: B-Spline Constraints: Fully Funded! Thanks everybody!

Post by jnxd »

abdullah wrote: Sat Jan 21, 2023 8:52 pm Point on B-Spline is merged.

@jnxd
Do you feel like AngleViaPoint next?
We need to chart the future course a little. So far, you're suggesting the constraint substitution (which is simple but is also just a long chain of if-else statements) and angle-via-point (which can evolve from what we're doing so far, but might need us to add more of those dreaded parameters). Are their other things?

Also in priority is the construction project, which I want to get done by March end. In that preferably we should have control over the nonuniformity of the B-spline, so the knots' parameters can change continuously.
My latest (or last) project: B-spline Construction Project.
chrisb
Veteran
Posts: 53934
Joined: Tue Mar 17, 2015 9:14 am

Re: B-Spline Constraints: Fully Funded! Thanks everybody!

Post by chrisb »

abdullah wrote: Sat Jan 21, 2023 8:52 pm Point on B-Spline is merged.
Thanks to jnxd! I rate this as another milestone in Sketcher development.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply