Commit 8a35ba06 authored by Ansgar Burchardt's avatar Ansgar Burchardt

Merge branch 'loadbalance-element-data-2.5' into 'releases/2.5'

[backport,uggrid] Allow transferring element data during loadbalance for 2.5

See merge request !188
parents 31ee0b2e 90811456
This diff is collapsed.
......@@ -487,7 +487,8 @@ namespace Dune {
{
#ifdef ModelP
// gather element data
// UGLBGatherScatter::template gather<0>(this->leafGridView(), dataHandle);
if (dataHandle.contains(dim, 0))
UGLBGatherScatter::template gather<0>(this->leafGridView(), dataHandle);
// gather node data
if (dataHandle.contains(dim,dim))
......@@ -500,7 +501,8 @@ namespace Dune {
#ifdef ModelP
// scatter element data
// UGLBGatherScatter::template scatter<0>(this->leafGridView(), dataHandle);
if (dataHandle.contains(dim, 0))
UGLBGatherScatter::template scatter<0>(this->leafGridView(), dataHandle);
// scatter node data
if (dataHandle.contains(dim,dim))
......
......@@ -65,16 +65,17 @@ namespace Dune {
LBMessageBuffer lbMessageBuffer;
dataHandle.gather(lbMessageBuffer, entity);
char*& buffer = gridView.grid().getRealImplementation(entity).getTarget()->message_buffer;
assert(not buffer);
auto ugEntity = gridView.grid().getRealImplementation(entity).getTarget();
assert(not ugEntity->message_buffer());
typedef typename DataHandle::DataType DataType;
buffer = (char*)malloc(sizeof(int) + numberOfParams*sizeof(DataType));
*((int*)buffer) = numberOfParams*sizeof(DataType); // Size of the actual payload
std::size_t buffer_size = numberOfParams * sizeof(DataType);
char* buffer = static_cast<char*>(std::malloc(buffer_size));
ugEntity->message_buffer(buffer, buffer_size);
for (int paramIdx = 0; paramIdx < numberOfParams; paramIdx++)
{
DataType *dataPointer = (DataType*)(buffer + sizeof(int) + paramIdx*sizeof(DataType));
DataType *dataPointer = (DataType*)(buffer + paramIdx*sizeof(DataType));
lbMessageBuffer.read(*dataPointer);
}
}
......@@ -100,7 +101,8 @@ namespace Dune {
continue;
// get data from UG message buffer and write to DUNE message buffer
char*& buffer = gridView.grid().getRealImplementation(entity).getTarget()->message_buffer;
auto ugEntity = gridView.grid().getRealImplementation(entity).getTarget();
auto buffer = ugEntity->message_buffer();
assert(buffer);
LBMessageBuffer lbMessageBuffer;
......@@ -108,7 +110,7 @@ namespace Dune {
for(int paramIdx = 0; paramIdx < numberOfParams; paramIdx++)
{
typedef typename DataHandle::DataType DataType;
DataType *dataPointer = (DataType*)(buffer + sizeof(int) + paramIdx*sizeof(DataType));
DataType *dataPointer = (DataType*)(buffer + paramIdx*sizeof(DataType));
lbMessageBuffer.write(*dataPointer);
}
......@@ -116,8 +118,7 @@ namespace Dune {
dataHandle.scatter(lbMessageBuffer, entity, numberOfParams);
// free object's local message buffer
free (buffer);
buffer = nullptr;
ugEntity->message_buffer_free();
}
}
};
......
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