translatingWallVelocityFvPatchVectorField: Changed the translation velocity to a Function1

to support time-variation
This commit is contained in:
Henry Weller
2016-02-10 09:44:55 +00:00
parent 5c6b378382
commit 9beda11f6f
2 changed files with 35 additions and 37 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -26,7 +26,6 @@ License
#include "translatingWallVelocityFvPatchVectorField.H" #include "translatingWallVelocityFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -38,21 +37,7 @@ translatingWallVelocityFvPatchVectorField
) )
: :
fixedValueFvPatchField<vector>(p, iF), fixedValueFvPatchField<vector>(p, iF),
U_(vector::zero) U_(0)
{}
Foam::translatingWallVelocityFvPatchVectorField::
translatingWallVelocityFvPatchVectorField
(
const translatingWallVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
U_(ptf.U_)
{} {}
@ -65,13 +50,27 @@ translatingWallVelocityFvPatchVectorField
) )
: :
fixedValueFvPatchField<vector>(p, iF), fixedValueFvPatchField<vector>(p, iF),
U_(dict.lookup("U")) U_(Function1<vector>::New("U", dict))
{ {
// Evaluate the wall velocity // Evaluate the wall velocity
updateCoeffs(); updateCoeffs();
} }
Foam::translatingWallVelocityFvPatchVectorField::
translatingWallVelocityFvPatchVectorField
(
const translatingWallVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
U_(ptf.U_, false)
{}
Foam::translatingWallVelocityFvPatchVectorField:: Foam::translatingWallVelocityFvPatchVectorField::
translatingWallVelocityFvPatchVectorField translatingWallVelocityFvPatchVectorField
( (
@ -79,7 +78,7 @@ translatingWallVelocityFvPatchVectorField
) )
: :
fixedValueFvPatchField<vector>(twvpvf), fixedValueFvPatchField<vector>(twvpvf),
U_(twvpvf.U_) U_(twvpvf.U_, false)
{} {}
@ -91,7 +90,7 @@ translatingWallVelocityFvPatchVectorField
) )
: :
fixedValueFvPatchField<vector>(twvpvf, iF), fixedValueFvPatchField<vector>(twvpvf, iF),
U_(twvpvf.U_) U_(twvpvf.U_, false)
{} {}
@ -104,9 +103,12 @@ void Foam::translatingWallVelocityFvPatchVectorField::updateCoeffs()
return; return;
} }
const scalar t = this->db().time().timeOutputValue();
const vector U = U_->value(t);
// Remove the component of U normal to the wall in case the wall is not flat // Remove the component of U normal to the wall in case the wall is not flat
const vectorField n(patch().nf()); const vectorField n(patch().nf());
vectorField::operator=(U_ - n*(n & U_)); vectorField::operator=(U - n*(n & U));
fixedValueFvPatchVectorField::updateCoeffs(); fixedValueFvPatchVectorField::updateCoeffs();
} }
@ -115,7 +117,7 @@ void Foam::translatingWallVelocityFvPatchVectorField::updateCoeffs()
void Foam::translatingWallVelocityFvPatchVectorField::write(Ostream& os) const void Foam::translatingWallVelocityFvPatchVectorField::write(Ostream& os) const
{ {
fvPatchVectorField::write(os); fvPatchVectorField::write(os);
os.writeKeyword("U") << U_ << token::END_STATEMENT << nl; U_->writeData(os);
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -47,9 +47,12 @@ Description
} }
\endverbatim \endverbatim
The \c U entry is a Function1 of time, see Foam::Function1Types.
SeeAlso SeeAlso
Foam::fixedValueFvPatchField Foam::fixedValueFvPatchField
Foam::Function1Types
SourceFiles SourceFiles
translatingWallVelocityFvPatchVectorField.C translatingWallVelocityFvPatchVectorField.C
@ -60,6 +63,7 @@ SourceFiles
#define translatingWallVelocityFvPatchVectorField_H #define translatingWallVelocityFvPatchVectorField_H
#include "fixedValueFvPatchFields.H" #include "fixedValueFvPatchFields.H"
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -77,7 +81,7 @@ class translatingWallVelocityFvPatchVectorField
// Private data // Private data
//- Translational velocity //- Translational velocity
vector U_; autoPtr<Function1<vector>> U_;
public: public:
@ -150,14 +154,6 @@ public:
// Member functions // Member functions
// Access functions
//- Return the velocity
const vector& U() const
{
return U_;
}
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
virtual void updateCoeffs(); virtual void updateCoeffs();