diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 95f6101f..b68dfdf9 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -157,6 +157,7 @@ $(derivedFvPatchFields)/mappedFlowRate/mappedFlowRateFvPatchVectorField.C $(derivedFvPatchFields)/mappedVelocityFluxFixedValue/mappedVelocityFluxFixedValueFvPatchField.C $(derivedFvPatchFields)/movingWallVelocity/movingWallVelocityFvPatchVectorField.C $(derivedFvPatchFields)/oscillatingFixedValue/oscillatingFixedValueFvPatchFields.C +$(derivedFvPatchFields)/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchFields.C $(derivedFvPatchFields)/outletInlet/outletInletFvPatchFields.C $(derivedFvPatchFields)/outletMappedUniformInlet/outletMappedUniformInletFvPatchFields.C $(derivedFvPatchFields)/partialSlip/partialSlipFvPatchFields.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchField.C new file mode 100644 index 00000000..5a19c438 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchField.C @@ -0,0 +1,214 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-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 "repetitivePulseFixedValueFvPatchField.H" +#include "mathematicalConstants.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +scalar repetitivePulseFixedValueFvPatchField::currentScale() const +{ + const scalar t = this->db().time().timeOutputValue(); + const scalar a = amplitude_->value(t); + const scalar f = frequency_->value(t); + + return 1.0 + a*sin(constant::mathematical::twoPi*f*t); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +repetitivePulseFixedValueFvPatchField::repetitivePulseFixedValueFvPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchField(p, iF), + refValue_(p.size()), + offset_(pTraits::zero), + amplitude_(), + frequency_(), + curTimeIndex_(-1) +{} + + +template +repetitivePulseFixedValueFvPatchField::repetitivePulseFixedValueFvPatchField +( + const repetitivePulseFixedValueFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchField(ptf, p, iF, mapper), + refValue_(ptf.refValue_, mapper), + offset_(ptf.offset_), + amplitude_(ptf.amplitude_().clone().ptr()), + frequency_(ptf.frequency_().clone().ptr()), + curTimeIndex_(-1) +{} + + +template +repetitivePulseFixedValueFvPatchField::repetitivePulseFixedValueFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchField(p, iF), + refValue_("refValue", dict, p.size()), + offset_(dict.lookupOrDefault("offset", pTraits::zero)), + amplitude_(DataEntry::New("amplitude", dict)), + frequency_(DataEntry::New("frequency", dict)), + curTimeIndex_(-1) +{ + if (dict.found("value")) + { + fixedValueFvPatchField::operator== + ( + Field("value", dict, p.size()) + ); + } + else + { + fixedValueFvPatchField::operator== + ( + refValue_*currentScale() + + offset_ + ); + } +} + + +template +repetitivePulseFixedValueFvPatchField::repetitivePulseFixedValueFvPatchField +( + const repetitivePulseFixedValueFvPatchField& ptf +) +: + fixedValueFvPatchField(ptf), + refValue_(ptf.refValue_), + offset_(ptf.offset_), + amplitude_(ptf.amplitude_().clone().ptr()), + frequency_(ptf.frequency_().clone().ptr()), + curTimeIndex_(-1) +{} + + +template +repetitivePulseFixedValueFvPatchField::repetitivePulseFixedValueFvPatchField +( + const repetitivePulseFixedValueFvPatchField& ptf, + const DimensionedField& iF +) +: + fixedValueFvPatchField(ptf, iF), + refValue_(ptf.refValue_), + offset_(ptf.offset_), + amplitude_(ptf.amplitude_().clone().ptr()), + frequency_(ptf.frequency_().clone().ptr()), + curTimeIndex_(-1) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void repetitivePulseFixedValueFvPatchField::autoMap +( + const fvPatchFieldMapper& m +) +{ + fixedValueFvPatchField::autoMap(m); + refValue_.autoMap(m); +} + + +template +void repetitivePulseFixedValueFvPatchField::rmap +( + const fvPatchField& ptf, + const labelList& addr +) +{ + fixedValueFvPatchField::rmap(ptf, addr); + + const repetitivePulseFixedValueFvPatchField& tiptf = + refCast >(ptf); + + refValue_.rmap(tiptf.refValue_, addr); +} + + +template +void repetitivePulseFixedValueFvPatchField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + if (curTimeIndex_ != this->db().time().timeIndex()) + { + fixedValueFvPatchField::operator== + ( + refValue_*currentScale() + + offset_ + ); + + curTimeIndex_ = this->db().time().timeIndex(); + } + + fixedValueFvPatchField::updateCoeffs(); +} + + +template +void repetitivePulseFixedValueFvPatchField::write(Ostream& os) const +{ + fixedValueFvPatchField::write(os); + refValue_.writeEntry("refValue", os); + os.writeKeyword("offset") << offset_ << token::END_STATEMENT << nl; + amplitude_->writeData(os); + frequency_->writeData(os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchField.H new file mode 100644 index 00000000..cec3e5f0 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchField.H @@ -0,0 +1,277 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2014 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::repetitivePulseFixedValueFvPatchField + +Group + grpGenericBoundaryConditions + +Description + This boundary condition provides an repetitive pulse condition in terms of + peak, duration and frequency. + + \f[ + x_p = (1 + a sin(2 \pi f t))x_{ref} + x_o + \f] + + where + + \vartable + x_p | patch values + x_{ref} | patch reference values + x_o | patch offset values + a | amplitude + f | frequency [1/s] + t | time [s] + \endvartable + + \heading Patch usage + + \table + Property | Description | Required | Default value + refValue | reference value | yes | + offset | offset value | no | 0.0 + amplitude | oscillation amplitude | yes | + frequency | oscillation frequency | yes | + \endtable + + Example of the boundary condition specification: + \verbatim + myPatch + { + type repetitivePulseFixedValue; + refValue uniform 5.0; + offset 0.0; + amplitude constant 0.5; + frequency constant 10; + } + \endverbatim + +Note + The amplitude and frequency entries are DataEntry types, able to describe + time varying functions. The example above gives the usage for supplying + constant values. + +SeeAlso + Foam::DataEntry + +SourceFiles + repetitivePulseFixedValueFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef repetitivePulseFixedValueFvPatchField_H +#define repetitivePulseFixedValueFvPatchField_H + +#include "Random.H" +#include "fixedValueFvPatchFields.H" +#include "DataEntry.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class repetitivePulseFixedValueFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template +class repetitivePulseFixedValueFvPatchField +: + public fixedValueFvPatchField +{ + // Private data + + //- Reference value + Field refValue_; + + //- Offset + Type offset_; + + //- Amplitude + autoPtr > amplitude_; + + //- Frequency + autoPtr > frequency_; + + //- Current time index + label curTimeIndex_; + + + // Private Member Functions + + //- Return current scale + scalar currentScale() const; + + +public: + + //- Runtime type information + TypeName("repetitivePulseFixedValue"); + + + // Constructors + + //- Construct from patch and internal field + repetitivePulseFixedValueFvPatchField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + repetitivePulseFixedValueFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given repetitivePulseFixedValueFvPatchField + // onto a new patch + repetitivePulseFixedValueFvPatchField + ( + const repetitivePulseFixedValueFvPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + repetitivePulseFixedValueFvPatchField + ( + const repetitivePulseFixedValueFvPatchField& + ); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp > + ( + new repetitivePulseFixedValueFvPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + repetitivePulseFixedValueFvPatchField + ( + const repetitivePulseFixedValueFvPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp > clone + ( + const DimensionedField& iF + ) const + { + return tmp > + ( + new repetitivePulseFixedValueFvPatchField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return the ref value + const Field& refValue() const + { + return refValue_; + } + + //- Return reference to the ref value to allow adjustment + Field& refValue() + { + return refValue_; + } + + //- Return amplitude + scalar amplitude() const + { + return amplitude_; + } + + scalar& amplitude() + { + return amplitude_; + } + + //- Return frequency + scalar frequency() const + { + return frequency_; + } + + scalar& frequency() + { + return frequency_; + } + + + // 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&, + const labelList& + ); + + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "repetitivePulseFixedValueFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchFields.C new file mode 100644 index 00000000..08fb780f --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchFields.C @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "repetitivePulseFixedValueFvPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(repetitivePulseFixedValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchFields.H new file mode 100644 index 00000000..29cdcccb --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef repetitivePulseFixedValueFvPatchFields_H +#define repetitivePulseFixedValueFvPatchFields_H + +#include "repetitivePulseFixedValueFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(repetitivePulseFixedValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchFieldsFwd.H b/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchFieldsFwd.H new file mode 100644 index 00000000..5b1f2eed --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchFieldsFwd.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef repetitivePulseFixedValueFvPatchFieldsFwd_H +#define repetitivePulseFixedValueFvPatchFieldsFwd_H + +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template class repetitivePulseFixedValueFvPatchField; + +makePatchTypeFieldTypedefs(repetitivePulseFixedValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //