Hot answers tagged

58 votes
Accepted

A geometric multigrid solver for Mathematica?

Background Details about multigrid solvers can be found in this pretty neat script by Volker John. That's basically the source from which I drew the information to implement the V-cycle solver below. ...
Henrik Schumacher's user avatar
43 votes
Accepted

How to perform Loop subdivision on a triangle mesh with Mathematica?

We need quite a bit of preparation. In the first place we need methods to compute cell adjacency matrices from here. I copied the code for completeness. ...
Henrik Schumacher's user avatar
41 votes
Accepted

Smoothing 3D contours as post processing

As announced before, here my take on the mean curvature flow for surfaces. The code is rather lengthy and I tried to recycle as much as possible from this post about finding minimal surfaces (solving ...
Henrik Schumacher's user avatar
25 votes
Accepted

Catmull-Clark and Doo-Sabin Subdivision Implementations

Catmull-Clark Subdivision Indeed, I have some code for Catmull-Clark subdivision and I planned to post it here for quite some time. This seems to be a good opportunity. The code is optimized for ...
Henrik Schumacher's user avatar
24 votes

Making holes from maze generated Graphics3D

Lets start by making a symbolic representation of maze, with BooleanRegion using graphic primitives. That will be our basis for discretization by any method. Number ...
Pinti's user avatar
  • 6,453
24 votes
Accepted

Making holes from maze generated Graphics3D

Here's an approach that unions the primitives as rasters, meshes, and smooths. Data from OP: ...
Greg Hurst's user avatar
  • 34.7k
23 votes
Accepted

How to access FEM shape functions?

There are no surface element shape functions. There are, however, the normal shape functions. Load the package: Needs["NDSolve`FEM`"] This gives you the ...
user21's user avatar
  • 38.5k
23 votes
Accepted

Making a graph or network interactively over an image

There are many ways to do this, modifying, improving my method or doing a completely different thing. My goal here is to show a very basic idea that should give you a start. ...
Vitaliy Kaurov's user avatar
21 votes
Accepted

How to generate a mesh with quadrilateral elements?

Based on the tutorial here QuadElement meshes behave exactly the same as TriangleElement meshes, with the exception that, for linear quad elements, four incidents per element are needed, and, for ...
Young's user avatar
  • 7,375
20 votes
Accepted

Eliminate an unexpected mesh line

The blue line occurs at the edge of the function, where ϕ wraps from to 0. We can get ...
2012rcampion's user avatar
  • 7,782
20 votes
Accepted

How to get a specified number of points that are nearly equally spaced in a closed rectangle

There is a neat (and widely known) trick to produce n approximately evenly distributed points in a disk, or on any surface of revolution. Points are placed on a ...
Szabolcs's user avatar
  • 231k
19 votes
Accepted

Hexagonal Mesh on a 3D surface

Update: With the function top defined in the original post you can replicate all the cool things you see in rm-rf's answer in the linked Q/A. For example, with a ...
kglr's user avatar
  • 363k
19 votes

DelaunayMesh in a specified closed region - creating a concave hull from a set of points

What you want is the 2D alpha shape to try to get close to the outline you seek. Of course, it's no longer a Delaunay triangulation since you're deleting certain polygons from the ...
RunnyKine's user avatar
  • 32.8k
19 votes

Voronoi tessellations on meshed surfaces

Using the Geodesics in Heat Algorithm implemented here, we can calculate the distances of all vertices on the surface to a given vertex. By repeating this algorithm on a selected subset of vertices on ...
Dunlop's user avatar
  • 3,783
19 votes

A geometric multigrid solver for Mathematica?

3D Example The problem with direct solvers is that starting in 3 dimensions, their performance for dealing with matrices stemming from PDEs drops rapidly. This is why I wanted to show at least one 3-...
Henrik Schumacher's user avatar
19 votes
Accepted

Smoother jelly / water effect on an image

perhaps: ...
kglr's user avatar
  • 363k
18 votes
Accepted

FEM: how to choose FEM element type

There is good news and bad news. So right now there is no option to make MeshRegion use Hex elements. However, you can use ...
user21's user avatar
  • 38.5k
18 votes

How to generate a mesh with quadrilateral elements?

Here is a different approach. The idea is to first generate a second order triangle mesh. Next a center coordinate is added in every triangle. Then we split every triangle into three first order quads ...
user21's user avatar
  • 38.5k
18 votes
Accepted

How to obtain the cell-adjacency graph of a mesh?

I think, I found a general and even faster way, but I haven't tested it for $1$- or $3$-dimensional MeshRegions. The following function computes the cell-vertex-...
Henrik Schumacher's user avatar
17 votes
Accepted

How to convert a surface into a solid

Method 1: Construct mesh elements manually We can triangulate a periodic quad-lattice on the surface: ...
Michael E2's user avatar
  • 228k
17 votes

Lloyd relaxation on VoronoiMesh

Here's my take on Lloyd's algorithm. The code I present here should not be too hard to encapsulate into a routine; I have only elected to present it in this way so that I can animate the progress of ...
J. M.'s persistent exhaustion's user avatar
17 votes
Accepted

How to mesh a region using adaptive cubic elements

I discarded my previous approach to generate cubes, then fuse them together, since it seems to do a lot of wasted work. Instead, I propose here my version of a cartesian mesher. The approach is ...
MarcoB's user avatar
  • 64.5k
17 votes

Catmull-Clark and Doo-Sabin Subdivision Implementations

Doo-Sabin Subdivision To my own surprise, Doo-Sabin subdivision is in many ways much easier to implement than Catmull-Clark subdivision. The only real problem I met was to compute the faces created at ...
Henrik Schumacher's user avatar
17 votes
Accepted

Creating a Hexagonal Lattice with VoronoiMesh

Here is what I was suggesting in comments: ...
MarcoB's user avatar
  • 64.5k
16 votes

DelaunayMesh in a specified closed region - creating a concave hull from a set of points

I was writing this code because when I googled "Concave Hull Mathematica" I didn't find this post. I went through the trouble of taking this code and improving the performance, and bringing it up to ...
Jason B.'s user avatar
  • 66.3k
16 votes

How to generate a mesh with quadrilateral elements?

That's not possible in general in V11.0. The only primitive from which a quad mesh can be generated is ToElementMesh[Rectangle[]] or ...
user21's user avatar
  • 38.5k
16 votes

How to generate a mesh with quadrilateral elements?

this is a bit of a hack but it works for this example: generate separate rectangle meshes -- note the connected edge nodes must be exactly coincident. ...
george2079's user avatar
  • 38.7k
16 votes

How to generate a mesh with quadrilateral elements?

Edit: This method is now implemented as StructuredMesh function (2D and 3D) in FEMAddOns package. With minor enhancements it is also implemented in MeshTools ...
Pinti's user avatar
  • 6,453
15 votes
Accepted

How to calculate a Delaunay mesh nerve?

The approach I would take is the following: Clear definitions, load a sample image, find corners in the image using the method you indicated in the OP: ...
MarcoB's user avatar
  • 64.5k
15 votes

Finite element mesh not resolving features

These should work: Method 1 ...
user21's user avatar
  • 38.5k

Only top scored, non community-wiki answers of a minimum length are eligible