$extrastylesheet
libmesh_base.h
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 
00020 #ifndef LIBMESH_LIBMESH_BASE_H
00021 #define LIBMESH_LIBMESH_BASE_H
00022 
00023 #include "libmesh/id_types.h"
00024 
00025 namespace libMesh {
00026 
00027 #ifndef LIBMESH_DISABLE_COMMWORLD
00028 
00031 processor_id_type n_processors();
00032 
00036 processor_id_type processor_id();
00037 #endif
00038 
00042 processor_id_type global_n_processors();
00043 
00048 processor_id_type global_processor_id();
00049 
00053 unsigned int n_threads();
00054 
00062 namespace libMeshPrivateData {
00063 #ifdef LIBMESH_HAVE_MPI
00064 
00067 extern processor_id_type _n_processors;
00068 
00072 extern processor_id_type _processor_id;
00073 #endif
00074 
00078 extern int _n_threads;
00079 }
00080 }
00081 
00082 
00083 
00084 // ------------------------------------------------------------
00085 // libMesh inline member functions
00086 #ifndef LIBMESH_DISABLE_COMMWORLD
00087 inline
00088 libMesh::processor_id_type libMesh::n_processors()
00089 {
00090   return libMesh::global_n_processors();
00091 }
00092 
00093 
00094 
00095 inline
00096 libMesh::processor_id_type libMesh::processor_id()
00097 {
00098   return libMesh::global_processor_id();
00099 }
00100 #endif // LIBMESH_DISABLE_COMMWORLD
00101 
00102 
00103 inline
00104 libMesh::processor_id_type libMesh::global_n_processors()
00105 {
00106 #ifdef LIBMESH_HAVE_MPI
00107   return libMeshPrivateData::_n_processors;
00108 #else
00109   return 1;
00110 #endif
00111 }
00112 
00113 inline
00114 libMesh::processor_id_type libMesh::global_processor_id()
00115 {
00116 #ifdef LIBMESH_HAVE_MPI
00117   return libMeshPrivateData::_processor_id;
00118 #else
00119   return 0;
00120 #endif
00121 }
00122 
00123 
00124 inline
00125 unsigned int libMesh::n_threads()
00126 {
00127   return static_cast<unsigned int>(libMeshPrivateData::_n_threads);
00128 }
00129 
00130 
00131 // We now put everything we can into a separate libMesh namespace;
00132 // code which forward declares libMesh classes or which specializes
00133 // libMesh templates may want to know whether it is compiling under
00134 // such conditions, to be backward compatible with older libMesh
00135 // versions:
00136 #define LIBMESH_USE_SEPARATE_NAMESPACE 1
00137 
00138 
00139 // Unless configured otherwise, we import all of namespace libMesh,
00140 // for backwards compatibility with pre-namespaced codes.
00141 
00142 #ifndef LIBMESH_REQUIRE_SEPARATE_NAMESPACE
00143 using namespace libMesh;
00144 #endif
00145 
00146 
00147 #endif // LIBMESH_LIBMESH_BASE_H