Commit a8523376 authored by Thomas Witkowski's avatar Thomas Witkowski

MeshDistributer makes use of parallel DOF mapping.

parent 7f6405c6
This diff is collapsed.
......@@ -31,6 +31,7 @@
#include "parallel/MeshLevelData.h"
#include "parallel/MeshPartitioner.h"
#include "parallel/InteriorBoundary.h"
#include "parallel/ParallelDofMapping.h"
#include "parallel/PeriodicMap.h"
#include "parallel/StdMpi.h"
#include "AMDiS_fwd.h"
......@@ -56,25 +57,10 @@ namespace AMDiS {
struct DofData
{
/// Number of DOFs in the rank mesh.
int nRankDofs;
/// Is the index of the first global DOF index, which is owned by the rank.
int rStartDofs;
/// Number of DOFs in the whole domain.
int nOverallDofs;
/// 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.
DofIndexToBool isRankDof;
/// Maps local to global dof indices.
DofMap mapDofToGlobal;
/// Maps local dof indices to real dof indices.
DofMap mapLocalToDof;
};
......@@ -171,11 +157,7 @@ namespace AMDiS {
/// Returns the number of DOFs in rank's domain for a given FE space.
inline int getNumberRankDofs(const FiniteElemSpace *feSpace)
{
FUNCNAME("MeshDistributor::getNumberRankDofs()");
TEST_EXIT_DBG(dofFeData.count(feSpace))("Should not happen!\n");
return dofFeData[feSpace].nRankDofs;
return dofMap[feSpace].nRankDofs;
}
/// Returns the number of DOFs in rank's domain for a set of FE spaces.
......@@ -184,10 +166,8 @@ namespace AMDiS {
FUNCNAME("MeshDistributor::getNumberRankDofs()");
int result = 0;
for (unsigned int i = 0; i < feSpaces.size(); i++) {
TEST_EXIT_DBG(dofFeData.count(feSpaces[i]))("Should not happen!\n");
result += dofFeData[feSpaces[i]].nRankDofs;
}
for (unsigned int i = 0; i < feSpaces.size(); i++)
result += dofMap[feSpaces[i]].nRankDofs;
return result;
}
......@@ -195,11 +175,7 @@ namespace AMDiS {
/// Returns the first global DOF index of an FE space, owned by rank.
inline int getStartDofs(const FiniteElemSpace *feSpace)
{
FUNCNAME("MeshDistributor::getStartDofs()");
TEST_EXIT_DBG(dofFeData.count(feSpace))("Should not happen!\n");
return dofFeData[feSpace].rStartDofs;
return dofMap[feSpace].rStartDofs;
}
/// Returns the first global DOF index for a set of FE spaces, owned by rank.
......@@ -208,11 +184,8 @@ namespace AMDiS {
FUNCNAME("MeshDistributor::getStartDofs()");
int result = 0;
for (unsigned int i = 0; i < feSpaces.size(); i++) {
TEST_EXIT_DBG(dofFeData.count(feSpaces[i]))("Should not happen!\n");
result += dofFeData[feSpaces[i]].rStartDofs;
}
for (unsigned int i = 0; i < feSpaces.size(); i++)
result += dofMap[feSpaces[i]].rStartDofs;
return result;
}
......@@ -220,11 +193,7 @@ namespace AMDiS {
/// Returns the global number of DOFs for a given FE space.
inline int getNumberOverallDofs(const FiniteElemSpace *feSpace)
{
FUNCNAME("MeshDistributor::getNumberOverallDofs()");
TEST_EXIT_DBG(dofFeData.count(feSpace))("Should not happen!\n");
return dofFeData[feSpace].nOverallDofs;
return dofMap[feSpace].nOverallDofs;
}
/// Returns the global number of DOFs for a set of FE spaces.
......@@ -233,34 +202,22 @@ namespace AMDiS {
FUNCNAME("MeshDistributor::getNumberOverallDofs()");
int result = 0;
for (unsigned int i = 0; i < feSpaces.size(); i++) {
TEST_EXIT_DBG(dofFeData.count(feSpaces[i]))("Should not happen!\n");
result += dofFeData[feSpaces[i]].nOverallDofs;
}
for (unsigned int i = 0; i < feSpaces.size(); i++)
result += dofMap[feSpaces[i]].nOverallDofs;
return result;
}
inline DofMap& getMapDofToGlobal(const FiniteElemSpace *feSpace)
inline map<DegreeOfFreedom, MultiIndex>& getMapDofToGlobal(const FiniteElemSpace *feSpace)
{
FUNCNAME("MeshDistributor::getMapDofToGlobal()");
TEST_EXIT_DBG(dofFeData.count(feSpace))("Should not happen!\n");
return dofFeData[feSpace].mapDofToGlobal;
return dofMap[feSpace].getMap();
}
/// Maps a local DOF to its global index.
inline DegreeOfFreedom mapDofToGlobal(const FiniteElemSpace *feSpace,
DegreeOfFreedom dof)
{
FUNCNAME("MeshDistributor::mapDofToGlobal()");
TEST_EXIT_DBG(dofFeData.count(feSpace))
("No DOF data for FE space at addr %p!\n", feSpace);
return dofFeData[feSpace].mapDofToGlobal[dof];
return dofMap[feSpace][dof].global;
}
/// Returns for a global index the DOF index in rank's subdomain. As there
......@@ -270,18 +227,6 @@ namespace AMDiS {
DegreeOfFreedom mapGlobalToLocal(const FiniteElemSpace *feSpace,
DegreeOfFreedom dof);
/// Maps a local DOF to its local index.
inline DegreeOfFreedom mapLocalToDof(const FiniteElemSpace *feSpace,
DegreeOfFreedom dof)
{
FUNCNAME("MeshDistributor::mapLocalToDof()");
TEST_EXIT_DBG(dofFeData.count(feSpace))
("No DOF data for FE space at addr %p!\n", feSpace);
return dofFeData[feSpace].mapLocalToDof[dof];
}
/// Returns the periodic mapping handler, \ref periodicMap.
inline PeriodicMap& getPeriodicMap()
{
......@@ -527,12 +472,12 @@ namespace AMDiS {
/// Reads a vector of dof pointers from an input stream.
void deserialize(istream &in, DofContainer &data,
map<int, const DegreeOfFreedom*> &dofMap);
map<int, const DegreeOfFreedom*> &dofIndexMap);
/// Reads a \ref RankToDofContainer from an input stream.
void deserialize(istream &in,
map<int, map<const FiniteElemSpace*, DofContainer> > &data,
map<const FiniteElemSpace*, map<int, const DegreeOfFreedom*> > &dofMap);
map<const FiniteElemSpace*, map<int, const DegreeOfFreedom*> > &dofIndexMap);
/// Writes a mapping from dof pointers to some values to an output stream.
template<typename T>
......@@ -554,7 +499,7 @@ namespace AMDiS {
/// Reads a mapping from dof pointer to some values from an input stream.
template<typename T>
void deserialize(istream &in, map<const DegreeOfFreedom*, T> &data,
map<int, const DegreeOfFreedom*> &dofMap)
map<int, const DegreeOfFreedom*> &dofIndexMap)
{
FUNCNAME("ParallelDomainBase::deserialize()");
......@@ -566,9 +511,10 @@ namespace AMDiS {
SerUtil::deserialize(in, v1);
SerUtil::deserialize(in, v2);
TEST_EXIT_DBG(dofMap.count(v1) != 0)("Cannot find DOF %d in map!\n", v1);
TEST_EXIT_DBG(dofIndexMap.count(v1) != 0)
("Cannot find DOF %d in map!\n", v1);
data[dofMap[v1]] = v2;
data[dofIndexMap[v1]] = v2;
}
}
......@@ -621,6 +567,8 @@ namespace AMDiS {
map<const FiniteElemSpace*, DofData> dofFeData;
ParallelDofMapping dofMap;
/// Database to store and query all sub-objects of all elements of the
/// macro mesh.
ElementObjectDatabase elObjDb;
......
......@@ -30,6 +30,7 @@
#include "AMDiS_fwd.h"
#include "Mesh.h"
#include "parallel/MpiHelper.h"
#include "parallel/ParallelDofMapping.h"
namespace AMDiS {
......@@ -106,7 +107,11 @@ namespace AMDiS {
boxPartitioning = b;
}
#if 0
void setLocalGlobalDofMap(map<DegreeOfFreedom, DegreeOfFreedom> *m)
#else
void setLocalGlobalDofMap(map<DegreeOfFreedom, MultiIndex> *m)
#endif
{
mapLocalGlobal = m;
}
......@@ -168,7 +173,7 @@ namespace AMDiS {
/// macro element index the box number it belongs to.
map<int, int> elInBox;
map<DegreeOfFreedom, DegreeOfFreedom> *mapLocalGlobal;
map<DegreeOfFreedom, MultiIndex> *mapLocalGlobal;
map<int, vector<int> > elNeighbours;
......
......@@ -14,6 +14,7 @@
#include <mpi.h>
#include "parallel/ParMetisPartitioner.h"
#include "parallel/ParallelDofMapping.h"
#include "parallel/MpiHelper.h"
#include "Serializer.h"
#include "Mesh.h"
......@@ -28,7 +29,7 @@ namespace AMDiS {
ParMetisMesh::ParMetisMesh(Mesh *mesh, MPI::Intracomm *comm,
std::map<int, bool>& elementInRank,
map<DegreeOfFreedom, DegreeOfFreedom> *mapLocalGlobal)
map<DegreeOfFreedom, MultiIndex> *mapLocalGlobal)
: dim(mesh->getDim()),
nElements(0),
mpiComm(comm)
......@@ -102,7 +103,7 @@ namespace AMDiS {
// write eind entries (element nodes)
for (int i = 0; i < dim + 1; i++) {
if (mapLocalGlobal)
*ptr_eind = (*mapLocalGlobal)[element->getDof(i, 0)];
*ptr_eind = (*mapLocalGlobal)[element->getDof(i, 0)].global;
else
*ptr_eind = element->getDof(i, 0);
......
......@@ -31,6 +31,7 @@
#include "AMDiS_fwd.h"
#include "Global.h"
#include "parallel/MeshPartitioner.h"
#include "parallel/ParallelDofMapping.h"
namespace AMDiS {
......@@ -43,7 +44,7 @@ namespace AMDiS {
public:
ParMetisMesh(Mesh *mesh, MPI::Intracomm *comm,
map<int, bool>& elementInRank,
map<DegreeOfFreedom, DegreeOfFreedom> *mapLocalGlobal);
map<DegreeOfFreedom, MultiIndex> *mapLocalGlobal);
~ParMetisMesh();
......
......@@ -165,11 +165,6 @@ namespace AMDiS {
WorldVector<double> c;
pdb.mesh->getDofIndexCoords(it->first, pdb.feSpaces[0], c);
int nAssoc = it->second.size();
#if 0
TEST_EXIT_DBG(nAssoc == 1 || nAssoc == 3 || (pdb.mesh->getDim() == 3 && nAssoc == 7))
("Should not happen! DOF %d (%e %e %e) has %d periodic associations!\n",
it->first, c[0], c[1], (pdb.mesh->getDim() == 2 ? 0.0 : c[2]), nAssoc);
#endif
}
......@@ -484,9 +479,7 @@ namespace AMDiS {
DOFIterator<WorldVector<double> > it(&coords, USED_DOFS);
for (it.reset(); !it.end(); ++it) {
coordsToIndex[(*it)] =
pdb.dofFeData[feSpace].mapDofToGlobal[it.getDOFIndex()];
coordsToIndex[(*it)] = pdb.dofMap[feSpace][it.getDOFIndex()].global;
// MSG(" CHECK FOR DOF %d AT COORDS %f %f %f\n",
// coordsToIndex[(*it)], (*it)[0], (*it)[1], (*it)[2]);
}
......@@ -646,16 +639,11 @@ namespace AMDiS {
const FiniteElemSpace *feSpace = pdb.feSpaces[0];
cout << "====== DOF MAP LOCAL -> GLOBAL ====== " << endl;
for (DofMap::iterator it = pdb.dofFeData[feSpace].mapDofToGlobal.begin();
it != pdb.dofFeData[feSpace].mapDofToGlobal.end(); it++) {
DegreeOfFreedom localdof = -1;
if (pdb.dofFeData[feSpace].mapLocalToDof.count(it->first) > 0)
localdof = pdb.dofFeData[feSpace].mapLocalToDof[it->first];
cout << "DOF " << it->first << " "
<< it->second << " "
<< localdof << endl;
map<DegreeOfFreedom, MultiIndex> &dofMap = pdb.dofMap[feSpace].getMap();
for (map<DegreeOfFreedom, MultiIndex>::iterator it = dofMap.begin();
it != dofMap.end(); ++it) {
cout << "DOF " << it->first << " " << it->second.global << "\n";
WorldVector<double> coords;
pdb.mesh->getDofIndexCoords(it->first, feSpace, coords);
coords.print();
......@@ -702,8 +690,9 @@ namespace AMDiS {
cout << endl;
DegreeOfFreedom localdof = -1;
for (DofMap::iterator dofIt = pdb.dofFeData[feSpace].mapDofToGlobal.begin();
dofIt != pdb.dofFeData[feSpace].mapDofToGlobal.end(); ++dofIt)
map<DegreeOfFreedom, MultiIndex> &dofMap = pdb.dofMap[feSpace].getMap();
for (map<DegreeOfFreedom, MultiIndex>::iterator it = dofMap.begin();
it != dofMap.end(); ++it)
if (dofIt->second == it->first)
localdof = dofIt->first;
......@@ -819,7 +808,7 @@ namespace AMDiS {
DOFIterator<WorldVector<double> > it(&coords, USED_DOFS);
for (it.reset(); !it.end(); ++it) {
file << it.getDOFIndex() << " "
<< pdb.dofFeData[feSpace].mapDofToGlobal[it.getDOFIndex()] << " "
<< pdb.dofMap[feSpace][it.getDOFIndex()].global << " "
<< pdb.getIsRankDof(feSpace, it.getDOFIndex());
for (int i = 0; i < pdb.mesh->getDim(); i++)
file << " " << (*it)[i];
......
......@@ -154,8 +154,9 @@ namespace AMDiS {
PetscScalar *vecPointer;
VecGetArray(tmp, &vecPointer);
for (int j = 0; j < nRankDofs; j++)
dofvec[meshDistributor->mapLocalToDof(feSpace, j)] = vecPointer[j];
ERROR_EXIT("REWRITE CODE!\n");
// for (int j = 0; j < nRankDofs; j++)
// dofvec[meshDistributor->mapLocalToDof(feSpace, j)] = vecPointer[j];
VecRestoreArray(tmp, &vecPointer);
}
......
......@@ -197,8 +197,9 @@ namespace AMDiS {
const FiniteElemSpace *feSpace = dv.getFeSpace();
int nRankDofs = meshDistributor->getNumberRankDofs(feSpace);
for (int j = 0; j < nRankDofs; j++)
dv[meshDistributor->mapLocalToDof(feSpace, j)] = vecPointer[c++];
ERROR_EXIT("REWRITE CODE!\n");
// for (int j = 0; j < nRankDofs; j++)
// dv[meshDistributor->mapLocalToDof(feSpace, j)] = vecPointer[c++];
}
VecRestoreArray(petscSolVec, &vecPointer);
......
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