From b1e395d5c81894da38a97d2d73cbd7e42b2a1557 Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Thu, 5 Sep 2024 16:08:25 +0200 Subject: [PATCH 01/13] add ambient dimension as type parameter for P4estMesh --- src/callbacks_step/analysis_dg2d.jl | 33 +++++++++++++++-- src/callbacks_step/analysis_dg3d.jl | 46 ++++++++++++++++++++++-- src/meshes/p4est_mesh.jl | 12 ++++--- src/solvers/dgsem_p4est/containers_2d.jl | 7 ++-- 4 files changed, 86 insertions(+), 12 deletions(-) diff --git a/src/callbacks_step/analysis_dg2d.jl b/src/callbacks_step/analysis_dg2d.jl index de6b9a2a4a6..4cd92ce7c5f 100644 --- a/src/callbacks_step/analysis_dg2d.jl +++ b/src/callbacks_step/analysis_dg2d.jl @@ -29,10 +29,39 @@ function create_cache_analysis(analyzer, mesh::TreeMesh{2}, return (; u_local, u_tmp1, x_local, x_tmp1) end +# Specialized cache for P4estMesh to allow for different ambient dimension from mesh dimension +function create_cache_analysis(analyzer, mesh::P4estMesh{2, NDIMS_AMBIENT}, + equations, dg::DG, cache, + RealT, uEltype) where {NDIMS_AMBIENT} + + # pre-allocate buffers + # We use `StrideArray`s here since these buffers are used in performance-critical + # places and the additional information passed to the compiler makes them faster + # than native `Array`s. + u_local = StrideArray(undef, uEltype, + StaticInt(nvariables(equations)), StaticInt(nnodes(analyzer)), + StaticInt(nnodes(analyzer))) + u_tmp1 = StrideArray(undef, uEltype, + StaticInt(nvariables(equations)), StaticInt(nnodes(analyzer)), + StaticInt(nnodes(dg))) + x_local = StrideArray(undef, RealT, + StaticInt(NDIMS_AMBIENT), StaticInt(nnodes(analyzer)), + StaticInt(nnodes(analyzer))) + x_tmp1 = StrideArray(undef, RealT, + StaticInt(NDIMS_AMBIENT), StaticInt(nnodes(analyzer)), + StaticInt(nnodes(dg))) + jacobian_local = StrideArray(undef, RealT, + StaticInt(nnodes(analyzer)), + StaticInt(nnodes(analyzer))) + jacobian_tmp1 = StrideArray(undef, RealT, + StaticInt(nnodes(analyzer)), StaticInt(nnodes(dg))) + + return (; u_local, u_tmp1, x_local, x_tmp1, jacobian_local, jacobian_tmp1) +end + function create_cache_analysis(analyzer, mesh::Union{StructuredMesh{2}, StructuredMeshView{2}, - UnstructuredMesh2D, - P4estMesh{2}, T8codeMesh{2}}, + UnstructuredMesh2D, T8codeMesh{2}}, equations, dg::DG, cache, RealT, uEltype) diff --git a/src/callbacks_step/analysis_dg3d.jl b/src/callbacks_step/analysis_dg3d.jl index 27e8a2b722f..fd501a7257c 100644 --- a/src/callbacks_step/analysis_dg3d.jl +++ b/src/callbacks_step/analysis_dg3d.jl @@ -35,9 +35,51 @@ function create_cache_analysis(analyzer, mesh::TreeMesh{3}, return (; u_local, u_tmp1, u_tmp2, x_local, x_tmp1, x_tmp2) end +# Specialized cache for P4estMesh to allow for different ambient dimension from mesh dimension function create_cache_analysis(analyzer, - mesh::Union{StructuredMesh{3}, P4estMesh{3}, - T8codeMesh{3}}, + mesh::P4estMesh{3, NDIMS_AMBIENT}, + equations, dg::DG, cache, + RealT, uEltype) where {NDIMS_AMBIENT} + + # pre-allocate buffers + # We use `StrideArray`s here since these buffers are used in performance-critical + # places and the additional information passed to the compiler makes them faster + # than native `Array`s. + u_local = StrideArray(undef, uEltype, + StaticInt(nvariables(equations)), StaticInt(nnodes(analyzer)), + StaticInt(nnodes(analyzer)), StaticInt(nnodes(analyzer))) + u_tmp1 = StrideArray(undef, uEltype, + StaticInt(nvariables(equations)), StaticInt(nnodes(analyzer)), + StaticInt(nnodes(dg)), StaticInt(nnodes(dg))) + u_tmp2 = StrideArray(undef, uEltype, + StaticInt(nvariables(equations)), StaticInt(nnodes(analyzer)), + StaticInt(nnodes(analyzer)), StaticInt(nnodes(dg))) + x_local = StrideArray(undef, RealT, + StaticInt(NDIMS_AMBIENT), StaticInt(nnodes(analyzer)), + StaticInt(nnodes(analyzer)), StaticInt(nnodes(analyzer))) + x_tmp1 = StrideArray(undef, RealT, + StaticInt(NDIMS_AMBIENT), StaticInt(nnodes(analyzer)), + StaticInt(nnodes(dg)), StaticInt(nnodes(dg))) + x_tmp2 = StrideArray(undef, RealT, + StaticInt(NDIMS_AMBIENT), StaticInt(nnodes(analyzer)), + StaticInt(nnodes(analyzer)), StaticInt(nnodes(dg))) + jacobian_local = StrideArray(undef, RealT, + StaticInt(nnodes(analyzer)), + StaticInt(nnodes(analyzer)), + StaticInt(nnodes(analyzer))) + jacobian_tmp1 = StrideArray(undef, RealT, + StaticInt(nnodes(analyzer)), StaticInt(nnodes(dg)), + StaticInt(nnodes(dg))) + jacobian_tmp2 = StrideArray(undef, RealT, + StaticInt(nnodes(analyzer)), + StaticInt(nnodes(analyzer)), StaticInt(nnodes(dg))) + + return (; u_local, u_tmp1, u_tmp2, x_local, x_tmp1, x_tmp2, jacobian_local, + jacobian_tmp1, jacobian_tmp2) +end + +function create_cache_analysis(analyzer, + mesh::Union{StructuredMesh{3}, T8codeMesh{3}}, equations, dg::DG, cache, RealT, uEltype) diff --git a/src/meshes/p4est_mesh.jl b/src/meshes/p4est_mesh.jl index 526f5d9f23b..b6deb02fab0 100644 --- a/src/meshes/p4est_mesh.jl +++ b/src/meshes/p4est_mesh.jl @@ -11,7 +11,8 @@ An unstructured curved mesh based on trees that uses the C library `p4est` to manage trees and mesh refinement. """ -mutable struct P4estMesh{NDIMS, RealT <: Real, IsParallel, P, Ghost, NDIMSP2, NNODES} <: +mutable struct P4estMesh{NDIMS, NDIMS_AMBIENT, RealT <: Real, IsParallel, P, Ghost, + NDIMSP2, NNODES} <: AbstractMesh{NDIMS} p4est :: P # Either PointerWrapper{p4est_t} or PointerWrapper{p8est_t} is_parallel :: IsParallel @@ -48,7 +49,8 @@ mutable struct P4estMesh{NDIMS, RealT <: Real, IsParallel, P, Ghost, NDIMSP2, NN ghost = ghost_new_p4est(p4est) ghost_pw = PointerWrapper(ghost) - mesh = new{NDIMS, eltype(tree_node_coordinates), typeof(is_parallel), + mesh = new{NDIMS, size(mesh.tree_node_coordinates, 1), + eltype(tree_node_coordinates), typeof(is_parallel), typeof(p4est_pw), typeof(ghost_pw), NDIMS + 2, length(nodes)}(p4est_pw, is_parallel, ghost_pw, @@ -66,8 +68,8 @@ mutable struct P4estMesh{NDIMS, RealT <: Real, IsParallel, P, Ghost, NDIMSP2, NN end end -const SerialP4estMesh{NDIMS} = P4estMesh{NDIMS, <:Real, <:False} -const ParallelP4estMesh{NDIMS} = P4estMesh{NDIMS, <:Real, <:True} +const SerialP4estMesh{NDIMS} = P4estMesh{NDIMS, NDIMS_AMBIENT, <:Real, <:False} +const ParallelP4estMesh{NDIMS} = P4estMesh{NDIMS, NDIMS_AMBIENT, <:Real, <:True} @inline mpi_parallel(mesh::SerialP4estMesh) = False() @inline mpi_parallel(mesh::ParallelP4estMesh) = True() @@ -87,7 +89,7 @@ function destroy_mesh(mesh::P4estMesh{3}) end @inline Base.ndims(::P4estMesh{NDIMS}) where {NDIMS} = NDIMS -@inline Base.real(::P4estMesh{NDIMS, RealT}) where {NDIMS, RealT} = RealT +@inline Base.real(::P4estMesh{NDIMS, NDIMS_AMBIENT, RealT}) where {NDIMS, NDIMS_AMBIENT, RealT} = RealT @inline function ntrees(mesh::P4estMesh) return mesh.p4est.trees.elem_count[] diff --git a/src/solvers/dgsem_p4est/containers_2d.jl b/src/solvers/dgsem_p4est/containers_2d.jl index 236d7d24c06..6af6fd6d90e 100644 --- a/src/solvers/dgsem_p4est/containers_2d.jl +++ b/src/solvers/dgsem_p4est/containers_2d.jl @@ -37,13 +37,14 @@ end # Interpolate tree_node_coordinates to each quadrant at the specified nodes function calc_node_coordinates!(node_coordinates, - mesh::P4estMesh{2}, - nodes::AbstractVector) + mesh::P4estMesh{2, NDIMS_AMBIENT}, + nodes::AbstractVector) where {NDIMS_AMBIENT} # We use `StrideArray`s here since these buffers are used in performance-critical # places and the additional information passed to the compiler makes them faster # than native `Array`s. tmp1 = StrideArray(undef, real(mesh), - StaticInt(2), static_length(nodes), static_length(mesh.nodes)) + StaticInt(NDIMS_AMBIENT), static_length(nodes), + static_length(mesh.nodes)) matrix1 = StrideArray(undef, real(mesh), static_length(nodes), static_length(mesh.nodes)) matrix2 = similar(matrix1) From 1d9a344c5e923385e3f700ae35a42d44d8cd335d Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Thu, 5 Sep 2024 16:31:04 +0200 Subject: [PATCH 02/13] add NDIMS_AMBIENT as parameter to serial/parallel aliases --- src/meshes/p4est_mesh.jl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/meshes/p4est_mesh.jl b/src/meshes/p4est_mesh.jl index b6deb02fab0..acb38aa8e13 100644 --- a/src/meshes/p4est_mesh.jl +++ b/src/meshes/p4est_mesh.jl @@ -9,7 +9,7 @@ P4estMesh{NDIMS} <: AbstractMesh{NDIMS} An unstructured curved mesh based on trees that uses the C library `p4est` -to manage trees and mesh refinement. +to manage trees and mesh refinement. """ mutable struct P4estMesh{NDIMS, NDIMS_AMBIENT, RealT <: Real, IsParallel, P, Ghost, NDIMSP2, NNODES} <: @@ -49,6 +49,11 @@ mutable struct P4estMesh{NDIMS, NDIMS_AMBIENT, RealT <: Real, IsParallel, P, Gho ghost = ghost_new_p4est(p4est) ghost_pw = PointerWrapper(ghost) + # To enable the treatment of a manifold of dimension NDIM embedded within an + # ambient space of dimension NDIMS_AMBIENT, we store both as type parameters and + # allow them to differ in the general case (e.g. when considering 2D surfaces in 3D). + # The ambient dimension NDIMS_AMBIENT is therefore set here in the inner constructor to + # size(mesh.tree_node_coordinates, 1). mesh = new{NDIMS, size(mesh.tree_node_coordinates, 1), eltype(tree_node_coordinates), typeof(is_parallel), typeof(p4est_pw), typeof(ghost_pw), NDIMS + 2, length(nodes)}(p4est_pw, @@ -68,8 +73,10 @@ mutable struct P4estMesh{NDIMS, NDIMS_AMBIENT, RealT <: Real, IsParallel, P, Gho end end -const SerialP4estMesh{NDIMS} = P4estMesh{NDIMS, NDIMS_AMBIENT, <:Real, <:False} -const ParallelP4estMesh{NDIMS} = P4estMesh{NDIMS, NDIMS_AMBIENT, <:Real, <:True} +const SerialP4estMesh{NDIMS, NDIMS_AMBIENT} = P4estMesh{NDIMS, NDIMS_AMBIENT, <:Real, + <:False} +const ParallelP4estMesh{NDIMS, NDIMS_AMBIENT} = P4estMesh{NDIMS, NDIMS_AMBIENT, <:Real, + <:True} @inline mpi_parallel(mesh::SerialP4estMesh) = False() @inline mpi_parallel(mesh::ParallelP4estMesh) = True() From dc55cca1c31752118e5693b553f6ff7fff68336c Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Thu, 5 Sep 2024 16:37:21 +0200 Subject: [PATCH 03/13] mesh.tree_node_coordinates should just be tree_node_coordinates in constructor. --- src/meshes/p4est_mesh.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/meshes/p4est_mesh.jl b/src/meshes/p4est_mesh.jl index acb38aa8e13..b0841fc8abe 100644 --- a/src/meshes/p4est_mesh.jl +++ b/src/meshes/p4est_mesh.jl @@ -53,8 +53,8 @@ mutable struct P4estMesh{NDIMS, NDIMS_AMBIENT, RealT <: Real, IsParallel, P, Gho # ambient space of dimension NDIMS_AMBIENT, we store both as type parameters and # allow them to differ in the general case (e.g. when considering 2D surfaces in 3D). # The ambient dimension NDIMS_AMBIENT is therefore set here in the inner constructor to - # size(mesh.tree_node_coordinates, 1). - mesh = new{NDIMS, size(mesh.tree_node_coordinates, 1), + # size(tree_node_coordinates, 1). + mesh = new{NDIMS, size(tree_node_coordinates, 1), eltype(tree_node_coordinates), typeof(is_parallel), typeof(p4est_pw), typeof(ghost_pw), NDIMS + 2, length(nodes)}(p4est_pw, is_parallel, From a0f0e207525094c8455f4f48cba632083eb89c00 Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Thu, 5 Sep 2024 21:46:29 +0200 Subject: [PATCH 04/13] update Base.show to include NDIMS_AMBIENT type parameter --- src/meshes/p4est_mesh.jl | 3 ++- src/solvers/dgsem_p4est/containers.jl | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/meshes/p4est_mesh.jl b/src/meshes/p4est_mesh.jl index b0841fc8abe..213aa63ae78 100644 --- a/src/meshes/p4est_mesh.jl +++ b/src/meshes/p4est_mesh.jl @@ -97,6 +97,7 @@ end @inline Base.ndims(::P4estMesh{NDIMS}) where {NDIMS} = NDIMS @inline Base.real(::P4estMesh{NDIMS, NDIMS_AMBIENT, RealT}) where {NDIMS, NDIMS_AMBIENT, RealT} = RealT +@inline ndims_ambient(::P4estMesh{NDIMS, NDIMS_AMBIENT}) where {NDIMS, NDIMS_AMBIENT} = NDIMS_AMBIENT @inline function ntrees(mesh::P4estMesh) return mesh.p4est.trees.elem_count[] @@ -106,7 +107,7 @@ end @inline ncellsglobal(mesh::P4estMesh) = Int(mesh.p4est.global_num_quadrants[]) function Base.show(io::IO, mesh::P4estMesh) - print(io, "P4estMesh{", ndims(mesh), ", ", real(mesh), "}") + print(io, "P4estMesh{", ndims(mesh), ", ", ndims_ambient(mesh), ", " real(mesh), "}") end function Base.show(io::IO, ::MIME"text/plain", mesh::P4estMesh) diff --git a/src/solvers/dgsem_p4est/containers.jl b/src/solvers/dgsem_p4est/containers.jl index f9830d0011c..a7f769eff1b 100644 --- a/src/solvers/dgsem_p4est/containers.jl +++ b/src/solvers/dgsem_p4est/containers.jl @@ -81,7 +81,7 @@ function Base.resize!(elements::P4estElementContainer, capacity) end # Create element container and initialize element data -function init_elements(mesh::Union{P4estMesh{NDIMS, RealT}, T8codeMesh{NDIMS, RealT}}, +function init_elements(mesh::Union{P4estMesh{NDIMS, NDIMS, RealT}, T8codeMesh{NDIMS, RealT}}, equations, basis, ::Type{uEltype}) where {NDIMS, RealT <: Real, uEltype <: Real} From 42ed48a6e4fcb3a80471934d1339a883faf1df32 Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Thu, 5 Sep 2024 21:56:25 +0200 Subject: [PATCH 05/13] fix typo --- src/meshes/p4est_mesh.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meshes/p4est_mesh.jl b/src/meshes/p4est_mesh.jl index 213aa63ae78..1ebad8b645e 100644 --- a/src/meshes/p4est_mesh.jl +++ b/src/meshes/p4est_mesh.jl @@ -107,7 +107,7 @@ end @inline ncellsglobal(mesh::P4estMesh) = Int(mesh.p4est.global_num_quadrants[]) function Base.show(io::IO, mesh::P4estMesh) - print(io, "P4estMesh{", ndims(mesh), ", ", ndims_ambient(mesh), ", " real(mesh), "}") + print(io, "P4estMesh{", ndims(mesh), ", ", ndims_ambient(mesh), ", ", real(mesh), "}") end function Base.show(io::IO, ::MIME"text/plain", mesh::P4estMesh) From b0873c854962614c2600a532d00f9240c5ad360a Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Fri, 6 Sep 2024 10:32:15 +0200 Subject: [PATCH 06/13] format --- src/meshes/p4est_mesh.jl | 3 ++- src/solvers/dgsem_p4est/containers.jl | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/meshes/p4est_mesh.jl b/src/meshes/p4est_mesh.jl index 1ebad8b645e..7cb3a7734e0 100644 --- a/src/meshes/p4est_mesh.jl +++ b/src/meshes/p4est_mesh.jl @@ -107,7 +107,8 @@ end @inline ncellsglobal(mesh::P4estMesh) = Int(mesh.p4est.global_num_quadrants[]) function Base.show(io::IO, mesh::P4estMesh) - print(io, "P4estMesh{", ndims(mesh), ", ", ndims_ambient(mesh), ", ", real(mesh), "}") + print(io, "P4estMesh{", ndims(mesh), ", ", ndims_ambient(mesh), ", ", real(mesh), + "}") end function Base.show(io::IO, ::MIME"text/plain", mesh::P4estMesh) diff --git a/src/solvers/dgsem_p4est/containers.jl b/src/solvers/dgsem_p4est/containers.jl index a7f769eff1b..3ef9cb2a421 100644 --- a/src/solvers/dgsem_p4est/containers.jl +++ b/src/solvers/dgsem_p4est/containers.jl @@ -81,7 +81,8 @@ function Base.resize!(elements::P4estElementContainer, capacity) end # Create element container and initialize element data -function init_elements(mesh::Union{P4estMesh{NDIMS, NDIMS, RealT}, T8codeMesh{NDIMS, RealT}}, +function init_elements(mesh::Union{P4estMesh{NDIMS, NDIMS, RealT}, + T8codeMesh{NDIMS, RealT}}, equations, basis, ::Type{uEltype}) where {NDIMS, RealT <: Real, uEltype <: Real} From be888bd2065d451de2f6da9430f5ce8a5fee659a Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Fri, 6 Sep 2024 11:21:39 +0200 Subject: [PATCH 07/13] SerialP4estMesh{NDIMS} and ParallelP4estMesh{NDIMS} do not need NDIMS_AMBIENT --- src/meshes/p4est_mesh.jl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/meshes/p4est_mesh.jl b/src/meshes/p4est_mesh.jl index 7cb3a7734e0..44466d4dad2 100644 --- a/src/meshes/p4est_mesh.jl +++ b/src/meshes/p4est_mesh.jl @@ -73,10 +73,8 @@ mutable struct P4estMesh{NDIMS, NDIMS_AMBIENT, RealT <: Real, IsParallel, P, Gho end end -const SerialP4estMesh{NDIMS, NDIMS_AMBIENT} = P4estMesh{NDIMS, NDIMS_AMBIENT, <:Real, - <:False} -const ParallelP4estMesh{NDIMS, NDIMS_AMBIENT} = P4estMesh{NDIMS, NDIMS_AMBIENT, <:Real, - <:True} +const SerialP4estMesh{NDIMS} = P4estMesh{NDIMS, <:Any, <:Real, <:False} +const ParallelP4estMesh{NDIMS} = P4estMesh{NDIMS, <:Any, <:Real, <:True} @inline mpi_parallel(mesh::SerialP4estMesh) = False() @inline mpi_parallel(mesh::ParallelP4estMesh) = True() From 458862be422218ae0e07082e0f46471e64053905 Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Fri, 6 Sep 2024 15:19:26 +0200 Subject: [PATCH 08/13] add reference to PR in code comment --- src/meshes/p4est_mesh.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meshes/p4est_mesh.jl b/src/meshes/p4est_mesh.jl index 44466d4dad2..fa378b87be0 100644 --- a/src/meshes/p4est_mesh.jl +++ b/src/meshes/p4est_mesh.jl @@ -53,7 +53,7 @@ mutable struct P4estMesh{NDIMS, NDIMS_AMBIENT, RealT <: Real, IsParallel, P, Gho # ambient space of dimension NDIMS_AMBIENT, we store both as type parameters and # allow them to differ in the general case (e.g. when considering 2D surfaces in 3D). # The ambient dimension NDIMS_AMBIENT is therefore set here in the inner constructor to - # size(tree_node_coordinates, 1). + # size(tree_node_coordinates, 1). See https://github.com/trixi-framework/Trixi.jl/pull/2068. mesh = new{NDIMS, size(tree_node_coordinates, 1), eltype(tree_node_coordinates), typeof(is_parallel), typeof(p4est_pw), typeof(ghost_pw), NDIMS + 2, length(nodes)}(p4est_pw, From 929e17189c1decc11d55594779297c704c56f380 Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Fri, 6 Sep 2024 17:43:19 +0200 Subject: [PATCH 09/13] add new type parameter to summary box --- src/meshes/p4est_mesh.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/meshes/p4est_mesh.jl b/src/meshes/p4est_mesh.jl index fa378b87be0..12da51c9a62 100644 --- a/src/meshes/p4est_mesh.jl +++ b/src/meshes/p4est_mesh.jl @@ -9,7 +9,7 @@ P4estMesh{NDIMS} <: AbstractMesh{NDIMS} An unstructured curved mesh based on trees that uses the C library `p4est` -to manage trees and mesh refinement. +to manage trees and mesh refinement. """ mutable struct P4estMesh{NDIMS, NDIMS_AMBIENT, RealT <: Real, IsParallel, P, Ghost, NDIMSP2, NNODES} <: @@ -119,8 +119,9 @@ function Base.show(io::IO, ::MIME"text/plain", mesh::P4estMesh) "polydeg" => length(mesh.nodes) - 1, ] summary_box(io, - "P4estMesh{" * string(ndims(mesh)) * ", " * string(real(mesh)) * - "}", setup) + "P4estMesh{" * string(ndims(mesh)) * ", " * + string(ndims_ambient(mesh)) * + ", " * string(real(mesh)) * "}", setup) end end From bca28d28af67832cb59efe88bf386719695f61b1 Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Tue, 10 Sep 2024 11:48:59 +0200 Subject: [PATCH 10/13] describe use of NDIMS_AMBIENT in docstring and comment --- src/meshes/p4est_mesh.jl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/meshes/p4est_mesh.jl b/src/meshes/p4est_mesh.jl index 12da51c9a62..79219b319c8 100644 --- a/src/meshes/p4est_mesh.jl +++ b/src/meshes/p4est_mesh.jl @@ -6,10 +6,16 @@ #! format: noindent """ - P4estMesh{NDIMS} <: AbstractMesh{NDIMS} + P4estMesh{NDIMS, NDIMS_AMBIENT} <: AbstractMesh{NDIMS} An unstructured curved mesh based on trees that uses the C library `p4est` to manage trees and mesh refinement. + +The parameter `NDIMS` denotes the dimension of the spatial domain or manifold represented +by the mesh itself, while `NDIMS_AMBIENT` denotes the dimension of the ambient space in +which the mesh is embedded. For example, the type `P4estMesh{3, 3}` corresponds to a +standard mesh for a three-dimensional volume, whereas `P4estMesh{2, 3}` corresponds to a +mesh for a two-dimensional surface or shell in three-dimensional space. """ mutable struct P4estMesh{NDIMS, NDIMS_AMBIENT, RealT <: Real, IsParallel, P, Ghost, NDIMSP2, NNODES} <: @@ -49,11 +55,14 @@ mutable struct P4estMesh{NDIMS, NDIMS_AMBIENT, RealT <: Real, IsParallel, P, Gho ghost = ghost_new_p4est(p4est) ghost_pw = PointerWrapper(ghost) - # To enable the treatment of a manifold of dimension NDIM embedded within an + # To enable the treatment of a manifold of dimension NDIM embedded within an # ambient space of dimension NDIMS_AMBIENT, we store both as type parameters and - # allow them to differ in the general case (e.g. when considering 2D surfaces in 3D). - # The ambient dimension NDIMS_AMBIENT is therefore set here in the inner constructor to - # size(tree_node_coordinates, 1). See https://github.com/trixi-framework/Trixi.jl/pull/2068. + # allow them to differ in the general case. This functionality is used in the + # (currently alpha-stage) package TrixiAtmo.jl for constructing discretizations + # on spherical shell domains for appplications in global atmospheric modelling. + # The ambient dimension NDIMS_AMBIENT is therefore set here in the inner + # constructor to size(tree_node_coordinates, 1). + # See https://github.com/trixi-framework/Trixi.jl/pull/2068. mesh = new{NDIMS, size(tree_node_coordinates, 1), eltype(tree_node_coordinates), typeof(is_parallel), typeof(p4est_pw), typeof(ghost_pw), NDIMS + 2, length(nodes)}(p4est_pw, From 8309f856f5d5ba2baa5dcef29f8fd2e95e31646b Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Tue, 10 Sep 2024 11:58:16 +0200 Subject: [PATCH 11/13] fix spelling --- src/meshes/p4est_mesh.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meshes/p4est_mesh.jl b/src/meshes/p4est_mesh.jl index 79219b319c8..f9ab62e7378 100644 --- a/src/meshes/p4est_mesh.jl +++ b/src/meshes/p4est_mesh.jl @@ -59,7 +59,7 @@ mutable struct P4estMesh{NDIMS, NDIMS_AMBIENT, RealT <: Real, IsParallel, P, Gho # ambient space of dimension NDIMS_AMBIENT, we store both as type parameters and # allow them to differ in the general case. This functionality is used in the # (currently alpha-stage) package TrixiAtmo.jl for constructing discretizations - # on spherical shell domains for appplications in global atmospheric modelling. + # on spherical shell domains for applications in global atmospheric modelling. # The ambient dimension NDIMS_AMBIENT is therefore set here in the inner # constructor to size(tree_node_coordinates, 1). # See https://github.com/trixi-framework/Trixi.jl/pull/2068. From b5605faa9503411c0566c394da0baef92994a08b Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Tue, 10 Sep 2024 14:26:30 +0200 Subject: [PATCH 12/13] remove reference to TrixiAtmo.jl and link to PR from comment --- src/meshes/p4est_mesh.jl | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/meshes/p4est_mesh.jl b/src/meshes/p4est_mesh.jl index f9ab62e7378..f9b5f1fb09b 100644 --- a/src/meshes/p4est_mesh.jl +++ b/src/meshes/p4est_mesh.jl @@ -57,12 +57,10 @@ mutable struct P4estMesh{NDIMS, NDIMS_AMBIENT, RealT <: Real, IsParallel, P, Gho # To enable the treatment of a manifold of dimension NDIM embedded within an # ambient space of dimension NDIMS_AMBIENT, we store both as type parameters and - # allow them to differ in the general case. This functionality is used in the - # (currently alpha-stage) package TrixiAtmo.jl for constructing discretizations - # on spherical shell domains for applications in global atmospheric modelling. - # The ambient dimension NDIMS_AMBIENT is therefore set here in the inner - # constructor to size(tree_node_coordinates, 1). - # See https://github.com/trixi-framework/Trixi.jl/pull/2068. + # allow them to differ in the general case. This functionality is used for + # constructing discretizations on spherical shell domains for applications in + # global atmospheric modelling. The ambient dimension NDIMS_AMBIENT is therefore + # set here in the inner constructor to size(tree_node_coordinates, 1). mesh = new{NDIMS, size(tree_node_coordinates, 1), eltype(tree_node_coordinates), typeof(is_parallel), typeof(p4est_pw), typeof(ghost_pw), NDIMS + 2, length(nodes)}(p4est_pw, From 8775644401f1e8f375d4e9aee52b406da5838825 Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Wed, 11 Sep 2024 13:48:18 +0200 Subject: [PATCH 13/13] add experimental feature note and fix NDIM -> NDIMS typo --- src/meshes/p4est_mesh.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/meshes/p4est_mesh.jl b/src/meshes/p4est_mesh.jl index f9b5f1fb09b..cd7f2144639 100644 --- a/src/meshes/p4est_mesh.jl +++ b/src/meshes/p4est_mesh.jl @@ -16,6 +16,10 @@ by the mesh itself, while `NDIMS_AMBIENT` denotes the dimension of the ambient s which the mesh is embedded. For example, the type `P4estMesh{3, 3}` corresponds to a standard mesh for a three-dimensional volume, whereas `P4estMesh{2, 3}` corresponds to a mesh for a two-dimensional surface or shell in three-dimensional space. + +!!! warning "Experimental implementation" + The use of `NDIMS != NDIMS_AMBIENT` is an experimental feature and may change in future + releases. """ mutable struct P4estMesh{NDIMS, NDIMS_AMBIENT, RealT <: Real, IsParallel, P, Ghost, NDIMSP2, NNODES} <: @@ -55,7 +59,7 @@ mutable struct P4estMesh{NDIMS, NDIMS_AMBIENT, RealT <: Real, IsParallel, P, Gho ghost = ghost_new_p4est(p4est) ghost_pw = PointerWrapper(ghost) - # To enable the treatment of a manifold of dimension NDIM embedded within an + # To enable the treatment of a manifold of dimension NDIMS embedded within an # ambient space of dimension NDIMS_AMBIENT, we store both as type parameters and # allow them to differ in the general case. This functionality is used for # constructing discretizations on spherical shell domains for applications in