ENH: fvPatchField: support for polling. Support for zero-copy transfer.

This commit is contained in:
mattijs
2012-01-16 15:59:03 +00:00
parent 515374726f
commit 2516d984b4
14 changed files with 161 additions and 23 deletions

View File

@ -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) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -254,5 +254,11 @@ Foam::UPstream::commsTypes Foam::UPstream::defaultCommsType
commsTypeNames.read(debug::optimisationSwitches().lookup("commsType"))
);
// Number of polling cycles in processor updates
int Foam::UPstream::nPollProcInterfaces
(
debug::optimisationSwitch("nPollProcInterfaces", 0)
);
// ************************************************************************* //

View File

@ -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) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -242,6 +242,8 @@ public:
//- Default commsType
static commsTypes defaultCommsType;
//- Number of polling cycles in processor updates
static int nPollProcInterfaces;
// Constructors
@ -273,6 +275,9 @@ public:
//- Wait until all requests (from start onwards) have finished.
static void waitRequests(const label start = 0);
//- Wait until request i has finished.
static void waitRequest(const label i);
//- Non-blocking comms: has request i finished?
static bool finishedRequest(const label i);

View File

@ -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) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -772,10 +772,11 @@ Foam::argList::argList
Info<< "Roots : " << roots << nl;
}
Info<< "Pstream initialized with:" << nl
<< " floatTransfer : " << Pstream::floatTransfer << nl
<< " nProcsSimpleSum : " << Pstream::nProcsSimpleSum << nl
<< " commsType : "
<< " floatTransfer : " << Pstream::floatTransfer << nl
<< " nProcsSimpleSum : " << Pstream::nProcsSimpleSum << nl
<< " commsType : "
<< Pstream::commsTypeNames[Pstream::defaultCommsType]
<< " polling iterations : " << Pstream::nPollProcInterfaces
<< endl;
}
}

View File

@ -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) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -60,7 +60,6 @@ class lduInterfaceField
//- Reference to the coupled patch this field is defined for
const lduInterface& interface_;
// Private Member Functions
//- Disallow default bitwise copy construct
@ -69,6 +68,11 @@ class lduInterfaceField
//- Disallow default bitwise assignment
void operator=(const lduInterfaceField&);
protected:
//- Update index used so that updateInterfaceMatrix is called only once
// during the construction of the matrix
bool updatedMatrix_;
public:
@ -81,7 +85,8 @@ public:
//- Construct given coupled patch
lduInterfaceField(const lduInterface& patch)
:
interface_(patch)
interface_(patch),
updatedMatrix_(false)
{}
@ -120,6 +125,24 @@ public:
) const
{}
//- Whether matrix has been updated
bool updatedMatrix() const
{
return updatedMatrix_;
}
//- Whether matrix has been updated
bool& updatedMatrix()
{
return updatedMatrix_;
}
//- Is all data available
virtual bool ready() const
{
return true;
}
//- Update result field based on interface functionality
virtual void updateInterfaceMatrix
(

View File

@ -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) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -74,6 +74,10 @@ void Foam::UPstream::waitRequests(const label start)
{}
void Foam::UPstream::waitRequest(const label i)
{}
bool Foam::UPstream::finishedRequest(const label i)
{
notImplemented("UPstream::finishedRequest()");

View File

@ -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) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -516,11 +516,55 @@ void Foam::UPstream::waitRequests(const label start)
}
void Foam::UPstream::waitRequest(const label i)
{
if (debug)
{
Pout<< "UPstream::waitRequest : starting wait for request:" << i
<< endl;
}
if (i >= PstreamGlobals::outstandingRequests_.size())
{
FatalErrorIn
(
"UPstream::waitRequest(const label)"
) << "There are " << PstreamGlobals::outstandingRequests_.size()
<< " outstanding send requests and you are asking for i=" << i
<< nl
<< "Maybe you are mixing blocking/non-blocking comms?"
<< Foam::abort(FatalError);
}
int flag;
if
(
MPI_Wait
(
&PstreamGlobals::outstandingRequests_[i],
MPI_STATUS_IGNORE
)
)
{
FatalErrorIn
(
"UPstream::waitRequest()"
) << "MPI_Wait returned with error" << Foam::endl;
}
if (debug)
{
Pout<< "UPstream::waitRequest : finished wait for request:" << i
<< endl;
}
}
bool Foam::UPstream::finishedRequest(const label i)
{
if (debug)
{
Pout<< "UPstream::waitRequests : starting wait for request:" << i
Pout<< "UPstream::waitRequests : checking finishedRequest:" << i
<< endl;
}
@ -546,7 +590,7 @@ bool Foam::UPstream::finishedRequest(const label i)
if (debug)
{
Pout<< "UPstream::waitRequests : finished wait for request:" << i
Pout<< "UPstream::waitRequests : finished finishedRequest:" << i
<< endl;
}
@ -554,6 +598,4 @@ bool Foam::UPstream::finishedRequest(const label i)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -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) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -198,6 +198,17 @@ tmp<Field<Type> > slicedFvPatchField<Type>::patchInternalField() const
}
template<class Type>
void slicedFvPatchField<Type>::patchInternalField(Field<Type>&) const
{
notImplemented
(
"slicedFvPatchField<Type>::"
"patchInternalField(Field<Type>&)"
);
}
template<class Type>
tmp<Field<Type> > slicedFvPatchField<Type>::patchNeighbourField
(

View File

@ -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) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -148,6 +148,9 @@ public:
//- Return internal field next to patch as patch field
virtual tmp<Field<Type> > patchInternalField() const;
//- Return internal field next to patch as patch field
virtual void patchInternalField(Field<Type>&) const;
//- Return neighbour coupled given internal cell data
virtual tmp<Field<Type> > patchNeighbourField
(

View File

@ -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) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -223,6 +223,13 @@ void processorFvPatchField<Type>::initInterfaceMatrixUpdate
}
template<class Type>
bool processorFvPatchField<Type>::ready() const
{
return true;
}
template<class Type>
void processorFvPatchField<Type>::updateInterfaceMatrix
(

View File

@ -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) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -179,6 +179,9 @@ public:
const Pstream::commsTypes commsType
) const;
//- Is all data available
virtual bool ready() const;
//- Update result field based on interface functionality
virtual void updateInterfaceMatrix
(
@ -221,6 +224,7 @@ public:
{
return pTraits<Type>::rank;
}
};

View File

@ -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) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -190,6 +190,13 @@ Foam::fvPatchField<Type>::patchInternalField() const
}
template<class Type>
void Foam::fvPatchField<Type>::patchInternalField(Field<Type>& pif) const
{
patch_.patchInternalField(internalField_, pif);
}
template<class Type>
void Foam::fvPatchField<Type>::autoMap
(

View File

@ -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) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -352,6 +352,9 @@ public:
//- Return internal field next to patch as patch field
virtual tmp<Field<Type> > patchInternalField() const;
//- Return internal field next to patch as patch field
virtual void patchInternalField(Field<Type>&) const;
//- Return patchField on the opposite patch of a coupled patch
virtual tmp<Field<Type> > patchNeighbourField() const
{

View File

@ -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) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -239,6 +239,10 @@ public:
template<class Type>
tmp<Field<Type> > patchInternalField(const UList<Type>&) const;
//- Return given internal field next to patch as patch field
template<class Type>
void patchInternalField(const UList<Type>&, Field<Type>&) const;
//- Return the corresponding patchField of the named field
template<class GeometricField, class Type>
const typename GeometricField::PatchFieldType& patchField

View File

@ -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) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -47,6 +47,24 @@ Foam::tmp<Foam::Field<Type> > Foam::fvPatch::patchInternalField
}
template<class Type>
void Foam::fvPatch::patchInternalField
(
const UList<Type>& f,
Field<Type>& pif
) const
{
pif.setSize(size());
const labelUList& faceCells = this->faceCells();
forAll(pif, facei)
{
pif[facei] = f[faceCells[facei]];
}
}
template<class GeometricField, class Type>
const typename GeometricField::PatchFieldType& Foam::fvPatch::patchField
(