Commit 02638872 authored by Thomas Witkowski's avatar Thomas Witkowski

Some new small functions for MeshDistributor

parent 90f28a27
......@@ -496,35 +496,6 @@ namespace AMDiS {
}
void MeshDistributor::synchVector(DOFVector<double> &vec)
{
StdMpi<vector<double> > stdMpi(mpiComm);
for (RankToDofContainer::iterator sendIt = sendDofs.begin();
sendIt != sendDofs.end(); ++sendIt) {
vector<double> dofs;
int nSendDofs = sendIt->second.size();
dofs.reserve(nSendDofs);
for (int i = 0; i < nSendDofs; i++)
dofs.push_back(vec[*((sendIt->second)[i])]);
stdMpi.send(sendIt->first, dofs);
}
for (RankToDofContainer::iterator recvIt = recvDofs.begin();
recvIt != recvDofs.end(); ++recvIt)
stdMpi.recv(recvIt->first, recvIt->second.size());
stdMpi.startCommunication();
for (RankToDofContainer::iterator recvIt = recvDofs.begin();
recvIt != recvDofs.end(); ++recvIt)
for (unsigned int i = 0; i < recvIt->second.size(); i++)
vec[*(recvIt->second)[i]] = stdMpi.getRecvData(recvIt->first)[i];
}
void MeshDistributor::synchVector(SystemVector &vec)
{
int nComponents = vec.getSize();
......@@ -958,6 +929,26 @@ namespace AMDiS {
}
void MeshDistributor::createBoundaryDofs(std::set<DegreeOfFreedom> &boundaryDofs)
{
FUNCNAME("MeshDistributor::createBoundaryDofs()");
boundaryDofs.clear();
for (RankToDofContainer::iterator it = sendDofs.begin();
it != sendDofs.end(); ++it)
for (DofContainer::iterator dofIt = it->second.begin();
dofIt != it->second.end(); ++dofIt)
boundaryDofs.insert(**dofIt);
for (RankToDofContainer::iterator it = recvDofs.begin();
it != recvDofs.end(); ++it)
for (DofContainer::iterator dofIt = it->second.begin();
dofIt != it->second.end(); ++dofIt)
boundaryDofs.insert(**dofIt);
}
void MeshDistributor::serialize(ostream &out, DofContainer &data)
{
int vecSize = data.size();
......
......@@ -28,6 +28,7 @@
#include "parallel/ParallelTypes.h"
#include "parallel/MeshPartitioner.h"
#include "parallel/InteriorBoundary.h"
#include "parallel/StdMpi.h"
#include "AMDiS_fwd.h"
#include "Global.h"
#include "ProblemTimeInterface.h"
......@@ -239,6 +240,10 @@ namespace AMDiS {
return recvDofs;
}
/// Creates a set of all DOFs that are on interior boundaries of rank's
/// domain. Thus, it creates the union of \ref sendDofs and \ref recvDofs.
void createBoundaryDofs(std::set<DegreeOfFreedom> &boundaryDofs);
// Writes all data of this object to an output stream.
void serialize(ostream &out);
......@@ -255,8 +260,35 @@ namespace AMDiS {
* after the DOFVector is set by some user defined functions, e.g., initial
* solution functions.
*/
void synchVector(DOFVector<double> &vec);
template<typename T>
void synchVector(DOFVector<T> &vec)
{
StdMpi<vector<T> > stdMpi(mpiComm);
for (RankToDofContainer::iterator sendIt = sendDofs.begin();
sendIt != sendDofs.end(); ++sendIt) {
vector<T> dofs;
int nSendDofs = sendIt->second.size();
dofs.reserve(nSendDofs);
for (int i = 0; i < nSendDofs; i++)
dofs.push_back(vec[*((sendIt->second)[i])]);
stdMpi.send(sendIt->first, dofs);
}
for (RankToDofContainer::iterator recvIt = recvDofs.begin();
recvIt != recvDofs.end(); ++recvIt)
stdMpi.recv(recvIt->first, recvIt->second.size());
stdMpi.startCommunication();
for (RankToDofContainer::iterator recvIt = recvDofs.begin();
recvIt != recvDofs.end(); ++recvIt)
for (unsigned int i = 0; i < recvIt->second.size(); i++)
vec[*(recvIt->second)[i]] = stdMpi.getRecvData(recvIt->first)[i];
}
/** \brief
* Works in the same way as the function above defined for DOFVectors. Due to
* performance, this function does not call \ref synchVector for each DOFVector,
......
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