Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <array>
7 : #include <cstddef>
8 : #include <cstdint>
9 : #include <unordered_map>
10 : #include <vector>
11 :
12 : /// \cond
13 : namespace amr {
14 : enum class Flag;
15 : template <size_t>
16 : struct Info;
17 : } // namespace amr
18 : namespace domain {
19 : enum class Topology : uint8_t;
20 : } // namespace domain
21 : template <size_t>
22 : class Element;
23 : template <size_t>
24 : class ElementId;
25 : template <size_t>
26 : class Mesh;
27 : /// \endcond
28 :
29 : namespace amr::projectors {
30 : /// Given `old_mesh` returns a new Mesh based on the refinement `flags` and
31 : /// `topologies`
32 : ///
33 : /// \note In dimensions that are h-refined, the Mesh is not changed by this
34 : /// function
35 : template <size_t Dim>
36 1 : Mesh<Dim> p_refined_mesh(const Mesh<Dim>& old_mesh,
37 : const std::array<amr::Flag, Dim>& flags,
38 : const std::array<domain::Topology, Dim>& topologies);
39 :
40 : /// Given the Mesh%es for a set of joining Element%s, returns the Mesh
41 : /// for the newly created parent Element.
42 : ///
43 : /// \details In each dimension the extent of the parent Mesh will be the
44 : /// maximum over the extents of each child Mesh
45 : template <size_t Dim>
46 1 : Mesh<Dim> parent_mesh(const std::vector<Mesh<Dim>>& children_meshes);
47 :
48 : /// Given the `parent_mesh`, returns the Mesh for the newly created child
49 : /// Element based on the refinement `flags` and `topologies`.
50 : template <size_t Dim>
51 1 : Mesh<Dim> child_mesh(const Mesh<Dim>& parent_mesh,
52 : const ElementId<Dim>& child_id,
53 : const std::array<amr::Flag, Dim>& flags,
54 : const std::array<domain::Topology, Dim>& topologies);
55 :
56 : /// \brief Computes the expected new Mesh of an Element after AMR that is
57 : /// communicated to neighboring Element%s
58 : ///
59 : /// \details The returned Mesh will be that of either `element` or its parent or
60 : /// children depending upon the `flags`. If an Element is joining, the returned
61 : /// Mesh will be that given by amr::projectors::parent_mesh. If an Element is
62 : /// splitting, the returned Mesh will be given by amr::projectors::child_mesh
63 : /// for the child with Side::Upper in each split dimension. (This will be
64 : /// incorrect for the Side::Lower child for domain::Topology::B1Radial,
65 : /// domain::Topology::B2Radial, or domain::Topology::B3Radial; see the note.)
66 : /// Otherwise the returned Mesh will be given by amr::projectors:p_refined_mesh
67 : ///
68 : /// \note This function is meant to be called only by
69 : /// amr::Actions::EvaluateRefinementCriteria and amr::Actions::UpdateAmrDecision
70 : /// in order to communicate the expected post-refinement Mesh to neighboring
71 : /// Elements. For radially split ball topologies, the upper child Mesh is
72 : /// returned because any existing neighboring elements in the radial direction
73 : /// will have the upper child as their neighbor.
74 : ///
75 : /// \see child_mesh parent_mesh p_refined_mesh
76 : template <size_t Dim>
77 1 : Mesh<Dim> new_mesh_to_communicate_to_neighbors(
78 : const Mesh<Dim>& current_mesh, const std::array<Flag, Dim>& flags,
79 : const Element<Dim>& element,
80 : const std::unordered_map<ElementId<Dim>, Info<Dim>>& neighbors_info);
81 : } // namespace amr::projectors
|