diff --git a/src/fieldSources/derived/MRFSource/MRFSource.C b/src/fieldSources/derived/MRFSource/MRFSource.C new file mode 100644 index 0000000000..3b0582a232 --- /dev/null +++ b/src/fieldSources/derived/MRFSource/MRFSource.C @@ -0,0 +1,176 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*----------------------------------------------------------------------------*/ + +#include "MRFSource.H" +#include "fvMesh.H" +#include "fvMatrices.H" +#include "MRFZone.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(MRFSource, 0); + addToRunTimeSelectionTable + ( + basicSource, + MRFSource, + dictionary + ); +} + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +void Foam::MRFSource::initialise() +{ + if (selectionMode_ != smCellZone) + { + FatalErrorIn("void Foam::MRFSource::initialise()") + << "The porosity region must be specified as a cellZone. Current " + << "selection mode is " << selectionModeTypeNames_[selectionMode_] + << exit(FatalError); + } + + mrfPtr_.reset + ( + new MRFZone + ( + name_, + mesh_, + coeffs_, + cellSetName_ + ) + ); + + const volVectorField& U = mesh_.lookupObject(UName_); + + mrfPtr_->correctBoundaryVelocity(const_cast(U)); + + fieldNames_.setSize(1, UName_); + applied_.setSize(1, false); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::MRFSource::MRFSource +( + const word& name, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh +) +: + basicSource(name, modelType, dict, mesh), + mrfPtr_(NULL), + UName_(coeffs_.lookupOrDefault("UName", "U")), + rhoName_(coeffs_.lookupOrDefault("rhoName", "rho")) +{ + initialise(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::MRFSource::addSup +( + fvMatrix& eqn, + const label fieldI +) +{ + if (eqn.dimensions() == dimForce) + { + const volScalarField& rho = + mesh_.lookupObject(rhoName_); + + // use 'true' flag to add to rhs of equation + mrfPtr_->addCoriolis(rho, eqn, true); + } + else + { + // use 'true' flag to add to rhs of equation + mrfPtr_->addCoriolis(eqn, true); + } +} + + +void Foam::MRFSource::relativeFlux(surfaceScalarField& phi) const +{ + mrfPtr_->relativeFlux(phi); +} + + +void Foam::MRFSource::relativeFlux +( + const surfaceScalarField& rho, + surfaceScalarField& phi +) const +{ + mrfPtr_->relativeFlux(rho, phi); +} + + +void Foam::MRFSource::absoluteFlux(surfaceScalarField& phi) const +{ + mrfPtr_->absoluteFlux(phi); +} + + +void Foam::MRFSource::absoluteFlux +( + const surfaceScalarField& rho, + surfaceScalarField& phi +) const +{ + mrfPtr_->absoluteFlux(rho, phi); +} + + +void Foam::MRFSource::writeData(Ostream& os) const +{ + os << indent << name_ << endl; + dict_.write(os); +} + + +bool Foam::MRFSource::read(const dictionary& dict) +{ + if (basicSource::read(dict)) + { + coeffs_.readIfPresent("UName", UName_); + coeffs_.readIfPresent("rhoName", rhoName_); + + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/fieldSources/derived/MRFSource/MRFSource.H b/src/fieldSources/derived/MRFSource/MRFSource.H new file mode 100644 index 0000000000..1742ac3011 --- /dev/null +++ b/src/fieldSources/derived/MRFSource/MRFSource.H @@ -0,0 +1,173 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::MRFSource + +Description + Multiple Reference Frame (MRF) source + + Example usage: + + MRFSourceCoeffs + { + origin (0 0 0); + axis (0 0 1); + omega 104.72; + } + +SourceFiles + MRFSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef MRFSource_H +#define MRFSource_H + +#include "basicSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class MRFZone; + +/*---------------------------------------------------------------------------*\ + Class MRFSource Declaration +\*---------------------------------------------------------------------------*/ + +class MRFSource +: + public basicSource +{ + +protected: + + // Protected data + + //- Run-time selectable porosity model + autoPtr mrfPtr_; + + //- Velocity field name, default = U + word UName_; + + //- Density field name, default = rho + word rhoName_; + + + // Protected Member Functions + + //- Initialise + void initialise(); + + +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + MRFSource(const MRFSource&); + + //- Disallow default bitwise assignment + void operator=(const MRFSource&); + + +public: + + //- Runtime type information + TypeName("MRFSource"); + + + // Constructors + + //- Construct from components + MRFSource + ( + const word& name, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh + ); + + + //- Destructor + virtual ~MRFSource() + {} + + + // Member Functions + + // Add explicit and implicit contributions + + //- Vector + virtual void addSup + ( + fvMatrix& eqn, + const label fieldI + ); + + + // Flux manipulations + + //- Make the given absolute flux relative + virtual void relativeFlux(surfaceScalarField& phi) const; + + //- Make the given absolute mass-flux relative + virtual void relativeFlux + ( + const surfaceScalarField& rho, + surfaceScalarField& phi + ) const; + + //- Make the given relative flux absolute + virtual void absoluteFlux(surfaceScalarField& phi) const; + + //- Make the given relative mass-flux absolute + virtual void absoluteFlux + ( + const surfaceScalarField& rho, + surfaceScalarField& phi + ) const; + + + // I-O + + //- Write data + virtual void writeData(Ostream&) const; + + //- Read dictionary + virtual bool read(const dictionary& dict); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //