/*---------------------------------------------------------------------------*\ ========= | \\ / 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 . \*---------------------------------------------------------------------------*/ #include "codedMixedFvPatchField.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template const Foam::wordList Foam::codedMixedFvPatchField::codeKeys ( {"code", "codeInclude", "localCode"} ); template const Foam::wordList Foam::codedMixedFvPatchField::codeDictVars ( {word::null, word::null, word::null} ); template const Foam::word Foam::codedMixedFvPatchField::codeOptions ( "codedMixedFvPatchFieldOptions" ); template const Foam::wordList Foam::codedMixedFvPatchField::compileFiles { "codedMixedFvPatchFieldTemplate.C" }; template const Foam::wordList Foam::codedMixedFvPatchField::copyFiles { "codedMixedFvPatchFieldTemplate.H" }; // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::codedMixedFvPatchField::codedMixedFvPatchField ( const fvPatch& p, const DimensionedField& iF, const dictionary& dict ) : mixedFvPatchField(p, iF, dict), codedBase ( dict.lookupOrDefault ( "name", word ( ( iF.mesh().name() == polyMesh::defaultRegion ? word::null : word(iF.mesh().name() + '_') ), iF.name(), '_', p.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 fvPatchField updateLibrary(dict); } template Foam::codedMixedFvPatchField::codedMixedFvPatchField ( const codedMixedFvPatchField& ptf, const fvPatch& p, const DimensionedField& iF, const fieldMapper& mapper ) : mixedFvPatchField(ptf, p, iF, mapper), codedBase(ptf) {} template Foam::codedMixedFvPatchField::codedMixedFvPatchField ( const codedMixedFvPatchField& ptf, const DimensionedField& iF ) : mixedFvPatchField(ptf, iF), codedBase(ptf) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template const Foam::mixedFvPatchField& Foam::codedMixedFvPatchField::redirectPatchField() const { if (!redirectPatchFieldPtr_.valid()) { OStringStream os; mixedFvPatchField::write(os); IStringStream is(os.str()); dictionary dict(is); // Override the type to enforce the fvPatchField::New constructor // to choose our type dict.set("type", codeName()); redirectPatchFieldPtr_.set ( dynamic_cast*> ( fvPatchField::New ( patch(), internalField(), dict ).ptr() ) ); } return redirectPatchFieldPtr_(); } template void Foam::codedMixedFvPatchField::updateCoeffs() { if (this->updated()) { return; } const mixedFvPatchField& fvp = redirectPatchField(); const_cast&>(fvp).updateCoeffs(); // Copy through coefficients this->refValue() = fvp.refValue(); this->refGrad() = fvp.refGrad(); this->valueFraction() = fvp.valueFraction(); mixedFvPatchField::updateCoeffs(); } template void Foam::codedMixedFvPatchField::evaluate ( const Pstream::commsTypes commsType ) { const mixedFvPatchField& fvp = redirectPatchField(); // - updates the value of fvp (though not used) // - resets the updated() flag const_cast&>(fvp).evaluate(commsType); // Update the value (using the coefficients) locally mixedFvPatchField::evaluate(commsType); } template void Foam::codedMixedFvPatchField::write(Ostream& os) const { mixedFvPatchField::write(os); codedBase::write(os); } // ************************************************************************* //