Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/src/meshes/dgmulti_meshes.jl
2055 views
1
# By default, Julia/LLVM does not use fused multiply-add operations (FMAs).
2
# Since these FMAs can increase the performance of many numerical algorithms,
3
# we need to opt-in explicitly.
4
# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details.
5
@muladd begin
6
#! format: noindent
7
8
"""
9
DGMultiMesh{NDIMS, ...}
10
11
`DGMultiMesh` describes a mesh type which wraps `StartUpDG.MeshData` and `boundary_faces` in a
12
dispatchable type. This is intended to store geometric data and connectivities for any type of
13
mesh (Cartesian, affine, curved, structured/unstructured).
14
"""
15
mutable struct DGMultiMesh{NDIMS, MeshType, MeshDataT <: MeshData{NDIMS}, BoundaryFaceT}
16
md::MeshDataT
17
18
boundary_faces::BoundaryFaceT
19
20
current_filename :: String
21
unsaved_changes :: Bool
22
23
function DGMultiMesh{NDIMS, MeshType, MeshDataT, BoundaryFaceT}(md,
24
bd) where {NDIMS,
25
MeshType,
26
MeshDataT,
27
BoundaryFaceT
28
}
29
return new{NDIMS, MeshType, MeshDataT, BoundaryFaceT}(md, bd, "", true)
30
end
31
end
32
33
@inline Base.ndims(::DGMultiMesh{NDIMS}) where {NDIMS} = NDIMS
34
@inline ncells(mesh::DGMultiMesh) = Int(mesh.md.num_elements)
35
36
get_name(mesh::DGMultiMesh) = mesh |> typeof |> nameof |> string
37
38
function get_element_type_from_string(input::String)
39
str = lowercase(input)
40
if startswith(str, "line")
41
return Line
42
elseif startswith(str, "tri")
43
return Tri
44
elseif startswith(str, "tet")
45
return Tet
46
elseif startswith(str, "quad")
47
return Quad
48
elseif startswith(str, "hex")
49
return Hex
50
elseif startswith(str, "wedge")
51
return Wedge
52
elseif startswith(str, "pyr")
53
return Pyr
54
else
55
@error "Unknown element type: $input"
56
end
57
end
58
59
const SerialDGMultiMesh{NDIMS} = DGMultiMesh{NDIMS}
60
@inline mpi_parallel(mesh::SerialDGMultiMesh) = False()
61
62
# enable use of @set and setproperties(...) for DGMultiMesh
63
function ConstructionBase.constructorof(::Type{DGMultiMesh{T1, T2, T3, T4}}) where {
64
T1,
65
T2,
66
T3,
67
T4
68
}
69
DGMultiMesh{T1, T2, T3, T4}
70
end
71
72
function Base.show(io::IO, mesh::DGMultiMesh{NDIMS, MeshType}) where {NDIMS, MeshType}
73
@nospecialize mesh # reduce precompilation time
74
print(io, "$MeshType DGMultiMesh with NDIMS = $NDIMS.")
75
end
76
77
function Base.show(io::IO, ::MIME"text/plain",
78
mesh::DGMultiMesh{NDIMS, MeshType}) where {NDIMS, MeshType}
79
@nospecialize mesh # reduce precompilation time
80
if get(io, :compact, false)
81
show(io, mesh)
82
else
83
summary_header(io, "DGMultiMesh{$NDIMS, $MeshType}, ")
84
summary_line(io, "number of elements", mesh.md.num_elements)
85
summary_line(io, "number of boundaries", length(mesh.boundary_faces))
86
for (boundary_name, faces) in mesh.boundary_faces
87
summary_line(increment_indent(io), "nfaces on $boundary_name",
88
length(faces))
89
end
90
summary_footer(io)
91
end
92
end
93
94
# This constructor is called by load_mesh_serial. Note that constructing the mesh this way
95
# doesn't specify whether the mesh is affine. We assume the more general case (non-affine).
96
function DGMultiMesh(md::MeshData{NDIMS}, boundary_names = []) where {NDIMS}
97
return DGMultiMesh{NDIMS, NonAffine, typeof(md), typeof(boundary_names)}(md,
98
boundary_names)
99
end
100
end # @muladd
101
102