Skip to content
Snippets Groups Projects
Commit d7ea2659 authored by Oliver Sander's avatar Oliver Sander Committed by sander
Browse files

Some cleanup

[[Imported from SVN: r9733]]
parent bbc34b2e
No related branches found
No related tags found
No related merge requests found
...@@ -36,8 +36,18 @@ private: ...@@ -36,8 +36,18 @@ private:
globalVectorEntries = MPIFunctions::gatherv(guIndex.getGridView(), localVectorEntries, localVectorEntriesSizes, root_rank); globalVectorEntries = MPIFunctions::gatherv(guIndex.getGridView(), localVectorEntries, localVectorEntriesSizes, root_rank);
} }
public:
VectorCommunicator(const GUIndex& gi, const int& root)
: guIndex(gi), root_rank(root)
{
// Get number of vector entries on each process
localVectorEntriesSizes = MPIFunctions::shareSizes(guIndex.getGridView(), guIndex.nOwnedLocalEntity());
}
VectorType reduceAdd(const VectorType& localVector)
{
transferVector(localVector);
VectorType createGlobalVector() const {
VectorType globalVector(guIndex.nGlobalEntity()); VectorType globalVector(guIndex.nGlobalEntity());
for (size_t k = 0; k < globalVectorEntries.size(); ++k) for (size_t k = 0; k < globalVectorEntries.size(); ++k)
...@@ -46,7 +56,10 @@ private: ...@@ -46,7 +56,10 @@ private:
return globalVector; return globalVector;
} }
VectorType copyIntoGlobalVector() const { VectorType reduceCopy(const VectorType& localVector)
{
transferVector(localVector);
VectorType globalVector(guIndex.nGlobalEntity()); VectorType globalVector(guIndex.nGlobalEntity());
for (size_t k = 0; k < globalVectorEntries.size(); ++k) for (size_t k = 0; k < globalVectorEntries.size(); ++k)
...@@ -55,7 +68,11 @@ private: ...@@ -55,7 +68,11 @@ private:
return globalVector; return globalVector;
} }
VectorType createLocalSolution() { VectorType scatter(const VectorType& global)
{
for (size_t k = 0; k < globalVectorEntries.size(); ++k)
globalVectorEntries[k].entry = global[globalVectorEntries[k].row];
const int localSize = localVectorEntriesSizes[guIndex.getGridView().comm().rank()]; const int localSize = localVectorEntriesSizes[guIndex.getGridView().comm().rank()];
// Create vector for transfer data // Create vector for transfer data
...@@ -73,34 +90,6 @@ private: ...@@ -73,34 +90,6 @@ private:
return x; return x;
} }
public:
VectorCommunicator(const GUIndex& gi, const int& root)
: guIndex(gi), root_rank(root)
{
// Get number of vector entries on each process
localVectorEntriesSizes = MPIFunctions::shareSizes(guIndex.getGridView(), guIndex.nOwnedLocalEntity());
}
VectorType reduceAdd(const VectorType& localVector)
{
transferVector(localVector);
return createGlobalVector();
}
VectorType reduceCopy(const VectorType& localVector)
{
transferVector(localVector);
return copyIntoGlobalVector();
}
VectorType scatter(const VectorType& global)
{
for (size_t k = 0; k < globalVectorEntries.size(); ++k)
globalVectorEntries[k].entry = global[globalVectorEntries[k].row];
return createLocalSolution();
}
private: private:
const GUIndex& guIndex; const GUIndex& guIndex;
int root_rank; int root_rank;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment