Skip to content

Local Grid Refinement: function unsuitable now can be used with only 2 arguments - #54

Merged
pjaap merged 3 commits into
WIAS-PDELib:masterfrom
bozhar:feature/simpler_unsuitable
Oct 16, 2026
Merged

pjaap merged 3 commits into
WIAS-PDELib:masterfrom
bozhar:feature/simpler_unsuitable

Conversation

@bozhar

@bozhar bozhar commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

it uses such arguments as barycentric coordiantes and area/volume. It work in both 2D and 3D.
This unifies the signature for both 2D and 3D.
New doc page has been added.

@pjaap pjaap left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for this PR!

Can you please change the commented lines below and:

  • set the Version in Project.toml to 1.8.0

Comment thread examples/examples2d.jl Outdated
Comment thread test/runtests.jl Outdated
Comment thread test/runtests.jl Outdated
@pjaap

pjaap commented Oct 13, 2026

Copy link
Copy Markdown
Member

@j-fu what do you think?

Comment thread src/tetgen.jl Outdated
Comment thread src/tetgen.jl Outdated
@j-fu

j-fu commented Oct 13, 2026

Copy link
Copy Markdown
Member

This is the idea with the callable struct:

abstract type AbstractUnsuitableCallback end

struct MyCallback <:AbstractUnsuitableCallback
end

function (::MyCallback)(center, volume)
         ...
end      

Then we can set unsuitable!(MyCallback()) and check if isa(opt[:unsuitable], AbstractUnsuitableCallback)

@bozhar
bozhar force-pushed the feature/simpler_unsuitable branch from 41e277e to 6a36219 Compare October 13, 2026 14:05
@pjaap

pjaap commented Oct 13, 2026

Copy link
Copy Markdown
Member

I see the problem with the .nargs ... it is hacky. I was my idea, so I take the blame 😄

I want to keep it very clean on the user side, so the CallableStruct is not a good idea. But what about something like

opts_unsuitable = opts[:unsiutable]
function unsuitable(pa, pb, pc, pd)
    if hasmethod(opts_unsuitable, Tuple{typeof(pa), typeof(pb), typeof(pc), typeof(pd)})
        return opts_unsuitable(pa, pb, pc, pd)
    else # assume two-argument function
       center = ...
       vol = ....
       return opts_unsuitable(center, vol)
    end
end

for TetGen ... and similar for Triangulate?

@pjaap

pjaap commented Oct 13, 2026

Copy link
Copy Markdown
Member

applicable may be better candidate: https://docs.julialang.org/en/v1/base/base/#Core.applicable

@bozhar
bozhar force-pushed the feature/simpler_unsuitable branch from 6a36219 to 61991c0 Compare October 14, 2026 08:31
…y 2 arguments

it uses such arguments as barycentric coordiantes and area/volume.
It work in both 2D and 3D.
This unifies the signature for both 2D and 3D.
New doc page has been added.
@bozhar
bozhar force-pushed the feature/simpler_unsuitable branch from 61991c0 to e38b11a Compare October 14, 2026 11:36
@bozhar

bozhar commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Changes (from 14.10.2026):

- Ideas from the discussion were implemented
- defined the function set_unsuitable!, which invokes a callback function:
-> applicable to both Triangulate and TetGen
-> implemented within utils.jl.
-> utilized across triangle.jl and tetgen.jl
-> automatically infers the input type
-> enables the consistent application of the unsuitable function across multiple contexts, thereby preventing code clutter and preserving modularity

@bozhar
bozhar requested a review from pjaap October 14, 2026 12:36

@pjaap pjaap left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this now. What do you think @j-fu

Comment thread src/utils.jl Outdated
Comment thread src/utils.jl Outdated
Comment thread src/utils.jl Outdated
@pjaap
pjaap merged commit 23e1901 into WIAS-PDELib:master Oct 16, 2026
8 checks passed
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.

3 participants