/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2019-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "cyclicFaPatchField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
Foam::cyclicFaPatchField::cyclicFaPatchField
(
const faPatch& p,
const DimensionedField& iF
)
:
coupledFaPatchField(p, iF),
cyclicPatch_(refCast(p))
{}
template
Foam::cyclicFaPatchField::cyclicFaPatchField
(
const cyclicFaPatchField& ptf,
const faPatch& p,
const DimensionedField& iF,
const faPatchFieldMapper& mapper
)
:
coupledFaPatchField(ptf, p, iF, mapper),
cyclicPatch_(refCast(p))
{
if (!isA(this->patch()))
{
FatalErrorInFunction
<< "\n patch type '" << p.type()
<< "' not constraint type '" << typeName << "'"
<< "\n for patch " << p.name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< exit(FatalError);
}
}
template
Foam::cyclicFaPatchField::cyclicFaPatchField
(
const faPatch& p,
const DimensionedField& iF,
const dictionary& dict,
IOobjectOption::readOption requireValue
)
:
coupledFaPatchField(p, iF, dict, IOobjectOption::NO_READ),
cyclicPatch_(refCast(p, dict))
{
if (!isA(p))
{
FatalIOErrorInFunction(dict)
<< "\n patch type '" << p.type()
<< "' not constraint type '" << typeName << "'"
<< "\n for patch " << p.name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< exit(FatalIOError);
}
if (IOobjectOption::isReadRequired(requireValue))
{
this->evaluate(Pstream::commsTypes::buffered);
}
}
template
Foam::cyclicFaPatchField::cyclicFaPatchField
(
const cyclicFaPatchField& ptf
)
:
cyclicLduInterfaceField(),
coupledFaPatchField(ptf),
cyclicPatch_(ptf.cyclicPatch_)
{}
template
Foam::cyclicFaPatchField::cyclicFaPatchField
(
const cyclicFaPatchField& ptf,
const DimensionedField& iF
)
:
coupledFaPatchField(ptf, iF),
cyclicPatch_(ptf.cyclicPatch_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
void Foam::cyclicFaPatchField::patchNeighbourField
(
UList& pnf
) const
{
const Field& iField = this->primitiveField();
const labelUList& faceCells = cyclicPatch_.faceCells();
const label sizeby2 = pnf.size()/2;
if (doTransform())
{
for (label facei=0; facei
Foam::tmp>
Foam::cyclicFaPatchField::patchNeighbourField() const
{
auto tpnf = tmp>::New(this->size());
this->patchNeighbourField(tpnf.ref());
return tpnf;
}
template
void Foam::cyclicFaPatchField::updateInterfaceMatrix
(
solveScalarField& result,
const bool add,
const lduAddressing& lduAddr,
const label patchId,
const solveScalarField& psiInternal,
const scalarField& coeffs,
const direction cmpt,
const Pstream::commsTypes commsType
) const
{
solveScalarField pnf(this->size());
const label sizeby2 = this->size()/2;
const labelUList& faceCells = cyclicPatch_.faceCells();
for (label facei = 0; facei < sizeby2; ++facei)
{
pnf[facei] = psiInternal[faceCells[facei + sizeby2]];
pnf[facei + sizeby2] = psiInternal[faceCells[facei]];
}
// Transform according to the transformation tensors
transformCoupleField(pnf, cmpt);
// Multiply the field by coefficients and add into the result
this->addToInternalField(result, !add, faceCells, coeffs, pnf);
}
template
void Foam::cyclicFaPatchField::updateInterfaceMatrix
(
Field& result,
const bool add,
const lduAddressing& lduAddr,
const label patchId,
const Field& psiInternal,
const scalarField& coeffs,
const Pstream::commsTypes commsType
) const
{
Field pnf(this->size());
const label sizeby2 = this->size()/2;
const labelUList& faceCells = cyclicPatch_.faceCells();
for (label facei = 0; facei < sizeby2; ++facei)
{
pnf[facei] = psiInternal[faceCells[facei + sizeby2]];
pnf[facei + sizeby2] = psiInternal[faceCells[facei]];
}
// Transform according to the transformation tensors
transformCoupleField(pnf);
// Multiply the field by coefficients and add into the result
this->addToInternalField(result, !add, faceCells, coeffs, pnf);
}
// ************************************************************************* //