gridap / GridapEmbedded.jl

Embedded finite element methods in Julia
Other
42 stars 14 forks source link

Some AnalyticalGeometry lack the name property #82

Closed cenmir closed 6 months ago

cenmir commented 7 months ago

Greetings!

Had an issue with the square function, the parameter name is not used in the last line in intersect. This causes an issue when used to compute EmbeddedBoundary.

Minimal example to reproduce error:

using Gridap
using GridapEmbedded

N = 10
partition = (N, N);
pmin = Point(-1, -1);
pmax = Point(1, 1);
bgmodel = CartesianDiscreteModel(pmin, pmax, partition);

geo1 = square(L=1.5, name="Outer");
geo2 = square(L=0.75, name="Inner");
geo = setdiff(geo1, geo2, name="csg");

cutgeo = cut(bgmodel, geo);

Γd = EmbeddedBoundary(cutgeo, "csg", "Inner");
Γn = EmbeddedBoundary(cutgeo, "csg", "Outer");

Potential fix:

function square(;L=1,x0=Point(0,0),name="square",edges=["edge$i" for i in 1:4])

    e1 = VectorValue(1,0)
    e2 = VectorValue(0,1)

    plane1=plane(x0=x0-0.5*L*e2,v=-e2,name=edges[1])
    plane2=plane(x0=x0+0.5*L*e2,v=+e2,name=edges[2])
    plane3=plane(x0=x0-0.5*L*e1,v=-e1,name=edges[3])
    plane4=plane(x0=x0+0.5*L*e1,v=+e1,name=edges[4])

    geo12 = intersect(plane1,plane2)
    geo34 = intersect(plane3,plane4)

    intersect(geo12,geo34, name=name)

end

Other AnalyticalGeometries also lack the name property, i don't know if this is by design or not.

ericneiva commented 6 months ago

Hi, @cenmir,

Thank you so much for reporting this :)

What you describe is very clear.

I agree with the fix and it should be propagated to other geometries.

Feel free to fork, apply these changes and assign the PR to me.

Btw, have you tried:

Γd = EmbeddedBoundary(cutgeo, geo, geo2);
Γn = EmbeddedBoundary(cutgeo, geo, geo1);

instead of passing the geometry names?