mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Function1::ramp: New set of scalar ramp functions
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
<entryName> <rampFunction>;
<entryName>Coeffs
{
start 10;
duration 20;
}
\endverbatim
or
\verbatim
<entryName>
{
type <rampFunction>;
start 10;
duration 20;
}
\endverbatim
Where:
\table
Property | Description | Required | Default value
start | Start time | no | 0
duration | Duration | yes |
\endtable
The following common ramp functions are provided: linear, quadratic, halfCosine,
quarterCosine and quaterSine, others can easily be added and registered to the run-time
selection system.
This commit is contained in:
@ -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
|
||||
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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)));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
||||
// ************************************************************************* //
|
||||
65
src/OpenFOAM/primitives/functions/Function1/linear/linear.C
Normal file
65
src/OpenFOAM/primitives/functions/Function1/linear/linear.C
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
101
src/OpenFOAM/primitives/functions/Function1/linear/linear.H
Normal file
101
src/OpenFOAM/primitives/functions/Function1/linear/linear.H
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
||||
// ************************************************************************* //
|
||||
69
src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C
Normal file
69
src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ramp.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::Function1Types::ramp::read(const dictionary& coeffs)
|
||||
{
|
||||
start_ = coeffs.lookupOrDefault<scalar>("start", 0);
|
||||
duration_ = coeffs.lookupType<scalar>("duration");
|
||||
}
|
||||
|
||||
|
||||
Foam::Function1Types::ramp::ramp
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Function1<scalar>(entryName)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::ramp::~ramp()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::Function1Types::ramp::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<scalar>::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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
150
src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H
Normal file
150
src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
<entryName> <rampFunction>;
|
||||
<entryName>Coeffs
|
||||
{
|
||||
start 10;
|
||||
duration 20;
|
||||
}
|
||||
\endverbatim
|
||||
or
|
||||
\verbatim
|
||||
<entryName>
|
||||
{
|
||||
type <rampFunction>;
|
||||
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<scalar>
|
||||
{
|
||||
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
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user