From a6b54b07d8512d8d81d47cb51a3b20562217f47e Mon Sep 17 00:00:00 2001 From: sergio <s.ferraris@opencfd.co.uk> Date: Thu, 21 Jul 2011 11:02:41 +0100 Subject: [PATCH] ENH: split of "jump" class and introduction of a porousBaffer BC --- .../derived/fan/fanFvPatchField.C | 56 ++---- .../derived/fan/fanFvPatchField.H | 40 +--- .../derived/fixedJump/fixedJumpFvPatchField.C | 130 +++++++++++++ .../derived/fixedJump/fixedJumpFvPatchField.H | 184 ++++++++++++++++++ src/turbulenceModels/Allwmake | 2 + .../derivedFvPatchFields/Make/files | 3 + .../derivedFvPatchFields/Make/options | 16 ++ .../porousBafflePressureFvPatchField.C | 132 +++++++++++++ .../porousBafflePressureFvPatchField.H | 177 +++++++++++++++++ .../porousBafflePressureFvPatchFieldFwd.H | 50 +++++ .../porousBafflePressureFvPatchFields.C | 119 +++++++++++ .../porousBafflePressureFvPatchFields.H | 50 +++++ 12 files changed, 879 insertions(+), 80 deletions(-) create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.H create mode 100644 src/turbulenceModels/derivedFvPatchFields/Make/files create mode 100644 src/turbulenceModels/derivedFvPatchFields/Make/options create mode 100644 src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C create mode 100644 src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.H create mode 100644 src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H create mode 100644 src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFields.C create mode 100644 src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFields.H diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C index 048e19497f0..6c1e1d309af 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,9 +35,8 @@ Foam::fanFvPatchField<Type>::fanFvPatchField const DimensionedField<Type, volMesh>& iF ) : - jumpCyclicFvPatchField<Type>(p, iF), - f_(0), - jump_(this->size(), 0.0) + fixedJumpFvPatchField<Type>(p, iF), + f_(0) {} @@ -50,9 +49,8 @@ Foam::fanFvPatchField<Type>::fanFvPatchField const fvPatchFieldMapper& mapper ) : - jumpCyclicFvPatchField<Type>(ptf, p, iF, mapper), - f_(ptf.f_), - jump_(ptf.jump_, mapper) + fixedJumpFvPatchField<Type>(ptf, p, iF, mapper), + f_(ptf.f_) {} @@ -64,9 +62,8 @@ Foam::fanFvPatchField<Type>::fanFvPatchField const dictionary& dict ) : - jumpCyclicFvPatchField<Type>(p, iF), - f_(), - jump_(this->size(), 0.0) + fixedJumpFvPatchField<Type>(p, iF), + f_() { { Istream& is = dict.lookup("f"); @@ -97,9 +94,8 @@ Foam::fanFvPatchField<Type>::fanFvPatchField ) : cyclicLduInterfaceField(), - jumpCyclicFvPatchField<Type>(ptf), - f_(ptf.f_), - jump_(ptf.jump_) + fixedJumpFvPatchField<Type>(ptf), + f_(ptf.f_) {} @@ -110,45 +106,19 @@ Foam::fanFvPatchField<Type>::fanFvPatchField const DimensionedField<Type, volMesh>& iF ) : - jumpCyclicFvPatchField<Type>(ptf, iF), - f_(ptf.f_), - jump_(ptf.jump_) + fixedJumpFvPatchField<Type>(ptf, iF), + f_(ptf.f_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<class Type> -void Foam::fanFvPatchField<Type>::autoMap -( - const fvPatchFieldMapper& m -) -{ - jumpCyclicFvPatchField<Type>::autoMap(m); - jump_.autoMap(m); -} - - -template<class Type> -void Foam::fanFvPatchField<Type>::rmap -( - const fvPatchField<Type>& ptf, - const labelList& addr -) -{ - jumpCyclicFvPatchField<Type>::rmap(ptf, addr); - - const fanFvPatchField<Type>& tiptf = - refCast<const fanFvPatchField<Type> >(ptf); - jump_.rmap(tiptf.jump_, addr); -} - template<class Type> void Foam::fanFvPatchField<Type>::write(Ostream& os) const { - fvPatchField<Type>::write(os); - os.writeKeyword("patchType") << "cyclic" << token::END_STATEMENT << nl; + + fixedJumpFvPatchField<Type>::write(os); IOstream::streamFormat fmt0 = os.format(IOstream::ASCII); os.writeKeyword("f") << f_ << token::END_STATEMENT << nl; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H index 9be8b5b6d9c..aec3f75e556 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,7 +35,7 @@ SourceFiles #ifndef fanFvPatchField_H #define fanFvPatchField_H -#include "jumpCyclicFvPatchField.H" +#include "fixedJumpFvPatchField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,16 +49,13 @@ namespace Foam template<class Type> class fanFvPatchField : - public jumpCyclicFvPatchField<Type> + public fixedJumpFvPatchField<Type> { // Private data //- Fan pressure rise polynomial coefficients List<scalar> f_; - //- "jump" field - Field<Type> jump_; - public: @@ -137,37 +134,6 @@ public: return f_; } - //- Return the "jump" across the patch. - virtual tmp<Field<Type> > jump() const - { - if (this->cyclicPatch().owner()) - { - return jump_; - } - else - { - return refCast<const fanFvPatchField<Type> > - ( - this->neighbourPatchField() - ).jump(); - } - } - - - // 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 fvPatchField<Type>&, - const labelList& - ); // Evaluation functions diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C new file mode 100644 index 00000000000..59d8bdfb941 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C @@ -0,0 +1,130 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 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 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "fixedJumpFvPatchField.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type> +Foam::fixedJumpFvPatchField<Type>::fixedJumpFvPatchField +( + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF +) +: + jumpCyclicFvPatchField<Type>(p, iF), + jump_(this->size(), pTraits<Type>::zero) +{} + + +template<class Type> +Foam::fixedJumpFvPatchField<Type>::fixedJumpFvPatchField +( + const fixedJumpFvPatchField<Type>& ptf, + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + jumpCyclicFvPatchField<Type>(ptf, p, iF, mapper), + jump_(ptf.jump_, mapper) +{} + + +template<class Type> +Foam::fixedJumpFvPatchField<Type>::fixedJumpFvPatchField +( + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const dictionary& dict +) +: + jumpCyclicFvPatchField<Type>(p, iF), + jump_("jump", dict, p.size()) +{} + + +template<class Type> +Foam::fixedJumpFvPatchField<Type>::fixedJumpFvPatchField +( + const fixedJumpFvPatchField<Type>& ptf +) +: + cyclicLduInterfaceField(), + jumpCyclicFvPatchField<Type>(ptf), + jump_(ptf.jump_) +{} + + +template<class Type> +Foam::fixedJumpFvPatchField<Type>::fixedJumpFvPatchField +( + const fixedJumpFvPatchField<Type>& ptf, + const DimensionedField<Type, volMesh>& iF +) +: + jumpCyclicFvPatchField<Type>(ptf, iF), + jump_(ptf.jump_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +void Foam::fixedJumpFvPatchField<Type>::autoMap +( + const fvPatchFieldMapper& m +) +{ + jumpCyclicFvPatchField<Type>::autoMap(m); + jump_.autoMap(m); +} + + +template<class Type> +void Foam::fixedJumpFvPatchField<Type>::rmap +( + const fvPatchField<Type>& ptf, + const labelList& addr +) +{ + jumpCyclicFvPatchField<Type>::rmap(ptf, addr); + + const fixedJumpFvPatchField<Type>& tiptf = + refCast<const fixedJumpFvPatchField<Type> >(ptf); + jump_.rmap(tiptf.jump_, addr); +} + + +template<class Type> +void Foam::fixedJumpFvPatchField<Type>::write(Ostream& os) const +{ + fvPatchField<Type>::write(os); + os.writeKeyword("patchType") << "cyclic" << token::END_STATEMENT << nl; + jump_.writeEntry("jump", os); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.H new file mode 100644 index 00000000000..e192e190b49 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.H @@ -0,0 +1,184 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 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 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 <http://www.gnu.org/licenses/>. + +Class + Foam::fixedJumpFvPatchField + +Description + Base class for "jump" of a field<type> + +SourceFiles + fixedJumpFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedJumpFvPatchField_H +#define fixedJumpFvPatchField_H + +#include "jumpCyclicFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class fixedJumpFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class fixedJumpFvPatchField +: + public jumpCyclicFvPatchField<Type> +{ + +protected: + + // Protected data + + //- "jump" field + Field<Type> jump_; + + +public: + + + // Constructors + + //- Construct from patch and internal field + fixedJumpFvPatchField + ( + const fvPatch&, + const DimensionedField<Type, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + fixedJumpFvPatchField + ( + const fvPatch&, + const DimensionedField<Type, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given fixedJumpFvPatchField onto a + // new patch + fixedJumpFvPatchField + ( + const fixedJumpFvPatchField<Type>&, + const fvPatch&, + const DimensionedField<Type, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + fixedJumpFvPatchField + ( + const fixedJumpFvPatchField<Type>& + ); + + //- Construct and return a clone + virtual tmp<fvPatchField<Type> > clone() const + { + return tmp<fvPatchField<Type> > + ( + new fixedJumpFvPatchField<Type>(*this) + ); + } + + //- Construct as copy setting internal field reference + fixedJumpFvPatchField + ( + const fixedJumpFvPatchField<Type>&, + const DimensionedField<Type, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchField<Type> > clone + ( + const DimensionedField<Type, volMesh>& iF + ) const + { + return tmp<fvPatchField<Type> > + ( + new fixedJumpFvPatchField<Type>(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return the "jump" across the patch. + virtual tmp<Field<Type> > jump() const + { + if (this->cyclicPatch().owner()) + { + return jump_; + } + else + { + return refCast<const fixedJumpFvPatchField<Type> > + ( + this->neighbourPatchField() + ).jump(); + } + } + + + // 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 fvPatchField<Type>&, + const labelList& + ); + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "fixedJumpFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/Allwmake b/src/turbulenceModels/Allwmake index e78f0c30dd5..3cba27ed1c3 100755 --- a/src/turbulenceModels/Allwmake +++ b/src/turbulenceModels/Allwmake @@ -1,9 +1,11 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +makeType=${1:-libso} set -x LES/Allwmake $* incompressible/Allwmake $* compressible/Allwmake $* +wmake $makeType derivedFvPatchFields # ----------------------------------------------------------------- end-of-file diff --git a/src/turbulenceModels/derivedFvPatchFields/Make/files b/src/turbulenceModels/derivedFvPatchFields/Make/files new file mode 100644 index 00000000000..360b593edb9 --- /dev/null +++ b/src/turbulenceModels/derivedFvPatchFields/Make/files @@ -0,0 +1,3 @@ +porousBafflePressure/porousBafflePressureFvPatchFields.C + +LIB = $(FOAM_LIBBIN)/libturbulenceDerivedFvPatchFields diff --git a/src/turbulenceModels/derivedFvPatchFields/Make/options b/src/turbulenceModels/derivedFvPatchFields/Make/options new file mode 100644 index 00000000000..7e9faff242b --- /dev/null +++ b/src/turbulenceModels/derivedFvPatchFields/Make/options @@ -0,0 +1,16 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/turbulenceModels \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel + +LIB_LIBS = \ + -lfiniteVolume \ + -lbasicThermophysicalModels \ + -lspecie \ + -lmeshTools \ + -lcompressibleTurbulenceModel \ + -lincompressibleTurbulenceModel diff --git a/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C b/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C new file mode 100644 index 00000000000..a89154d6066 --- /dev/null +++ b/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C @@ -0,0 +1,132 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 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 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "porousBafflePressureFvPatchField.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type> +Foam::porousBafflePressureFvPatchField<Type>::porousBafflePressureFvPatchField +( + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF +) +: + fixedJumpFvPatchField<Type>(p, iF), + D_(0), + I_(0), + length_(0) +{} + + +template<class Type> +Foam::porousBafflePressureFvPatchField<Type>::porousBafflePressureFvPatchField +( + const porousBafflePressureFvPatchField<Type>& ptf, + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + fixedJumpFvPatchField<Type>(ptf, p, iF, mapper), + D_(ptf.D_), + I_(ptf.I_), + length_(ptf.length_) +{} + + +template<class Type> +Foam::porousBafflePressureFvPatchField<Type>::porousBafflePressureFvPatchField +( + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const dictionary& dict +) +: + fixedJumpFvPatchField<Type>(p, iF), + D_(readScalar(dict.lookup("D"))), + I_(readScalar(dict.lookup("I"))), + length_(readScalar(dict.lookup("length"))) +{ + if (dict.found("value")) + { + fvPatchField<Type>::operator= + ( + Field<Type>("value", dict, p.size()) + ); + } + else + { + this->evaluate(Pstream::blocking); + } +} + + +template<class Type> +Foam::porousBafflePressureFvPatchField<Type>::porousBafflePressureFvPatchField +( + const porousBafflePressureFvPatchField<Type>& ptf +) +: + cyclicLduInterfaceField(), + fixedJumpFvPatchField<Type>(ptf), + D_(ptf.D_), + I_(ptf.I_), + length_(ptf.length_) +{} + + +template<class Type> +Foam::porousBafflePressureFvPatchField<Type>::porousBafflePressureFvPatchField +( + const porousBafflePressureFvPatchField<Type>& ptf, + const DimensionedField<Type, volMesh>& iF +) +: + fixedJumpFvPatchField<Type>(ptf, iF), + D_(ptf.D_), + I_(ptf.I_), + length_(ptf.length_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +template<class Type> +void Foam::porousBafflePressureFvPatchField<Type>::write(Ostream& os) const +{ + + fixedJumpFvPatchField<Type>::write(os); + + os.writeKeyword("D") << D_ << token::END_STATEMENT << nl; + os.writeKeyword("I") << I_ << token::END_STATEMENT << nl; + os.writeKeyword("length") << length_ << token::END_STATEMENT << nl; + + this->writeEntry("value", os); +} + + +// ************************************************************************* // diff --git a/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.H b/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.H new file mode 100644 index 00000000000..a44e9c1ae95 --- /dev/null +++ b/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.H @@ -0,0 +1,177 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 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 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 <http://www.gnu.org/licenses/>. + +Class + Foam::porousBafflePressureFvPatchField + +Description + Foam::porousBafflePressureFvPatchField + the porous baffle operates on a cyclic patch and introduce a jump on the p + field as follow: + + deltaP = -(I*mu*U + 0.5*D*rho*magSqr(U)*L) + + where: + + I is the inertial coefficient + D is the darcy coeafficient + L is the porous media lenght in the flow direction + +SourceFiles + porousBafflePressureFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef porousBafflePressureFvPatchField_H +#define porousBafflePressureFvPatchField_H + +#include "fixedJumpFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class porousBafflePressureFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class porousBafflePressureFvPatchField +: + public fixedJumpFvPatchField<Type> +{ + // Private data + + //- Darcy pressure lost coefficient + scalar D_; + + //- Inertia pressure lost coefficient + scalar I_; + + //- Porous media length + scalar length_; + + +public: + + //- Runtime type information + TypeName("porousBafflePressure"); + + + // Constructors + + //- Construct from patch and internal field + porousBafflePressureFvPatchField + ( + const fvPatch&, + const DimensionedField<Type, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + porousBafflePressureFvPatchField + ( + const fvPatch&, + const DimensionedField<Type, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given porousBafflePressureFvPatchField + // onto a new patch + porousBafflePressureFvPatchField + ( + const porousBafflePressureFvPatchField<Type>&, + const fvPatch&, + const DimensionedField<Type, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + porousBafflePressureFvPatchField + ( + const porousBafflePressureFvPatchField<Type>& + ); + + //- Construct and return a clone + virtual tmp<fvPatchField<Type> > clone() const + { + return tmp<fvPatchField<Type> > + ( + new porousBafflePressureFvPatchField<Type>(*this) + ); + } + + //- Construct as copy setting internal field reference + porousBafflePressureFvPatchField + ( + const porousBafflePressureFvPatchField<Type>&, + const DimensionedField<Type, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchField<Type> > clone + ( + const DimensionedField<Type, volMesh>& iF + ) const + { + return tmp<fvPatchField<Type> > + ( + new porousBafflePressureFvPatchField<Type>(*this, iF) + ); + } + + + // Member functions + + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + //- Write + virtual void write(Ostream&) const; +}; + + +//- Specialisation of the jump-condition for the pressure +template<> +void porousBafflePressureFvPatchField<scalar>::updateCoeffs(); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "porousBafflePressureFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H b/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H new file mode 100644 index 00000000000..57c8c3f1ab8 --- /dev/null +++ b/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 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 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef porousBafflePressureFvPatchFieldsFwd_H +#define porousBafflePressureFvPatchFieldsFwd_H + +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type> class porousBafflePressureFvPatchField; + +makePatchTypeFieldTypedefs(porousBafflePressure); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFields.C b/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFields.C new file mode 100644 index 00000000000..f82551589d0 --- /dev/null +++ b/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFields.C @@ -0,0 +1,119 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 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 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "porousBafflePressureFvPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" +#include "surfaceFields.H" + +#include "compressible/turbulenceModel/turbulenceModel.H" +#include "incompressible/turbulenceModel/turbulenceModel.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makeTemplatePatchTypeField +( + fvPatchScalarField, + porousBafflePressureFvPatchScalarField +); + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +//- Specialisation of the jump-condition for the pressure +template<> +void Foam::porousBafflePressureFvPatchField<Foam::scalar>::updateCoeffs() +{ + if (updated()) + { + return; + } + + const label patchI = patch().index(); + + const surfaceScalarField& phi = + db().lookupObject<surfaceScalarField>("phi"); + + const fvsPatchField<scalar>& phip = + patch().patchField<surfaceScalarField, scalar>(phi); + + scalarField Un(phip/patch().magSf()); + + if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0)) + { + const incompressible::turbulenceModel& model = + db().lookupObject<incompressible::turbulenceModel> + ( + "turbulenceModel" + ); + + const scalarField nuEffw = model.nuEff()().boundaryField()[patchI]; + + jump_ = -(I_*nuEffw*mag(Un) + D_*0.5*magSqr(Un)*length_); + } + else + { + const compressible::turbulenceModel& model = + db().lookupObject<compressible::turbulenceModel> + ( + "turbulenceModel" + ); + + const scalarField muEffw = model.muEff()().boundaryField()[patchI]; + + const scalarField rhow = + patch().lookupPatchField<volScalarField, scalar>("rho"); + + Un /= rhow; + + jump_ = -(I_*muEffw*mag(Un) + D_*0.5*rhow*magSqr(Un)*length_); + } + + if (debug) + { + scalar avePressureJump = gAverage(jump_); + scalar aveVelocity = gAverage(mag(Un)); + + Info<< patch().boundaryMesh().mesh().name() << ':' + << patch().name() << ':' + << " Average pressure drop :" << avePressureJump + << " Average velocity :" << aveVelocity + << endl; + } + + jumpCyclicFvPatchField<scalar>::updateCoeffs(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFields.H b/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFields.H new file mode 100644 index 00000000000..b06bf1f6e48 --- /dev/null +++ b/src/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFields.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 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 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef porousBafflePressureFvPatchFields_H +#define porousBafflePressureFvPatchFields_H + +#include "porousBafflePressureFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +makePatchTypeFieldTypedefs(porousBafflePressure); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // -- GitLab