MeshDistributor.h 21.8 KB
Newer Older
1 2 3 4
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
5
// ==  http://www.amdis-fem.org                                              ==
6 7
// ==                                                                        ==
// ============================================================================
8 9 10 11 12 13 14 15 16 17 18 19
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


20

21
/** \file MeshDistributor.h */
22

23 24
#ifndef AMDIS_MESHDISTRIBUTOR_H
#define AMDIS_MESHDISTRIBUTOR_H
25 26


Thomas Witkowski's avatar
Thomas Witkowski committed
27
#include <mpi.h>
28
#include "parallel/ParallelTypes.h"
29
#include "parallel/MeshPartitioner.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
30
#include "parallel/InteriorBoundary.h"
31
#include "parallel/StdMpi.h"
32
#include "AMDiS_fwd.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
33
#include "Global.h"
34 35
#include "ProblemTimeInterface.h"
#include "ProblemIterationInterface.h"
36
#include "FiniteElemSpace.h"
37
#include "Serializer.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
38
#include "BoundaryManager.h"
39
#include "ElementObjectData.h"
40
#include "SystemVector.h"
41

42
namespace AMDiS {
43 44

  using namespace std;
Thomas Witkowski's avatar
Thomas Witkowski committed
45 46 47 48


  struct BoundaryDofInfo
  {
49
    map<GeoIndex, DofContainerSet> geoDofs;
Thomas Witkowski's avatar
Thomas Witkowski committed
50
  };
51
  
Thomas Witkowski's avatar
Thomas Witkowski committed
52

53
  class MeshDistributor
54
  {
55
  private:
56
    MeshDistributor();
57
	          
58
    virtual ~MeshDistributor() {}
59

60
  public:
61
    void initParallelization();
62

63
    void exitParallelization();
64

65 66 67
    /// Adds a DOFVector to the set of \ref interchangeVecs. Thus, this vector 
    /// will be automatically interchanged between ranks when mesh is 
    /// repartitioned.
68 69 70 71 72
    void addInterchangeVector(DOFVector<double> *vec)
    {
      interchangeVectors.push_back(vec);
    }

73 74 75 76 77 78 79
    /// Adds all DOFVectors of a SystemVector to \ref interchangeVecs.
    void addInterchangeVector(SystemVector *vec)
    {
      for (int i = 0; i < vec->getSize(); i++)
	interchangeVectors.push_back(vec->getDOFVector(i));
    }
    
80
    /** \brief
81 82 83 84 85
     * This function checks if the mesh has changed on at least on rank. In 
     * this case, the interior boundaries are adapted on all ranks such that 
     * they fit together on all ranks. Furthermore the function 
     * \ref updateLocalGlobalNumbering() is called to update the DOF numberings 
     * and mappings on all rank due to the new mesh structure.
86
     *
87 88 89 90 91
     * \param[in]  tryRepartition   If this parameter is true, repartitioning 
     *                              may be done. This depends on several other 
     *                              parameters. If the parameter is false, the 
     *                              mesh is only checked and adapted but never 
     *                              repartitioned.
92
     */
93
    void checkMeshChange(bool tryRepartition = true);
94

95 96 97 98 99 100 101 102 103 104
    /** \brief
     * Checks if is required to repartition the mesh. If this is the case, a new
     * partition will be created and the mesh will be redistributed between the
     * ranks.
     */
    void repartitionMesh();
    
    /// Calculates the imbalancing factor and prints it to screen.
    void printImbalanceFactor();

105
    /** \brief
106 107 108 109
     * Test, if the mesh consists of macro elements only. The mesh partitioning 
     * of the parallelization works for macro meshes only and would fail, if the 
     * mesh is already refined in some way. Therefore, this function will exit
     * the program if it finds a non macro element in the mesh.
110 111
     */
    void testForMacroMesh();
112

113 114
    /// Set for each element on the partitioning level the number of 
    /// leaf elements.
115
    void setInitialElementWeights();
116

117
    inline virtual string getName() 
118 119 120
    { 
      return name; 
    }
121

Thomas Witkowski's avatar
Thomas Witkowski committed
122 123 124 125 126
    inline Mesh* getMesh()
    {
      return mesh;
    }

127 128 129 130 131
    /// Returns \ref feSpace.
    inline const FiniteElemSpace* getFeSpace()
    {
      return feSpace;
    }
132 133 134
    
    /// Returns \ref nRankDOFs, the number of DOFs in the rank mesh.
    inline int getNumberRankDofs() 
135
    {
136
      return nRankDofs;
137
    }
138

139 140 141 142 143 144
    /// Returns \ref rStartDofs, the first global DOF index owned by rank.
    inline int getStartDofs()
    {
      return rStartDofs;
    }

145
    /// Returns \ref nOverallDofs, the global number of DOFs.
146
    inline int getNumberOverallDofs()
147
    {
148
      return nOverallDofs;
149
    }
150

Thomas Witkowski's avatar
Thomas Witkowski committed
151 152 153 154 155
    inline DofMapping& getMapLocalGlobalDofs()
    {
      return mapLocalGlobalDofs;
    }

156
    /// Maps a local DOF to its global index.
157
    inline DegreeOfFreedom mapLocalToGlobal(DegreeOfFreedom dof)
158
    {
159
      return mapLocalGlobalDofs[dof];
160
    }
161

162 163
    DegreeOfFreedom mapGlobalToLocal(DegreeOfFreedom dof);

164
    /// Maps a local DOF to its local index.
165 166 167 168 169
    inline DegreeOfFreedom mapLocalToDofIndex(DegreeOfFreedom dof)
    {
      return mapLocalDofIndex[dof];
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
170 171 172 173 174 175
    /// Returns the periodic mapping for all boundary DOFs in rank.
    inline PeriodicDofMap& getPeriodicMapping()
    {
      return periodicDof;
    }

176 177
    /// Returns for a global dof index its periodic mapping for a given 
    /// boundary type.
178
    inline int getPeriodicMapping(int globalDofIndex, BoundaryType type)
179
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
180 181
      FUNCNAME("MeshDistributor::getPeriodicMapping()");

182
      TEST_EXIT_DBG(periodicDof[type].count(globalDofIndex) == 1)
Thomas Witkowski's avatar
Thomas Witkowski committed
183 184
	("There is no periodic association for global DOF %d for boundary type %d!\n",
	 globalDofIndex, type);
185 186 187 188

      return periodicDof[type][globalDofIndex];
    }

189
    /// For a given global DOF index, this function returns the set of periodic
190 191
    /// associations, i.e., the boundary types the DOF is associated to, for 
    /// this DOF.
192
    inline std::set<BoundaryType>& getPerDofAssociations(int globalDofIndex)
193
    {      
194 195 196
      TEST_EXIT_DBG(periodicDofAssociations.count(globalDofIndex)) 
 	("Should not happen!\n"); 

197
      return periodicDofAssociations[globalDofIndex];
198
    }
199

200
    /// Returns true, if the DOF (global index) is a periodic DOF.
201
    inline bool isPeriodicDof(int globalDofIndex)
202
    {
203 204
      return (periodicDofAssociations.count(globalDofIndex) > 0 &&
	       periodicDofAssociations[globalDofIndex].size() > 0);
205 206
    }

207 208 209
    /// Returns true, if the DOF (global index) is a periodic DOF for the given
    /// boundary type.
    inline bool isPeriodicDof(int globalDofIndex, BoundaryType type)
210 211
    {
      return (periodicDof[type].count(globalDofIndex) > 0);
212 213
    }

214 215
    /// Return true, if the given DOF is owned by the rank. If false, the DOF
    /// is in rank's partition, but is owned by some other rank.
216 217
    inline bool getIsRankDof(DegreeOfFreedom dof)
    {
218 219 220 221
      if (isRankDof.count(dof))
	return isRankDof[dof];

      return false;
222
    }
223

224 225 226 227 228
    inline DofIndexToBool& getIsRankDof()
    {
      return isRankDof;
    }

229
    inline long getLastMeshChangeIndex()
230
    {
231
      return lastMeshChangeIndex;
232
    }
233

234
    inline int getMpiRank()
235
    {
236
      return mpiRank;
237
    }
238

Thomas Witkowski's avatar
Thomas Witkowski committed
239 240 241 242 243
    inline int getMpiSize()
    {
      return mpiSize;
    }

244 245 246
    inline MPI::Intracomm& getMpiComm()
    {
      return mpiComm;
247 248
    }

249
    inline RankToDofContainer& getSendDofs()
250
    {
251
      return sendDofs;
252 253
    }

254
    inline RankToDofContainer& getRecvDofs()
255
    {
256
      return recvDofs;
257
    }
258

259 260 261 262
    /// Creates a set of all DOFs that are on interior boundaries of rank's
    /// domain. Thus, it creates the union of \ref sendDofs and \ref recvDofs.
    void createBoundaryDofs(std::set<DegreeOfFreedom> &boundaryDofs);

263
    // Writes all data of this object to an output stream.
264
    void serialize(ostream &out);
265

266
    // Reads the object data from an input stream.
267
    void deserialize(istream &in);
268 269

    /** \brief
270 271 272 273
     * This function must be used if the values of a DOFVector must be 
     * synchronised over all ranks. That means, that each rank sends the 
     * values of the DOFs, which are owned by the rank and lie on an interior 
     * bounday, to all other ranks also having these DOFs.
274
     *
275 276 277
     * This function must be used, for example, after the lineary system is 
     * solved, or after the DOFVector is set by some user defined functions, 
     * e.g., initial solution functions.
278
     */    
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
    template<typename T>
    void synchVector(DOFVector<T> &vec) 
    {
      StdMpi<vector<T> > stdMpi(mpiComm);

      for (RankToDofContainer::iterator sendIt = sendDofs.begin();
	   sendIt != sendDofs.end(); ++sendIt) {
	vector<T> dofs;
	int nSendDofs = sendIt->second.size();
	dofs.reserve(nSendDofs);
	
	for (int i = 0; i < nSendDofs; i++)
	  dofs.push_back(vec[*((sendIt->second)[i])]);
	
	stdMpi.send(sendIt->first, dofs);
      }
      
      for (RankToDofContainer::iterator recvIt = recvDofs.begin();
	   recvIt != recvDofs.end(); ++recvIt)
	stdMpi.recv(recvIt->first, recvIt->second.size());
      
      stdMpi.startCommunication();
      
      for (RankToDofContainer::iterator recvIt = recvDofs.begin();
	   recvIt != recvDofs.end(); ++recvIt)
	for (unsigned int i = 0; i < recvIt->second.size(); i++)
	  vec[*(recvIt->second)[i]] = stdMpi.getRecvData(recvIt->first)[i];      
    }
    
308
    /** \brief
309 310 311
     * Works in the same way as the function above defined for DOFVectors. Due
     * to performance, this function does not call \ref synchVector for each 
     * DOFVector, but instead sends all values of all DOFVectors all at once.
312 313 314
     */
    void synchVector(SystemVector &vec);

315 316
    void check3dValidMesh();

Thomas Witkowski's avatar
Thomas Witkowski committed
317 318 319 320 321
    void setBoundaryDofRequirement(Flag flag)
    {
      createBoundaryDofFlag = flag;
    }

322 323 324 325 326
    BoundaryDofInfo& getBoundaryDofInfo()
    {
      return boundaryDofInfo;
    }

327 328
    void getAllBoundaryDofs(DofContainer& dofs);

329 330 331 332 333 334

  public:
    /// Adds a stationary problem to the global mesh distributor objects.
    static void addProblemStatGlobal(ProblemStatSeq *probStat);

    
335
  protected:
336 337
    void addProblemStat(ProblemStatSeq *probStat);

338 339
    /// Determines the interior boundaries, i.e. boundaries between ranks, and
    /// stores all information about them in \ref interiorBoundary.
340
    void createInteriorBoundaryInfo();
341

Thomas Witkowski's avatar
Thomas Witkowski committed
342 343 344 345 346
    void updateInteriorBoundaryInfo();

    void createMeshElementData();

    void createBoundaryData();
Thomas Witkowski's avatar
Thomas Witkowski committed
347

Thomas Witkowski's avatar
Thomas Witkowski committed
348 349
    void createBoundaryDofs();

350 351
    /// Removes all macro elements from the mesh that are not part of ranks 
    /// partition.
352 353
    void removeMacroElements();

354 355
    /// Updates the local and global DOF numbering after the mesh has been 
    /// changed.
356
    void updateLocalGlobalNumbering();
357

358
    /** \brief
359 360 361
     * Creates to all dofs in rank's partition that are on a periodic boundary
     * the mapping from dof index to the other periodic dof indices. This 
     * information is stored in \ref periodicDof.
362
     */
363 364
    void createPeriodicMap();

365 366 367 368 369 370 371 372
    /** \brief
     * This function is called only once during the initialization when the
     * whole macro mesh is available on all cores. It copies the pointers of all
     * macro elements to \ref allMacroElements and stores all neighbour 
     * information based on macro element indices (and not pointer based) in 
     * \ref macroElementNeighbours. These information are then used to 
     * reconstruct macro elements during mesh redistribution.
     */
373 374
    void createMacroElementInfo();

375 376
    void updateMacroElementInfo();

377
    /** \brief
378 379 380 381 382 383
     * Checks for all given interior boundaries if the elements fit together on
     * both sides of the boundaries. If this is not the case, the mesh is 
     * adapted. Because refinement of a certain element may forces the 
     * refinement of other elements, it is not guaranteed that all rank's meshes
     * fit together after this function terminates. Hence, it must be called 
     * until a stable mesh refinement is reached.
384
     *
385 386
     * \param[in] allBound   Defines a map from rank to interior boundaries 
     *                       which should be checked.
387
     *
388 389 390
     * \return    If the mesh has  been changed by this function, it returns 
     *            true. Otherwise, it returns false, i.e., the given interior 
     *            boundaries fit together on both sides.
391 392
     */
    bool checkAndAdaptBoundary(RankToBoundMap &allBound);
393
  
394 395
    /// Sets \ref isRankDof to all matrices and rhs vectors in a given 
    /// stationary problem.
396
    void setRankDofs(ProblemStatSeq *probStat);
397

398 399
    /// Sets \ref isRankDof to all matrices and rhs vectors in all 
    /// stationary problems.
400 401
    void setRankDofs();

402 403 404 405
    /// Removes all periodic boundary condition information from all matrices and
    /// vectors of all stationary problems and from the mesh itself.
    void removePeriodicBoundaryConditions();

Thomas Witkowski's avatar
Thomas Witkowski committed
406
    // Removes all periodic boundaries from a given boundary map.
407
    void removePeriodicBoundaryConditions(BoundaryIndexMap& boundaryMap);
Thomas Witkowski's avatar
Thomas Witkowski committed
408

409
    /// Writes a vector of dof pointers to an output stream.
410
    void serialize(ostream &out, DofContainer &data);
411 412

    /// Reads a vector of dof pointers from an input stream.
413 414
    void deserialize(istream &in, DofContainer &data,
		     map<int, const DegreeOfFreedom*> &dofMap);
415 416

    /// Writes a \ref RankToDofContainer to an output stream.
417
    void serialize(ostream &out, RankToDofContainer &data);
418 419

    /// Reads a \ref RankToDofContainer from an input stream.
420 421
    void deserialize(istream &in, RankToDofContainer &data,
		     map<int, const DegreeOfFreedom*> &dofMap);
422

423
    /// Writes a periodic dof mapping to an output stream.
424
    void serialize(ostream &out, PeriodicDofMap &data);
425

426
    void serialize(ostream &out, map<int, std::set<int> >& data);
427

428
    /// Reads a periodic dof mapping from an input stream.
429
    void deserialize(istream &in, PeriodicDofMap &data);
430

431
    void deserialize(istream &in, map<int, std::set<int> >& data);
432

433 434
    /// Writes a mapping from dof pointers to some values to an output stream.
    template<typename T>
435
    void serialize(ostream &out, map<const DegreeOfFreedom*, T> &data)
436
    {
437 438
      FUNCNAME("ParallelDomainBase::serialize()");

439
      int mapSize = data.size();
440
      SerUtil::serialize(out, mapSize);
441
      for (typename map<const DegreeOfFreedom*, T>::iterator it = data.begin();
442 443 444
	   it != data.end(); ++it) {
	int v1 = (*(it->first));
	T v2 = it->second;
445 446
	SerUtil::serialize(out, v1);
	SerUtil::serialize(out, v2);
447 448 449 450 451
      }
    }

    /// Reads a mapping from dof pointer to some values from an input stream.
    template<typename T>
452 453
    void deserialize(istream &in, map<const DegreeOfFreedom*, T> &data,
		     map<int, const DegreeOfFreedom*> &dofMap)
454
    {
455 456
      FUNCNAME("ParallelDomainBase::deserialize()");

457
      int mapSize = 0;
458
      SerUtil::deserialize(in, mapSize);
459 460 461
      for (int i = 0; i < mapSize; i++) {
	int v1 = 0;
	T v2;
462 463
	SerUtil::deserialize(in, v1);
	SerUtil::deserialize(in, v2);
464 465 466

	TEST_EXIT_DBG(dofMap.count(v1) != 0)("Cannot find DOF %d in map!\n", v1);

467 468 469
	data[dofMap[v1]] = v2;
      }
    }
470

471
  protected:
472 473
    /// List of all stationary problems that are managed by this mesh 
    /// distributor.
474
    vector<ProblemStatSeq*> problemStat;
Thomas Witkowski's avatar
Thomas Witkowski committed
475

476 477 478
    /// If true, the mesh distributor is already initialized;
    bool initialized;

479 480 481 482 483 484
    /// The rank of the current process.
    int mpiRank;

    /// Overall number of processes.
    int mpiSize;

485 486
    /// MPI communicator collected all processes, which should be used for
    /// calculation. The Debug procces is not included in this communicator.
487 488 489
    MPI::Intracomm mpiComm;

    /// Name of the problem (as used in the init files)
490
    string name;
491

492 493 494
    /// Finite element space of the problem.
    FiniteElemSpace *feSpace;

495 496 497
    /// Mesh of the problem.
    Mesh *mesh;

498
    /** \brief
499 500 501
     * A refinement manager that should be used on the mesh. It is used to 
     * refine elements at interior boundaries in order to fit together with 
     * elements on the other side of the interior boundary.
502 503 504
     */    
    RefinementManager *refineManager;

505 506 507
    /// Info level.
    int info;

508 509
    /// Pointer to a mesh partitioner that is used to partition the mesh to 
    /// the ranks.
510
    MeshPartitioner *partitioner;
511

512 513
    /// Weights for the elements, i.e., the number of leaf elements within 
    /// this element.
514
    map<int, double> elemWeights;
515 516

    /** \brief
517 518
     * Stores to every macro element index the number of the rank that owns this
     * macro element.
519
     */
520
    map<int, int> partitionMap;
521

522
    /// Number of DOFs in the rank mesh.
523
    int nRankDofs;
Thomas Witkowski's avatar
Thomas Witkowski committed
524

525 526 527
    /// Is the index of the first global DOF index, which is owned by the rank.
    int rStartDofs;

528
    /// Number of DOFs in the whole domain.
529 530
    int nOverallDofs;

531 532
    /// Data structure to store all sub-objects of all elements of the 
    /// macro mesh.
Thomas Witkowski's avatar
Thomas Witkowski committed
533 534
    ElementObjects elObjects;

535
    /// Maps to each macro element index a pointer to the corresponding element.
536
    map<int, Element*> macroElIndexMap;
Thomas Witkowski's avatar
Thomas Witkowski committed
537
    
538
    /// Maps to each macro element index the type of this element.
539
    map<int, int> macroElIndexTypeMap;
Thomas Witkowski's avatar
Thomas Witkowski committed
540

Thomas Witkowski's avatar
Thomas Witkowski committed
541
    /** \brief 
542 543 544 545
     * Defines the interior boundaries of the domain that result from 
     * partitioning the whole mesh. Contains only the boundaries, which are 
     * owned by the rank, i.e., the object gives for every neighbour rank i 
     * the boundaries this rank owns and shares with rank i.
Thomas Witkowski's avatar
Thomas Witkowski committed
546 547 548 549
     */
    InteriorBoundary myIntBoundary;
    
    /** \brief
550 551 552 553
     * Defines the interior boundaries of the domain that result from 
     * partitioning the whole mesh. Contains only the boundaries, which are 
     * not owned by the rank, i.e., the object gives for every neighbour rank 
     * i the boundaries that are owned by rank i and are shared with this rank.
Thomas Witkowski's avatar
Thomas Witkowski committed
554
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
555
    InteriorBoundary otherIntBoundary;
Thomas Witkowski's avatar
Thomas Witkowski committed
556

557
    /** \brief
558 559
     * Defines the periodic boundaries with other ranks. Periodic boundaries
     * have no owner, as it is the case of interior boundaries.
560 561 562
     */
    InteriorBoundary periodicBoundary;

563
    /** \brief
564 565
     * This map contains for each rank the list of DOFs the current rank must 
     * send to exchange solution DOFs at the interior boundaries.
566
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
567
    RankToDofContainer sendDofs;
568 569

    /** \brief
570 571 572
     * This map contains on each rank the list of DOFs from which the current 
     * rank will receive DOF values (i.e., this are all DOFs at an interior 
     * boundary). The DOF indices are given in rank's local numbering.
573
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
574
    RankToDofContainer recvDofs;
575 576

    /// Maps local to global dof indices.
577
    DofMapping mapLocalGlobalDofs;
578

Thomas Witkowski's avatar
Thomas Witkowski committed
579
    /// Maps local dof indices to real dof indices.
580
    DofMapping mapLocalDofIndex;  
581 582

    /** \brief
583 584 585
     * Maps all DOFs in ranks partition to a bool value. If it is true, the DOF 
     * is owned by the rank. Otherwise, its an interior boundary DOF that is 
     * owned by another rank.
586
     */
587 588
    DofIndexToBool isRankDof;

589
    /** \brief
590 591 592 593
     * If periodic boundaries are used, this map stores, for each periodic 
     * boundary type, for all DOFs in rank's partition (that are on periodic 
     * boundaries), the corresponding mapped periodic DOFs. The mapping is 
     * defined by using global DOF indices.
594
     */
595
    PeriodicDofMap periodicDof;
596 597
    
    /** \brief
598 599 600 601 602
     * If periodic boundaries are used, this map stores to each periodic DOF in 
     * rank's partition the set of periodic boundaries the DOF is associated to.
     * In 2D, most DOFs are only on one periodic boundary. Only, e.g., in a box 
     * with all boundaries being periodic, the four corners are associated by 
     * two different boundaries.
603
     */
604
    map<int, std::set<BoundaryType> > periodicDofAssociations;
605

606 607 608 609 610
    
    /// This set of values must be interchanged between ranks when the mesh is 
    /// repartitioned.
    vector<DOFVector<double>*> interchangeVectors;
		        
611 612 613
    /** \brief
     * If the problem definition has been read from a serialization file, this 
     * variable is true, otherwise it is false. This variable is used to stop the
614 615
     * initialization function, if the problem definition has already been read
     * from a serialization file.
616 617
     */
    bool deserialized;
618

619 620 621
    /// Denotes whether there exists a filewriter for this object.
    bool writeSerializationFile;

622 623 624
    /// If true, it is possible to repartition the mesh during computations.
    bool repartitioningAllowed;

625 626
    /// Stores the number of mesh changes that must lie in between to 
    /// repartitionings.
627 628
    int repartitionIthChange;

629 630
    /// Counts the number of mesh changes after the last mesh repartitioning 
    /// was done.
631
    int nMeshChangesAfterLastRepartitioning;
632

633 634 635
    /// Countes the number of mesh repartitions that were done. Till now, this 
    /// variable is used only for debug outputs.
    int repartitioningCounter;
636

637
    /// Directory name where all debug output files should be written to.
638
    string debugOutputDir;
639

640
    /** \brief
641 642
     * Stores the mesh change index. This is used to recognize changes in the
     * mesh structure (e.g. through refinement or coarsening managers).
643 644
     */
    long lastMeshChangeIndex;
645

646 647 648 649
    /// Stores for all macro elements of the original macro mesh the
    /// neighbourhood information based on element indices. Thus, each macro
    /// element index is mapped to a vector containing all indices of 
    /// neighbouring macro elements.
650
    map<int, vector<int> > macroElementNeighbours;
651

652 653
    /// Store all macro elements of the overall mesh, i.e., before the
    /// mesh is redistributed for the first time.
654
    vector<MacroElement*> allMacroElements;
655

Thomas Witkowski's avatar
Thomas Witkowski committed
656 657 658
    Flag createBoundaryDofFlag;

    BoundaryDofInfo boundaryDofInfo;
659

Thomas Witkowski's avatar
Thomas Witkowski committed
660
  public:
661 662 663
    /// The boundary DOFs are sorted by subobject entities, i.e., first all
    /// face DOFs, edge DOFs and to the last vertex DOFs will be set to
    /// communication structure vectors, \ref sendDofs and \ref recvDofs.
Thomas Witkowski's avatar
Thomas Witkowski committed
664 665
    static const Flag BOUNDARY_SUBOBJ_SORTED;

666 667 668 669 670 671 672 673 674
    /// When boundary DOFs are created, \ref boundaryDofInfo is filled for
    /// all DOFs that this rank will send to other ranks (thus, rank 
    /// owned DOFs.
    static const Flag BOUNDARY_FILL_INFO_SEND_DOFS;

    /// When boundary DOFs are created, \ref boundaryDofInfo is filled for
    /// all DOFs that this rank will receive from other ranks (thus, DOFs
    /// that are owned by another rank).
    static const Flag BOUNDARY_FILL_INFO_RECV_DOFS;
Thomas Witkowski's avatar
Thomas Witkowski committed
675

676 677
    static MeshDistributor *globalMeshDistributor;

678
    friend class ParallelDebug;
679 680 681
  };
}

682
#endif // AMDIS_MESHDISTRIBUTOR_H