Modeling Irregular Shapes: How to Import Curve Data and Loft a Solid
Irregular shapes can come in several different formats. For example, we have previously discussed importing STL files and NASTRAN® meshes into the COMSOL Multiphysics® software. These formats are common when working with scanned biological data. In this blog series, we will look at different ways of handling irregular shapes in COMSOL Multiphysics.
An Example of an Irregular Shape: The Human Head
One possible format when working with scanned data is text files with coordinate data from images of slices produced by an MRI or CT scan. In this example, let’s look at a case where we have a number of files or cross-sectional coordinates from different planes of a human head. Each coordinate file represents a curve of the outer surface of the head in that particular plane.
In short, the procedure includes:
- Creating curve objects of each of the text files
- Partitioning the edges of the curves to make sure that the points are aligned in the loft direction
- Lofting the curves into a solid
- Hiding unnecessary edges to produce a consistent shape
Now, let’s look at each step in more detail.
To be able to import a text file in the Interpolation Curve feature, the coordinates need to be organized in the Sectionwise format. This is a native format of COMSOL Multiphysics in which the text file is organized to format one section with coordinates, one with the element connectivity, and one with data columns. The first two sections are needed here, while the data columns can be omitted when using this format for geometry creation. Below is an example of a file in the Sectionwise format:
%Coordinates One to three columns containing x, y (optional), and z (optional) %Elements Triangulation where each row contains the row indices of the points in the Coordinates section that make up one element (triangular in 2D, tetrahedral in 3D) %Data (funname) Column of data values for each point
In this example, we have 17 text files containing coordinate data from the 3D object. One Interpolation Curve feature per text file is added, which gives 17 curve objects in total. The Closed curve setting is used to ensure that the created curve objects are indeed closed and that the first- and second-order derivatives are continuous everywhere. In COMSOL Multiphysics, lofting a closed curve produces a solid object, while lofting an open curve produces a surface. The Relative tolerance is increased to 0.001 or 0.01 to produce a smoother representation of the curve. With the default tolerance (which is 0), the curves have a more jagged shape. In this example, the top of the head is represented by a point.
The Settings window for the Interpolation Curve feature (left) and all of the curves representing the outer shell of a head (right). The Relative tolerance is increased to 0.001 or 0.01 to produce a smoother representation. The Closed curve setting ensures that the curve becomes closed and has continuous first- and second-order derivatives everywhere.
Considerations for Lofting Solids
Now that we have the curve objects that define the outline of each cross section of the head, we can create the solid shape with the Loft operation. The Loft operation is one of the geometry modeling tools included in the Design Module, which you can read about in this introductory blog post. Before setting up the Loft operation, we need to make sure that the curve objects are suitable as profiles for lofting. Lofting curves or surfaces to a solid requires the different profiles to have the same number of edges and points. The exception is the first and last objects (called the start and end profiles), which can be points, as is the case for the top of the head in this example.
A closed interpolation curve has two vertices, but it is not possible to choose their positions. So, the criterion mentioned above — to have the same number of edges and points of the intermediate objects — is already fulfilled, as all of the created curves have two edges. However, where these points are placed on the profile objects is also important. When the loft works its way through the curves, it connects all of the points with edges in the direction of the loft. If the points are not positioned along a fairly straight line, the resulting surfaces might become distorted. Therefore, we often need to partition the edges further to accomplish a good representation of all of the surfaces. To do this, we can use two different procedures: creating curves from data and lofting them into an object.
Partitioning the Edges of Curves
How to partition the edges and which features to use for this purpose is not an exact science, but something for which you use some trial and error and decide based on what looks best after a visual inspection. Here, we use the Partition Objects and Partition Edges features. The advantage of using the Partition Objects operation is that this option allows multiple curve objects to be partitioned at locations defined by the points of intersection with a selected plane. As some of the interpolation curves already contain points that are fairly well aligned on the front and back of this human head example, a Work plane is added at y = 0 to create more points along the same imaginary lines.
Partitioning some of the curves using a Work plane at y = 0. The settings for the Partition Objects feature (left). The curve objects highlighted in blue (right) are partitioned at two places using the work plane, which is pictured as a gray sheet with a rectangular grid.
The Partition Edges feature partitions selected edges based on either specified relative arc lengths or by projecting one or several vertices. As we want the vertices to line up fairly well when lofting curves, projecting vertices is a good option. However, for some edges, it is better to specify a relative arc length to have more control over where the vertex is created.
The Settings windows for the Partition Edges features, showing both the Vertex projection (left) and the Arc length (middle) specification types, and the edges selected for a vertex projection (right).
To verify that the geometry objects have the same amount of edges and points, we click the Select Objects button above the Graphics window, select a curve object in the Graphics window, and then click the Measure button in either the Geometry or Mesh tab. The output of this measurement is written to the Messages log.
Lofting the Solid
Now that the points are roughly aligned, it is time to create the solid. The Loft feature contains many options, but we only use the most straightforward procedure here: adding all of the curve objects and the point on the top of the head in the Profile objects list. The start and end profiles are determined automatically by the Loft operation. As shown in the left image below, there are many collapsed sections (highlighted in blue) that can be used to fine-tune the loft; for example, to specify the direction of the loft. The collapsed sections are not used in this example.
A surface or solid object lofted from closed continuous profile curves has at least two seams that go through the vertices of the profile curves, creating two face partitions. More seams may be introduced by the operation, depending on the alignment of the vertices on the different curves. If the profile curves have discontinuous tangents, additional seams are introduced and go through these points. No additional seams are introduced when using the default setting Face partitioning: Minimal in the Loft operation (see the image above), as is the case in this example.
If we want the lofted surface to be more partitioned — for example, to assign boundary conditions — the partitioning options Column and Grid can be used. The first option divides the surface along each vertex in the profile curves, while the latter also adds the profile curves. Yet another possibility is to use the different Partitions operations available in the Geometry ribbon. On the other hand, if we want to have a more clean appearance, we can use Virtual Operations to create composite faces. Ignore Edges is one of the features that can be used for this purpose, but Form Composite Faces also gives the same end result.
Learn Different Approaches for Modeling Irregular Shapes
This blog post has discussed the possibility of creating curves from coordinate data and then lofting these curves into a solid object. Upcoming posts in this blog series will discuss other possible formats as well as approaches for handling irregular shapes in COMSOL Multiphysics.
Download the file used to create the example featured here:
NASTRAN is a registered trademark of NASA.
- COMSOL Now
- Today in Science