parallel_hilbert.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 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 #ifndef LIBMESH_PARALLEL_HILBERT_H
20 #define LIBMESH_PARALLEL_HILBERT_H
21 
22 // This class contains all the functionality for bin sorting
23 // Templated on the type of keys you will be sorting and the
24 // type of iterator you will be using.
25 
26 #include "libmesh/libmesh_config.h"
27 
28 #if defined(LIBMESH_HAVE_LIBHILBERT) && defined(LIBMESH_HAVE_MPI)
29 
30 // Local includes
31 #include "hilbert.h"
32 #include "libmesh/parallel.h"
33 
34 // C++ includes
35 #include <cstddef>
36 
37 namespace libMesh {
38 namespace Parallel {
39  // A StandardType<> specialization to return a derived MPI datatype
40  // to handle communication of HilbertIndices. We use a singleton
41  // pattern here because a global variable would have tried to call
42  // MPI functions before MPI got initialized.
43  template <>
44  class StandardType<Hilbert::HilbertIndices> : public DataType
45  {
46  public:
47  explicit
48  StandardType(const Hilbert::HilbertIndices* =NULL) {
49  // _static_type never gets freed, but it only gets committed once
50  // so it's not a *huge* memory leak...
51  static DataType _static_type;
52  static bool _is_initialized = false;
53  if (!_is_initialized)
54  {
56  _is_initialized = true;
57  }
58  _datatype = _static_type;
59  }
60  };
61 } // namespace Parallel
62 } // namespace libMesh
63 
64 #endif // LIBMESH_HAVE_LIBHILBERT && LIBMESH_HAVE_MPI
65 
66 #endif // LIBMESH_PARALLEL_HILBERT_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:06 UTC

Hosted By:
SourceForge.net Logo