Generate mesh from SDF

Suppose I have a simple signed-distance function/field (SDF) defined natively in Julia. Is there an easy way to generate a mesh of this SDF (eg to use within an FEM simulation)?

Nothing fancy wrt the type of mesh etc. I’m just trying to see if there’s already any support for this kind of thing.

Do you see a need to preserve the contours? If not, then simply define the SDF by interpolation on an arbitrary mesh.

Thanks, @PetrKryslUCSD!

Do you see a need to preserve the contours?

Nope. I don’t need anything other than the zero level set.

If not, then simply define the SDF by interpolation on an arbitrary mesh.

Hmm but this would require me to redefine all my SDFs in terms of a mesh directly. I’m not sure this is as “simple” (or practical) as you imply.

More importantly, I lose my parameterization, which produces my SDF. For example, I have a simple function which takes as an input a center and radius, and produces the SDF for the corresponding circle. I would then like a routine that can generate an arbitrary mesh from this SDF.

But what is the use of this mesh? What do you need it for? If you have an explicit expression for your SDF, then you don’t need a mesh. But if you need a mesh for something else, you can still use the explicit expression. Or, you can interpolate the SDF on the mesh.

But what is the use of this mesh?

I’d like to do an FEM simulation using something like gridAP.

But if you need a mesh for something else, you can still use the explicit expression.

I think the challenge is that most FEM libraries (at least the ones I’m familiar with) expect standard meshes as inputs. Although, perhaps there’s an easy way around this?

Thanks for the help!

I am not seeing the problem from your point of view, I suspect. Typically the mesh is needed to deal with the complexity of the geometrical domain, not the SDF, so that is what drives the mesh construction. Somehow I get the feeling that you want to create a mesh to reflect the available SDF?

Thanks for being patient :grinning:

Typically the mesh is needed to deal with the complexity of the geometrical domain, not the SDF, so that is what drives the mesh construction. Somehow I get the feeling that you want to create a mesh to reflect the available SDF?

Currently, I’m primarily using the zero-level set of the SDF to describe various geometries themselves. But I’m also using the SDF because it has several other useful features (especially related to optimization).

In theory, I could just use a mesh directly. After all, as you say, the mesh can describe a complicated geometry rather well. But then I miss out on some of the other features of my SDF (for one I’m using a rather robust library that already has SDFs defined for various shapes in 2D and 3D).

So yes, I’d essentially like to mesh the interior of the zero-level contour of my SDF. That way I can use this geometrical description within an FEM solve (and do some additional processing on it).

It seems like GitHub - JuliaGeometry/Meshing.jl: Meshing and isosurface extraction algorithms should work, if I’m understanding the question correctly.

For example: API · Meshing

1 Like

Perfect! It produces meshes for SDFs, as I was hoping. Thanks!