# 16FEM in Three Dimensions

## 16.1 Creating Three-Dimensional Meshes

Our first task in developing three-dimensional (3d) FEM capability is to generate 3d meshes to describe our geometries. Fortunately, `gmsh` is well equipped to do this, with its two-dimensional (2d) meshing capabilities extending directly into three dimensions. As in the case of 2d meshes, there are many ways to generate a given geometry in three dimensions. In this chapter we will consider only one of these approaches. The `gmsh` documentation and many online sources should be consulted for a comprehensive discussion of this topic.

A problem that we will encounter using unstructured 3d meshes is that visualizing what we have done can be difficult; there is simply too much going on. In the examples in this chapter, many of the figures of meshed structures were generated using low-resolution meshing. This is necessary to make these figures at all useful. The `.geo` file accompanying these examples will show the resolution used to generate any results quoted from the FEM analysis. Also, the `gmsh` ability to rotate a figure in space was utilized in generating some of the figures. Since the rotation chosen for a figure was arbitrary (it looked good), details of the rotation are not given.

The `gmsh` script `struct16_1.geo` shows the construction of a cube:

``````// struct16_1.geo
// first experiments with 3D

lc = 1;

Point(1) = {-.5, -.5, -.5, lc};
Point(2) = {.5, -.5, -.5, lc};
Point(3) = {.5, .5, -.5, lc}; Point(4) = {-.5, .5, -.5, ...``````

Get Introduction to Numerical Electrostatics Using MATLAB now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.