Commit e8831f17 authored by Thomas Witkowski's avatar Thomas Witkowski

Backup my code.

parent 3225608e
......@@ -55,6 +55,7 @@ namespace AMDiS {
recvDofs(NULL),
needGlobalMapping(false),
nRankDofs(0),
nLocalDofs(0),
nOverallDofs(0),
rStartDofs(0),
overlap(false)
......@@ -76,7 +77,7 @@ namespace AMDiS {
TEST_EXIT_DBG(dofMap.count(dof0) == 0)("Should not happen!\n");
dofMap[dof0].local = dof1;
nLocalDofs++;
if (dof1 != -1)
nRankDofs++;
}
......@@ -88,7 +89,7 @@ namespace AMDiS {
TEST_EXIT_DBG(dofMap.count(dof0) == 0)("Should not happen!\n");
dofMap[dof0].local = dof1;
nLocalDofs++;
nonRankDofs.insert(dof0);
}
......@@ -155,7 +156,7 @@ namespace AMDiS {
bool needGlobalMapping;
public:
///
int nRankDofs, nOverallDofs, rStartDofs;
int nRankDofs, nLocalDofs, nOverallDofs, rStartDofs;
bool overlap;
};
......@@ -214,6 +215,26 @@ namespace AMDiS {
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 result = 0;
......@@ -257,6 +278,8 @@ namespace AMDiS {
mpiComm = m;
feSpaces = fe;
for (unsigned int i = 0; i < feSpaces.size(); i++) {
feSpacesUnique.insert(feSpaces[i]);
addFeSpace(feSpaces[i]);
data[feSpaces[i]].setNeedGlobalMapping(needGlobalMapping);
}
......@@ -264,10 +287,12 @@ namespace AMDiS {
void update()
{
// for (unsigned int i = 0; i < feSpaces.size(); i++)
// data[feSpaces[i]].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);
}
......@@ -317,7 +342,9 @@ namespace AMDiS {
vector<const FiniteElemSpace*> feSpaces;
int nRankDofs, nOverallDofs, rStartDofs;
std::set<const FiniteElemSpace*> feSpacesUnique;
int nRankDofs, nLocalDofs, nOverallDofs, rStartDofs;
};
}
......
......@@ -218,7 +218,6 @@ namespace AMDiS {
for (unsigned int i = 0; i < meshDistributor->getFeSpaces().size(); i++) {
const FiniteElemSpace *feSpace = meshDistributor->getFeSpace(i);
createPrimals(feSpace);
createDuals(feSpace);
createLagrange(feSpace);
......@@ -244,56 +243,11 @@ namespace AMDiS {
lagrangeMap[feSpace].nRankDofs,
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)
{
{
FUNCNAME("PetscSolverFeti::createPrimals()");
// === Define all vertices on the interior boundaries of the macro mesh ===
......@@ -322,8 +276,6 @@ namespace AMDiS {
primalDofMap[feSpace].setOverlap(true);
primalDofMap[feSpace].setDofComm(meshDistributor->getSendDofs(),
meshDistributor->getRecvDofs());
primalDofMap[feSpace].update();
}
......@@ -393,8 +345,6 @@ namespace AMDiS {
it != allBoundaryDofs.end(); ++it)
if (!isPrimal(feSpace, **it))
dualDofMap[feSpace].insertRankDof(**it);
dualDofMap[feSpace].update();
}
......@@ -409,13 +359,17 @@ namespace AMDiS {
map<DegreeOfFreedom, MultiIndex>& dualMap = dualDofMap[feSpace].getMap();
for (map<DegreeOfFreedom, MultiIndex>::iterator it = dualMap.begin(); it != dualMap.end(); ++it) {
if (meshDistributor->getIsRankDof(feSpace, it->first)) {
lagrangeMap[feSpace].insert(it->first, nRankLagrange);
lagrangeMap[feSpace].insertRankDof(it->first, nRankLagrange);
int degree = boundaryDofRanks[it->first].size();
nRankLagrange += (degree * (degree - 1)) / 2;
} else {
lagrangeMap[feSpace].insert(it->first);
}
}
lagrangeMap[feSpace].nRankDofs = nRankLagrange;
lagrangeMap[feSpace].update();
lagrangeMap[feSpace].setOverlap(true);
lagrangeMap[feSpace].setDofComm(meshDistributor->getSendDofs(),
meshDistributor->getRecvDofs());
}
......@@ -449,8 +403,6 @@ namespace AMDiS {
for (map<DegreeOfFreedom, MultiIndex>::iterator it = dualDofMap[feSpace].getMap().begin();
it != dualDofMap[feSpace].getMap().end(); ++it)
localDofMap[feSpace].insertRankDof(it->first);
localDofMap[feSpace].update();
}
......@@ -586,8 +538,7 @@ namespace AMDiS {
int maxLocalPrimal = mat_b_primal_cols.size();
mpi::globalMax(maxLocalPrimal);
TEST_EXIT(mat_b_primal_cols.size() ==
primalDofMap[feSpace].size() * nComponents)
TEST_EXIT(mat_b_primal_cols.size() == primalDofMap.getLocalDofs())
("Should not happen!\n");
for (map<int, vector<pair<int, double> > >::iterator it = mat_b_primal_cols.begin();
it != mat_b_primal_cols.end(); ++it) {
......@@ -831,8 +782,8 @@ namespace AMDiS {
// === contained in rank's domain. ===
vector<PetscInt> globalIsIndex, localIsIndex;
globalIsIndex.reserve(primalDofMap[feSpace].size() * nComponents);
localIsIndex.reserve(primalDofMap[feSpace].size() * nComponents);
globalIsIndex.reserve(primalDofMap.getLocalDofs());
localIsIndex.reserve(primalDofMap.getLocalDofs());
{
int counter = 0;
......
Markdown is supported
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