/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2017-2020 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 "freestreamFvPatchField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
Foam::freestreamFvPatchField::freestreamFvPatchField
(
const fvPatch& p,
const DimensionedField& iF
)
:
inletOutletFvPatchField(p, iF),
freestreamBCPtr_(nullptr)
{}
template
Foam::freestreamFvPatchField::freestreamFvPatchField
(
const fvPatch& p,
const DimensionedField& iF,
const dictionary& dict
)
:
inletOutletFvPatchField(p, iF),
freestreamBCPtr_(nullptr)
{
fvPatchFieldBase::readDict(dict);
this->phiName_ = dict.getOrDefault("phi", "phi");
if
(
freestreamValue().assign
(
"freestreamValue", dict, p.size(), IOobjectOption::LAZY_READ
)
)
{
if (!this->readValueEntry(dict))
{
fvPatchField::operator=(freestreamValue());
}
}
else
{
// Freestream value provided by another patch
freestreamBCPtr_ =
fvPatchField::New(p, iF, dict.subDict("freestreamBC"));
// Force user to supply an initial value
// - we do not know if the supplied BC has all dependencies available
this->readValueEntry(dict, IOobjectOption::MUST_READ);
}
}
template
Foam::freestreamFvPatchField::freestreamFvPatchField
(
const freestreamFvPatchField& ptf,
const fvPatch& p,
const DimensionedField& iF,
const fvPatchFieldMapper& mapper
)
:
inletOutletFvPatchField(ptf, p, iF, mapper),
freestreamBCPtr_(nullptr)
{
if (ptf.freestreamBCPtr_)
{
freestreamBCPtr_ =
fvPatchField::New(ptf.freestreamBCPtr_(), p, iF, mapper);
}
}
template
Foam::freestreamFvPatchField::freestreamFvPatchField
(
const freestreamFvPatchField& ptf
)
:
inletOutletFvPatchField(ptf),
freestreamBCPtr_(nullptr)
{
if (ptf.freestreamBCPtr_)
{
freestreamBCPtr_ = ptf.freestreamBCPtr_->clone();
}
}
template
Foam::freestreamFvPatchField::freestreamFvPatchField
(
const freestreamFvPatchField& ptf,
const DimensionedField& iF
)
:
inletOutletFvPatchField(ptf, iF),
freestreamBCPtr_(nullptr)
{
if (ptf.freestreamBCPtr_)
{
freestreamBCPtr_ = ptf.freestreamBCPtr_->clone();
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
void Foam::freestreamFvPatchField::autoMap(const fvPatchFieldMapper& m)
{
inletOutletFvPatchField::autoMap(m);
if (freestreamBCPtr_)
{
freestreamBCPtr_->autoMap(m);
}
}
template
void Foam::freestreamFvPatchField::rmap
(
const fvPatchField& ptf,
const labelList& addr
)
{
inletOutletFvPatchField::rmap(ptf, addr);
const auto& fsptf = refCast>(ptf);
if (freestreamBCPtr_ && fsptf.freestreamBCPtr_)
{
freestreamBCPtr_->rmap(fsptf.freestreamBCPtr_(), addr);
}
}
template
void Foam::freestreamFvPatchField::updateCoeffs()
{
if (this->updated())
{
return;
}
if (freestreamBCPtr_)
{
freestreamBCPtr_->evaluate();
freestreamValue() = freestreamBCPtr_();
}
inletOutletFvPatchField::updateCoeffs();
}
template
void Foam::freestreamFvPatchField::write(Ostream& os) const
{
fvPatchField::write(os);
os.writeEntryIfDifferent("phi", "phi", this->phiName_);
if (freestreamBCPtr_)
{
os.beginBlock("freestreamBC");
freestreamBCPtr_->write(os);
os.endBlock();
}
else
{
freestreamValue().writeEntry("freestreamValue", os);
}
fvPatchField::writeValueEntry(os);
}
// ************************************************************************* //