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

Transfer of DOFVectors in mesh repartitioning.

parent 30c3b864
......@@ -6,6 +6,7 @@
#include "ElInfo.h"
#include "RefinementManager.h"
#include "Debug.h"
#include "DOFVector.h"
namespace AMDiS {
......@@ -356,4 +357,64 @@ namespace AMDiS {
{
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 {
/// Returns true, if the given mesh structure code is equal to this one.
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:
/// Insert a new element to the structure code. Is used by the init function.
void insertElement(bool isLeaf);
......
......@@ -107,7 +107,7 @@ namespace AMDiS {
while (elInfo) {
if (!macroElement) {
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++];
macroElement = true;
}
......
......@@ -73,7 +73,7 @@ namespace AMDiS {
for (unsigned int i = 0; i < vecs.size(); i++) {
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)]);
}
}
......
......@@ -995,7 +995,7 @@ namespace AMDiS {
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. ===
std::set<MacroElement*> newMacroEl;
......@@ -1033,6 +1033,8 @@ namespace AMDiS {
// === Send and receive mesh structure codes. ===
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();
it != partitioner->getSendElements().end(); ++it) {
for (std::vector<int>::iterator elIt = it->second.begin();
......@@ -1040,6 +1042,10 @@ namespace AMDiS {
MeshStructure elCode;
elCode.init(mesh, *elIt);
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 {
MSG("Debug mode tests finished!\n");
#endif
MSG("DONE\n");
}
......
......@@ -402,6 +402,9 @@ namespace AMDiS {
data[dofMap[v1]] = v2;
}
}
public:
DOFVector<double>* testVec;
protected:
///
......
......@@ -61,6 +61,16 @@ namespace AMDiS {
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)
{
buf[0] = data;
......@@ -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 {
int intSizeOf(std::vector<const DegreeOfFreedom*> &data);
int intSizeOf(std::vector<std::vector<double> > &data);
void makeBuf(int &data, int *buf);
void makeFromBuf(int &data, int *buf, int bufSize);
......@@ -92,6 +94,10 @@ namespace AMDiS {
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>
......
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