Commit 32b71148 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Fixed some bugs for periodic BCs in 3D in parrallel computing.

parent 8be28f3a
...@@ -172,6 +172,7 @@ namespace AMDiS { ...@@ -172,6 +172,7 @@ namespace AMDiS {
} }
} }
BoundaryType ElInfo::getBoundary(GeoIndex pos, int i) BoundaryType ElInfo::getBoundary(GeoIndex pos, int i)
{ {
static int indexOffset[3][3] = { static int indexOffset[3][3] = {
......
...@@ -14,11 +14,13 @@ ...@@ -14,11 +14,13 @@
#include "FiniteElemSpace.h" #include "FiniteElemSpace.h"
#include "BasisFunction.h" #include "BasisFunction.h"
#include "Serializer.h" #include "Serializer.h"
#include "VertexVector.h"
namespace AMDiS { namespace AMDiS {
void BoundaryObject::setReverseMode(BoundaryObject &otherBound, void BoundaryObject::setReverseMode(BoundaryObject &otherBound,
FiniteElemSpace *feSpace) FiniteElemSpace *feSpace,
BoundaryType boundary)
{ {
FUNCNAME("BoundaryObject::setReverseMode()"); FUNCNAME("BoundaryObject::setReverseMode()");
...@@ -31,7 +33,8 @@ namespace AMDiS { ...@@ -31,7 +33,8 @@ namespace AMDiS {
case 3: case 3:
TEST_EXIT_DBG(otherBound.elType == 0) TEST_EXIT_DBG(otherBound.elType == 0)
("Only 3D macro elements with level 0 are supported!\n"); ("Only 3D macro elements with level 0 are supported. This element has level %d!\n", otherBound.elType);
if (subObj == EDGE) { if (subObj == EDGE) {
int el0_v0 = el->getVertexOfEdge(ithObj, 0); int el0_v0 = el->getVertexOfEdge(ithObj, 0);
...@@ -45,15 +48,22 @@ namespace AMDiS { ...@@ -45,15 +48,22 @@ namespace AMDiS {
basFcts->getLocalIndices(el, feSpace->getAdmin(), localDofs0); basFcts->getLocalIndices(el, feSpace->getAdmin(), localDofs0);
basFcts->getLocalIndices(otherBound.el, feSpace->getAdmin(), localDofs1); basFcts->getLocalIndices(otherBound.el, feSpace->getAdmin(), localDofs1);
TEST_EXIT_DBG(localDofs0[el0_v0] == localDofs1[el1_v0] || Mesh *mesh = feSpace->getMesh();
localDofs0[el0_v0] == localDofs1[el1_v1])
("This should not happen!\n"); if (mesh->isPeriodicAssociation(boundary) == false) {
TEST_EXIT_DBG(localDofs0[el0_v1] == localDofs1[el1_v0] || TEST_EXIT_DBG(localDofs0[el0_v0] == localDofs1[el1_v0] ||
localDofs0[el0_v1] == localDofs1[el1_v1]) localDofs0[el0_v0] == localDofs1[el1_v1])
("This should not happen!\n"); ("This should not happen!\n");
TEST_EXIT_DBG(localDofs0[el0_v1] == localDofs1[el1_v0] ||
if (localDofs0[el0_v0] != localDofs1[el1_v0]) localDofs0[el0_v1] == localDofs1[el1_v1])
otherMode = true; ("This should not happen!\n");
if (localDofs0[el0_v0] != localDofs1[el1_v0])
otherMode = true;
} else {
if (mesh->associated(localDofs0[el0_v0], localDofs1[el1_v0]) == false)
otherMode = true;
}
} }
if (subObj == FACE && ithObj != 1) { if (subObj == FACE && ithObj != 1) {
......
...@@ -54,7 +54,9 @@ namespace AMDiS { ...@@ -54,7 +54,9 @@ namespace AMDiS {
excludedSubstructures(0) excludedSubstructures(0)
{} {}
void setReverseMode(BoundaryObject &otherBound, FiniteElemSpace *feSpace); void setReverseMode(BoundaryObject &otherBound,
FiniteElemSpace *feSpace,
BoundaryType boundary);
bool operator==(const BoundaryObject& other) const; bool operator==(const BoundaryObject& other) const;
......
This diff is collapsed.
...@@ -483,10 +483,6 @@ namespace AMDiS { ...@@ -483,10 +483,6 @@ namespace AMDiS {
std::map<std::pair<DofEdge, DofEdge>, BoundaryType> periodicEdges; std::map<std::pair<DofEdge, DofEdge>, BoundaryType> periodicEdges;
std::map<std::pair<DofFace, DofFace>, BoundaryType> periodicFaces; std::map<std::pair<DofFace, DofFace>, BoundaryType> periodicFaces;
// Stores to each DOF all its periodic associations.
std::map<DegreeOfFreedom, std::set<BoundaryType> > periodicDofAssoc;
/** \brief /** \brief
* Defines the interior boundaries of the domain that result from partitioning * Defines the interior boundaries of the domain that result from partitioning
* the whole mesh. Contains only the boundaries, which are owned by the rank, i.e., * the whole mesh. Contains only the boundaries, which are owned by the rank, i.e.,
......
...@@ -364,6 +364,8 @@ namespace AMDiS { ...@@ -364,6 +364,8 @@ namespace AMDiS {
for (int i = 0; i < nElements; i++) { for (int i = 0; i < nElements; i++) {
wgts[i] = min(wgts[i], kpartMax); wgts[i] = min(wgts[i], kpartMax);
wgts[i] = max(wgts[i], 1);
smin = std::min(smin, wgts[i]); smin = std::min(smin, wgts[i]);
smax = std::max(smax, wgts[i]); smax = std::max(smax, wgts[i]);
ssum += wgts[i]; ssum += wgts[i];
......
...@@ -67,8 +67,11 @@ namespace AMDiS { ...@@ -67,8 +67,11 @@ namespace AMDiS {
// === To the last, do the same of periodic boundaries. === // === To the last, do the same of periodic boundaries. ===
for (RankToBoundMap::iterator rankIt = pdb.periodicBoundary.boundary.begin(); for (RankToBoundMap::iterator rankIt = pdb.periodicBoundary.boundary.begin();
rankIt != pdb.periodicBoundary.boundary.end(); ++rankIt) { rankIt != pdb.periodicBoundary.boundary.end(); ++rankIt) {
if (rankIt->first == pdb.mpiRank)
continue;
int nValues = rankIt->second.size(); int nValues = rankIt->second.size();
int* sBuffer = new int[nValues]; int* sBuffer = new int[nValues];
for (int i = 0; i < nValues; i++) for (int i = 0; i < nValues; i++)
...@@ -118,11 +121,17 @@ namespace AMDiS { ...@@ -118,11 +121,17 @@ namespace AMDiS {
for (RankToBoundMap::iterator rankIt = pdb.periodicBoundary.boundary.begin(); for (RankToBoundMap::iterator rankIt = pdb.periodicBoundary.boundary.begin();
rankIt != pdb.periodicBoundary.boundary.end(); ++rankIt) { rankIt != pdb.periodicBoundary.boundary.end(); ++rankIt) {
if (rankIt->first == pdb.mpiRank)
continue;
for (unsigned int i = 0; i < rankIt->second.size(); i++) { for (unsigned int i = 0; i < rankIt->second.size(); i++) {
int elIndex1 = recvBuffers[bufCounter][i]; int elIndex1 = recvBuffers[bufCounter][i];
int elIndex2 = pdb.periodicBoundary.boundary[rankIt->first][i].neighObj.elIndex; int elIndex2 = pdb.periodicBoundary.boundary[rankIt->first][i].neighObj.elIndex;
TEST_EXIT(elIndex1 == elIndex2)("Wrong element index at periodic boundary!\n"); TEST_EXIT(elIndex1 == elIndex2)
("Wrong element index at periodic boundary el %d with rank %d: %d %d\n",
pdb.periodicBoundary.boundary[rankIt->first][i].rankObj.elIndex,
rankIt->first, elIndex1, elIndex2);
} }
delete [] recvBuffers[bufCounter++]; delete [] recvBuffers[bufCounter++];
......
...@@ -26,14 +26,16 @@ namespace AMDiS { ...@@ -26,14 +26,16 @@ namespace AMDiS {
ProblemVec::buildAfterCoarsen(adaptInfo, flag, assembleMatrix, assembleVector); ProblemVec::buildAfterCoarsen(adaptInfo, flag, assembleMatrix, assembleVector);
double vm, rss; double vm, rss;
processMemUsage(vm, rss); processMemUsage(vm, rss);
vm /= 1024.0;
rss /= 1024.0;
MSG("My memory usage is VM = %f RSS = %f\n", vm, rss); MSG("My memory usage is VM = %f MB RSS = %f MB\n", vm, rss);
mpi::globalAdd(vm); mpi::globalAdd(vm);
mpi::globalAdd(rss); mpi::globalAdd(rss);
MSG("Overall memory usage is VM = %f RSS = %f\n", vm, rss); MSG("Overall memory usage is VM = %f MB RSS = %f MB\n", vm, rss);
} }
......
...@@ -128,8 +128,8 @@ namespace AMDiS { ...@@ -128,8 +128,8 @@ namespace AMDiS {
} }
// === Up to now we have assembled on row. Now, the row must be send to the === // === Up to now we have assembled one row. Now, the row must be send to the ===
// === corresponding rows to the petsc matrix. === // === corresponding rows in the petsc matrix. ===
if (periodicRow) { if (periodicRow) {
// The row dof is periodic, so send dof to all the corresponding rows. // The row dof is periodic, so send dof to all the corresponding rows.
...@@ -144,7 +144,8 @@ namespace AMDiS { ...@@ -144,7 +144,8 @@ namespace AMDiS {
MatSetValues(petscMatrix, 1, &rowIndex, cols.size(), MatSetValues(petscMatrix, 1, &rowIndex, cols.size(),
&(cols[0]), &(values[0]), ADD_VALUES); &(cols[0]), &(values[0]), ADD_VALUES);
for (std::set<int>::iterator perIt = perAsc.begin(); perIt != perAsc.end(); ++perIt) { for (std::set<int>::iterator perIt = perAsc.begin();
perIt != perAsc.end(); ++perIt) {
std::vector<int> perCols; std::vector<int> perCols;
perCols.reserve(300); perCols.reserve(300);
std::vector<double> perValues; std::vector<double> perValues;
......
...@@ -60,7 +60,7 @@ namespace AMDiS { ...@@ -60,7 +60,7 @@ namespace AMDiS {
int intSizeOf(std::vector<AtomicBoundary> &data) int intSizeOf(std::vector<AtomicBoundary> &data)
{ {
return data.size() * 3; return data.size() * 6;
} }
int intSizeOf(std::vector<BoundaryObject> &data) int intSizeOf(std::vector<BoundaryObject> &data)
...@@ -242,9 +242,12 @@ namespace AMDiS { ...@@ -242,9 +242,12 @@ namespace AMDiS {
void makeBuf(std::vector<AtomicBoundary> &data, int *buf) void makeBuf(std::vector<AtomicBoundary> &data, int *buf)
{ {
for (unsigned int i = 0; i < data.size(); i++) { for (unsigned int i = 0; i < data.size(); i++) {
buf[i * 3] = data[i].rankObj.elIndex; buf[i * 6] = data[i].rankObj.elIndex;
buf[i * 3 + 1] = data[i].rankObj.subObj; buf[i * 6 + 1] = data[i].rankObj.subObj;
buf[i * 3 + 2] = data[i].rankObj.ithObj; buf[i * 6 + 2] = data[i].rankObj.ithObj;
buf[i * 6 + 3] = data[i].neighObj.elIndex;
buf[i * 6 + 4] = data[i].neighObj.subObj;
buf[i * 6 + 5] = data[i].neighObj.ithObj;
} }
} }
...@@ -253,13 +256,16 @@ namespace AMDiS { ...@@ -253,13 +256,16 @@ namespace AMDiS {
if (bufSize == 0) if (bufSize == 0)
return; return;
TEST_EXIT(bufSize % 3 == 0)("This should not happen!\n"); TEST_EXIT(bufSize % 6 == 0)("This should not happen!\n");
data.resize(bufSize / 3); data.resize(bufSize / 6);
for (int i = 0; i < bufSize / 3; i++) { for (int i = 0; i < bufSize / 6; i++) {
data[i].rankObj.elIndex = buf[i * 3]; data[i].rankObj.elIndex = buf[i * 6];
data[i].rankObj.subObj = static_cast<GeoIndex>(buf[i * 3 + 1]); data[i].rankObj.subObj = static_cast<GeoIndex>(buf[i * 6 + 1]);
data[i].rankObj.ithObj = buf[i * 3 + 2]; data[i].rankObj.ithObj = buf[i * 6 + 2];
data[i].neighObj.elIndex = buf[i * 6 + 3];
data[i].neighObj.subObj = static_cast<GeoIndex>(buf[i * 6 + 4]);
data[i].neighObj.ithObj = buf[i * 6 + 5];
} }
} }
......
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