From ab3081aa6bb9cfd813e4fbd0f398d0b13f22b515 Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Tue, 9 Feb 2016 18:45:13 +0000 Subject: [PATCH] noSlip: New wall boundary condition for velocity noSlip is equivalent to fixedValue with a value of (0 0 0) but is simpler to specify e.g. upperWall { type noSlip; } --- src/finiteVolume/Make/files | 1 + .../basic/fixedValue/fixedValueFvPatchField.C | 12 ++ .../basic/fixedValue/fixedValueFvPatchField.H | 8 + .../derived/noSlip/noSlipFvPatchVectorField.C | 102 ++++++++++++ .../derived/noSlip/noSlipFvPatchVectorField.H | 153 ++++++++++++++++++ .../fvPatchFields/fvPatchField/fvPatchField.C | 53 +++--- .../fvPatchFields/fvPatchField/fvPatchField.H | 8 + .../incompressible/simpleFoam/pitzDaily/0/U | 6 +- 8 files changed, 321 insertions(+), 22 deletions(-) create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.C create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.H diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 92e61cecc0..4506679f7b 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -156,6 +156,7 @@ $(derivedFvPatchFields)/mappedFixedPushedInternalValue/mappedFixedPushedInternal $(derivedFvPatchFields)/mappedFixedValue/mappedFixedValueFvPatchFields.C $(derivedFvPatchFields)/mappedFlowRate/mappedFlowRateFvPatchVectorField.C $(derivedFvPatchFields)/mappedVelocityFluxFixedValue/mappedVelocityFluxFixedValueFvPatchField.C +$(derivedFvPatchFields)/noSlip/noSlipFvPatchVectorField.C $(derivedFvPatchFields)/movingWallVelocity/movingWallVelocityFvPatchVectorField.C $(derivedFvPatchFields)/outletInlet/outletInletFvPatchFields.C $(derivedFvPatchFields)/outletMappedUniformInlet/outletMappedUniformInletFvPatchFields.C diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C index 3c09e36a1d..445bed4f7e 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C @@ -38,6 +38,18 @@ Foam::fixedValueFvPatchField<Type>::fixedValueFvPatchField {} +template<class Type> +Foam::fixedValueFvPatchField<Type>::fixedValueFvPatchField +( + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const Type& value +) +: + fvPatchField<Type>(p, iF, value) +{} + + template<class Type> Foam::fixedValueFvPatchField<Type>::fixedValueFvPatchField ( diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H index 105a1afddc..be4e368ca4 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H @@ -87,6 +87,14 @@ public: const DimensionedField<Type, volMesh>& ); + //- Construct from patch, internal field and value + fixedValueFvPatchField + ( + const fvPatch&, + const DimensionedField<Type, volMesh>&, + const Type& value + ); + //- Construct from patch, internal field and dictionary fixedValueFvPatchField ( diff --git a/src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.C new file mode 100644 index 0000000000..da715a6d29 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.C @@ -0,0 +1,102 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "noSlipFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField +( + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF +) +: + fixedValueFvPatchVectorField(p, iF, vector::zero) +{} + + +Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField +( + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF, + const dictionary& dict +) +: + fixedValueFvPatchVectorField(p, iF, vector::zero) +{} + + +Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField +( + const noSlipFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchVectorField(p, iF, vector::zero) +{} + + +Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField +( + const noSlipFvPatchVectorField& mwvpvf +) +: + fixedValueFvPatchVectorField(mwvpvf) +{} + + +Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField +( + const noSlipFvPatchVectorField& mwvpvf, + const DimensionedField<vector, volMesh>& iF +) +: + fixedValueFvPatchVectorField(mwvpvf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::noSlipFvPatchVectorField::write(Ostream& os) const +{ + fvPatchVectorField::write(os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchVectorField, + noSlipFvPatchVectorField + ); +} + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.H new file mode 100644 index 0000000000..a2925e992f --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.H @@ -0,0 +1,153 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 <http://www.gnu.org/licenses/>. + +Class + Foam::noSlipFvPatchVectorField + +Group + grpWallBoundaryConditions + +Description + This boundary condition fixes the velocity to zero at walls. + + \heading Patch usage + + Example of the boundary condition specification: + \verbatim + myPatch + { + type noSlip; + } + \endverbatim + +SeeAlso + Foam::fixedValueFvPatchVectorField + +SourceFiles + noSlipFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef noSlipFvPatchVectorField_H +#define noSlipFvPatchVectorField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class noSlipFvPatchVectorField Declaration +\*---------------------------------------------------------------------------*/ + +class noSlipFvPatchVectorField +: + public fixedValueFvPatchVectorField +{ + +public: + + //- Runtime type information + TypeName("noSlip"); + + + // Constructors + + //- Construct from patch and internal field + noSlipFvPatchVectorField + ( + const fvPatch&, + const DimensionedField<vector, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + noSlipFvPatchVectorField + ( + const fvPatch&, + const DimensionedField<vector, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given noSlipFvPatchVectorField + // onto a new patch + noSlipFvPatchVectorField + ( + const noSlipFvPatchVectorField&, + const fvPatch&, + const DimensionedField<vector, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + noSlipFvPatchVectorField + ( + const noSlipFvPatchVectorField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchVectorField> clone() const + { + return tmp<fvPatchVectorField> + ( + new noSlipFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + noSlipFvPatchVectorField + ( + const noSlipFvPatchVectorField&, + const DimensionedField<vector, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchVectorField> clone + ( + const DimensionedField<vector, volMesh>& iF + ) const + { + return tmp<fvPatchVectorField> + ( + new noSlipFvPatchVectorField(*this, iF) + ); + } + + + // Member functions + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C index e46692d50b..2487e76cc9 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C @@ -52,15 +52,15 @@ Foam::fvPatchField<Type>::fvPatchField ( const fvPatch& p, const DimensionedField<Type, volMesh>& iF, - const word& patchType + const Type& value ) : - Field<Type>(p.size()), + Field<Type>(p.size(), value), patch_(p), internalField_(iF), updated_(false), manipulatedMatrix_(false), - patchType_(patchType) + patchType_(word::null) {} @@ -69,41 +69,33 @@ Foam::fvPatchField<Type>::fvPatchField ( const fvPatch& p, const DimensionedField<Type, volMesh>& iF, - const Field<Type>& f + const word& patchType ) : - Field<Type>(f), + Field<Type>(p.size()), patch_(p), internalField_(iF), updated_(false), manipulatedMatrix_(false), - patchType_(word::null) + patchType_(patchType) {} template<class Type> Foam::fvPatchField<Type>::fvPatchField ( - const fvPatchField<Type>& ptf, const fvPatch& p, const DimensionedField<Type, volMesh>& iF, - const fvPatchFieldMapper& mapper + const Field<Type>& f ) : - Field<Type>(p.size()), + Field<Type>(f), patch_(p), internalField_(iF), updated_(false), manipulatedMatrix_(false), - patchType_(ptf.patchType_) -{ - // For unmapped faces set to internal field value (zero-gradient) - if (notNull(iF) && iF.size()) - { - fvPatchField<Type>::operator=(this->patchInternalField()); - } - this->map(ptf, mapper); -} + patchType_(word::null) +{} template<class Type> @@ -144,6 +136,31 @@ Foam::fvPatchField<Type>::fvPatchField } +template<class Type> +Foam::fvPatchField<Type>::fvPatchField +( + const fvPatchField<Type>& ptf, + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + Field<Type>(p.size()), + patch_(p), + internalField_(iF), + updated_(false), + manipulatedMatrix_(false), + patchType_(ptf.patchType_) +{ + // For unmapped faces set to internal field value (zero-gradient) + if (notNull(iF) && iF.size()) + { + fvPatchField<Type>::operator=(this->patchInternalField()); + } + this->map(ptf, mapper); +} + + template<class Type> Foam::fvPatchField<Type>::fvPatchField ( diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H index c87a5b1ee0..496524c763 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H @@ -166,6 +166,14 @@ public: const DimensionedField<Type, volMesh>& ); + //- Construct from patch, internal field and value + fvPatchField + ( + const fvPatch&, + const DimensionedField<Type, volMesh>&, + const Type& value + ); + //- Construct from patch and internal field and patch type fvPatchField ( diff --git a/tutorials/incompressible/simpleFoam/pitzDaily/0/U b/tutorials/incompressible/simpleFoam/pitzDaily/0/U index 885c5b9de4..9c15c3c575 100644 --- a/tutorials/incompressible/simpleFoam/pitzDaily/0/U +++ b/tutorials/incompressible/simpleFoam/pitzDaily/0/U @@ -33,14 +33,12 @@ boundaryField upperWall { - type fixedValue; - value uniform (0 0 0); + type noSlip; } lowerWall { - type fixedValue; - value uniform (0 0 0); + type noSlip; } frontAndBack -- GitLab