introvoyz042's picture
Migrated from GitHub
5a600cf verified
Raw History Blame Contribute Delete
4.81 kB
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "partialSlipFvPatchField.H"
#include "symmTransformField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::partialSlipFvPatchField<Type>::partialSlipFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, fvMesh>& iF
)
:
transformFvPatchField<Type>(p, iF),
valueFraction_(p.size(), 1.0)
{}
template<class Type>
Foam::partialSlipFvPatchField<Type>::partialSlipFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, fvMesh>& iF,
const dictionary& dict
)
:
transformFvPatchField<Type>(p, iF),
valueFraction_("valueFraction", units::fraction, dict, p.size())
{
evaluate();
}
template<class Type>
Foam::partialSlipFvPatchField<Type>::partialSlipFvPatchField
(
const partialSlipFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, fvMesh>& iF,
const fieldMapper& mapper
)
:
transformFvPatchField<Type>(ptf, p, iF, mapper),
valueFraction_(mapper(ptf.valueFraction_))
{}
template<class Type>
Foam::partialSlipFvPatchField<Type>::partialSlipFvPatchField
(
const partialSlipFvPatchField<Type>& ptf,
const DimensionedField<Type, fvMesh>& iF
)
:
transformFvPatchField<Type>(ptf, iF),
valueFraction_(ptf.valueFraction_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::partialSlipFvPatchField<Type>::map
(
const fvPatchField<Type>& ptf,
const fieldMapper& mapper
)
{
transformFvPatchField<Type>::map(ptf, mapper);
const partialSlipFvPatchField<Type>& dmptf =
refCast<const partialSlipFvPatchField<Type>>(ptf);
mapper(valueFraction_, dmptf.valueFraction_);
}
template<class Type>
void Foam::partialSlipFvPatchField<Type>::reset
(
const fvPatchField<Type>& ptf
)
{
transformFvPatchField<Type>::reset(ptf);
const partialSlipFvPatchField<Type>& dmptf =
refCast<const partialSlipFvPatchField<Type>>(ptf);
valueFraction_.reset(dmptf.valueFraction_);
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::partialSlipFvPatchField<Type>::snGrad() const
{
tmp<vectorField> nHat = patch().nf();
const Field<Type> pif(patchInternalField());
return
(
(1.0 - valueFraction_)*transform(I - sqr(nHat), pif) - pif
)*patch().deltaCoeffs();
}
template<class Type>
void Foam::partialSlipFvPatchField<Type>::evaluate
(
const Pstream::commsTypes
)
{
if (!this->updated())
{
this->updateCoeffs();
}
tmp<vectorField> nHat = patch().nf();
Field<Type>::operator=
(
(1.0 - valueFraction_)
*transform(I - sqr(nHat), patchInternalField())
);
transformFvPatchField<Type>::evaluate();
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::partialSlipFvPatchField<Type>::snGradTransformDiag() const
{
const vectorField nHat(patch().nf());
vectorField diag(nHat.size());
diag.replace(vector::X, mag(nHat.component(vector::X)));
diag.replace(vector::Y, mag(nHat.component(vector::Y)));
diag.replace(vector::Z, mag(nHat.component(vector::Z)));
return
valueFraction_*pTraits<Type>::one
+ (1.0 - valueFraction_)
*transformMask
(
pTraits<Type>::zero,
pow<pTraits<Type>::rank>(diag)
);
}
template<class Type>
void Foam::partialSlipFvPatchField<Type>::write(Ostream& os) const
{
transformFvPatchField<Type>::write(os);
writeEntry(os, "valueFraction", valueFraction_);
}
// ************************************************************************* //