/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-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 .
\*---------------------------------------------------------------------------*/
#include "codedFixedValuePointPatchField.H"
#include "addToRunTimeSelectionTable.H"
#include "fieldMapper.H"
#include "pointFields.H"
#include "dynamicCode.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template
const Foam::wordList Foam::codedFixedValuePointPatchField::codeKeys
(
{"code", "codeInclude", "localCode"}
);
template
const Foam::wordList Foam::codedFixedValuePointPatchField::codeDictVars
(
{word::null, word::null, word::null}
);
template
const Foam::word Foam::codedFixedValuePointPatchField::codeOptions
(
"codedFixedValuePointPatchFieldOptions"
);
template
const Foam::wordList Foam::codedFixedValuePointPatchField::compileFiles
{
"codedFixedValuePointPatchFieldTemplate.C"
};
template
const Foam::wordList Foam::codedFixedValuePointPatchField::copyFiles
{
"codedFixedValuePointPatchFieldTemplate.H"
};
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
Foam::codedFixedValuePointPatchField::codedFixedValuePointPatchField
(
const pointPatch& p,
const DimensionedField& iF,
const dictionary& dict
)
:
fixedValuePointPatchField(p, iF, dict),
codedBase
(
dict.lookup("name"),
dict,
codeKeys,
codeDictVars,
codeOptions,
compileFiles,
copyFiles
)
{
const word fieldType(pTraits::typeName);
// Set variable substitutions
varSubstitutions().set
(
{
{"TemplateType", fieldType},
{"FieldType", fieldType.capitalise() + "Field"},
{"verbose", Foam::name(bool(debug))}
}
);
// Compile the library containing user-defined pointPatchField
updateLibrary(dict);
}
template
Foam::codedFixedValuePointPatchField::codedFixedValuePointPatchField
(
const codedFixedValuePointPatchField& ptf,
const pointPatch& p,
const DimensionedField& iF,
const fieldMapper& mapper
)
:
fixedValuePointPatchField(ptf, p, iF, mapper),
codedBase(ptf)
{}
template
Foam::codedFixedValuePointPatchField::codedFixedValuePointPatchField
(
const codedFixedValuePointPatchField& ptf,
const DimensionedField& iF
)
:
fixedValuePointPatchField(ptf, iF),
codedBase(ptf)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
const Foam::pointPatchField&
Foam::codedFixedValuePointPatchField::redirectPatchField() const
{
if (!redirectPatchFieldPtr_.valid())
{
OStringStream os;
writeEntry(os, "type", codeName());
writeEntry(os, "value", static_cast&>(*this));
IStringStream is(os.str());
dictionary dict(is);
redirectPatchFieldPtr_.set
(
pointPatchField::New
(
this->patch(),
this->internalField(),
dict
).ptr()
);
}
return redirectPatchFieldPtr_();
}
template
void Foam::codedFixedValuePointPatchField::updateCoeffs()
{
if (this->updated())
{
return;
}
const pointPatchField& fvp = redirectPatchField();
const_cast&>(fvp).updateCoeffs();
// Copy through value
this->operator==(fvp);
fixedValuePointPatchField::updateCoeffs();
}
template
void Foam::codedFixedValuePointPatchField::evaluate
(
const Pstream::commsTypes commsType
)
{
const pointPatchField& fvp = redirectPatchField();
const_cast&>(fvp).evaluate(commsType);
fixedValuePointPatchField::evaluate(commsType);
}
template
void Foam::codedFixedValuePointPatchField::write(Ostream& os) const
{
fixedValuePointPatchField::write(os);
codedBase::write(os);
}
// ************************************************************************* //