diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 377b958ded..32cdbee9ca 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -76,8 +76,14 @@ primitives/quaternion/quaternion.C primitives/septernion/septernion.C primitives/triad/triad.C -/* functions, data entries */ +/* Run-time selectable functions */ primitives/functions/Function1/makeDataEntries.C +primitives/functions/Function1/ramp/ramp.C +primitives/functions/Function1/linear/linear.C +primitives/functions/Function1/quadratic/quadratic.C +primitives/functions/Function1/quarterSine/quarterSine.C +primitives/functions/Function1/quarterCosine/quarterCosine.C +primitives/functions/Function1/halfCosine/halfCosine.C primitives/functions/Polynomial/polynomialFunction.C primitives/subModelBase/subModelBase.C diff --git a/src/OpenFOAM/primitives/functions/Function1/halfCosine/halfCosine.C b/src/OpenFOAM/primitives/functions/Function1/halfCosine/halfCosine.C new file mode 100644 index 0000000000..5abf42d10f --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/halfCosine/halfCosine.C @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 "halfCosine.H" +#include "mathematicalConstants.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace Function1Types +{ + makeScalarFunction1(halfCosine); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::Function1Types::halfCosine::halfCosine +( + const word& entryName, + const dictionary& dict +) +: + ramp(entryName, dict) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::Function1Types::halfCosine::~halfCosine() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::scalar Foam::Function1Types::halfCosine::value(const scalar t) const +{ + return 0.5*(1 - cos(constant::mathematical::pi*linearRamp(t))); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/halfCosine/halfCosine.H b/src/OpenFOAM/primitives/functions/Function1/halfCosine/halfCosine.H new file mode 100644 index 0000000000..774402adf3 --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/halfCosine/halfCosine.H @@ -0,0 +1,101 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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::Function1Types::halfCosine + +Description + Half-cosine ramp function starting from 0 and increasing to 1 from \c start + over the \c duration and remaining at 1 thereafter. + +See also + Foam::Function1Types::ramp + +SourceFiles + halfCosine.C + +\*---------------------------------------------------------------------------*/ + +#ifndef halfCosine_H +#define halfCosine_H + +#include "ramp.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace Function1Types +{ + +/*---------------------------------------------------------------------------*\ + Class halfCosine Declaration +\*---------------------------------------------------------------------------*/ + +class halfCosine +: + public ramp +{ + // Private Member Functions + + //- Disallow default bitwise assignment + void operator=(const halfCosine&); + + +public: + + // Runtime type information + TypeName("halfCosine"); + + + // Constructors + + //- Construct from entry name and dictionary + halfCosine + ( + const word& entryName, + const dictionary& dict + ); + + + //- Destructor + virtual ~halfCosine(); + + + // Member Functions + + //- Return value for time t + scalar value(const scalar t) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Function1Types +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/linear/linear.C b/src/OpenFOAM/primitives/functions/Function1/linear/linear.C new file mode 100644 index 0000000000..658a64bf38 --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/linear/linear.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 "linear.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace Function1Types +{ + makeScalarFunction1(linear); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::Function1Types::linear::linear +( + const word& entryName, + const dictionary& dict +) +: + ramp(entryName, dict) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::Function1Types::linear::~linear() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::scalar Foam::Function1Types::linear::value(const scalar t) const +{ + return linearRamp(t); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/linear/linear.H b/src/OpenFOAM/primitives/functions/Function1/linear/linear.H new file mode 100644 index 0000000000..4d41519347 --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/linear/linear.H @@ -0,0 +1,101 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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::Function1Types::linear + +Description + Linear ramp function starting from 0 and increasing linearly to 1 from \c + start over the \c duration and remaining at 1 thereafter. + +See also + Foam::Function1Types::ramp + +SourceFiles + linear.C + +\*---------------------------------------------------------------------------*/ + +#ifndef linear_H +#define linear_H + +#include "ramp.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace Function1Types +{ + +/*---------------------------------------------------------------------------*\ + Class linear Declaration +\*---------------------------------------------------------------------------*/ + +class linear +: + public ramp +{ + // Private Member Functions + + //- Disallow default bitwise assignment + void operator=(const linear&); + + +public: + + // Runtime type information + TypeName("linear"); + + + // Constructors + + //- Construct from entry name and dictionary + linear + ( + const word& entryName, + const dictionary& dict + ); + + + //- Destructor + virtual ~linear(); + + + // Member Functions + + //- Return value for time t + scalar value(const scalar t) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Function1Types +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/quadratic/quadratic.C b/src/OpenFOAM/primitives/functions/Function1/quadratic/quadratic.C new file mode 100644 index 0000000000..a35f82e79f --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/quadratic/quadratic.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 "quadratic.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace Function1Types +{ + makeScalarFunction1(quadratic); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::Function1Types::quadratic::quadratic +( + const word& entryName, + const dictionary& dict +) +: + ramp(entryName, dict) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::Function1Types::quadratic::~quadratic() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::scalar Foam::Function1Types::quadratic::value(const scalar t) const +{ + return sqr(linearRamp(t)); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/quadratic/quadratic.H b/src/OpenFOAM/primitives/functions/Function1/quadratic/quadratic.H new file mode 100644 index 0000000000..39575bc5a7 --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/quadratic/quadratic.H @@ -0,0 +1,101 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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::Function1Types::quadratic + +Description + Quadratic ramp function starting from 0 and increasing quadratically to 1 + from \c t_0 over the \c duration and remaining at 1 thereafter. + +See also + Foam::Function1Types::ramp + +SourceFiles + quadratic.C + +\*---------------------------------------------------------------------------*/ + +#ifndef quadratic_H +#define quadratic_H + +#include "ramp.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace Function1Types +{ + +/*---------------------------------------------------------------------------*\ + Class quadratic Declaration +\*---------------------------------------------------------------------------*/ + +class quadratic +: + public ramp +{ + // Private Member Functions + + //- Disallow default bitwise assignment + void operator=(const quadratic&); + + +public: + + // Runtime type information + TypeName("quadratic"); + + + // Constructors + + //- Construct from entry name and dictionary + quadratic + ( + const word& entryName, + const dictionary& dict + ); + + + //- Destructor + virtual ~quadratic(); + + + // Member Functions + + //- Return value for time t + scalar value(const scalar t) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Function1Types +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/quarterCosine/quarterCosine.C b/src/OpenFOAM/primitives/functions/Function1/quarterCosine/quarterCosine.C new file mode 100644 index 0000000000..025df283f6 --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/quarterCosine/quarterCosine.C @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 "quarterCosine.H" +#include "mathematicalConstants.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace Function1Types +{ + makeScalarFunction1(quarterCosine); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::Function1Types::quarterCosine::quarterCosine +( + const word& entryName, + const dictionary& dict +) +: + ramp(entryName, dict) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::Function1Types::quarterCosine::~quarterCosine() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::scalar Foam::Function1Types::quarterCosine::value(const scalar t) const +{ + return 1 - cos(0.5*constant::mathematical::pi*linearRamp(t)); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/quarterCosine/quarterCosine.H b/src/OpenFOAM/primitives/functions/Function1/quarterCosine/quarterCosine.H new file mode 100644 index 0000000000..a96db22bf1 --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/quarterCosine/quarterCosine.H @@ -0,0 +1,101 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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::Function1Types::quarterCosine + +Description + Quarter-cosine ramp function starting from 0 and increasing to 1 from \c + start over the \c duration and remaining at 1 thereafter. + +See also + Foam::Function1Types::ramp + +SourceFiles + quarterCosine.C + +\*---------------------------------------------------------------------------*/ + +#ifndef quarterCosine_H +#define quarterCosine_H + +#include "ramp.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace Function1Types +{ + +/*---------------------------------------------------------------------------*\ + Class quarterCosine Declaration +\*---------------------------------------------------------------------------*/ + +class quarterCosine +: + public ramp +{ + // Private Member Functions + + //- Disallow default bitwise assignment + void operator=(const quarterCosine&); + + +public: + + // Runtime type information + TypeName("quarterCosine"); + + + // Constructors + + //- Construct from entry name and dictionary + quarterCosine + ( + const word& entryName, + const dictionary& dict + ); + + + //- Destructor + virtual ~quarterCosine(); + + + // Member Functions + + //- Return value for time t + scalar value(const scalar t) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Function1Types +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/quarterSine/quarterSine.C b/src/OpenFOAM/primitives/functions/Function1/quarterSine/quarterSine.C new file mode 100644 index 0000000000..ad144a4057 --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/quarterSine/quarterSine.C @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 "quarterSine.H" +#include "mathematicalConstants.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace Function1Types +{ + makeScalarFunction1(quarterSine); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::Function1Types::quarterSine::quarterSine +( + const word& entryName, + const dictionary& dict +) +: + ramp(entryName, dict) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::Function1Types::quarterSine::~quarterSine() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::scalar Foam::Function1Types::quarterSine::value(const scalar t) const +{ + return sin(0.5*constant::mathematical::pi*linearRamp(t)); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/quarterSine/quarterSine.H b/src/OpenFOAM/primitives/functions/Function1/quarterSine/quarterSine.H new file mode 100644 index 0000000000..3e2d41368c --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/quarterSine/quarterSine.H @@ -0,0 +1,101 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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::Function1Types::quarterSine + +Description + Quarter-sine ramp function starting from 0 and increasing to 1 from \c start + over the \c duration and remaining at 1 thereafter. + +See also + Foam::Function1Types::ramp + +SourceFiles + quarterSine.C + +\*---------------------------------------------------------------------------*/ + +#ifndef quarterSine_H +#define quarterSine_H + +#include "ramp.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace Function1Types +{ + +/*---------------------------------------------------------------------------*\ + Class quarterSine Declaration +\*---------------------------------------------------------------------------*/ + +class quarterSine +: + public ramp +{ + // Private Member Functions + + //- Disallow default bitwise assignment + void operator=(const quarterSine&); + + +public: + + // Runtime type information + TypeName("quarterSine"); + + + // Constructors + + //- Construct from entry name and dictionary + quarterSine + ( + const word& entryName, + const dictionary& dict + ); + + + //- Destructor + virtual ~quarterSine(); + + + // Member Functions + + //- Return value for time t + scalar value(const scalar t) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Function1Types +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C new file mode 100644 index 0000000000..40645aa191 --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 "ramp.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +void Foam::Function1Types::ramp::read(const dictionary& coeffs) +{ + start_ = coeffs.lookupOrDefault("start", 0); + duration_ = coeffs.lookupType("duration"); +} + + +Foam::Function1Types::ramp::ramp +( + const word& entryName, + const dictionary& dict +) +: + Function1(entryName) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::Function1Types::ramp::~ramp() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::Function1Types::ramp::writeData(Ostream& os) const +{ + Function1::writeData(os); + os << token::END_STATEMENT << nl; + os << indent << word(this->name() + "Coeffs") << nl; + os << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.writeKeyword("start") << start_ << token::END_STATEMENT << nl; + os.writeKeyword("duration") << duration_ << token::END_STATEMENT << nl; + os << decrIndent << indent << token::END_BLOCK << endl; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H new file mode 100644 index 0000000000..08a5d4c64e --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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::Function1Types::ramp + +Description + Ramp function base class for the set of scalar functions starting from 0 and + increasing monotonically to 1 from \c start over the \c duration and + remaining at 1 thereafter. + + Usage: + \verbatim + ; + Coeffs + { + start 10; + duration 20; + } + \endverbatim + or + \verbatim + + { + type ; + start 10; + duration 20; + } + \endverbatim + + Where: + \table + Property | Description | Required | Default value + start | Start time | no | 0 + duration | Duration | yes | + \endtable + +See also + Foam::Function1 + +SourceFiles + ramp.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ramp_H +#define ramp_H + +#include "Function1.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace Function1Types +{ + +/*---------------------------------------------------------------------------*\ + Class ramp Declaration +\*---------------------------------------------------------------------------*/ + +class ramp +: + public Function1 +{ +protected: + + // Protected data + + //- Start-time of the ramp function + scalar start_; + + //- Duration of the ramp function + scalar duration_; + + //- Simple linear ramp function + // which form the basis of many more complex ramp functions + inline scalar linearRamp(const scalar t) const + { + return max(min((t - start_)/duration_, 1), 0); + } + + +private: + + // Private Member Functions + + //- Read the coefficients from the given dictionary + void read(const dictionary& coeffs); + + //- Disallow default bitwise assignment + void operator=(const ramp&); + + +public: + + // Constructors + + //- Construct from entry name and dictionary + ramp + ( + const word& entryName, + const dictionary& dict + ); + + + //- Destructor + virtual ~ramp(); + + + // Member Functions + + //- Return value for time t + scalar value(const scalar t) const = 0; + + //- Write in dictionary format + virtual void writeData(Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Function1Types +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //