Rheolef  7.2
an efficient C++ finite element environment
communicator.h
Go to the documentation of this file.
1 # ifndef _RHEO_COMMUNICATOR_H
2 # define _RHEO_COMMUNICATOR_H
3 //
4 // This file is part of Rheolef.
5 //
6 // Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7 //
8 // Rheolef is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // Rheolef is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with Rheolef; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 //
22 // =========================================================================
23 // AUTHOR: Pierre.Saramito@imag.fr
24 // DATE: 27 november 1998
25 
26 namespace rheolef {
56 } // namespace rheolef
57 #include "rheolef/compiler_mpi.h"
58 
59 namespace rheolef {
60 
62  struct sequential {};
63 
64  // compile-time predicate: is_sequential, is_distributed
65  template<class M>
66  struct is_sequential {
67  static const bool value = false;
68  };
69  template<class M>
70  struct is_distributed {
71  static const bool value = false;
72  };
73  template<>
75  static const bool value = true;
76  };
77  template<>
79  static const bool value = false;
80  };
81 
82  // useful in expressions of type mixing fields and class-functions:
83  // promote memory_type to the field one
84  template<class M1, class M2>
85  struct promote_memory {
87  };
88  template<>
90  typedef sequential type;
91  };
92  template<>
94  typedef sequential type;
95  };
96  template<>
98  typedef sequential type;
99  };
100 
101 } // namespace rheolef
102 
103 #ifndef _RHEOLEF_HAVE_MPI
104 // -----------------------------------------------------------------------
105 // distributed code & library should compile even without mpi
106 // -----------------------------------------------------------------------
107 # ifndef rheo_default_memory_model
108 # define rheo_default_memory_model sequential
109 # endif
110 namespace rheolef {
111 // [verbatim_communicator]
112 struct communicator {
114  int size() const;
115  int rank() const;
116 };
117 // [verbatim_communicator]
118 inline int communicator size() const { return 1; }
119 inline int communicator rank() const { return 0; }
120 } // namespace rheolef
121 #else
122 // -----------------------------------------------------------------------
123 // distributed code here
124 // -----------------------------------------------------------------------
125 namespace rheolef {
126  using mpi::communicator;
127 
128  struct distributed {};
129 
130  template<>
132  static const bool value = false;
133  };
134  template<>
136  static const bool value = true;
137  };
138  template<>
140  typedef distributed type;
141  };
142  template<>
144  typedef distributed type;
145  };
146  template<>
148  typedef distributed type;
149  };
150 } // namespace rheolef
151 
152 # ifndef rheo_default_memory_model
153 # define rheo_default_memory_model distributed
154 # endif
155 #endif // _RHEOLEF_HAVE_MPI
156 
157 #endif // _RHEO_COMMUNICATOR_H
field::size_type size_type
Definition: branch.cc:430
see the communicator page for the full documentation
size_t size_type
Definition: basis_get.cc:76
This file is part of Rheolef.
static const bool value
Definition: communicator.h:71
static const bool value
Definition: communicator.h:67
undefined_memory_model type
Definition: communicator.h:86