Importing and Exporting Meshes
It can be useful to import meshes already created by external software or, alternatively, to export a mesh generated by COMSOL Multiphysics into other software. Importing an externally generated mesh can be helpful when a mesh is already saved in a file and recreating the geometry would be difficult and time consuming.
See the section Imported Meshes and Element Orders for information on how elements are curved when working with imported meshes and Mesh-Based Geometry sequences. See also Importing Meshes from Files with Length Unit and Importing Externally Generated Mesh Data for details about files containing length units, what to think about when importing incomplete mesh data and when transferring domain and boundary data.
The supported file formats for import, importing mesh data from results, and import of geometry to mesh are covered in different sections:
When you want to generate a computational mesh based on the imported mesh, or you just want to add boundary layers to an imported domain mesh, see the section Creating a Computational Mesh for Imported Mesh Data for more information.
Any mesh in the software can be exported for use in other models or into other software. The section Exporting Meshes gives more details about supported formats and settings for the export.
Imported Meshes and Element Orders
When a mesh operates on a geometry, elements are curved using the geometry, according to the specified geometry shape function. For imported meshes and mesh-based geometries, there are two possibilities:
If the imported mesh contains second-order elements, the Information section and Mesh Statistics include 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 checkbox is selected.
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 vertices 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.
See the section Creating a Computational Mesh for Imported Mesh Data for more information about generating a mesh that can be used for computation.
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 that 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.
See Conforming, Nonconforming, and Nonmatching Meshes for import of nonconforming mesh data.