diff --git a/src/fvMotionSolver/Make/files b/src/fvMotionSolver/Make/files index 87e8e39c25..bea2f10656 100644 --- a/src/fvMotionSolver/Make/files +++ b/src/fvMotionSolver/Make/files @@ -33,5 +33,6 @@ pointPatchFields/derived/oscillatingDisplacement/oscillatingDisplacementPointPat pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C +pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.C LIB = $(FOAM_LIBBIN)/libfvMotionSolvers diff --git a/src/fvMotionSolver/pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.C new file mode 100644 index 0000000000..f7d7e8b147 --- /dev/null +++ b/src/fvMotionSolver/pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.C @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +\*---------------------------------------------------------------------------*/ + +#include "waveDisplacementPointPatchVectorField.H" +#include "pointPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "Time.H" +#include "polyMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +waveDisplacementPointPatchVectorField:: +waveDisplacementPointPatchVectorField +( + const pointPatch& p, + const DimensionedField& iF +) +: + fixedValuePointPatchField(p, iF), + amplitude_(vector::zero), + omega_(0.0), + waveLength_(vector::zero) +{} + + +waveDisplacementPointPatchVectorField:: +waveDisplacementPointPatchVectorField +( + const pointPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValuePointPatchField(p, iF, dict), + amplitude_(dict.lookup("amplitude")), + omega_(readScalar(dict.lookup("omega"))), + waveLength_(dict.lookupOrDefault("waveLength", vector::zero)) +{ + if (!dict.found("value")) + { + updateCoeffs(); + } +} + + +waveDisplacementPointPatchVectorField:: +waveDisplacementPointPatchVectorField +( + const waveDisplacementPointPatchVectorField& ptf, + const pointPatch& p, + const DimensionedField& iF, + const pointPatchFieldMapper& mapper +) +: + fixedValuePointPatchField(ptf, p, iF, mapper), + amplitude_(ptf.amplitude_), + omega_(ptf.omega_), + waveLength_(ptf.waveLength_) +{} + + +waveDisplacementPointPatchVectorField:: +waveDisplacementPointPatchVectorField +( + const waveDisplacementPointPatchVectorField& ptf, + const DimensionedField& iF +) +: + fixedValuePointPatchField(ptf, iF), + amplitude_(ptf.amplitude_), + omega_(ptf.omega_), + waveLength_(ptf.waveLength_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void waveDisplacementPointPatchVectorField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + const polyMesh& mesh = this->dimensionedInternalField().mesh()(); + const Time& t = mesh.time(); + + const scalarField points( waveLength_ & patch().localPoints()); + + Field::operator= + ( + amplitude_*cos(omega_*t.value() - points) + ); + + fixedValuePointPatchField::updateCoeffs(); +} + + +void waveDisplacementPointPatchVectorField::write(Ostream& os) const +{ + pointPatchField::write(os); + os.writeKeyword("amplitude") + << amplitude_ << token::END_STATEMENT << nl; + os.writeKeyword("omega") + << omega_ << token::END_STATEMENT << nl; + os.writeKeyword("waveLength") + << waveLength_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePointPatchTypeField +( + pointPatchVectorField, + waveDisplacementPointPatchVectorField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/fvMotionSolver/pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.H b/src/fvMotionSolver/pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.H new file mode 100644 index 0000000000..e1edc3fefa --- /dev/null +++ b/src/fvMotionSolver/pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.H @@ -0,0 +1,149 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +Class + Foam::waveDisplacementPointPatchVectorField + +Description + Foam::waveDisplacementPointPatchVectorField + +SourceFiles + waveDisplacementPointPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef waveDisplacementPointPatchVectorField_H +#define waveDisplacementPointPatchVectorField_H + +#include "fixedValuePointPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class waveDisplacementPointPatchVectorField Declaration +\*---------------------------------------------------------------------------*/ + +class waveDisplacementPointPatchVectorField +: + public fixedValuePointPatchField +{ + // Private data + + vector amplitude_; + scalar omega_; + vector waveLength_; + + +public: + + //- Runtime type information + TypeName("waveDisplacement"); + + + // Constructors + + //- Construct from patch and internal field + waveDisplacementPointPatchVectorField + ( + const pointPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + waveDisplacementPointPatchVectorField + ( + const pointPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given patchField onto a new patch + waveDisplacementPointPatchVectorField + ( + const waveDisplacementPointPatchVectorField&, + const pointPatch&, + const DimensionedField&, + const pointPatchFieldMapper& + ); + + //- Construct and return a clone + virtual autoPtr > clone() const + { + return autoPtr > + ( + new waveDisplacementPointPatchVectorField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + waveDisplacementPointPatchVectorField + ( + const waveDisplacementPointPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual autoPtr > clone + ( + const DimensionedField& iF + ) const + { + return autoPtr > + ( + new waveDisplacementPointPatchVectorField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //