libMesh
Loading...
Searching...
No Matches
remote_elem.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
19
20#ifndef LIBMESH_REMOTE_ELEM_H
21#define LIBMESH_REMOTE_ELEM_H
22
23// Local includes
24#include "libmesh/elem.h"
25#include "libmesh/libmesh_singleton.h"
26
27// C++ includes
28#include <limits>
29
30#define remote_elem_error(func_name) \
31 do { \
32 std::stringstream message_stream; \
33 message_stream << "RemoteElem::" << func_name << " was called. A RemoteElem is not a\n" << \
34 "real Elem, merely a shim accessible on distributed meshes via\n" << \
35 "Elem::neighbor_ptr(), to indicate when a neighbor exists but is not\n" << \
36 "local or ghosted on this processor. Calling this method was an\n" << \
37 "application or library error. Investigate a stack trace for details.\n"; \
38 libMesh::Threads::lock_singleton_spin_mutex(); \
39 libMesh::MacroFunctions::report_error(__FILE__, __LINE__, LIBMESH_DATE, LIBMESH_TIME, message_stream); \
40 libMesh::Threads::unlock_singleton_spin_mutex(); \
41 LIBMESH_THROW(libMesh::LogicError(message_stream.str())); \
42 } while (0)
43
44
45namespace libMesh
46{
47
59class RemoteElem : public Elem,
60 public Singleton
61{
62public:
63
67 static const dof_id_type remote_elem_id = static_cast<dof_id_type>(-2);
68
72private:
74 0,
75 nullptr,
77 nullptr)
78 { this->set_id(remote_elem_id); }
79
80public:
81
82 RemoteElem (RemoteElem &&) = delete;
83 RemoteElem (const RemoteElem &) = delete;
84 RemoteElem & operator= (const RemoteElem &) = delete;
86
90 virtual ~RemoteElem();
91
96 static const Elem & create ();
97
98 virtual Point master_point (const unsigned int /*i*/) const override
99 { remote_elem_error("master_point"); return Point(); }
100
101#ifdef LIBMESH_ENABLE_DEPRECATED
102 virtual Node * & set_node (const unsigned int i) override
103 { remote_elem_error("set_node"); return Elem::set_node(i); }
104#endif // LIBMESH_ENABLE_DEPRECATED
105
106 virtual void set_node (const unsigned int /*i*/, Node * /*node*/) override
107 { remote_elem_error("set_node"); }
108
112 using Elem::key;
113
114 virtual dof_id_type key (const unsigned int) const override
115 { remote_elem_error("key"); return 0; }
116
117 virtual dof_id_type low_order_key (const unsigned int) const override
118 { remote_elem_error("low_order_key"); return 0; }
119
120 virtual unsigned int local_side_node(unsigned int /*side*/,
121 unsigned int /*side_node*/) const override
122 { remote_elem_error("local_side_node"); return 0; }
123
124 virtual unsigned int local_edge_node(unsigned int /*side*/,
125 unsigned int /*side_node*/) const override
126 { remote_elem_error("local_edge_node"); return 0; }
127
128 virtual bool is_remote () const override
129 { return true; }
130
131 virtual void connectivity(const unsigned int,
132 const IOPackage,
133 std::vector<dof_id_type> &) const override
134 { remote_elem_error("connectivity"); }
135
136 virtual ElemType type () const override
137 { return REMOTEELEM; }
138
139 virtual unsigned short dim () const override
140 { remote_elem_error("dim"); return 0; }
141
142 virtual unsigned int n_nodes () const override
143 { remote_elem_error("n_nodes"); return 0; }
144
145 virtual unsigned int n_sides () const override
146 { remote_elem_error("n_sides"); return 0; }
147
148 virtual unsigned int n_vertices () const override
149 { remote_elem_error("n_vertices"); return 0; }
150
151 virtual unsigned int n_edges () const override
152 { remote_elem_error("n_edges"); return 0; }
153
154 virtual unsigned int n_faces () const override
155 { remote_elem_error("n_faces"); return 0; }
156
157 virtual unsigned int n_children () const override
158 { remote_elem_error("n_children"); return 0; }
159
160 virtual bool is_vertex(const unsigned int) const override
161 { remote_elem_error("is_vertex"); return false; }
162
163 virtual bool is_edge(const unsigned int) const override
164 { remote_elem_error("is_edge"); return false; }
165
166 virtual bool is_face(const unsigned int) const override
167 { remote_elem_error("is_face"); return false; }
168
169 virtual bool is_node_on_side(const unsigned int,
170 const unsigned int) const override
171 { remote_elem_error("is_node_on_side"); return false; }
172
173 virtual std::vector<unsigned int> nodes_on_side(const unsigned int) const override
174 { remote_elem_error("nodes_on_side"); return {0}; }
175
176 virtual std::vector<unsigned int> nodes_on_edge(const unsigned int) const override
177 { remote_elem_error("nodes_on_edge"); return {0}; }
178
179 virtual std::vector<unsigned int> edges_adjacent_to_node(const unsigned int) const override
180 { remote_elem_error("edges_adjacent_to_node"); return {0};}
181
182 virtual std::vector<unsigned int> sides_on_edge(const unsigned int) const override
183 { remote_elem_error("sides_on_edge"); return {0}; }
184
185 virtual bool is_child_on_side(const unsigned int,
186 const unsigned int) const override
187 { remote_elem_error("is_child_on_side"); return false; }
188
189 virtual bool is_edge_on_side(const unsigned int,
190 const unsigned int) const override
191 { remote_elem_error("is_edge_on_side"); return false; }
192
193 virtual bool is_node_on_edge(const unsigned int,
194 const unsigned int) const override
195 { remote_elem_error("is_node_on_edge"); return false; }
196
197 virtual unsigned int n_sub_elem () const override
198 { remote_elem_error("n_sub_elem"); return 0; }
199
200 virtual std::unique_ptr<Elem> side_ptr (const unsigned int) override
201 { remote_elem_error("side_ptr"); return std::unique_ptr<Elem>(); }
202
203 virtual void side_ptr (std::unique_ptr<Elem> &,
204 const unsigned int) override
205 { remote_elem_error("side_ptr"); }
206
207 virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int) override
208 { remote_elem_error("build_side_ptr"); return std::unique_ptr<Elem>(); }
209
210 virtual void build_side_ptr (std::unique_ptr<Elem> &,
211 const unsigned int) override
212 { remote_elem_error("build_side_ptr"); }
213
214 // Avoid hiding deprecated version with different signature
216
217 virtual std::unique_ptr<Elem> build_edge_ptr (const unsigned int) override
218 { remote_elem_error("build_edge_ptr"); return std::unique_ptr<Elem>(); }
219
220 virtual void build_edge_ptr (std::unique_ptr<Elem> &, const unsigned int) override
221 { remote_elem_error("build_edge_ptr"); }
222
223 virtual Order default_order () const override
224 { remote_elem_error("default_order"); return static_cast<Order>(1); }
225
226#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
227
228 virtual bool infinite () const override
229 { remote_elem_error("infinite"); return false; }
230
231#endif
232
233#ifdef LIBMESH_ENABLE_AMR
234
239 virtual Real embedding_matrix (const unsigned int,
240 const unsigned int,
241 const unsigned int) const override
242 { remote_elem_error("embedding_matrix"); return 0.; }
243
245
246#endif // LIBMESH_ENABLE_AMR
247
248 virtual unsigned int n_permutations() const override
249 { remote_elem_error("n_permutations"); return 0; }
250
251 virtual void permute(unsigned int) override
252 { remote_elem_error("permute"); }
253
254 virtual void flip(BoundaryInfo *) override final
255 { remote_elem_error("flip"); }
256
257 virtual bool is_flipped() const override final
258 { remote_elem_error("is_flipped"); return false; }
259
260 virtual unsigned int center_node_on_side(const unsigned short) const override
261 { remote_elem_error("center_node_on_side"); return invalid_uint; }
262
263 virtual ElemType side_type (const unsigned int) const override
264 { remote_elem_error("side_type"); return INVALID_ELEM; }
265
266 virtual bool on_reference_element(const Point & /*p*/,
267 const Real /*eps*/ = TOLERANCE) const override
268 { remote_elem_error("on_reference_element"); return false; }
269
270protected:
271
276};
277
278// Singleton RemoteElem
279extern const RemoteElem * remote_elem;
280
281} // namespace libMesh
282
283#endif // LIBMESH_REMOTE_ELEM_H
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
dof_id_type & set_id()
Definition dof_object.h:827
This is the base class from which all geometric element types are derived.
Definition elem.h:96
virtual Node *& set_node(const unsigned int i)
Definition elem.h:2567
virtual dof_id_type key(const unsigned int s) const =0
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i)=0
A Node is like a Point, but with more information.
Definition node.h:55
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
In parallel meshes where a ghost element has neighbors which do not exist on the local processor,...
Definition remote_elem.h:61
virtual bool is_node_on_edge(const unsigned int, const unsigned int) const override
virtual Real embedding_matrix(const unsigned int, const unsigned int, const unsigned int) const override
Matrix that transforms the parents nodes into the children's nodes.
virtual bool is_flipped() const override final
RemoteElem & operator=(const RemoteElem &)=delete
virtual std::vector< unsigned int > edges_adjacent_to_node(const unsigned int) const override
virtual bool is_edge(const unsigned int) const override
virtual unsigned short dim() const override
virtual unsigned int n_vertices() const override
static const Elem & create()
Return a reference to the global RemoteElem singleton object.
Definition remote_elem.C:71
virtual bool is_remote() const override
virtual unsigned int local_side_node(unsigned int, unsigned int) const override
virtual ~RemoteElem()
Sets remote_elem to nullptr.
Definition remote_elem.C:59
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int) override
virtual unsigned int n_sides() const override
RemoteElem(RemoteElem &&)=delete
virtual void set_node(const unsigned int, Node *) override
Sets local Node i to refer to node.
virtual bool is_node_on_side(const unsigned int, const unsigned int) const override
static const dof_id_type remote_elem_id
A unique id to distinguish remote element links.
Definition remote_elem.h:67
virtual unsigned int n_permutations() const override
Returns the number of independent permutations of element nodes - e.g.
virtual ElemType type() const override
RemoteElem()
Constructor.
Definition remote_elem.h:73
RemoteElem(const RemoteElem &)=delete
virtual void flip(BoundaryInfo *) override final
Flips the element (by swapping node and neighbor pointers) to have a mapping Jacobian of opposite sig...
virtual unsigned int center_node_on_side(const unsigned short) const override
virtual unsigned int n_children() const override
virtual void build_edge_ptr(std::unique_ptr< Elem > &, const unsigned int) override
Resets the loose element edge, which may currently point to a different edge than i or even a differe...
virtual bool is_vertex(const unsigned int) const override
virtual dof_id_type low_order_key(const unsigned int) const override
virtual unsigned int n_edges() const override
virtual void side_ptr(std::unique_ptr< Elem > &, const unsigned int) override
Resets the loose element side, which may currently point to a different side than i or even a differe...
virtual Point master_point(const unsigned int) const override
Definition remote_elem.h:98
virtual unsigned int n_nodes() const override
virtual bool on_reference_element(const Point &, const Real=TOLERANCE) const override
virtual bool infinite() const override
virtual unsigned int n_sub_elem() const override
virtual unsigned int n_faces() const override
virtual bool is_edge_on_side(const unsigned int, const unsigned int) const override
virtual dof_id_type key(const unsigned int) const override
virtual std::vector< unsigned int > nodes_on_side(const unsigned int) const override
virtual std::vector< unsigned int > nodes_on_edge(const unsigned int) const override
virtual bool is_face(const unsigned int) const override
virtual void build_side_ptr(std::unique_ptr< Elem > &, const unsigned int) override
Resets the loose element side, which may currently point to a different side than i or even a differe...
virtual Node *& set_node(const unsigned int i) override
virtual Order default_order() const override
virtual bool is_child_on_side(const unsigned int, const unsigned int) const override
virtual ElemType side_type(const unsigned int) const override
virtual unsigned int local_edge_node(unsigned int, unsigned int) const override
Similar to Elem::local_side_node(), but instead of a side id, takes an edge id and a node id on that ...
virtual void connectivity(const unsigned int, const IOPackage, std::vector< dof_id_type > &) const override
virtual std::unique_ptr< Elem > build_edge_ptr(const unsigned int) override
virtual std::vector< unsigned int > sides_on_edge(const unsigned int) const override
virtual void permute(unsigned int) override
Permutes the element (by swapping node and neighbor pointers) according to the specified index.
Elem * _elemlinks_data[1]
Data for link to (nullptr!) parent.
virtual std::unique_ptr< Elem > side_ptr(const unsigned int) override
Base class for all library singleton objects.
The libMesh namespace provides an interface to certain functionality in the library.
IOPackage
libMesh interfaces with several different software packages for the purposes of creating,...
ElemType
Defines an enum for geometric element types.
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition libmesh.h:303
const RemoteElem * remote_elem
Definition remote_elem.C:57
static constexpr Real TOLERANCE
uint8_t dof_id_type
Definition id_types.h:67
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real