diff --git a/src/dynamicFvMesh/Make/files b/src/dynamicFvMesh/Make/files index 42105a9a60..0403ea42ed 100644 --- a/src/dynamicFvMesh/Make/files +++ b/src/dynamicFvMesh/Make/files @@ -18,5 +18,6 @@ $(solidBodyMotionFunctions)/axisRotationMotion/axisRotationMotion.C $(solidBodyMotionFunctions)/multiMotion/multiMotion.C $(solidBodyMotionFunctions)/oscillatingLinearMotion/oscillatingLinearMotion.C $(solidBodyMotionFunctions)/oscillatingRotatingMotion/oscillatingRotatingMotion.C +solidBodyMotionFvMesh/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.C LIB = $(FOAM_LIBBIN)/libdynamicFvMesh diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.C b/src/dynamicFvMesh/solidBodyMotionFvMesh/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.C new file mode 100644 index 0000000000..f925d3a20b --- /dev/null +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.C @@ -0,0 +1,197 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 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 "solidBodyMotionDisplacementPointPatchVectorField.H" +#include "transformField.H" +#include "addToRunTimeSelectionTable.H" +#include "pointPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // + +solidBodyMotionDisplacementPointPatchVectorField:: +solidBodyMotionDisplacementPointPatchVectorField +( + const pointPatch& p, + const DimensionedField& iF +) +: + fixedValuePointPatchVectorField(p, iF), + SBMFPtr_() +{} + + +solidBodyMotionDisplacementPointPatchVectorField:: +solidBodyMotionDisplacementPointPatchVectorField +( + const pointPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValuePointPatchVectorField(p, iF, dict, false), + SBMFPtr_(solidBodyMotionFunction::New(dict, this->db().time())) +{ + if (!dict.found("value")) + { + // Determine current local points and offset + fixedValuePointPatchVectorField::operator== + ( + transform(SBMFPtr_().transformation(), localPoints0()) + -localPoints0() + ); + } +} + + +solidBodyMotionDisplacementPointPatchVectorField:: +solidBodyMotionDisplacementPointPatchVectorField +( + const solidBodyMotionDisplacementPointPatchVectorField& ptf, + const pointPatch& p, + const DimensionedField& iF, + const pointPatchFieldMapper& mapper +) +: + fixedValuePointPatchVectorField(ptf, p, iF, mapper), + SBMFPtr_(ptf.SBMFPtr_().clone().ptr()) +{ + // For safety re-evaluate + + fixedValuePointPatchVectorField::operator== + ( + transform(SBMFPtr_().transformation(), localPoints0()) + -localPoints0() + ); +} + + +solidBodyMotionDisplacementPointPatchVectorField:: +solidBodyMotionDisplacementPointPatchVectorField +( + const solidBodyMotionDisplacementPointPatchVectorField& ptf +) +: + fixedValuePointPatchVectorField(ptf), + SBMFPtr_(ptf.SBMFPtr_().clone().ptr()) +{} + + +solidBodyMotionDisplacementPointPatchVectorField:: +solidBodyMotionDisplacementPointPatchVectorField +( + const solidBodyMotionDisplacementPointPatchVectorField& ptf, + const DimensionedField& iF +) +: + fixedValuePointPatchVectorField(ptf, iF), + SBMFPtr_(ptf.SBMFPtr_().clone().ptr()) +{ + // For safety re-evaluate + + fixedValuePointPatchVectorField::operator== + ( + transform(SBMFPtr_().transformation(), localPoints0()) + -localPoints0() + ); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +const pointField& +solidBodyMotionDisplacementPointPatchVectorField::localPoints0() const +{ + if (!localPoints0Ptr_.valid()) + { + pointIOField points0 + ( + IOobject + ( + "points", + this->db().time().constant(), + polyMesh::meshSubDir, + this->db(), + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + + localPoints0Ptr_.reset(new pointField(points0, patch().meshPoints())); + } + return localPoints0Ptr_(); +} + + +void solidBodyMotionDisplacementPointPatchVectorField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + // Determine current local points and offset + fixedValuePointPatchVectorField::operator== + ( + transform(SBMFPtr_().transformation(), localPoints0()) + -localPoints0() + ); + + fixedValuePointPatchVectorField::updateCoeffs(); +} + + +void solidBodyMotionDisplacementPointPatchVectorField:: +write(Ostream& os) const +{ + // Note: write value + fixedValuePointPatchVectorField::write(os); + + os.writeKeyword(solidBodyMotionFunction::typeName) << SBMFPtr_->type() + << token::END_STATEMENT << nl; + os << indent << word(SBMFPtr_->type() + "Coeffs"); + SBMFPtr_->writeData(os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePointPatchTypeField +( + pointPatchVectorField, + solidBodyMotionDisplacementPointPatchVectorField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.H b/src/dynamicFvMesh/solidBodyMotionFvMesh/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.H new file mode 100644 index 0000000000..c8319cd95f --- /dev/null +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.H @@ -0,0 +1,169 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 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::solidBodyMotionDisplacementPointPatchVectorField + +Description + Enables the specification of a fixed value boundary condition using the + solid body motion functions. + +SourceFiles + solidBodyMotionDisplacementPointPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef solidBodyMotionDisplacementPointPatchVectorField_H +#define solidBodyMotionDisplacementPointPatchVectorField_H + +#include "solidBodyMotionFunction.H" +#include "fixedValuePointPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class solidBodyMotionDisplacementPointPatchVectorField Declaration +\*---------------------------------------------------------------------------*/ + +class solidBodyMotionDisplacementPointPatchVectorField +: + public fixedValuePointPatchVectorField +{ + // Private data + + //- The motion control function + autoPtr SBMFPtr_; + + mutable autoPtr localPoints0Ptr_; + + +public: + + //- Runtime type information + TypeName("solidBodyMotionDisplacement"); + + + // Constructors + + //- Construct from patch and internal field + solidBodyMotionDisplacementPointPatchVectorField + ( + const pointPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + solidBodyMotionDisplacementPointPatchVectorField + ( + const pointPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given patchField onto a new patch + solidBodyMotionDisplacementPointPatchVectorField + ( + const solidBodyMotionDisplacementPointPatchVectorField&, + const pointPatch&, + const DimensionedField&, + const pointPatchFieldMapper& + ); + + //- Construct as copy + solidBodyMotionDisplacementPointPatchVectorField + ( + const solidBodyMotionDisplacementPointPatchVectorField& + ); + + //- Construct and return a clone + virtual autoPtr > clone() const + { + return autoPtr > + ( + new solidBodyMotionDisplacementPointPatchVectorField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + solidBodyMotionDisplacementPointPatchVectorField + ( + const solidBodyMotionDisplacementPointPatchVectorField&, + const DimensionedField& + ); + + + //- Construct and return a clone setting internal field reference + virtual autoPtr > clone + ( + const DimensionedField& iF + ) const + { + return autoPtr > + ( + new solidBodyMotionDisplacementPointPatchVectorField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Access + + //- Return the fluctuation scale + const solidBodyMotionFunction& motion() const + { + return SBMFPtr_(); + } + + const pointField& localPoints0() const; + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/SDA/SDA.H b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/SDA/SDA.H index f24afc9dc6..67bef0f9ed 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/SDA/SDA.H +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/SDA/SDA.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -118,6 +118,19 @@ public: const Time& runTime ); + //- Construct and return a clone + virtual autoPtr clone() const + { + return autoPtr + ( + new SDA + ( + SBMFCoeffs_, + time_ + ) + ); + } + //- Destructor virtual ~SDA(); diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/axisRotationMotion/axisRotationMotion.H b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/axisRotationMotion/axisRotationMotion.H index bc6b679365..9f78e72d1b 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/axisRotationMotion/axisRotationMotion.H +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/axisRotationMotion/axisRotationMotion.H @@ -88,6 +88,19 @@ public: const Time& runTime ); + //- Construct and return a clone + virtual autoPtr clone() const + { + return autoPtr + ( + new axisRotationMotion + ( + SBMFCoeffs_, + time_ + ) + ); + } + //- Destructor virtual ~axisRotationMotion(); diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/linearMotion/linearMotion.H b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/linearMotion/linearMotion.H index cd79131d77..036ed957b6 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/linearMotion/linearMotion.H +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/linearMotion/linearMotion.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -84,6 +84,19 @@ public: const Time& runTime ); + //- Construct and return a clone + virtual autoPtr clone() const + { + return autoPtr + ( + new linearMotion + ( + SBMFCoeffs_, + time_ + ) + ); + } + //- Destructor virtual ~linearMotion(); diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/multiMotion/multiMotion.H b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/multiMotion/multiMotion.H index 9bbf045efa..93eb8dd8e5 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/multiMotion/multiMotion.H +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/multiMotion/multiMotion.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -84,6 +84,19 @@ public: const Time& runTime ); + //- Construct and return a clone + virtual autoPtr clone() const + { + return autoPtr + ( + new multiMotion + ( + SBMFCoeffs_, + time_ + ) + ); + } + //- Destructor virtual ~multiMotion(); diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingLinearMotion/oscillatingLinearMotion.H b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingLinearMotion/oscillatingLinearMotion.H index a3251b80c9..d080f486ef 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingLinearMotion/oscillatingLinearMotion.H +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingLinearMotion/oscillatingLinearMotion.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -87,6 +87,19 @@ public: const Time& runTime ); + //- Construct and return a clone + virtual autoPtr clone() const + { + return autoPtr + ( + new oscillatingLinearMotion + ( + SBMFCoeffs_, + time_ + ) + ); + } + //- Destructor virtual ~oscillatingLinearMotion(); diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingRotatingMotion/oscillatingRotatingMotion.H b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingRotatingMotion/oscillatingRotatingMotion.H index cbe10a95ec..60692b98f2 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingRotatingMotion/oscillatingRotatingMotion.H +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingRotatingMotion/oscillatingRotatingMotion.H @@ -90,6 +90,19 @@ public: const Time& runTime ); + //- Construct and return a clone + virtual autoPtr clone() const + { + return autoPtr + ( + new oscillatingRotatingMotion + ( + SBMFCoeffs_, + time_ + ) + ); + } + //- Destructor virtual ~oscillatingRotatingMotion(); diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.H b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.H index 87ec08746f..169d5d17aa 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.H +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.H @@ -95,6 +95,19 @@ public: const Time& runTime ); + //- Construct and return a clone + virtual autoPtr clone() const + { + return autoPtr + ( + new rotatingMotion + ( + SBMFCoeffs_, + time_ + ) + ); + } + //- Destructor virtual ~rotatingMotion(); diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunction.C b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunction.C index 10a3bb0799..214ac972a1 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunction.C +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunction.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -70,4 +70,10 @@ bool Foam::solidBodyMotionFunction::read(const dictionary& SBMFCoeffs) } +void Foam::solidBodyMotionFunction::writeData(Ostream& os) const +{ + os << SBMFCoeffs_; +} + + // ************************************************************************* // diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunction.H b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunction.H index 77a8920a22..075e746297 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunction.H +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunction.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -106,6 +106,9 @@ public: const Time& runTime ); + //- Construct and return a clone + virtual autoPtr clone() const = 0; + // Selectors @@ -128,6 +131,9 @@ public: //- Update properties from given dictionary virtual bool read(const dictionary& SBMFCoeffs) = 0; + + //- Write in dictionary format + virtual void writeData(Ostream&) const; }; diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/tabulated6DoFMotion/tabulated6DoFMotion.H b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/tabulated6DoFMotion/tabulated6DoFMotion.H index 763d7105cf..0a5bfc736f 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/tabulated6DoFMotion/tabulated6DoFMotion.H +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/tabulated6DoFMotion/tabulated6DoFMotion.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -100,6 +100,19 @@ public: const Time& runTime ); + //- Construct and return a clone + virtual autoPtr clone() const + { + return autoPtr + ( + new tabulated6DoFMotion + ( + SBMFCoeffs_, + time_ + ) + ); + } + //- Destructor virtual ~tabulated6DoFMotion();