/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 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 .
\*---------------------------------------------------------------------------*/
#include "cyclicAMIPointPatchField.H"
#include "transformField.H"
#include "pointFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
Foam::cyclicAMIPointPatchField::cyclicAMIPointPatchField
(
const pointPatch& p,
const DimensionedField& iF
)
:
coupledPointPatchField(p, iF),
cyclicAMIPatch_(refCast(p)),
ppiPtr_(nullptr),
nbrPpiPtr_(nullptr)
{}
template
Foam::cyclicAMIPointPatchField::cyclicAMIPointPatchField
(
const pointPatch& p,
const DimensionedField& iF,
const dictionary& dict
)
:
coupledPointPatchField(p, iF, dict),
cyclicAMIPatch_(refCast(p, dict)),
ppiPtr_(nullptr),
nbrPpiPtr_(nullptr)
{
if (!isType(p))
{
FatalIOErrorInFunction(dict)
<< "patch " << this->patch().index() << " not cyclicAMI type. "
<< "Patch type = " << p.type()
<< exit(FatalIOError);
}
}
template
Foam::cyclicAMIPointPatchField::cyclicAMIPointPatchField
(
const cyclicAMIPointPatchField& ptf,
const pointPatch& p,
const DimensionedField& iF,
const pointPatchFieldMapper& mapper
)
:
coupledPointPatchField(ptf, p, iF, mapper),
cyclicAMIPatch_(refCast(p)),
ppiPtr_(nullptr),
nbrPpiPtr_(nullptr)
{
if (!isType(this->patch()))
{
FatalErrorInFunction
<< "Field type does not correspond to patch type for patch "
<< this->patch().index() << "." << endl
<< "Field type: " << typeName << endl
<< "Patch type: " << this->patch().type()
<< exit(FatalError);
}
}
template
Foam::cyclicAMIPointPatchField::cyclicAMIPointPatchField
(
const cyclicAMIPointPatchField& ptf,
const DimensionedField& iF
)
:
coupledPointPatchField(ptf, iF),
cyclicAMIPatch_(ptf.cyclicAMIPatch_),
ppiPtr_(nullptr),
nbrPpiPtr_(nullptr)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
bool Foam::cyclicAMIPointPatchField::coupled() const
{
return cyclicAMIPatch_.coupled();
}
template
void Foam::cyclicAMIPointPatchField::swapAddSeparated
(
const Pstream::commsTypes,
Field& pField
) const
{
if (cyclicAMIPatch_.cyclicAMIPatch().owner())
{
// We inplace modify pField. To prevent the other side (which gets
// evaluated at a later date) using already changed values we do
// all swaps on the side that gets evaluated first.
// Get neighbouring pointPatch
const cyclicAMIPointPatch& nbrPatch = cyclicAMIPatch_.neighbPatch();
// Get neighbouring pointPatchField
const GeometricField& fld =
refCast>
(
this->internalField()
);
const cyclicAMIPointPatchField& nbr =
refCast>
(
fld.boundaryField()[nbrPatch.index()]
);
Field ptFld(this->patchInternalField(pField));
Field nbrPtFld(nbr.patchInternalField(pField));
if (doTransform())
{
const tensor& forwardT = this->forwardT()[0];
const tensor& reverseT = this->reverseT()[0];
transform(ptFld, reverseT, ptFld);
transform(nbrPtFld, forwardT, nbrPtFld);
}
// convert point field to face field, AMI interpolate, then
// face back to point
{
// add neighbour side contribution to owner
Field nbrFcFld(nbrPpi().pointToFaceInterpolate(nbrPtFld));
// interpolate to owner
if (cyclicAMIPatch_.cyclicAMIPatch().applyLowWeightCorrection())
{
Field fcFld(ppi().pointToFaceInterpolate(ptFld));
nbrFcFld =
cyclicAMIPatch_.cyclicAMIPatch().interpolate
(
nbrFcFld,
fcFld
);
}
else
{
nbrFcFld =
cyclicAMIPatch_.cyclicAMIPatch().interpolate(nbrFcFld);
}
// add to internal field
this->addToInternalField
(
pField,
ppi().faceToPointInterpolate(nbrFcFld)()
);
}
{
// add owner side contribution to neighbour
Field fcFld(ppi().pointToFaceInterpolate(ptFld));
// interpolate to neighbour
if (cyclicAMIPatch_.cyclicAMIPatch().applyLowWeightCorrection())
{
Field nbrFcFld(nbrPpi().pointToFaceInterpolate(nbrPtFld));
fcFld =
cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().interpolate
(
fcFld,
nbrFcFld
);
}
else
{
fcFld =
cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().interpolate
(
fcFld
);
}
// add to internal field
nbr.addToInternalField
(
pField,
nbrPpi().faceToPointInterpolate(fcFld)()
);
}
}
}
// ************************************************************************* //