libMesh
Loading...
Searching...
No Matches
remote_elem.C
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// Local includes
21#include "libmesh/remote_elem.h"
22#include "libmesh/libmesh_singleton.h"
23#include "libmesh/threads.h"
24
25
26
27namespace
28{
29using namespace libMesh;
30
31// Class to be dispatched by Singleton::setup()
32// to create the \p RemoteElem singleton.
33// While this actual object has file-level static
34// scope and will be initialized before main(),
35// importantly the setup() method will not be invoked
36// until after main().
37class RemoteElemSetup : public Singleton::Setup
38{
39 void setup ()
40 {
42 }
43} remote_elem_setup;
44
45}
46
47
48
49namespace libMesh
50{
51
52// Pointer to singleton RemoteElem. As an extern variable with static
53// storage duration, its initial value is nullptr, however we also
54// explicitly initialize it to nullptr to avoid any possible
55// confusion. The actual remote_elem is constructed when
56// Singleton::setup() is called in the libMeshInit constructor.
57const RemoteElem * remote_elem = nullptr;
58
60{
61 remote_elem = nullptr;
62
63 // Putting this somewhere to unconfuse Nvidia, which thinks an
64 // object used solely to invoke its constructor is "never
65 // referenced".
66 libmesh_ignore(remote_elem_setup);
67}
68
69
70
72{
73 // The RemoteElem constructor is private, and RemoteElem::create()
74 // is a static member function, so this makes it difficult to use
75 // std::make_unique<RemoteElem> here. Therefore we just resort to
76 // using the traditional "new" in this instance.
77 if (remote_elem == nullptr)
79
80 return *remote_elem;
81}
82
83
84} // namespace libMesh
This is the base class from which all geometric element types are derived.
Definition elem.h:96
In parallel meshes where a ghost element has neighbors which do not exist on the local processor,...
Definition remote_elem.h:61
static const Elem & create()
Return a reference to the global RemoteElem singleton object.
Definition remote_elem.C:71
virtual ~RemoteElem()
Sets remote_elem to nullptr.
Definition remote_elem.C:59
RemoteElem()
Constructor.
Definition remote_elem.h:73
Abstract base class for runtime singleton setup.
virtual void setup()=0
Setup method.
The libMesh namespace provides an interface to certain functionality in the library.
void libmesh_ignore(const Args &...)
const RemoteElem * remote_elem
Definition remote_elem.C:57