Importing Meshes
You can import a mesh from a COMSOL Multiphysics native file or from another meshing sequence. In 3D you can also import meshes from NASTRAN, STL, VRML, sectionwise, PLY, and 3MF files. In 2D you can also import 2D meshes from NASTRAN (the third coordinate must then be the same for all mesh points) and from sectionwise files. See also Import for details about the options in the Import node.
Importing a mesh to a component where the Geometry node defines a geometry clears the geometry. In order to use an imported mesh together with an existing geometry, import it in a mesh part. Then use a Copy node under the Mesh node of the geometry’s component to transfer the imported mesh and associate it with the geometry.
When a mesh is imported into COMSOL Multiphysics, the Import node automatically determines a partitioning of the mesh into domains, boundaries, edges, and points. If the automatically performed partitioning does not match the requirements, you can modify the face partitioning by manually adjusting the corresponding parameters. To hide the geometry based on an imported mesh in a view, use an Hide for Mesh Import node.
To import additional meshes, add another Import node. Then COMSOL Multiphysics adds the elements and points of the newly imported mesh to the existing mesh.
Meshes from different Import nodes form an assembly.
Imported Meshes and Element Orders
After importing mesh data on the COMSOL Multiphysics native format or NASTRAN format, you can change the element order for the shape functions used for the COMSOL Multiphysics simulation regardless of whether the imported data contained first- or second-order element node information. You change the element order used in the Settings window of a physics interface (for example, Heat Transfer in Solids, Solid Mechanics, or Laminar Flow) in the Discretization section. The second-order element node information is primarily used for representing curved boundaries. However, second-order information on the boundary will not be adjusted to the curvature of the boundary unless the original imported data contains second-order element node information that represent such curvature. This means, for example, that a triangular element on a curved boundary cannot in general have its element nodes all lying in the same plane. If you import a mesh containing second-order element node information and then lower the order in the Discretization setting to linear, then the curvature of the boundary is no longer respected. If you import a mesh containing second-order element node information and increase the element order in the Discretization settings to cubic or higher, the higher-order nodes are inserted on the boundary based on interpolation using the second-order element data.
If the imported mesh contains second-order elements, the Statistics window includes the following information: Imported mesh with second-order elements.
Importing Meshes from Files with Length Unit
When you import mesh from a file that defines a length unit, the import operation scales the imported mesh to match the length unit of the Component with the Mesh node containing the corresponding Import node. For an Import node under a Mesh Part node, the import operation scales the mesh if the Use units check box is selected.
Using Several Meshing Sequences of Imported Mesh Type
You can define several meshing sequences for the same geometry (see Adding, Editing, and Building Meshing Sequences). If the geometry sequence is empty (a necessary condition for the Imported mesh sequence type), the first Mesh node under the Meshes node defines a topology and is referred to as the master sequence. All of the other Mesh nodes should define a geometry topologically similar to the one defined by the master sequence. Two geometries are considered to be similar if they have the same number of geometric entities and their points have the same coordinates.
When you build a non-master sequence, COMSOL Multiphysics first builds the master sequence. If the build of the master sequence fails or if the geometries defined by these two sequences are not similar, an error occurs.
If you want to use the geometric multigrid solver, several meshing sequences must be added first.
Remeshing Imported Meshes
It is possible to remesh an imported mesh to create a new mesh more suited to solving the problem at hand. See Creating Geometry from Mesh for more information.
Modifying Imported Meshes
For 3D and 2D imported meshing sequences, the Refine, Adapt, and Convert operations are available for modifying imported meshes. For 3D imported meshes, the Free Tetrahedral, Free Triangular, and Free Quad operations are also available. For 1D imported meshing sequences, the Refine and Adapt operations are available. See Refine, Adapt, Convert, Free Tetrahedral, Free Triangular, and Free Quad for more information.
Importing Externally Generated Mesh Data
It is possible to import externally generated mesh data using a COMSOL mesh file. The file format contains a section with mesh points coordinates, followed by sections with mesh element information, divided into separate subsections for each mesh element type (see Mesh in the chapter The COMSOL File Formats in the COMSOL Multiphysics Programming Reference Manual).
Importing Incomplete Mesh Data
A COMSOL Multiphysics mesh contains elements for all space dimension levels. For example, a tetrahedral mesh consists of domain (tetrahedra), boundary (triangles), edge, and vertex elements. Furthermore, each element has an index to the geometric entity it belongs to. If a mesh file is incomplete — for example, if it only contains tetrahedra — the Import operation automatically generates the missing element data. To illustrate this behavior, import the file mesh_example_1.mphtxt from
applications/COMSOL_Multiphysics/Meshing_Tutorials/
This file contains domain elements only with geometric entity information dividing the mesh into two domains. Now, export the imported mesh to a file using the default settings. Then, compare the resulting file (see mesh_example_4.mphtxt) with the file mesh_example_1.mphtxt and note that the exported file contains complete mesh information; that is, it contains domain elements, boundary elements, edge elements, vertex elements, and geometric entity information.
Transferring Domain Information
If you have an externally generated mesh with a predefined partitioning of the elements, you can transfer this partitioning to COMSOL Multiphysics by specifying geometric entity information in the .mphtxt file. To illustrate this, import the file mesh_example_2.mphtxt. This file contains domain elements only, without any geometric entity information. The imported mesh consists of one domain only. Note that the imported mesh from the file mesh_example_1.mphtxt consists of two domains according to the given geometric entity information.
Transferring Boundary Information
To transfer boundary partitioning information of an externally generated mesh you need to include boundary elements with the corresponding geometric entity information in the .mphtxt file. To illustrate this, import the file mesh_example_3.mphtxt with the Boundary partitioning option set to Minimal. This file contains domain and boundary elements with geometric entity information defining 5 boundaries. Note that the imported mesh also has 5 boundaries. Now import the file mesh_example_1.mphtxt, which has no boundary information, using the same import settings. Note that the imported mesh now has 3 boundaries only because the Minimal option generates the minimal possible partitioning that is required by the topological criteria.
Nonconforming Meshes
If you import mesh data defining a nonconforming mesh (for a definition, see Conforming Meshes) the import operation will typically create edge or face elements of the mesh edges or mesh faces corresponding to each nonconformity in the mesh because these mesh edges or mesh faces are typically only adjacent to one 2D or 3D element each. To illustrate this, import the 2D mesh file mesh_nonconforming.mphtxt (available in the COMSOL Multiphysics installation under applications/COMSOL_Multiphysics/Meshing_Tutorials/) using default settings. This file contains 8 mesh vertices and 3 quad elements only, defining a mesh with a so-called hanging node. Note that the imported mesh gets 2 domains, 8 edges, and 6 vertices.
About the Sectionwise File Format
A sectionwise file is a text file with the extension .txt that stores information defining an unstructured mesh of simplex elements in any dimension. A sectionwise file starts with an optional header followed by the sections:
Coordinates. Starts with the line % Coordinates followed by one line for each vertex (1 to 3 columns, depending on the space dimension for x, y, and z).
Elements. Starts with the line % Elements followed by one line for each (simplex) element. The number of columns (1, 2, 3, or 4) determines the element type (vertex, edge, triangle, or tetrahedron). Each row contains the row indices (1-based) of the points in the Coordinates section defining the corresponding element.
Data. An optional section starting with % Data followed by one line of data values for each vertex.