From 0fa129e83ccdea233c96cdb4b17174c65787f9c3 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 16 Jan 2023 09:51:34 +0100 Subject: [PATCH] COMP: add compressed send/recv placeholder (instantiation for integrals) --- .../processorLduInterfaceTemplates.C | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C index 2ccb499292..2a0c06c607 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C @@ -67,6 +67,12 @@ void Foam::processorLduInterface::send resizeBuf(byteRecvBuf_, nBytes); + if (!nBytes) + { + // Can skip empty messages + return; + } + UIPstream::read ( commsType, @@ -164,11 +170,15 @@ void Foam::processorLduInterface::compressedSend && (!std::is_integral::value && sizeof(scalar) != sizeof(float)) ) { - static const label nCmpts = sizeof(Type)/sizeof(scalar); - label nm1 = (f.size() - 1)*nCmpts; - label nlast = sizeof(Type)/sizeof(float); - label nFloats = nm1 + nlast; - label nBytes = nFloats*sizeof(float); + static const label nCmpts = + ( + // Placeholder value for unusable template instantiation + std::is_integral::value + ? 1 + : sizeof(Type)/sizeof(scalar) + ); + const label nm1 = (f.size() - 1)*nCmpts; + const label nBytes = f.size()*nCmpts*sizeof(float); const scalar *sArray = reinterpret_cast(f.cdata()); const scalar *slast = &sArray[nm1]; @@ -250,11 +260,15 @@ void Foam::processorLduInterface::compressedReceive && (!std::is_integral::value && sizeof(scalar) != sizeof(float)) ) { - static const label nCmpts = sizeof(Type)/sizeof(scalar); - label nm1 = (f.size() - 1)*nCmpts; - label nlast = sizeof(Type)/sizeof(float); - label nFloats = nm1 + nlast; - label nBytes = nFloats*sizeof(float); + static const label nCmpts = + ( + // Placeholder value for unusable template instantiation + std::is_integral::value + ? 1 + : sizeof(Type)/sizeof(scalar) + ); + const label nm1 = (f.size() - 1)*nCmpts; + const label nBytes = f.size()*nCmpts*sizeof(float); if (