Commit 83d26d19 authored by Mark Olesen's avatar Mark Olesen Committed by Andrew Heather
Browse files

ENH: replace processorFvPatchField specialization with 'if...' (#1304)

- only apply component-wise transformCoupleField for non-scalar types
parent c96a84e6
......@@ -129,7 +129,6 @@ $(constraintFvPatchFields)/jumpCyclic/jumpCyclicFvPatchFields.C
$(constraintFvPatchFields)/jumpCyclicAMI/jumpCyclicAMIFvPatchFields.C
$(constraintFvPatchFields)/nonuniformTransformCyclic/nonuniformTransformCyclicFvPatchFields.C
$(constraintFvPatchFields)/processor/processorFvPatchFields.C
$(constraintFvPatchFields)/processor/processorFvPatchScalarField.C
$(constraintFvPatchFields)/processorCyclic/processorCyclicFvPatchFields.C
$(constraintFvPatchFields)/symmetryPlane/symmetryPlaneFvPatchFields.C
$(constraintFvPatchFields)/symmetryPlane/symmetryPlaneFvPatchScalarField.C
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
......@@ -402,11 +402,13 @@ void Foam::processorFvPatchField<Type>::updateInterfaceMatrix
// Recv finished so assume sending finished as well.
outstandingSendRequest_ = -1;
outstandingRecvRequest_ = -1;
// Consume straight from scalarReceiveBuf_
// Transform according to the transformation tensor
transformCoupleField(scalarReceiveBuf_, cmpt);
if (!std::is_arithmetic<Type>::value)
{
// Transform non-scalar data according to the transformation tensor
transformCoupleField(scalarReceiveBuf_, cmpt);
}
// Multiply the field by coefficients and add into the result
this->addToInternalField(result, !add, coeffs, scalarReceiveBuf_);
......@@ -418,8 +420,11 @@ void Foam::processorFvPatchField<Type>::updateInterfaceMatrix
procPatch_.compressedReceive<scalar>(commsType, this->size())()
);
// Transform according to the transformation tensor
transformCoupleField(pnf, cmpt);
if (!std::is_arithmetic<Type>::value)
{
// Transform non-scalar data according to the transformation tensor
transformCoupleField(pnf, cmpt);
}
// Multiply the field by coefficients and add into the result
this->addToInternalField(result, !add, coeffs, pnf);
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation
......@@ -28,7 +28,7 @@ License
#ifndef processorFvPatchFields_H
#define processorFvPatchFields_H
#include "processorFvPatchScalarField.H"
#include "processorFvPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "processorFvPatchScalarField.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<>
void Foam::processorFvPatchField<Foam::scalar>::initInterfaceMatrixUpdate
(
scalarField&,
const bool add,
const scalarField& psiInternal,
const scalarField&,
const direction,
const Pstream::commsTypes commsType
) const
{
this->patch().patchInternalField(psiInternal, scalarSendBuf_);
if
(
commsType == Pstream::commsTypes::nonBlocking
&& !Pstream::floatTransfer
)
{
// Fast path.
if (debug && !this->ready())
{
FatalErrorInFunction
<< "On patch " << procPatch_.name()
<< " outstanding request."
<< abort(FatalError);
}
scalarReceiveBuf_.setSize(scalarSendBuf_.size());
outstandingRecvRequest_ = UPstream::nRequests();
UIPstream::read
(
Pstream::commsTypes::nonBlocking,
procPatch_.neighbProcNo(),
reinterpret_cast<char*>(scalarReceiveBuf_.begin()),
scalarReceiveBuf_.byteSize(),
procPatch_.tag(),
procPatch_.comm()
);
outstandingSendRequest_ = UPstream::nRequests();
UOPstream::write
(
Pstream::commsTypes::nonBlocking,
procPatch_.neighbProcNo(),
reinterpret_cast<const char*>(scalarSendBuf_.begin()),
scalarSendBuf_.byteSize(),
procPatch_.tag(),
procPatch_.comm()
);
}
else
{
procPatch_.compressedSend(commsType, scalarSendBuf_);
}
const_cast<processorFvPatchField<scalar>&>(*this).updatedMatrix() = false;
}
template<>
void Foam::processorFvPatchField<Foam::scalar>::updateInterfaceMatrix
(
scalarField& result,
const bool add,
const scalarField&,
const scalarField& coeffs,
const direction,
const Pstream::commsTypes commsType
) const
{
if (this->updatedMatrix())
{
return;
}
if
(
commsType == Pstream::commsTypes::nonBlocking
&& !Pstream::floatTransfer
)
{
// Fast path.
if
(
outstandingRecvRequest_ >= 0
&& outstandingRecvRequest_ < Pstream::nRequests()
)
{
UPstream::waitRequest(outstandingRecvRequest_);
}
// Recv finished so assume sending finished as well.
outstandingSendRequest_ = -1;
outstandingRecvRequest_ = -1;
// Consume straight from scalarReceiveBuf_
this->addToInternalField(result, !add, coeffs, scalarReceiveBuf_);
}
else
{
scalarField pnf
(
procPatch_.compressedReceive<scalar>(commsType, this->size())()
);
this->addToInternalField(result, !add, coeffs, pnf);
}
const_cast<processorFvPatchField<scalar>&>(*this).updatedMatrix() = true;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2012 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef processorFvPatchScalarField_H
#define processorFvPatchScalarField_H
#include "processorFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<>
void processorFvPatchField<scalar>::initInterfaceMatrixUpdate
(
scalarField&,
const bool add,
const scalarField&,
const scalarField&,
const direction,
const Pstream::commsTypes commsType
) const;
template<>
void processorFvPatchField<scalar>::updateInterfaceMatrix
(
scalarField& result,
const bool add,
const scalarField&,
const scalarField& coeffs,
const direction,
const Pstream::commsTypes commsType
) const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
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