From 076fe3b92922c88c9f5b91aeae0b860f14cf17de Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 11 May 2009 15:15:47 +0100 Subject: [PATCH] New active-baffle BC. --- .../activeBaffleVelocityFvPatchVectorField.C | 248 +++++++++++++++++++++ .../activeBaffleVelocityFvPatchVectorField.H | 178 +++++++++++++++ 2 files changed, 426 insertions(+) create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.H diff --git a/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C new file mode 100644 index 0000000..3e1cf7f --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C @@ -0,0 +1,248 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "activeBaffleVelocityFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::activeBaffleVelocityFvPatchVectorField:: +activeBaffleVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchVectorField(p, iF), + pName_("p"), + cyclicPatchName_(), + cyclicPatchLabel_(-1), + initWallSf_(0), + initCyclicSf_(0), + openFraction_(0), + openFractionDelta_(0), + curTimeIndex_(-1) +{} + + +Foam::activeBaffleVelocityFvPatchVectorField:: +activeBaffleVelocityFvPatchVectorField +( + const activeBaffleVelocityFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchVectorField(ptf, p, iF, mapper), + pName_(ptf.pName_), + cyclicPatchName_(ptf.cyclicPatchName_), + cyclicPatchLabel_(ptf.cyclicPatchLabel_), + initWallSf_(ptf.initWallSf_), + initCyclicSf_(ptf.initCyclicSf_), + openFraction_(ptf.openFraction_), + openFractionDelta_(ptf.openFractionDelta_), + curTimeIndex_(-1) +{} + + +Foam::activeBaffleVelocityFvPatchVectorField:: +activeBaffleVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchVectorField(p, iF), + pName_("p"), + cyclicPatchName_(dict.lookup("cyclicPatch")), + cyclicPatchLabel_(p.patch().boundaryMesh().findPatchID(cyclicPatchName_)), + initWallSf_(p.Sf()), + initCyclicSf_(p.boundaryMesh()[cyclicPatchLabel_].Sf()), + openFraction_(readScalar(dict.lookup("openFraction"))), + openFractionDelta_(readScalar(dict.lookup("openFractionDelta"))), + curTimeIndex_(-1) +{ + fvPatchVectorField::operator=(vector::zero); + + if (dict.found("p")) + { + dict.lookup("p") >> pName_; + } +} + + +Foam::activeBaffleVelocityFvPatchVectorField:: +activeBaffleVelocityFvPatchVectorField +( + const activeBaffleVelocityFvPatchVectorField& ptf +) +: + fixedValueFvPatchVectorField(ptf), + pName_(ptf.pName_), + cyclicPatchName_(ptf.cyclicPatchName_), + cyclicPatchLabel_(ptf.cyclicPatchLabel_), + initWallSf_(ptf.initWallSf_), + initCyclicSf_(ptf.initCyclicSf_), + openFraction_(ptf.openFraction_), + openFractionDelta_(ptf.openFractionDelta_), + curTimeIndex_(-1) +{} + + +Foam::activeBaffleVelocityFvPatchVectorField:: +activeBaffleVelocityFvPatchVectorField +( + const activeBaffleVelocityFvPatchVectorField& ptf, + const DimensionedField& iF +) +: + fixedValueFvPatchVectorField(ptf, iF), + pName_(ptf.pName_), + cyclicPatchName_(ptf.cyclicPatchName_), + cyclicPatchLabel_(ptf.cyclicPatchLabel_), + initWallSf_(ptf.initWallSf_), + initCyclicSf_(ptf.initCyclicSf_), + openFraction_(ptf.openFraction_), + openFractionDelta_(ptf.openFractionDelta_), + curTimeIndex_(-1) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::activeBaffleVelocityFvPatchVectorField::autoMap +( + const fvPatchFieldMapper& m +) +{ + fixedValueFvPatchVectorField::autoMap(m); + initWallSf_.autoMap(m); + initCyclicSf_.autoMap(m); +} + +void Foam::activeBaffleVelocityFvPatchVectorField::rmap +( + const fvPatchVectorField& ptf, + const labelList& addr +) +{ + fixedValueFvPatchVectorField::rmap(ptf, addr); + + const activeBaffleVelocityFvPatchVectorField& tiptf = + refCast(ptf); + + initWallSf_.rmap(tiptf.initWallSf_, addr); + initCyclicSf_.rmap(tiptf.initCyclicSf_, addr); +} + + +void Foam::activeBaffleVelocityFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Execute the change to the openFraction only once per time-step + if (curTimeIndex_ != this->db().time().timeIndex()) + { + const volScalarField& p = db().lookupObject + ( + pName_ + ); + + const fvPatch& cyclicPatch = patch().boundaryMesh()[cyclicPatchLabel_]; + const labelList& cyclicFaceCells = cyclicPatch.patch().faceCells(); + const vectorField& cyclicSf = cyclicPatch.Sf(); + label nCyclicFaces = cyclicFaceCells.size(); + label nCyclicFacesPerSide = nCyclicFaces/2; + + scalar forceDiff = 0; + + for (label facei=0; facei& + ); + + //- Construct from patch, internal field and dictionary + activeBaffleVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given activeBaffleVelocityFvPatchVectorField + // onto a new patch + activeBaffleVelocityFvPatchVectorField + ( + const activeBaffleVelocityFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + activeBaffleVelocityFvPatchVectorField + ( + const activeBaffleVelocityFvPatchVectorField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new activeBaffleVelocityFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + activeBaffleVelocityFvPatchVectorField + ( + const activeBaffleVelocityFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new activeBaffleVelocityFvPatchVectorField(*this, iF) + ); + } + + + // Member functions + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchVectorField&, + const labelList& + ); + + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // -- 2.11.4.GIT