/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2021 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 "fixedJumpFvPatchField.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::fixedJumpFvPatchField::fixedJumpFvPatchField ( const fvPatch& p, const DimensionedField& iF ) : jumpCyclicFvPatchField(p, iF), jump_(this->size(), Zero), jump0_(this->size(), Zero), minJump_(pTraits::min), relaxFactor_(-1), timeIndex_(-1) {} template Foam::fixedJumpFvPatchField::fixedJumpFvPatchField ( const fixedJumpFvPatchField& ptf, const fvPatch& p, const DimensionedField& iF, const fvPatchFieldMapper& mapper ) : jumpCyclicFvPatchField(ptf, p, iF, mapper), jump_(ptf.jump_, mapper), jump0_(ptf.jump0_, mapper), minJump_(ptf.minJump_), relaxFactor_(ptf.relaxFactor_), timeIndex_(ptf.timeIndex_) {} template Foam::fixedJumpFvPatchField::fixedJumpFvPatchField ( const fvPatch& p, const DimensionedField& iF, const dictionary& dict, const bool needValue ) : jumpCyclicFvPatchField(p, iF, dict, false), // needValue = false jump_(p.size(), Zero), jump0_(p.size(), Zero), minJump_(dict.getOrDefault("minJump", pTraits::min)), relaxFactor_(dict.getOrDefault("relax", -1)), timeIndex_(this->db().time().timeIndex()) { if (this->cyclicPatch().owner()) { if (needValue) { jump_.assign("jump", dict, p.size(), IOobjectOption::MUST_READ); } jump0_.assign("jump0", dict, p.size(), IOobjectOption::LAZY_READ); } if (needValue) { if (!this->readValueEntry(dict)) { this->evaluate(Pstream::commsTypes::buffered); } } } template Foam::fixedJumpFvPatchField::fixedJumpFvPatchField ( const fixedJumpFvPatchField& ptf ) : jumpCyclicFvPatchField(ptf), jump_(ptf.jump_), jump0_(ptf.jump0_), minJump_(ptf.minJump_), relaxFactor_(ptf.relaxFactor_), timeIndex_(ptf.timeIndex_) {} template Foam::fixedJumpFvPatchField::fixedJumpFvPatchField ( const fixedJumpFvPatchField& ptf, const DimensionedField& iF ) : jumpCyclicFvPatchField(ptf, iF), jump_(ptf.jump_), jump0_(ptf.jump0_), minJump_(ptf.minJump_), relaxFactor_(ptf.relaxFactor_), timeIndex_(ptf.timeIndex_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::fixedJumpFvPatchField::setJump(const Field& jump) { if (this->cyclicPatch().owner()) { jump_ = max(jump, minJump_); } } template void Foam::fixedJumpFvPatchField::setJump(const Type& jump) { if (this->cyclicPatch().owner()) { jump_ = max(jump, minJump_); } } template Foam::tmp> Foam::fixedJumpFvPatchField::jump() const { if (this->cyclicPatch().owner()) { return jump_; } else { return refCast> ( this->neighbourPatchField() ).jump(); } } template Foam::tmp> Foam::fixedJumpFvPatchField::jump0() const { if (this->cyclicPatch().owner()) { return jump0_; } else { return refCast> ( this->neighbourPatchField() ).jump0(); } } template Foam::scalar Foam::fixedJumpFvPatchField::relaxFactor() const { return relaxFactor_; } template void Foam::fixedJumpFvPatchField::relax() { if (!this->cyclicPatch().owner() || relaxFactor_ < 0) { return; } jump_ = lerp(jump0_, jump_, relaxFactor_); if (timeIndex_ != this->db().time().timeIndex()) { jump0_ = jump_; timeIndex_ = this->db().time().timeIndex(); } } template void Foam::fixedJumpFvPatchField::autoMap ( const fvPatchFieldMapper& m ) { jumpCyclicFvPatchField::autoMap(m); jump_.autoMap(m); jump0_.autoMap(m); } template void Foam::fixedJumpFvPatchField::rmap ( const fvPatchField& ptf, const labelList& addr ) { jumpCyclicFvPatchField::rmap(ptf, addr); const auto& fjptf = refCast>(ptf); jump_.rmap(fjptf.jump_, addr); jump0_.rmap(fjptf.jump0_, addr); } template void Foam::fixedJumpFvPatchField::write(Ostream& os) const { fvPatchField::write(os); // Write patchType if not done already by fvPatchField if (this->patchType().empty()) { os.writeEntry("patchType", this->interfaceFieldType()); } if (this->cyclicPatch().owner()) { jump_.writeEntry("jump", os); if (relaxFactor_ > 0) { os.writeEntry("relax", relaxFactor_); jump0_.writeEntry("jump0", os); } } if (minJump_ != pTraits::min) { os.writeEntry("minJump", minJump_); } fvPatchField::writeValueEntry(os); } // ************************************************************************* //