Commit e8831f17 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Backup my code.

parent 3225608e
...@@ -55,6 +55,7 @@ namespace AMDiS { ...@@ -55,6 +55,7 @@ namespace AMDiS {
recvDofs(NULL), recvDofs(NULL),
needGlobalMapping(false), needGlobalMapping(false),
nRankDofs(0), nRankDofs(0),
nLocalDofs(0),
nOverallDofs(0), nOverallDofs(0),
rStartDofs(0), rStartDofs(0),
overlap(false) overlap(false)
...@@ -76,7 +77,7 @@ namespace AMDiS { ...@@ -76,7 +77,7 @@ namespace AMDiS {
TEST_EXIT_DBG(dofMap.count(dof0) == 0)("Should not happen!\n"); TEST_EXIT_DBG(dofMap.count(dof0) == 0)("Should not happen!\n");
dofMap[dof0].local = dof1; dofMap[dof0].local = dof1;
nLocalDofs++;
if (dof1 != -1) if (dof1 != -1)
nRankDofs++; nRankDofs++;
} }
...@@ -88,7 +89,7 @@ namespace AMDiS { ...@@ -88,7 +89,7 @@ namespace AMDiS {
TEST_EXIT_DBG(dofMap.count(dof0) == 0)("Should not happen!\n"); TEST_EXIT_DBG(dofMap.count(dof0) == 0)("Should not happen!\n");
dofMap[dof0].local = dof1; dofMap[dof0].local = dof1;
nLocalDofs++;
nonRankDofs.insert(dof0); nonRankDofs.insert(dof0);
} }
...@@ -155,7 +156,7 @@ namespace AMDiS { ...@@ -155,7 +156,7 @@ namespace AMDiS {
bool needGlobalMapping; bool needGlobalMapping;
public: public:
/// ///
int nRankDofs, nOverallDofs, rStartDofs; int nRankDofs, nLocalDofs, nOverallDofs, rStartDofs;
bool overlap; bool overlap;
}; };
...@@ -214,6 +215,26 @@ namespace AMDiS { ...@@ -214,6 +215,26 @@ namespace AMDiS {
return nRankDofs; return nRankDofs;
} }
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()
{
TEST_EXIT_DBG(nLocalDofs >= 0)("Should not happen!\n");
return nLocalDofs;
}
int getOverallDofs(vector<const FiniteElemSpace*> &feSpaces) int getOverallDofs(vector<const FiniteElemSpace*> &feSpaces)
{ {
int result = 0; int result = 0;
...@@ -257,6 +278,8 @@ namespace AMDiS { ...@@ -257,6 +278,8 @@ namespace AMDiS {
mpiComm = m; mpiComm = m;
feSpaces = fe; feSpaces = fe;
for (unsigned int i = 0; i < feSpaces.size(); i++) { for (unsigned int i = 0; i < feSpaces.size(); i++) {
feSpacesUnique.insert(feSpaces[i]);
addFeSpace(feSpaces[i]); addFeSpace(feSpaces[i]);
data[feSpaces[i]].setNeedGlobalMapping(needGlobalMapping); data[feSpaces[i]].setNeedGlobalMapping(needGlobalMapping);
} }
...@@ -264,10 +287,12 @@ namespace AMDiS { ...@@ -264,10 +287,12 @@ namespace AMDiS {
void update() void update()
{ {
// for (unsigned int i = 0; i < feSpaces.size(); i++) for (std::set<const FiniteElemSpace*>::iterator it = feSpacesUnique.begin();
// data[feSpaces[i]].update(); it != feSpacesUnique.end(); ++it)
data[*it].update();
nRankDofs = getRankDofs(feSpaces); nRankDofs = getRankDofs(feSpaces);
nLocalDofs = getLocalDofs(feSpaces);
nOverallDofs = getOverallDofs(feSpaces); nOverallDofs = getOverallDofs(feSpaces);
rStartDofs = getStartDofs(feSpaces); rStartDofs = getStartDofs(feSpaces);
} }
...@@ -317,7 +342,9 @@ namespace AMDiS { ...@@ -317,7 +342,9 @@ namespace AMDiS {
vector<const FiniteElemSpace*> feSpaces; vector<const FiniteElemSpace*> feSpaces;
int nRankDofs, nOverallDofs, rStartDofs; std::set<const FiniteElemSpace*> feSpacesUnique;
int nRankDofs, nLocalDofs, nOverallDofs, rStartDofs;
}; };
} }
......
...@@ -218,7 +218,6 @@ namespace AMDiS { ...@@ -218,7 +218,6 @@ namespace AMDiS {
for (unsigned int i = 0; i < meshDistributor->getFeSpaces().size(); i++) { for (unsigned int i = 0; i < meshDistributor->getFeSpaces().size(); i++) {
const FiniteElemSpace *feSpace = meshDistributor->getFeSpace(i); const FiniteElemSpace *feSpace = meshDistributor->getFeSpace(i);
createPrimals(feSpace); createPrimals(feSpace);
createDuals(feSpace); createDuals(feSpace);
createLagrange(feSpace); createLagrange(feSpace);
...@@ -244,56 +243,11 @@ namespace AMDiS { ...@@ -244,56 +243,11 @@ namespace AMDiS {
lagrangeMap[feSpace].nRankDofs, lagrangeMap[feSpace].nRankDofs,
lagrangeMap[feSpace].nOverallDofs); lagrangeMap[feSpace].nOverallDofs);
} }
// === Communicate lagrangeMap to all other ranks. ===
for (unsigned int i = 0; i < meshDistributor->getFeSpaces().size(); i++) {
const FiniteElemSpace *feSpace = meshDistributor->getFeSpace(i);
StdMpi<vector<int> > stdMpi(meshDistributor->getMpiComm());
for (DofComm::Iterator it(meshDistributor->getSendDofs(), feSpace);
!it.end(); it.nextRank()) {
for (; !it.endDofIter(); it.nextDof())
if (!isPrimal(feSpace, it.getDofIndex())) {
DegreeOfFreedom d = lagrangeMap[feSpace][it.getDofIndex()].local;
stdMpi.getSendData(it.getRank()).push_back(d);
}
}
stdMpi.updateSendDataSize();
for (DofComm::Iterator it(meshDistributor->getRecvDofs(), feSpace);
!it.end(); it.nextRank()) {
bool recvData = false;
for (; !it.endDofIter(); it.nextDof())
if (!isPrimal(feSpace, it.getDofIndex())) {
recvData = true;
break;
}
if (recvData)
stdMpi.recv(it.getRank());
}
stdMpi.startCommunication();
for (DofComm::Iterator it(meshDistributor->getRecvDofs(), feSpace);
!it.end(); it.nextRank()) {
int counter = 0;
for (; !it.endDofIter(); it.nextDof()) {
if (!isPrimal(feSpace, it.getDofIndex())) {
DegreeOfFreedom d = stdMpi.getRecvData(it.getRank())[counter++];
lagrangeMap[feSpace].insert(it.getDofIndex(), d);
}
}
}
}
} }
void PetscSolverFeti::createPrimals(const FiniteElemSpace *feSpace) void PetscSolverFeti::createPrimals(const FiniteElemSpace *feSpace)
{ {
FUNCNAME("PetscSolverFeti::createPrimals()"); FUNCNAME("PetscSolverFeti::createPrimals()");
// === Define all vertices on the interior boundaries of the macro mesh === // === Define all vertices on the interior boundaries of the macro mesh ===
...@@ -322,8 +276,6 @@ namespace AMDiS { ...@@ -322,8 +276,6 @@ namespace AMDiS {
primalDofMap[feSpace].setOverlap(true); primalDofMap[feSpace].setOverlap(true);
primalDofMap[feSpace].setDofComm(meshDistributor->getSendDofs(), primalDofMap[feSpace].setDofComm(meshDistributor->getSendDofs(),
meshDistributor->getRecvDofs()); meshDistributor->getRecvDofs());
primalDofMap[feSpace].update();
} }
...@@ -393,8 +345,6 @@ namespace AMDiS { ...@@ -393,8 +345,6 @@ namespace AMDiS {
it != allBoundaryDofs.end(); ++it) it != allBoundaryDofs.end(); ++it)
if (!isPrimal(feSpace, **it)) if (!isPrimal(feSpace, **it))
dualDofMap[feSpace].insertRankDof(**it); dualDofMap[feSpace].insertRankDof(**it);
dualDofMap[feSpace].update();
} }
...@@ -409,13 +359,17 @@ namespace AMDiS { ...@@ -409,13 +359,17 @@ namespace AMDiS {
map<DegreeOfFreedom, MultiIndex>& dualMap = dualDofMap[feSpace].getMap(); map<DegreeOfFreedom, MultiIndex>& dualMap = dualDofMap[feSpace].getMap();
for (map<DegreeOfFreedom, MultiIndex>::iterator it = dualMap.begin(); it != dualMap.end(); ++it) { for (map<DegreeOfFreedom, MultiIndex>::iterator it = dualMap.begin(); it != dualMap.end(); ++it) {
if (meshDistributor->getIsRankDof(feSpace, it->first)) { if (meshDistributor->getIsRankDof(feSpace, it->first)) {
lagrangeMap[feSpace].insert(it->first, nRankLagrange); lagrangeMap[feSpace].insertRankDof(it->first, nRankLagrange);
int degree = boundaryDofRanks[it->first].size(); int degree = boundaryDofRanks[it->first].size();
nRankLagrange += (degree * (degree - 1)) / 2; nRankLagrange += (degree * (degree - 1)) / 2;
} else {
lagrangeMap[feSpace].insert(it->first);
} }
} }
lagrangeMap[feSpace].nRankDofs = nRankLagrange; lagrangeMap[feSpace].nRankDofs = nRankLagrange;
lagrangeMap[feSpace].update(); lagrangeMap[feSpace].setOverlap(true);
lagrangeMap[feSpace].setDofComm(meshDistributor->getSendDofs(),
meshDistributor->getRecvDofs());
} }
...@@ -449,8 +403,6 @@ namespace AMDiS { ...@@ -449,8 +403,6 @@ namespace AMDiS {
for (map<DegreeOfFreedom, MultiIndex>::iterator it = dualDofMap[feSpace].getMap().begin(); for (map<DegreeOfFreedom, MultiIndex>::iterator it = dualDofMap[feSpace].getMap().begin();
it != dualDofMap[feSpace].getMap().end(); ++it) it != dualDofMap[feSpace].getMap().end(); ++it)
localDofMap[feSpace].insertRankDof(it->first); localDofMap[feSpace].insertRankDof(it->first);
localDofMap[feSpace].update();
} }
...@@ -586,8 +538,7 @@ namespace AMDiS { ...@@ -586,8 +538,7 @@ namespace AMDiS {
int maxLocalPrimal = mat_b_primal_cols.size(); int maxLocalPrimal = mat_b_primal_cols.size();
mpi::globalMax(maxLocalPrimal); mpi::globalMax(maxLocalPrimal);
TEST_EXIT(mat_b_primal_cols.size() == TEST_EXIT(mat_b_primal_cols.size() == primalDofMap.getLocalDofs())
primalDofMap[feSpace].size() * nComponents)
("Should not happen!\n"); ("Should not happen!\n");
for (map<int, vector<pair<int, double> > >::iterator it = mat_b_primal_cols.begin(); for (map<int, vector<pair<int, double> > >::iterator it = mat_b_primal_cols.begin();
it != mat_b_primal_cols.end(); ++it) { it != mat_b_primal_cols.end(); ++it) {
...@@ -831,8 +782,8 @@ namespace AMDiS { ...@@ -831,8 +782,8 @@ namespace AMDiS {
// === contained in rank's domain. === // === contained in rank's domain. ===
vector<PetscInt> globalIsIndex, localIsIndex; vector<PetscInt> globalIsIndex, localIsIndex;
globalIsIndex.reserve(primalDofMap[feSpace].size() * nComponents); globalIsIndex.reserve(primalDofMap.getLocalDofs());
localIsIndex.reserve(primalDofMap[feSpace].size() * nComponents); localIsIndex.reserve(primalDofMap.getLocalDofs());
{ {
int counter = 0; int counter = 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment