Liebe Gitlab-Nutzerin, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind über den Reiter "Standard" erreichbar.
Die Administratoren


Dear Gitlab user,
it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab.
The administrators

FeSpaceMapping.cc 2.65 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
//
// 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.


#include "parallel/FeSpaceMapping.h"
Thomas Witkowski's avatar
FETI-DP  
Thomas Witkowski committed
14
#include "parallel/StdMpi.h"
15 16 17 18 19 20 21 22 23 24 25 26 27 28

namespace AMDiS {

  using namespace std;

  void GlobalDofMap::clear()
  {
    dofMap.clear();
    nRankDofs = 0;
    nOverallDofs = 0;
    rStartDofs = 0;
  }


Thomas Witkowski's avatar
Thomas Witkowski committed
29
  void GlobalDofMap::update()
30
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
31 32 33
    for (map<DegreeOfFreedom, MultiIndex>::iterator it = dofMap.begin(); it != dofMap.end(); ++it)
      if (it->second.local == -1 && nonRankDofs.count(it->first) == 0)
	it->second.local = nRankDofs++;
34 35 36 37 38
    
    nOverallDofs = 0;
    rStartDofs = 0;
    mpi::getDofNumbering(*mpiComm, nRankDofs, rStartDofs, nOverallDofs);
    
Thomas Witkowski's avatar
Thomas Witkowski committed
39
    if (needGlobalMapping)
40
      addOffset(rStartDofs);
Thomas Witkowski's avatar
FETI-DP  
Thomas Witkowski committed
41 42 43

    if (overlap)
      computeNonLocalIndices();
44 45 46 47 48
  }


  void GlobalDofMap::addOffset(int offset)
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
49 50
    for (map<DegreeOfFreedom, MultiIndex>::iterator it = dofMap.begin(); it != dofMap.end(); ++it)
      it->second.local += offset;
51 52
  }

Thomas Witkowski's avatar
FETI-DP  
Thomas Witkowski committed
53 54 55 56 57 58 59 60 61 62
  void GlobalDofMap::computeNonLocalIndices()
  {
    FUNCNAME("GlobalDofMap::computeNonLocalIndices()");

    typedef map<int, map<const FiniteElemSpace*, DofContainer> >::iterator it_type;

    StdMpi<vector<int> > stdMpi(*mpiComm);
    for (DofComm::Iterator it(*sendDofs, feSpace); !it.end(); it.nextRank())
      for (; !it.endDofIter(); it.nextDof())
	if (dofMap.count(it.getDofIndex()) && !nonRankDofs.count(it.getDofIndex()))
Thomas Witkowski's avatar
Thomas Witkowski committed
63
	  stdMpi.getSendData(it.getRank()).push_back(dofMap[it.getDofIndex()].local);
Thomas Witkowski's avatar
FETI-DP  
Thomas Witkowski committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

    stdMpi.updateSendDataSize();

    for (DofComm::Iterator it(*recvDofs, feSpace); !it.end(); it.nextRank()) {
      bool recvFromRank = false;
      for (; !it.endDofIter(); it.nextDof()) {
	if (nonRankDofs.count(it.getDofIndex())) {
	  recvFromRank = true;
	  break;
	}
      }

      if (recvFromRank) 
	stdMpi.recv(it.getRank());
    }

    stdMpi.startCommunication();

    for (DofComm::Iterator it(*recvDofs, feSpace);
	 !it.end(); it.nextRank()) {
      int i = 0;
      for (; !it.endDofIter(); it.nextDof())
	if (nonRankDofs.count(it.getDofIndex()))
Thomas Witkowski's avatar
Thomas Witkowski committed
87
	  dofMap[it.getDofIndex()].local = stdMpi.getRecvData(it.getRank())[i++];
Thomas Witkowski's avatar
FETI-DP  
Thomas Witkowski committed
88 89 90 91 92 93 94 95 96 97
    }
  }


  void GlobalDofMap::print()
  {
    FUNCNAME("GlobalDofMap::print()");
    
    MSG("Local to global mapping on this rank: \n");

Thomas Witkowski's avatar
Thomas Witkowski committed
98
    for (map<DegreeOfFreedom, MultiIndex>::iterator it = dofMap.begin(); it != dofMap.end(); ++it)
Thomas Witkowski's avatar
FETI-DP  
Thomas Witkowski committed
99
      if (nonRankDofs.count(it->first) == 0)	
Thomas Witkowski's avatar
Thomas Witkowski committed
100
	MSG("  %d -> %d  (rank-dof)\n", it->first, it->second.local);
Thomas Witkowski's avatar
FETI-DP  
Thomas Witkowski committed
101
      else
Thomas Witkowski's avatar
Thomas Witkowski committed
102
	MSG("  %d -> %d  \n", it->first, it->second.local);
Thomas Witkowski's avatar
FETI-DP  
Thomas Witkowski committed
103
  }
104
}