ENH: cyclicAMI - clear finished send/recv requests

This commit is contained in:
mattijs 2024-02-08 14:58:10 +00:00 committed by Mark Olesen
parent 119dd84327
commit e651d63566
4 changed files with 129 additions and 28 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2019-2023 OpenCFD Ltd. Copyright (C) 2019-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -444,7 +444,14 @@ void Foam::cyclicACMIFvPatchField<Type>::initEvaluate
<< " starting send&receive" << " starting send&receive"
<< endl; << endl;
if (!this->ready()) // Bypass polyPatch to get nbrId.
// - use cyclicACMIFvPatch::neighbPatch() virtual instead
const cyclicACMIFvPatch& neighbPatch = cyclicACMIPatch_.neighbPatch();
const labelUList& nbrFaceCells = neighbPatch.faceCells();
const Field<Type> pnf(this->primitiveField(), nbrFaceCells);
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Outstanding recv request(s) on patch " << "Outstanding recv request(s) on patch "
@ -453,11 +460,8 @@ void Foam::cyclicACMIFvPatchField<Type>::initEvaluate
<< abort(FatalError); << abort(FatalError);
} }
// By-pass polyPatch to get nbrId. Instead use cyclicACMIFvPatch virtual // Assume that sends are also OK
// neighbPatch() sendRequests_.clear();
const cyclicACMIFvPatch& neighbPatch = cyclicACMIPatch_.neighbPatch();
const labelUList& nbrFaceCells = neighbPatch.faceCells();
const Field<Type> pnf(this->primitiveField(), nbrFaceCells);
cyclicACMIPatch_.initInterpolate cyclicACMIPatch_.initInterpolate
( (
@ -515,6 +519,10 @@ void Foam::cyclicACMIFvPatchField<Type>::evaluate
).ptr() ).ptr()
); );
// Receive requests all handled by last function call
recvRequests_.clear();
auto& patchNeighbourField = patchNeighbourFieldPtr_.ref(); auto& patchNeighbourField = patchNeighbourFieldPtr_.ref();
if (doTransform()) if (doTransform())
@ -559,7 +567,16 @@ void Foam::cyclicACMIFvPatchField<Type>::initInterfaceMatrixUpdate
<< " starting send&receive" << " starting send&receive"
<< endl; << endl;
if (!this->ready()) const labelUList& nbrFaceCells =
lduAddr.patchAddr(cyclicACMIPatch_.neighbPatchID());
solveScalarField pnf(psiInternal, nbrFaceCells);
// Transform according to the transformation tensors
transformCoupleField(pnf, cmpt);
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Outstanding recv request(s) on patch " << "Outstanding recv request(s) on patch "
@ -568,13 +585,8 @@ void Foam::cyclicACMIFvPatchField<Type>::initInterfaceMatrixUpdate
<< abort(FatalError); << abort(FatalError);
} }
const labelUList& nbrFaceCells = // Assume that sends are also OK
lduAddr.patchAddr(cyclicACMIPatch_.neighbPatchID()); sendRequests_.clear();
solveScalarField pnf(psiInternal, nbrFaceCells);
// Transform according to the transformation tensors
transformCoupleField(pnf, cmpt);
cyclicACMIPatch_.initInterpolate cyclicACMIPatch_.initInterpolate
( (
@ -635,6 +647,9 @@ void Foam::cyclicACMIFvPatchField<Type>::updateInterfaceMatrix
recvRequests_, recvRequests_,
scalarRecvBufs_ scalarRecvBufs_
); );
// Receive requests all handled by last function call
recvRequests_.clear();
} }
else else
{ {
@ -676,7 +691,16 @@ void Foam::cyclicACMIFvPatchField<Type>::initInterfaceMatrixUpdate
<< exit(FatalError); << exit(FatalError);
} }
if (!this->ready()) const labelUList& nbrFaceCells =
lduAddr.patchAddr(cyclicACMIPatch_.neighbPatchID());
Field<Type> pnf(psiInternal, nbrFaceCells);
// Transform according to the transformation tensors
transformCoupleField(pnf);
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Outstanding recv request(s) on patch " << "Outstanding recv request(s) on patch "
@ -685,13 +709,8 @@ void Foam::cyclicACMIFvPatchField<Type>::initInterfaceMatrixUpdate
<< abort(FatalError); << abort(FatalError);
} }
const labelUList& nbrFaceCells = // Assume that sends are also OK
lduAddr.patchAddr(cyclicACMIPatch_.neighbPatchID()); sendRequests_.clear();
Field<Type> pnf(psiInternal, nbrFaceCells);
// Transform according to the transformation tensors
transformCoupleField(pnf);
cyclicACMIPatch_.initInterpolate cyclicACMIPatch_.initInterpolate
( (
@ -741,6 +760,9 @@ void Foam::cyclicACMIFvPatchField<Type>::updateInterfaceMatrix
recvRequests_, recvRequests_,
recvBufs_ recvBufs_
); );
// Receive requests all handled by last function call
recvRequests_.clear();
} }
else else
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2023 OpenCFD Ltd. Copyright (C) 2019-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -446,14 +446,27 @@ void Foam::cyclicAMIFvPatchField<Type>::initEvaluate
// Start sending // Start sending
// By-pass polyPatch to get nbrId. Instead use cyclicAMIFvPatch virtual // Bypass polyPatch to get nbrId.
// neighbPatch() // - use cyclicACMIFvPatch::neighbPatch() virtual instead
const cyclicAMIFvPatch& neighbPatch = cyclicAMIPatch_.neighbPatch(); const cyclicAMIFvPatch& neighbPatch = cyclicAMIPatch_.neighbPatch();
const labelUList& nbrFaceCells = neighbPatch.faceCells(); const labelUList& nbrFaceCells = neighbPatch.faceCells();
const Field<Type> pnf(this->primitiveField(), nbrFaceCells); const Field<Type> pnf(this->primitiveField(), nbrFaceCells);
const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch(); const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch();
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
{
FatalErrorInFunction
<< "Outstanding recv request(s) on patch "
<< cyclicAMIPatch_.name()
<< " field " << this->internalField().name()
<< abort(FatalError);
}
// Assume that sends are also OK
sendRequests_.clear();
cpp.initInterpolate cpp.initInterpolate
( (
pnf, pnf,
@ -516,6 +529,10 @@ void Foam::cyclicAMIFvPatchField<Type>::evaluate
defaultValues defaultValues
).ptr() ).ptr()
); );
// Receive requests all handled by last function call
recvRequests_.clear();
auto& patchNeighbourField = patchNeighbourFieldPtr_.ref(); auto& patchNeighbourField = patchNeighbourFieldPtr_.ref();
if (doTransform()) if (doTransform())
@ -563,6 +580,19 @@ void Foam::cyclicAMIFvPatchField<Type>::initInterfaceMatrixUpdate
const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch(); const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch();
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
{
FatalErrorInFunction
<< "Outstanding recv request(s) on patch "
<< cyclicAMIPatch_.name()
<< " field " << this->internalField().name()
<< abort(FatalError);
}
// Assume that sends are also OK
sendRequests_.clear();
cpp.initInterpolate cpp.initInterpolate
( (
pnf, pnf,
@ -624,6 +654,9 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
scalarRecvBufs_, scalarRecvBufs_,
defaultValues defaultValues
); );
// Receive requests all handled by last function call
recvRequests_.clear();
} }
else else
{ {
@ -682,6 +715,19 @@ void Foam::cyclicAMIFvPatchField<Type>::initInterfaceMatrixUpdate
const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch(); const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch();
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
{
FatalErrorInFunction
<< "Outstanding recv request(s) on patch "
<< cyclicAMIPatch_.name()
<< " field " << this->internalField().name()
<< abort(FatalError);
}
// Assume that sends are also OK
sendRequests_.clear();
cpp.initInterpolate cpp.initInterpolate
( (
pnf, pnf,
@ -742,6 +788,9 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
recvBufs_, recvBufs_,
defaultValues defaultValues
); );
// Receive requests all handled by last function call
recvRequests_.clear();
} }
else else
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013 OpenFOAM Foundation Copyright (C) 2013 OpenFOAM Foundation
Copyright (C) 2019,2023 OpenCFD Ltd. Copyright (C) 2019-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -217,6 +217,18 @@ void Foam::cyclicACMIGAMGInterfaceField::initInterfaceMatrixUpdate
: AMI.srcMap() : AMI.srcMap()
); );
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
{
FatalErrorInFunction
<< "Outstanding recv request(s) on patch "
<< cyclicACMIInterface_.index()
<< abort(FatalError);
}
// Assume that sends are also OK
sendRequests_.clear();
// Insert send/receive requests (non-blocking). See e.g. // Insert send/receive requests (non-blocking). See e.g.
// cyclicAMIPolyPatchTemplates.C // cyclicAMIPolyPatchTemplates.C
const label oldWarnComm = UPstream::commWarn(AMI.comm()); const label oldWarnComm = UPstream::commWarn(AMI.comm());
@ -276,6 +288,9 @@ void Foam::cyclicACMIGAMGInterfaceField::updateInterfaceMatrix
solveScalarField work; solveScalarField work;
map.receive(recvRequests_, scalarRecvBufs_, work); map.receive(recvRequests_, scalarRecvBufs_, work);
// Receive requests all handled by last function call
recvRequests_.clear();
solveScalarField pnf(faceCells.size(), Zero); solveScalarField pnf(faceCells.size(), Zero);
AMI.weightedSum AMI.weightedSum
( (

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2019,2023 OpenCFD Ltd. Copyright (C) 2019-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -218,6 +218,18 @@ void Foam::cyclicAMIGAMGInterfaceField::initInterfaceMatrixUpdate
: AMI.srcMap() : AMI.srcMap()
); );
// Assert that all receives are known to have finished
if (!recvRequests_.empty())
{
FatalErrorInFunction
<< "Outstanding recv request(s) on patch "
<< cyclicAMIInterface_.index()
<< abort(FatalError);
}
// Assume that sends are also OK
sendRequests_.clear();
// Insert send/receive requests (non-blocking). See e.g. // Insert send/receive requests (non-blocking). See e.g.
// cyclicAMIPolyPatchTemplates.C // cyclicAMIPolyPatchTemplates.C
const label oldWarnComm = UPstream::commWarn(AMI.comm()); const label oldWarnComm = UPstream::commWarn(AMI.comm());
@ -290,6 +302,9 @@ void Foam::cyclicAMIGAMGInterfaceField::updateInterfaceMatrix
solveScalarField work; solveScalarField work;
map.receive(recvRequests_, scalarRecvBufs_, work); map.receive(recvRequests_, scalarRecvBufs_, work);
// Receive requests all handled by last function call
recvRequests_.clear();
solveScalarField pnf(faceCells.size(), Zero); solveScalarField pnf(faceCells.size(), Zero);
AMI.weightedSum AMI.weightedSum
( (