Commit e65d2afd authored by Ansgar Burchardt's avatar Ansgar Burchardt Committed by Markus Blatt

[uggrid] Use accessor functions to access message buffer

(cherry picked from commit e14927db)
parent 31ee0b2e
......@@ -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