Meshes and output

Import and geometry

The import layer first constructs a solver-independent ImportedMesh containing vertices, tetrahedral connectivity, volume groups and tagged face sets. Negative orientations are corrected. Boundary tags are mapped to the names used by the semidiscretization; each exterior face must belong to exactly one boundary set unless untagged boundaries are explicitly allowed.

MaxwellTrixi.ImportedMesh — Type
ImportedMesh(vertex_coordinates, EToV; element_groups, group_names,
             face_sets, face_set_names, edge_nodes)

Linear tetrahedral mesh as read from a file, before any solver-specific processing. vertex_coordinates is a tuple of three coordinate vectors, EToV the K x 4 element-to-vertex connectivity. element_groups holds one integer tag per element and face_sets maps an integer tag to the faces of that set, each face given by its three vertex ids. Names are optional and map a tag to a string. edge_nodes maps a sorted pair of vertex ids to the coordinates of the mid-edge node of a quadratic tetrahedron; it is empty for straight-sided meshes. Tetrahedra with negative Jacobian are reoriented on construction.

Build a solver mesh with DGMultiMesh(dg, imported), curved if edge_nodes is not empty.

source
MaxwellTrixi.read_gambit — Function
read_gambit(path)

Read a linear tetrahedral mesh from a Gambit neutral file (.neu) into an ImportedMesh. Element groups become element tags with the group name, boundary condition sets become face sets numbered in file order with the set name.

source
MaxwellTrixi.read_gmsh — Function
read_gmsh(path; size_factor = 1.0, order = 1, verbose = false)

Read a tetrahedral mesh from a Gmsh .msh file of any format version into an ImportedMesh. Physical groups of volumes become element tags, physical groups of surfaces become face sets, both keyed by the physical tag with the physical name when one is defined. Quadratic tetrahedra keep their mid-edge nodes, which makes the DGMultiMesh curved; higher orders are reduced to their corner vertices. A .geo geometry file is meshed first, with every prescribed mesh size multiplied by size_factor, which gives a resolution family from one geometry, and at the given order, 1 or 2; Gmsh places the nodes of order 2 on the curved geometry. Requires the Gmsh.jl package: using Gmsh before calling.

source
Trixi.DGMultiMesh — Method
DGMultiMesh(dg::DGMulti, imported::ImportedMesh;
            is_on_boundary = nothing, allow_untagged_boundary = false)

Build the solver mesh of an imported tetrahedral mesh. Face sets of the file become boundary keys, see face_set_key. is_on_boundary adds coordinate-predicate boundaries in the style of Trixi's DGMultiMesh. With edge nodes, the elements are mapped by their quadratic shape functions and the mesh is Curved().

source
MaxwellTrixi.face_set_key — Function
face_set_key(tag, names)

Key used for a face set in boundary_conditions: the set name as a Symbol if one exists, otherwise tag_<tag>.

source
MaxwellTrixi.boundary_face_sets — Function
boundary_face_sets(imported, md, fv; extra = NamedTuple(), allow_untagged_boundary = false)

Map the face sets of imported to global face ids of the MeshData md, using the reference element face vertices fv. Sets consisting of interior faces only are skipped; a set mixing boundary and interior faces is an error. extra adds face sets that were tagged by coordinate predicates. Every boundary face must end up in exactly one set unless allow_untagged_boundary is set.

source
MaxwellTrixi.MESH_REGISTRY — Constant
MESH_REGISTRY

Reference meshes available through download_mesh. Gambit files come from nodal-dg (Hesthaven, Warburton) and MIDG2 (Warburton), Gmsh meshes and the sphere-in-box geometry from OpenSEMBA/dgtd (BSD-3-Clause). The .geo file is meshed on demand by read_gmsh at any size_factor.

source
MaxwellTrixi.download_mesh — Function
download_mesh(name; directory = default_mesh_directory())

Return the local path of the reference mesh name from MESH_REGISTRY, downloading it into directory unless the file is already there.

source

Quadratic Gmsh elements retain their edge nodes and use a quadratic geometry map $x=\Phi_K(r)$. Physical differentiation and quadrature use the map's metric terms and $J=\det(\partial\Phi_K/\partial r)$. The solution degree is independent of the geometry degree. Higher-order imported Gmsh geometry is reduced to its corner vertices; it is not retained at arbitrary order.

Point evaluation

For a point located in element $K$, interpolation evaluates

\[u_h(x)=\sum_a u_{K,a}\,\ell_a(\Phi_K^{-1}(x)).\]

The evaluator locates points once and caches their element and interpolation weights. Affine tetrahedra are located by barycentric coordinates. Curved tetrahedra and DGSEM hexahedra invert the element map by Newton iteration; DGSEM then interpolates with the tensor-product basis. Rebuild an evaluator after mesh adaptation. A point on a DG interface receives one element trace rather than an average of both traces.

MaxwellTrixi.PointEvaluator — Type
PointEvaluator(points, semi)

Interpolation of a solution to points, on the straight-sided or curved tetrahedra of a DGMultiMesh or on the hexahedra of any three-dimensional DGSEM mesh. Each point is located in its element once; evaluator(u_ode, semi) then returns the state at every point.

source

VTK and ParaView

The package's VTK solution writer targets DGMulti tetrahedra, including curved geometry. It exports high-order Lagrange cells and can write a PVD time collection. DGSEM output uses Trixi's SaveSolutionCallback and Trixi2Vtk instead. These are different output paths.

MaxwellTrixi.write_mesh_vtk — Function
write_mesh_vtk(imported::ImportedMesh, prefix)

Write prefix_volume.vtu with all tetrahedra and the cell data element_group, and prefix_faces.vtu with all tagged faces and the cell data face_tag and on_boundary, for inspection in ParaView. Returns the written file names.

source
MaxwellTrixi.write_solution_vtk — Function
write_solution_vtk(u_ode, semi, filename; solution_variables = cons2cons)

Write the solution u_ode of the DGMulti semidiscretization semi as Lagrange tetrahedra of the solution degree to filename.vtu, one point field per variable of solution_variables. Returns the written file names.

source
write_solution_vtk(u_odes, times, semi, prefix; solution_variables = cons2cons)

Write one .vtu file per entry of u_odes and a ParaView collection prefix.pvd that attaches times to them, for example write_solution_vtk(sol.u, sol.t, semi, "cavity"). Returns the collection file name.

source
MaxwellTrixi.SaveVtkCallback — Type
SaveVtkCallback(; interval = 0, dt = nothing,
                save_initial_solution = true, save_final_solution = true,
                output_directory = "out", filename = "solution",
                solution_variables = cons2prim)

Write the solution as VTK files during the simulation, every interval accepted time steps or every dt in simulation time, through write_solution_vtk. The files <filename>_<step>.vtu and the ParaView collection <filename>.pvd are written to output_directory; the collection is updated after every output, so a running simulation can be inspected.

source

The P4est dipole ParaView script is in utils/paraview/dipole_p4est.py. It shows actual element edges in a clipped half-domain and an $H_y$ slice. The field and linear-mesh collections must contain matching times. The repository README contains the conversion commands. Rendering from element edges avoids relying on refinement-level cell data from the converter.

Native field slices

PlotData2D on Trixi main provides slices of three-dimensional affine DGMulti tetrahedra. This is the path used by the tetrahedral figure and video scripts. Curved tetrahedral slicing is currently unsupported by that native path; the Mie visualization requests an affine mesh explicitly, while the numerical curved-mesh examples remain available.

The P4est visualization uses a Cartesian hexahedral slice routine. It preserves separate DG traces and element outlines and updates geometry together with the field values during AMR. It is not a general curved-hexahedron slicer.