Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
datamap.hpp
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2008-02-28
7 
8  Copyright (C) 2008 Université Joseph Fourier (Grenoble I)
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 3.0 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
29 #ifndef __DataMap_H
30 #define __DataMap_H 1
31 
32 #include <vector>
33 #include <feel/feelcore/feel.hpp>
36 
37 namespace Feel
38 {
46 class DataMap
47 {
48 
49 public:
50 
51 
55 
56 
58 
62 
63  DataMap( WorldComm const& _worldComm = Environment::worldComm() );
64 
69  DataMap( size_type n, size_type n_local, WorldComm const& _worldComm = Environment::worldComm() );
70 
76  DataMap( size_type n, std::vector<int> const& firstdof, std::vector<int> const& lastdof );
77 
78  DataMap( DataMap const & dm );
79 
80  virtual ~DataMap();
81 
83 
87 
88  DataMap& operator=( DataMap const& dm );
89 
91 
95 
99  size_type nDof() const
100  {
101  return M_n_dofs;
102  }
103 
108  {
109  return this->nLocalDofWithGhost()/*nDofOnProcessor (M_comm.rank())*/;
110  }
111 
116  {
117  return nLocalDofWithoutGhost(this->worldComm().rank());
118  }
119 
123  size_type nLocalDofWithoutGhost( const int proc ) const
124  {
125  return M_n_localWithoutGhost_df[proc];
126  }
127 
132  {
133  return this->nLocalDofWithGhost(this->worldComm().rank());
134  }
135 
139  size_type nLocalDofWithGhost( const int proc ) const
140  {
141  return M_n_localWithGhost_df[proc];
142  }
143 
147  size_type nMyDof () const
148  {
149  return this->nDofOnProcessor ( M_worldComm.rank() );
150  }
151 
155  size_type nDofOnProcessor( const size_type proc ) const
156  {
157  FEELPP_ASSERT( proc < M_first_df.size() )( proc )( M_first_df.size() ).error( "invalid proc id or dof table" );
158  return M_n_localWithoutGhost_df[proc];
159  //return ( M_last_df[proc] - M_first_df[proc]+1);
160  }
161 
162  size_type nProcessors() const
163  {
164  return ( M_worldComm.size() );
165  }
166 
171  {
172  size_type proc = M_worldComm.rank();
173  FEELPP_ASSERT( proc < M_first_df.size() )( proc )( M_first_df.size() ).error( "invalid proc id or dof table" );
174  return M_first_df[proc];
175  }
179  size_type firstDof( const size_type proc ) const
180  {
181  FEELPP_ASSERT( proc < M_first_df.size() )( proc )( M_first_df.size() ).error( "invalid proc id or dof table" );
182  return M_first_df[proc];
183  }
184 
185  size_type firstDofGlobalCluster() const
186  {
187  size_type proc = M_worldComm.rank();
188  FEELPP_ASSERT( proc < M_first_df_globalcluster.size() )( proc )( M_first_df_globalcluster.size() ).error( "invalid proc id or dof table" );
189  return M_first_df_globalcluster[proc];
190  }
191 
192  size_type firstDofGlobalCluster( uint16_type proc ) const
193  {
194  FEELPP_ASSERT( proc < M_first_df_globalcluster.size() )( proc )( M_first_df_globalcluster.size() ).error( "invalid proc id or dof table" );
195  return M_first_df_globalcluster[proc];
196  }
197 
198  std::vector<size_type> const& firstDofGlobalClusterWorld() const
199  {
201  }
202 
207  {
208  size_type proc = M_worldComm.rank();
209  FEELPP_ASSERT( proc < M_last_df.size() )( proc )( M_last_df.size() ).error( "invalid proc id or dof table" );
210  return M_last_df[proc];
211  }
215  size_type lastDof( const unsigned int proc ) const
216  {
217  FEELPP_ASSERT( proc < M_last_df.size() )( proc )( M_last_df.size() ).error( "invalid proc id or dof table" );
218  return M_last_df[proc];
219  }
220 
225  {
226  size_type proc = M_worldComm.rank();
227  FEELPP_ASSERT( proc < M_last_df_globalcluster.size() )( proc )( M_last_df_globalcluster.size() ).error( "invalid proc id or dof table" );
228  return M_last_df_globalcluster[proc];
229  }
230 
231  size_type lastDofGlobalCluster( uint16_type proc ) const
232  {
233  FEELPP_ASSERT( proc < M_last_df_globalcluster.size() )( proc )( M_last_df_globalcluster.size() ).error( "invalid proc id or dof table" );
234  return M_last_df_globalcluster[proc];
235  }
236 
237  std::vector<size_type> const& lastDofGlobalClusterWorld() const
238  {
240  }
241 
242  uint16_type procOnGlobalCluster( size_type globDof ) const;
243 
244  bool dofGlobalClusterIsOnProc( size_type globDof ) const
245  {
246  return this->dofGlobalClusterIsOnProc( globDof, this->worldComm().globalRank() );
247  }
248 
249  bool dofGlobalClusterIsOnProc( size_type globDof, int proc ) const
250  {
251  return ( ( this->nLocalDofWithoutGhost(proc) > 0 ) && ( globDof <= M_last_df_globalcluster[proc] ) && ( globDof >= M_first_df_globalcluster[proc] ) );
252  }
253 
254  bool dofGlobalProcessIsGhost( size_type dof) const
255  {
256  return !this->dofGlobalClusterIsOnProc(this->mapGlobalProcessToGlobalCluster( dof ));
257  }
258 
259  boost::tuple<bool,size_type> searchGlobalProcessDof( size_type gpdof ) const;
260 
261 
263  size_type lid( size_type GID ) const
264  {
265  uint16_type pid = M_worldComm.rank();
266 
267  if ( GID >= firstDof( pid ) &&
268  GID <= lastDof( pid ) )
269  return GID - firstDof( pid );
270 
272  }
273 
275  size_type gid( size_type LID ) const
276  {
277  uint16_type pid = M_worldComm.rank();
278 
279  if ( LID < ( lastDof( pid )-firstDof( pid ) + 1 ) )
280  return firstDof( pid ) + LID;
281 
283  }
284 
286  bool myGID( size_type GID ) const
287  {
288  return( lid( GID )!=invalid_size_type_value );
289  }
290 
292  bool myLID( size_type LID ) const
293  {
294  return( gid( LID )!=invalid_size_type_value );
295  }
296 
299  {
300  return( firstDof( 0 ) );
301  }
302 
305  {
306  return( lastDof( M_worldComm.size()-1 ) );
307  }
308 
311  {
312  return firstDof( M_worldComm.rank() );
313  }
314 
317  {
318  return lastDof( M_worldComm.rank() );
319  };
320 
323  {
324  return 0;
325  };
326 
329  {
330  return lastDof( M_worldComm.rank() )-firstDof( M_worldComm.rank() );
331  };
332 
335  {
336  return M_n_dofs;
337  };
338 
340  //size_type nMyElements() const {return nLocalDofWithGhost();};
342  {
343  return nLocalDof();
344  };
345 
347  std::vector<size_type> const& myGlobalElements() const;
348 
349  std::vector<size_type> const& mapGlobalProcessToGlobalCluster() const
350  {
352  }
353  std::vector<size_type> const& mapGlobalClusterToGlobalProcess() const
354  {
356  }
357  size_type mapGlobalProcessToGlobalCluster( size_type i ) const
358  {
360  }
361  size_type mapGlobalClusterToGlobalProcess( size_type i ) const
362  {
364  }
365 
366  void setNDof( size_type ndof );
367 
368  void setNLocalDofWithoutGhost( const size_type proc, const size_type n, bool inWorld=true );
369  void setNLocalDofWithGhost( const size_type proc, const size_type n, bool inWorld=true );
370  void setFirstDof( const size_type proc, const size_type df, bool inWorld=true );
371  void setLastDof( const size_type proc, const size_type df, bool inWorld=true );
372  void setFirstDofGlobalCluster( const size_type proc, const size_type df, bool inWorld=true );
373  void setLastDofGlobalCluster( const size_type proc, const size_type df, bool inWorld=true );
374 
375  void setMapGlobalProcessToGlobalCluster( std::vector<size_type> const& map );
376  void setMapGlobalClusterToGlobalProcess( std::vector<size_type> const& map );
377  void setMapGlobalProcessToGlobalCluster( size_type i, size_type j );
378  void setMapGlobalClusterToGlobalProcess( size_type i, size_type j );
379  void resizeMapGlobalProcessToGlobalCluster( size_type n );
380  void resizeMapGlobalClusterToGlobalProcess( size_type n );
381 
382  void updateDataInWorld();
383 
385  bool closed() const
386  {
387  return M_closed;
388  }
389 
390  void showMeMapGlobalProcessToGlobalCluster( std::ostream& __out = std::cout ) const;
391 
395  //mpi::communicator const& comm() const { return M_comm; }
396  WorldComm const& worldComm() const
397  {
398  return M_worldComm;
399  }
400  // warning (vincent!!)
401  WorldComm const& comm() const
402  {
403  return M_worldComm;
404  }
405 
407 
408 
409 
413 
414 
415 
417 
421 
422  void close() const;
423 
425 
426 
427 
428 protected:
429 
430  mutable bool M_closed;
431 
436 
440  std::vector<size_type> M_n_localWithoutGhost_df;
441 
445  std::vector<size_type> M_n_localWithGhost_df;
446 
450  std::vector<size_type> M_first_df;
451 
455  std::vector<size_type> M_last_df;
456 
460  std::vector<size_type> M_first_df_globalcluster;
461 
465  std::vector<size_type> M_last_df_globalcluster;
466 
467  // ??
468  mutable std::vector<size_type> M_myglobalelements;
469 
470 
474  std::vector<size_type> M_mapGlobalProcessToGlobalCluster;
475 
479  std::vector<size_type> M_mapGlobalClusterToGlobalProcess;
480 
484  //mpi::communicator M_comm;
485  WorldComm M_worldComm;
486 private:
487 
488 };
489 
490 } // Feel
491 #endif /* __DataMap_H */

Generated on Sun Oct 20 2013 08:24:56 for Feel++ by doxygen 1.8.4