Commit 1746edf0 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Changed class names.

parent 4e83eefc
...@@ -102,4 +102,185 @@ namespace AMDiS { ...@@ -102,4 +102,185 @@ namespace AMDiS {
else else
MSG(" %d -> %d \n", it->first, it->second.local); MSG(" %d -> %d \n", it->first, it->second.local);
} }
void ParallelDofMapping::addFeSpace(const FiniteElemSpace* feSpace)
{
FUNCNAME("ParallelDofMapping::addFeSpace()");
if (data.count(feSpace))
data.find(feSpace)->second.clear();
else
data.insert(make_pair(feSpace, GlobalDofMap(mpiComm)));
data.find(feSpace)->second.setFeSpace(feSpace);
}
int ParallelDofMapping::getRankDofs(vector<const FiniteElemSpace*> &fe)
{
FUNCNAME("ParallelDofMapping::getRankDofs()");
int result = 0;
for (unsigned int i = 0; i < fe.size(); i++) {
TEST_EXIT_DBG(data.count(fe[i]))("Cannot find FE space: %p\n", fe[i]);
result += data[fe[i]].nRankDofs;
}
return result;
}
int ParallelDofMapping::getLocalDofs(vector<const FiniteElemSpace*> &fe)
{
FUNCNAME("ParallelDofMapping::getLocalDofs()");
int result = 0;
for (unsigned int i = 0; i < fe.size(); i++) {
TEST_EXIT_DBG(data.count(fe[i]))("Cannot find FE space: %p\n", fe[i]);
result += data[fe[i]].nLocalDofs;
}
return result;
}
int ParallelDofMapping::getOverallDofs(vector<const FiniteElemSpace*> &feSpaces)
{
FUNCNAME("ParallelDofMapping::getOverallDofs()");
int result = 0;
for (unsigned int i = 0; i < feSpaces.size(); i++) {
TEST_EXIT_DBG(data.count(feSpaces[i]))("Should not happen!\n");
result += data.find(feSpaces[i])->second.nOverallDofs;
}
return result;
}
int ParallelDofMapping::getStartDofs(vector<const FiniteElemSpace*> &feSpaces)
{
FUNCNAME("ParallelDofMapping::getStartDofs()");
int result = 0;
for (unsigned int i = 0; i < feSpaces.size(); i++) {
TEST_EXIT_DBG(data.count(feSpaces[i]))("Should not happen!\n");
result += data.find(feSpaces[i])->second.rStartDofs;
}
return result;
}
void ParallelDofMapping::init(MPI::Intracomm *m,
vector<const FiniteElemSpace*> &fe,
bool needGlobalMapping,
bool bNonLocalDofs)
{
FUNCNAME("ParallelDofMapping::init()");
mpiComm = m;
feSpaces = fe;
hasNonLocalDofs = bNonLocalDofs;
for (unsigned int i = 0; i < feSpaces.size(); i++) {
feSpacesUnique.insert(feSpaces[i]);
addFeSpace(feSpaces[i]);
data[feSpaces[i]].setNeedGlobalMapping(needGlobalMapping);
data[feSpaces[i]].setNonLocalDofs(hasNonLocalDofs);
}
}
void ParallelDofMapping::update()
{
FUNCNAME("ParallelDofMapping::update()");
for (std::set<const FiniteElemSpace*>::iterator it = feSpacesUnique.begin();
it != feSpacesUnique.end(); ++it)
data[*it].update();
nRankDofs = getRankDofs(feSpaces);
nLocalDofs = getLocalDofs(feSpaces);
nOverallDofs = getOverallDofs(feSpaces);
rStartDofs = getStartDofs(feSpaces);
computeMatIndex();
}
void ParallelDofMapping::computeMatIndex()
{
FUNCNAME("ParallelDofMapping::computeMatIndex()");
dofToMatIndex.clear();
int offset = rStartDofs;
for (unsigned int i = 0; i < feSpaces.size(); i++) {
map<DegreeOfFreedom, MultiIndex>& dofMap = data[feSpaces[i]].getMap();
typedef map<DegreeOfFreedom, MultiIndex>::iterator ItType;
for (ItType it = dofMap.begin(); it != dofMap.end(); ++it) {
if (data[feSpaces[i]].isRankDof(it->first)) {
int globalMatIndex = it->second.local + offset;
dofToMatIndex.add(i, it->first, globalMatIndex);
}
}
offset += data[feSpaces[i]].nRankDofs;
if (!hasNonLocalDofs)
continue;
TEST_EXIT_DBG(sendDofs != NULL && recvDofs != NULL)
("No communicator given!\n");
StdMpi<vector<DegreeOfFreedom> > stdMpi(*mpiComm);
for (DofComm::Iterator it(*sendDofs, feSpaces[i]);
!it.end(); it.nextRank()) {
vector<DegreeOfFreedom> sendGlobalDofs;
for (; !it.endDofIter(); it.nextDof())
if (dofMap.count(it.getDofIndex()))
sendGlobalDofs.push_back(dofToMatIndex.get(i, it.getDofIndex()));
stdMpi.send(it.getRank(), sendGlobalDofs);
}
for (DofComm::Iterator it(*recvDofs, feSpaces[i]);
!it.end(); it.nextRank())
stdMpi.recv(it.getRank());
stdMpi.startCommunication();
{
for (DofComm::Iterator it(*recvDofs, feSpaces[i]);
!it.end(); it.nextRank()) {
int counter = 0;
for (; !it.endDofIter(); it.nextDof()) {
if (dofMap.count(it.getDofIndex())) {
DegreeOfFreedom d = stdMpi.getRecvData(it.getRank())[counter++];
dofToMatIndex.add(i, it.getDofIndex(), d);
}
}
}
}
}
}
void ParallelDofMapping::setDofComm(DofComm &pSend, DofComm &pRecv)
{
FUNCNAME("ParallelDofMapping::setDofComm()");
sendDofs = &pSend;
recvDofs = &pRecv;
for (std::set<const FiniteElemSpace*>::iterator it = feSpacesUnique.begin();
it != feSpacesUnique.end(); ++it)
data[*it].setDofComm(pSend, pRecv);
}
} }
...@@ -216,11 +216,10 @@ namespace AMDiS { ...@@ -216,11 +216,10 @@ namespace AMDiS {
}; };
template<typename T> class ParallelDofMapping
class FeSpaceData
{ {
public: public:
FeSpaceData() ParallelDofMapping()
: mpiComm(NULL), : mpiComm(NULL),
sendDofs(NULL), sendDofs(NULL),
recvDofs(NULL), recvDofs(NULL),
...@@ -231,39 +230,18 @@ namespace AMDiS { ...@@ -231,39 +230,18 @@ namespace AMDiS {
rStartDofs(-1) rStartDofs(-1)
{} {}
T& operator[](const FiniteElemSpace* feSpace) inline GlobalDofMap& operator[](const FiniteElemSpace* feSpace)
{ {
FUNCNAME("FeSpaceData::operator[]()"); FUNCNAME("ParallelDofMapping::operator[]()");
TEST_EXIT_DBG(data.count(feSpace))("Should not happen!\n"); TEST_EXIT_DBG(data.count(feSpace))("Should not happen!\n");
return data.find(feSpace)->second; return data.find(feSpace)->second;
} }
void addFeSpace(const FiniteElemSpace* feSpace) void addFeSpace(const FiniteElemSpace* feSpace);
{
FUNCNAME("FeSpaceData::addFeSpace()");
if (data.count(feSpace))
data.find(feSpace)->second.clear();
else
data.insert(make_pair(feSpace, T(mpiComm)));
data.find(feSpace)->second.setFeSpace(feSpace);
}
int getRankDofs(vector<const FiniteElemSpace*> &fe)
{
FUNCNAME("FeSpaceData::getRankDofs()");
int result = 0; int getRankDofs(vector<const FiniteElemSpace*> &fe);
for (unsigned int i = 0; i < fe.size(); i++) {
TEST_EXIT_DBG(data.count(fe[i]))("Cannot find FE space: %p\n", fe[i]);
result += data[fe[i]].nRankDofs;
}
return result;
}
inline int getRankDofs() inline int getRankDofs()
{ {
...@@ -272,18 +250,7 @@ namespace AMDiS { ...@@ -272,18 +250,7 @@ namespace AMDiS {
return nRankDofs; return nRankDofs;
} }
int getLocalDofs(vector<const FiniteElemSpace*> &fe) int getLocalDofs(vector<const FiniteElemSpace*> &fe);
{
FUNCNAME("FeSpaceData::getLocalDofs()");
int result = 0;
for (unsigned int i = 0; i < fe.size(); i++) {
TEST_EXIT_DBG(data.count(fe[i]))("Cannot find FE space: %p\n", fe[i]);
result += data[fe[i]].nLocalDofs;
}
return result;
}
inline int getLocalDofs() inline int getLocalDofs()
{ {
...@@ -292,16 +259,7 @@ namespace AMDiS { ...@@ -292,16 +259,7 @@ namespace AMDiS {
return nLocalDofs; return nLocalDofs;
} }
int getOverallDofs(vector<const FiniteElemSpace*> &feSpaces) int getOverallDofs(vector<const FiniteElemSpace*> &feSpaces);
{
int result = 0;
for (unsigned int i = 0; i < feSpaces.size(); i++) {
TEST_EXIT_DBG(data.count(feSpaces[i]))("Should not happen!\n");
result += data.find(feSpaces[i])->second.nOverallDofs;
}
return result;
}
inline int getOverallDofs() inline int getOverallDofs()
{ {
...@@ -310,18 +268,9 @@ namespace AMDiS { ...@@ -310,18 +268,9 @@ namespace AMDiS {
return nOverallDofs; return nOverallDofs;
} }
int getStartDofs(vector<const FiniteElemSpace*> &feSpaces) int getStartDofs(vector<const FiniteElemSpace*> &feSpaces);
{
int result = 0;
for (unsigned int i = 0; i < feSpaces.size(); i++) {
TEST_EXIT_DBG(data.count(feSpaces[i]))("Should not happen!\n");
result += data.find(feSpaces[i])->second.rStartDofs;
}
return result;
}
int getStartDofs() inline int getStartDofs()
{ {
TEST_EXIT_DBG(rStartDofs >= 0)("Should not happen!\n"); TEST_EXIT_DBG(rStartDofs >= 0)("Should not happen!\n");
...@@ -331,102 +280,13 @@ namespace AMDiS { ...@@ -331,102 +280,13 @@ namespace AMDiS {
void init(MPI::Intracomm *m, void init(MPI::Intracomm *m,
vector<const FiniteElemSpace*> &fe, vector<const FiniteElemSpace*> &fe,
bool needGlobalMapping, bool needGlobalMapping,
bool bNonLocalDofs) bool bNonLocalDofs);
{
mpiComm = m;
feSpaces = fe;
hasNonLocalDofs = bNonLocalDofs;
for (unsigned int i = 0; i < feSpaces.size(); i++) {
feSpacesUnique.insert(feSpaces[i]);
addFeSpace(feSpaces[i]);
data[feSpaces[i]].setNeedGlobalMapping(needGlobalMapping);
data[feSpaces[i]].setNonLocalDofs(hasNonLocalDofs);
}
}
void update()
{
for (std::set<const FiniteElemSpace*>::iterator it = feSpacesUnique.begin();
it != feSpacesUnique.end(); ++it)
data[*it].update();
nRankDofs = getRankDofs(feSpaces);
nLocalDofs = getLocalDofs(feSpaces);
nOverallDofs = getOverallDofs(feSpaces);
rStartDofs = getStartDofs(feSpaces);
computeMatIndex();
}
void computeMatIndex() void update();
{
dofToMatIndex.clear();
int offset = rStartDofs;
for (unsigned int i = 0; i < feSpaces.size(); i++) {
map<DegreeOfFreedom, MultiIndex>& dofMap = data[feSpaces[i]].getMap();
typedef map<DegreeOfFreedom, MultiIndex>::iterator ItType;
for (ItType it = dofMap.begin(); it != dofMap.end(); ++it) {
if (data[feSpaces[i]].isRankDof(it->first)) {
int globalMatIndex = it->second.local + offset;
dofToMatIndex.add(i, it->first, globalMatIndex);
}
}
offset += data[feSpaces[i]].nRankDofs;
if (!hasNonLocalDofs)
continue;
TEST_EXIT_DBG(sendDofs != NULL && recvDofs != NULL)
("No communicator given!\n");
StdMpi<vector<DegreeOfFreedom> > stdMpi(*mpiComm);
for (DofComm::Iterator it(*sendDofs, feSpaces[i]);
!it.end(); it.nextRank()) {
vector<DegreeOfFreedom> sendGlobalDofs;
for (; !it.endDofIter(); it.nextDof())
if (dofMap.count(it.getDofIndex()))
sendGlobalDofs.push_back(dofToMatIndex.get(i, it.getDofIndex()));
stdMpi.send(it.getRank(), sendGlobalDofs);
}
for (DofComm::Iterator it(*recvDofs, feSpaces[i]);
!it.end(); it.nextRank())
stdMpi.recv(it.getRank());
stdMpi.startCommunication();
{
for (DofComm::Iterator it(*recvDofs, feSpaces[i]);
!it.end(); it.nextRank()) {
int counter = 0;
for (; !it.endDofIter(); it.nextDof()) {
if (dofMap.count(it.getDofIndex())) {
DegreeOfFreedom d = stdMpi.getRecvData(it.getRank())[counter++];
dofToMatIndex.add(i, it.getDofIndex(), d);
}
}
}
}
}
}
void setDofComm(DofComm &pSend, DofComm &pRecv) void computeMatIndex();
{
sendDofs = &pSend;
recvDofs = &pRecv;
for (std::set<const FiniteElemSpace*>::iterator it = feSpacesUnique.begin(); void setDofComm(DofComm &pSend, DofComm &pRecv);
it != feSpacesUnique.end(); ++it)
data[*it].setDofComm(pSend, pRecv);
}
inline int getMatIndex(int ithComponent, DegreeOfFreedom d) inline int getMatIndex(int ithComponent, DegreeOfFreedom d)
{ {
...@@ -435,7 +295,7 @@ namespace AMDiS { ...@@ -435,7 +295,7 @@ namespace AMDiS {
inline int getLocalMatIndex(int ithComponent, DegreeOfFreedom d) inline int getLocalMatIndex(int ithComponent, DegreeOfFreedom d)
{ {
FUNCNAME("FeSpaceData::getLocalMatIndex()"); FUNCNAME("ParallelDofMapping::getLocalMatIndex()");
TEST_EXIT_DBG(data[feSpaces[ithComponent]].isRankDof(d)) TEST_EXIT_DBG(data[feSpaces[ithComponent]].isRankDof(d))
("Should not happen!\n"); ("Should not happen!\n");
...@@ -455,7 +315,7 @@ namespace AMDiS { ...@@ -455,7 +315,7 @@ namespace AMDiS {
/// are also owned by this rank. /// are also owned by this rank.
bool hasNonLocalDofs; bool hasNonLocalDofs;
map<const FiniteElemSpace*, T> data; map<const FiniteElemSpace*, GlobalDofMap> data;
vector<const FiniteElemSpace*> feSpaces; vector<const FiniteElemSpace*> feSpaces;
......
...@@ -2287,7 +2287,7 @@ namespace AMDiS { ...@@ -2287,7 +2287,7 @@ namespace AMDiS {
TEST_EXIT_DBG(dofFeData.count(feSpace))("Should not happen!\n"); TEST_EXIT_DBG(dofFeData.count(feSpace))("Should not happen!\n");
for (DofMapping::iterator it = dofFeData[feSpace].mapDofToGlobal.begin(); for (DofMap::iterator it = dofFeData[feSpace].mapDofToGlobal.begin();
it != dofFeData[feSpace].mapDofToGlobal.end(); ++it) it != dofFeData[feSpace].mapDofToGlobal.end(); ++it)
if (it->second == dof) if (it->second == dof)
return it->first; return it->first;
......
...@@ -70,10 +70,10 @@ namespace AMDiS { ...@@ -70,10 +70,10 @@ namespace AMDiS {
DofIndexToBool isRankDof; DofIndexToBool isRankDof;
/// Maps local to global dof indices. /// Maps local to global dof indices.
DofMapping mapDofToGlobal; DofMap mapDofToGlobal;
/// Maps local dof indices to real dof indices. /// Maps local dof indices to real dof indices.
DofMapping mapLocalToDof; DofMap mapLocalToDof;
}; };
...@@ -271,7 +271,7 @@ namespace AMDiS { ...@@ -271,7 +271,7 @@ namespace AMDiS {
return result; return result;
} }
inline DofMapping& getMapDofToGlobal(const FiniteElemSpace *feSpace) inline DofMap& getMapDofToGlobal(const FiniteElemSpace *feSpace)
{ {
FUNCNAME("MeshDistributor::getMapDofToGlobal()"); FUNCNAME("MeshDistributor::getMapDofToGlobal()");
......
...@@ -203,7 +203,7 @@ namespace AMDiS { ...@@ -203,7 +203,7 @@ namespace AMDiS {
for (PeriodicDofMap::iterator it = otherMap.begin(); for (PeriodicDofMap::iterator it = otherMap.begin();
it != otherMap.end(); ++it) { it != otherMap.end(); ++it) {
for (DofMapping::iterator dofIt = it->second.begin(); for (DofMap::iterator dofIt = it->second.begin();
dofIt != it->second.end(); ++dofIt) { dofIt != it->second.end(); ++dofIt) {
if (dofMap.count(it->first) == 1 && if (dofMap.count(it->first) == 1 &&
dofMap[it->first].count(dofIt->first) == 1) { dofMap[it->first].count(dofIt->first) == 1) {
...@@ -222,7 +222,7 @@ namespace AMDiS { ...@@ -222,7 +222,7 @@ namespace AMDiS {
for (PeriodicDofMap::iterator it = dofMap.begin(); for (PeriodicDofMap::iterator it = dofMap.begin();
it != dofMap.end(); ++it) { it != dofMap.end(); ++it) {
for (DofMapping::iterator dofIt = it->second.begin(); for (DofMap::iterator dofIt = it->second.begin();
dofIt != it->second.end(); ++dofIt) { dofIt != it->second.end(); ++dofIt) {
if (it->second[dofIt->second] != dofIt->first) { if (it->second[dofIt->second] != dofIt->first) {
MSG("[DBG] For boundary type %d: DOF %d -> %d, but %d -> %d!\n", MSG("[DBG] For boundary type %d: DOF %d -> %d, but %d -> %d!\n",
...@@ -646,7 +646,7 @@ namespace AMDiS { ...@@ -646,7 +646,7 @@ namespace AMDiS {
cout << "====== DOF MAP LOCAL -> GLOBAL ====== " << endl; cout << "====== DOF MAP LOCAL -> GLOBAL ====== " << endl;
for (DofMapping::iterator it = pdb.dofFeData[feSpace].mapDofToGlobal.begin(); for (DofMap::iterator it = pdb.dofFeData[feSpace].mapDofToGlobal.begin();
it != pdb.dofFeData[feSpace].mapDofToGlobal.end(); it++) { it != pdb.dofFeData[feSpace].mapDofToGlobal.end(); it++) {
DegreeOfFreedom localdof = -1; DegreeOfFreedom localdof = -1;
if (pdb.dofFeData[feSpace].mapLocalToDof.count(it->first) > 0) if (pdb.dofFeData[feSpace].mapLocalToDof.count(it->first) > 0)
...@@ -686,7 +686,7 @@ namespace AMDiS { ...@@ -686,7 +686,7 @@ namespace AMDiS {
const FiniteElemSpace* feSpace = pdb.feSpaces[0]; const FiniteElemSpace* feSpace = pdb.feSpaces[0];
typedef map<DegreeOfFreedom, DegreeOfFreedom> DofMapping; typedef map<DegreeOfFreedom, DegreeOfFreedom> DofMap;
typedef map<DegreeOfFreedom, std::set<DegreeOfFreedom> > PeriodicDofMap; typedef map<DegreeOfFreedom, std::set<DegreeOfFreedom> > PeriodicDofMap;
if (rank == -1 || pdb.mpiRank == rank) { if (rank == -1 || pdb.mpiRank == rank) {
...@@ -701,7 +701,7 @@ namespace AMDiS { ...@@ -701,7 +701,7 @@ namespace AMDiS {
cout << endl; cout << endl;
DegreeOfFreedom localdof = -1; DegreeOfFreedom localdof = -1;
for (DofMapping::iterator dofIt = pdb.dofFeData[feSpace].mapDofToGlobal.begin(); for (DofMap::iterator dofIt = pdb.dofFeData[feSpace].mapDofToGlobal.begin();
dofIt != pdb.dofFeData[feSpace].mapDofToGlobal.end(); ++dofIt) dofIt != pdb.dofFeData[feSpace].mapDofToGlobal.end(); ++dofIt)
if (dofIt->second == it->first) if (dofIt->second == it->first)
localdof = dofIt->first; localdof = dofIt->first;
......
...@@ -49,7 +49,7 @@ namespace AMDiS { ...@@ -49,7 +49,7 @@ namespace AMDiS {
typedef map<int, DofContainer> RankToDofContainer; typedef map<int, DofContainer> RankToDofContainer;
/// Defines a mapping type from DOF indices to DOF indices. /// Defines a mapping type from DOF indices to DOF indices.
typedef map<DegreeOfFreedom, DegreeOfFreedom> DofMapping; typedef map<DegreeOfFreedom, DegreeOfFreedom> DofMap;
/// Defines a mapping type from DOFs to boolean values. /// Defines a mapping type from DOFs to boolean values.
typedef map<const DegreeOfFreedom*, bool> DofToBool; typedef map<const DegreeOfFreedom*, bool> DofToBool;
......