Commit 613caf74 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Transfer of DOFVectors in mesh repartitioning.

parent 30c3b864
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "ElInfo.h" #include "ElInfo.h"
#include "RefinementManager.h" #include "RefinementManager.h"
#include "Debug.h" #include "Debug.h"
#include "DOFVector.h"
namespace AMDiS { namespace AMDiS {
...@@ -356,4 +357,64 @@ namespace AMDiS { ...@@ -356,4 +357,64 @@ namespace AMDiS {
{ {
return (other.getCode() == code); return (other.getCode() == code);
} }
void MeshStructure::getMeshStructureValues(Mesh *mesh,
int macroElIndex,
const DOFVector<double>* vec,
std::vector<double>& values)
{
FUNCNAME("MeshStructure::getMeshStructureValues()");
values.clear();
TraverseStack stack;
ElInfo *elInfo = stack.traverseFirstOneMacro(mesh, macroElIndex, -1,
Mesh::CALL_EVERY_EL_PREORDER);
while (elInfo) {
if (elInfo->getLevel() == 0) {
for (int i = 0; i < mesh->getGeo(VERTEX); i++)
values.push_back((*vec)[elInfo->getElement()->getDof(i, 0)]);
} else {
if (!elInfo->getElement()->isLeaf())
values.push_back((*vec)[elInfo->getElement()->getChild(0)->getDof(mesh->getDim(), 0)]);
}
elInfo = stack.traverseNext(elInfo);
}
}
void MeshStructure::setMeshStructureValues(Mesh *mesh,
int macroElIndex,
DOFVector<double>* vec,
const std::vector<double>& values)
{
FUNCNAME("MeshStructure::setMeshStructureValues()");
TEST_EXIT_DBG(values.size() >= mesh->getGeo(VERTEX))("Should not happen!\n");
unsigned int counter = 0;
TraverseStack stack;
ElInfo *elInfo = stack.traverseFirstOneMacro(mesh, macroElIndex, -1,
Mesh::CALL_EVERY_EL_PREORDER);
while (elInfo) {
if (elInfo->getLevel() == 0) {
for (int i = 0; i < mesh->getGeo(VERTEX); i++)
(*vec)[elInfo->getElement()->getDof(i, 0)] = values[counter++];
} else {
if (!elInfo->getElement()->isLeaf()) {
TEST_EXIT_DBG(counter < values.size())("Should not happen!\n");
(*vec)[elInfo->getElement()->getChild(0)->getDof(mesh->getDim(), 0)] =
values[counter++];
}
}
elInfo = stack.traverseNext(elInfo);
}
}
} }
...@@ -150,6 +150,17 @@ namespace AMDiS { ...@@ -150,6 +150,17 @@ namespace AMDiS {
/// Returns true, if the given mesh structure code is equal to this one. /// Returns true, if the given mesh structure code is equal to this one.
bool compare(MeshStructure &other); bool compare(MeshStructure &other);
void getMeshStructureValues(Mesh *mesh,
int macroElIndex,
const DOFVector<double>* vec,
std::vector<double>& values);
void setMeshStructureValues(Mesh *mesh,
int macroElIndex,
DOFVector<double>* vec,
const std::vector<double>& values);
protected: protected:
/// Insert a new element to the structure code. Is used by the init function. /// Insert a new element to the structure code. Is used by the init function.
void insertElement(bool isLeaf); void insertElement(bool isLeaf);
......
...@@ -107,7 +107,7 @@ namespace AMDiS { ...@@ -107,7 +107,7 @@ namespace AMDiS {
while (elInfo) { while (elInfo) {
if (!macroElement) { if (!macroElement) {
Element *mEl = elInfo->getMacroElement()->getElement(); Element *mEl = elInfo->getMacroElement()->getElement();
for (int i = 0; i <= mesh->getDim(); i++) for (int i = 0; i < mesh->getGeo(VERTEX); i++)
(*vec)[mEl->getDof(i, 0)] = values[valuePos++]; (*vec)[mEl->getDof(i, 0)] = values[valuePos++];
macroElement = true; macroElement = true;
} }
......
...@@ -73,7 +73,7 @@ namespace AMDiS { ...@@ -73,7 +73,7 @@ namespace AMDiS {
for (unsigned int i = 0; i < vecs.size(); i++) { for (unsigned int i = 0; i < vecs.size(); i++) {
values[i].clear(); values[i].clear();
for (int j = 0; j <= mesh->getDim(); j++) for (int j = 0; j < mesh->getGeo(VERTEX); j++)
values[i].push_back((*vecs[i])[elInfo->getElement()->getDof(j, 0)]); values[i].push_back((*vecs[i])[elInfo->getElement()->getDof(j, 0)]);
} }
} }
......
...@@ -995,7 +995,7 @@ namespace AMDiS { ...@@ -995,7 +995,7 @@ namespace AMDiS {
elIndexMap[(*it)->getIndex()] = *it; elIndexMap[(*it)->getIndex()] = *it;
// === Craete set of all new macro elements this rank will receive from === // === Create set of all new macro elements this rank will receive from ===
// === other ranks. === // === other ranks. ===
std::set<MacroElement*> newMacroEl; std::set<MacroElement*> newMacroEl;
...@@ -1033,6 +1033,8 @@ namespace AMDiS { ...@@ -1033,6 +1033,8 @@ namespace AMDiS {
// === Send and receive mesh structure codes. === // === Send and receive mesh structure codes. ===
std::map<int, MeshCodeVec> sendCodes; std::map<int, MeshCodeVec> sendCodes;
std::map<int, std::vector<std::vector<double> > > sendValues;
for (std::map<int, std::vector<int> >::iterator it = partitioner->getSendElements().begin(); for (std::map<int, std::vector<int> >::iterator it = partitioner->getSendElements().begin();
it != partitioner->getSendElements().end(); ++it) { it != partitioner->getSendElements().end(); ++it) {
for (std::vector<int>::iterator elIt = it->second.begin(); for (std::vector<int>::iterator elIt = it->second.begin();
...@@ -1040,6 +1042,10 @@ namespace AMDiS { ...@@ -1040,6 +1042,10 @@ namespace AMDiS {
MeshStructure elCode; MeshStructure elCode;
elCode.init(mesh, *elIt); elCode.init(mesh, *elIt);
sendCodes[it->first].push_back(elCode); sendCodes[it->first].push_back(elCode);
std::vector<double> valVec;
elCode.getMeshStructureValues(mesh, *elIt, testVec, valVec);
sendValues[it->first].push_back(valVec);
} }
} }
...@@ -1136,9 +1142,6 @@ namespace AMDiS { ...@@ -1136,9 +1142,6 @@ namespace AMDiS {
MSG("Debug mode tests finished!\n"); MSG("Debug mode tests finished!\n");
#endif #endif
MSG("DONE\n");
} }
......
...@@ -403,6 +403,9 @@ namespace AMDiS { ...@@ -403,6 +403,9 @@ namespace AMDiS {
} }
} }
public:
DOFVector<double>* testVec;
protected: protected:
/// ///
std::vector<ProblemVec*> probStat; std::vector<ProblemVec*> probStat;
......
...@@ -61,6 +61,16 @@ namespace AMDiS { ...@@ -61,6 +61,16 @@ namespace AMDiS {
return data.size(); return data.size();
} }
int intSizeOf(std::vector<std::vector<double> > &data)
{
int size = 1;
for (unsigned int i = 0; i < data.size(); i++)
size += data[i].size() + 1;
return size;
}
void makeBuf(int &data, int *buf) void makeBuf(int &data, int *buf)
{ {
buf[0] = data; buf[0] = data;
...@@ -269,4 +279,29 @@ namespace AMDiS { ...@@ -269,4 +279,29 @@ namespace AMDiS {
} }
} }
void makeBuf(std::vector<std::vector<double> > &data, double *buf)
{
buf[0] = data.size();
int counter = 1;
for (unsigned int i = 0; i < data.size(); i++) {
buf[counter++] = data[i].size();
for (unsigned int j = 0; j < data[i].size(); j++)
buf[counter++] = data[i][j];
}
}
void makeFromBuf(std::vector<std::vector<double> > &data, double *buf, int bufSize)
{
data.resize(buf[0]);
int counter = 1;
for (unsigned int i = 0; i < data.size(); i++) {
data[i].resize(buf[counter++]);
for (unsigned int j = 0; j < data[i].size(); j++)
data[i][j] = buf[counter++];
}
}
} }
...@@ -52,6 +52,8 @@ namespace AMDiS { ...@@ -52,6 +52,8 @@ namespace AMDiS {
int intSizeOf(std::vector<const DegreeOfFreedom*> &data); int intSizeOf(std::vector<const DegreeOfFreedom*> &data);
int intSizeOf(std::vector<std::vector<double> > &data);
void makeBuf(int &data, int *buf); void makeBuf(int &data, int *buf);
void makeFromBuf(int &data, int *buf, int bufSize); void makeFromBuf(int &data, int *buf, int bufSize);
...@@ -92,6 +94,10 @@ namespace AMDiS { ...@@ -92,6 +94,10 @@ namespace AMDiS {
void makeFromBuf(std::vector<BoundaryObject> &data, int *buf, int bufSize); void makeFromBuf(std::vector<BoundaryObject> &data, int *buf, int bufSize);
void makeBuf(std::vector<std::vector<double> > &data, double *buf);
void makeFromBuf(std::vector<std::vector<double> > &data, double *buf, int bufSize);
template<typename SendT, typename RecvT=SendT> template<typename SendT, typename RecvT=SendT>
......
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