MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
ncsubmesh.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#ifndef MFEM_NCSUBMESH
13#define MFEM_NCSUBMESH
14
15#include "../ncmesh.hpp"
16#include "submesh.hpp"
17#include "submesh_utils.hpp"
18#include <unordered_map>
19
20namespace mfem
21{
22
23/**
24 * @brief Class representing a Nonconformal SubMesh. This is only used by
25 * SubMesh.
26 */
27class NCSubMesh : public NCMesh
28{
29 friend class SubMesh; ///< Only SubMesh can use methods in this class
30public:
31 using From = SubMesh::From; ///< Convenience type alias
32 /// Get the parent NCMesh object
33 const NCMesh* GetParent() const
34 {
35 return parent_;
36 }
37
38 /**
39 * @brief Check if NCMesh @a m is a NCSubMesh.
40 *
41 * @param m The input NCMesh
42 */
43 static bool IsNCSubMesh(const NCMesh *m)
44 {
45 return dynamic_cast<const NCSubMesh *>(m) != nullptr;
46 }
47private:
48
49 /// Private constructor
50 NCSubMesh(SubMesh& submesh, const NCMesh &parent, From from,
51 const Array<int> &attributes);
52
53 /// The parent NCMesh. Not owned.
54 const NCMesh *parent_;
55
56 /// Mapping from submesh element nc ids (index of the array), to the parent
57 /// element ids. If from a boundary, these map to faces in the parent.
58 Array<int> parent_element_ids_;
59
60 /// Mapping from NCSubMesh node ids (index of the array), to the parent
61 /// NCMesh node ids.
62 Array<int> parent_node_ids_;
63
64 /// Mapping from parent NCMesh node ids to submesh NCMesh node ids.
65 // Inverse map of parent_node_ids_.
66 std::unordered_map<int, int> parent_to_submesh_node_ids_;
67
68 /// Mapping from parent NCMesh element ids to submesh NCMesh element ids.
69 // Inverse map of parent_element_ids_.
70 std::unordered_map<int, int> parent_to_submesh_element_ids_;
71
72 // Helper friend methods for construction.
74 const Array<int> &attributes);
76 const Array<int> &attributes);
77
78 /**
79 * @brief Accessor for parent nodes
80 * @details Required to bypass access protection in parent class.
81 *
82 * @return const HashTable<Node>&
83 */
84 const HashTable<Node> &ParentNodes() const { return parent_->nodes; }
85
86 /**
87 * @brief Accessor for parent faces
88 * @details Required to bypass access protection in parent class.
89 *
90 * @return const HashTable<Face>&
91 */
92 const HashTable<Face> &ParentFaces() const { return parent_->faces; }
93};
94
95} // namespace mfem
96
97#endif // MFEM_NCSUBMESH
A class for non-conforming AMR. The class is not used directly by the user, rather it is an extension...
Definition ncmesh.hpp:140
HashTable< Node > nodes
Definition ncmesh.hpp:619
HashTable< Face > faces
Definition ncmesh.hpp:620
friend class NCSubMesh
Definition ncmesh.hpp:1351
Class representing a Nonconformal SubMesh. This is only used by SubMesh.
Definition ncsubmesh.hpp:28
static bool IsNCSubMesh(const NCMesh *m)
Check if NCMesh m is a NCSubMesh.
Definition ncsubmesh.hpp:43
const NCMesh * GetParent() const
Get the parent NCMesh object.
Definition ncsubmesh.hpp:33
SubMesh::From From
Definition ncsubmesh.hpp:31
Subdomain representation of a topological parent in another Mesh.
Definition submesh.hpp:44
From
Indicator from which part of the parent Mesh the SubMesh is created.
Definition submesh.hpp:49
void ConstructFaceTree(NCSubMeshT &submesh, const Array< int > &attributes)
Construct a nonconformal mesh (serial or parallel) for a surface submesh, from an existing nonconform...
void ConstructVolumeTree(NCSubMeshT &submesh, const Array< int > &attributes)
Construct a nonconformal mesh (serial or parallel) for a volume submesh, from an existing nonconforma...