Commit f6ed5ddc authored by mattijs's avatar mattijs
Browse files

BUG: #704 processorCyclic: non-blocking comms, multiple tags

parent e147ee52
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,7 +24,6 @@ License
\*---------------------------------------------------------------------------*/
#include "processorPointPatchField.H"
//#include "transformField.H"
#include "processorPolyPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -92,73 +91,6 @@ processorPointPatchField<Type>::~processorPointPatchField()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void processorPointPatchField<Type>::initSwapAddSeparated
(
const Pstream::commsTypes commsType,
Field<Type>& pField
)
const
{
// if (Pstream::parRun())
// {
// // Get internal field into correct order for opposite side
// Field<Type> pf
// (
// this->patchInternalField
// (
// pField,
// procPatch_.reverseMeshPoints()
// )
// );
//
// OPstream::write
// (
// commsType,
// procPatch_.neighbProcNo(),
// reinterpret_cast<const char*>(pf.begin()),
// pf.byteSize(),
// procPatch_.tag()
// );
// }
}
template<class Type>
void processorPointPatchField<Type>::swapAddSeparated
(
const Pstream::commsTypes commsType,
Field<Type>& pField
) const
{
// if (Pstream::parRun())
// {
// Field<Type> pnf(this->size());
//
// IPstream::read
// (
// commsType,
// procPatch_.neighbProcNo(),
// reinterpret_cast<char*>(pnf.begin()),
// pnf.byteSize(),
// procPatch_.tag()
// );
//
// if (doTransform())
// {
// const processorPolyPatch& ppp = procPatch_.procPolyPatch();
// const tensor& forwardT = ppp.forwardT();
//
// transform(pnf, forwardT, pnf);
// }
//
// addToInternalField(pField, pnf, procPatch_.separatedPoints());
// }
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -57,7 +57,6 @@ class processorPointPatchField
//- Local reference to processor patch
const processorPointPatch& procPatch_;
public:
//- Runtime type information
......@@ -176,19 +175,13 @@ public:
)
{}
//- Initialise swap of non-collocated patch point values
virtual void initSwapAddSeparated
(
const Pstream::commsTypes commsType,
Field<Type>&
) const;
//- Complete swap of patch point values and add to local values
//- Assume processor patch always collocated
virtual void swapAddSeparated
(
const Pstream::commsTypes commsType,
Field<Type>&
) const;
) const
{}
};
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -38,7 +38,8 @@ Foam::processorCyclicPointPatchField<Type>::processorCyclicPointPatchField
)
:
coupledPointPatchField<Type>(p, iF),
procPatch_(refCast<const processorCyclicPointPatch>(p))
procPatch_(refCast<const processorCyclicPointPatch>(p)),
receiveBuf_(0)
{}
......@@ -51,7 +52,8 @@ Foam::processorCyclicPointPatchField<Type>::processorCyclicPointPatchField
)
:
coupledPointPatchField<Type>(p, iF, dict),
procPatch_(refCast<const processorCyclicPointPatch>(p))
procPatch_(refCast<const processorCyclicPointPatch>(p)),
receiveBuf_(0)
{}
......@@ -65,7 +67,8 @@ Foam::processorCyclicPointPatchField<Type>::processorCyclicPointPatchField
)
:
coupledPointPatchField<Type>(ptf, p, iF, mapper),
procPatch_(refCast<const processorCyclicPointPatch>(ptf.patch()))
procPatch_(refCast<const processorCyclicPointPatch>(ptf.patch())),
receiveBuf_(0)
{}
......@@ -77,7 +80,8 @@ Foam::processorCyclicPointPatchField<Type>::processorCyclicPointPatchField
)
:
coupledPointPatchField<Type>(ptf, iF),
procPatch_(refCast<const processorCyclicPointPatch>(ptf.patch()))
procPatch_(refCast<const processorCyclicPointPatch>(ptf.patch())),
receiveBuf_(0)
{}
......@@ -109,6 +113,18 @@ void Foam::processorCyclicPointPatchField<Type>::initSwapAddSeparated
)
);
if (commsType == Pstream::nonBlocking)
{
receiveBuf_.setSize(pf.size());
IPstream::read
(
commsType,
procPatch_.neighbProcNo(),
reinterpret_cast<char*>(receiveBuf_.begin()),
receiveBuf_.byteSize(),
procPatch_.tag()
);
}
OPstream::write
(
commsType,
......@@ -130,16 +146,19 @@ void Foam::processorCyclicPointPatchField<Type>::swapAddSeparated
{
if (Pstream::parRun())
{
Field<Type> pnf(this->size());
IPstream::read
(
commsType,
procPatch_.neighbProcNo(),
reinterpret_cast<char*>(pnf.begin()),
pnf.byteSize(),
procPatch_.tag()
);
// If nonblocking data has already been received into receiveBuf_
if (commsType != Pstream::nonBlocking)
{
receiveBuf_.setSize(this->size());
IPstream::read
(
commsType,
procPatch_.neighbProcNo(),
reinterpret_cast<char*>(receiveBuf_.begin()),
receiveBuf_.byteSize(),
procPatch_.tag()
);
}
if (doTransform())
{
......@@ -147,11 +166,11 @@ void Foam::processorCyclicPointPatchField<Type>::swapAddSeparated
procPatch_.procCyclicPolyPatch();
const tensor& forwardT = ppp.forwardT()[0];
transform(pnf, forwardT, pnf);
transform(receiveBuf_, forwardT, receiveBuf_);
}
// All points are separated
this->addToInternalField(pField, pnf);
this->addToInternalField(pField, receiveBuf_);
}
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -57,6 +57,9 @@ class processorCyclicPointPatchField
//- Local reference to processor patch
const processorCyclicPointPatch& procPatch_;
//- Receive buffer for non-blocking communication
mutable Field<Type> receiveBuf_;
public:
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -37,10 +37,7 @@ namespace Foam
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
(
......@@ -66,20 +63,10 @@ Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
neighbProcNo,
transform
),
tag_
(
Pstream::nProcs()*max(myProcNo, neighbProcNo)
+ min(myProcNo, neighbProcNo)
),
referPatchName_(referPatchName),
tag_(-1),
referPatchID_(-1)
{
if (debug)
{
Pout<< "processorCyclicPolyPatch " << name << " uses tag " << tag_
<< endl;
}
}
{}
Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
......@@ -92,20 +79,10 @@ Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
)
:
processorPolyPatch(name, dict, index, bm, patchType),
tag_
(
Pstream::nProcs()*max(myProcNo(), neighbProcNo())
+ min(myProcNo(), neighbProcNo())
),
referPatchName_(dict.lookup("referPatch")),
tag_(dict.lookupOrDefault<int>("tag", -1)),
referPatchID_(-1)
{
if (debug)
{
Pout<< "processorCyclicPolyPatch " << name << " uses tag " << tag_
<< endl;
}
}
{}
Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
......@@ -115,8 +92,8 @@ Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
)
:
processorPolyPatch(pp, bm),
tag_(pp.tag_),
referPatchName_(pp.referPatchName()),
tag_(pp.tag()),
referPatchID_(-1)
{}
......@@ -132,8 +109,8 @@ Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
)
:
processorPolyPatch(pp, bm, index, newSize, newStart),
tag_(pp.tag_),
referPatchName_(referPatchName),
tag_(-1),
referPatchID_(-1)
{}
......@@ -148,8 +125,8 @@ Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
)
:
processorPolyPatch(pp, bm, index, mapAddressing, newStart),
tag_(pp.tag_),
referPatchName_(pp.referPatchName()),
tag_(-1),
referPatchID_(-1)
{}
......@@ -162,6 +139,45 @@ Foam::processorCyclicPolyPatch::~processorCyclicPolyPatch()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
int Foam::processorCyclicPolyPatch::tag() const
{
if (tag_ == -1)
{
// Get unique tag to use for all comms. Make sure that both sides
// use the same tag
const cyclicPolyPatch& cycPatch = refCast<const cyclicPolyPatch>
(
referPatch()
);
if (cycPatch.owner())
{
tag_ = Hash<word>()(cycPatch.name());
}
else
{
tag_ = Hash<word>()(cycPatch.neighbPatch().name());
}
if (tag_ == Pstream::msgType() || tag_ == -1)
{
FatalErrorIn("processorCyclicPolyPatch::tag() const")
<< "Tag calculated from cyclic patch name " << tag_
<< " is the same as the current message type "
<< Pstream::msgType() << " or -1" << nl
<< "Please set a non-conflicting, unique, tag by hand"
<< " using the 'tag' entry"
<< exit(FatalError);
}
if (debug)
{
Pout<< "processorCyclicPolyPatch " << name() << " uses tag " << tag_
<< endl;
}
}
return tag_;
}
void Foam::processorCyclicPolyPatch::initGeometry(PstreamBuffers& pBufs)
{
......@@ -283,6 +299,11 @@ void Foam::processorCyclicPolyPatch::write(Ostream& os) const
processorPolyPatch::write(os);
os.writeKeyword("referPatch") << referPatchName_
<< token::END_STATEMENT << nl;
if (tag_ != -1)
{
os.writeKeyword("tag") << tag_
<< token::END_STATEMENT << nl;
}
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -54,12 +54,12 @@ class processorCyclicPolyPatch
{
// Private data
//- Message tag to use for communication
const int tag_;
//- Name of originating patch
const word referPatchName_;
//- Message tag to use for communication
mutable int tag_;
//- Index of originating patch
mutable label referPatchID_;
......@@ -264,10 +264,7 @@ public:
}
//- Return message tag to use for communication
virtual int tag() const
{
return tag_;
}
virtual int tag() const;
//- Does this side own the patch ?
virtual bool owner() const
......
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