mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Function1: Optimized field evaluations
This commit is contained in:
committed by
Andrew Heather
parent
2f431ffd3d
commit
3b6eb380d0
@ -89,7 +89,7 @@ primitives/septernion/septernion.C
|
||||
primitives/triad/triad.C
|
||||
|
||||
/* Run-time selectable functions */
|
||||
primitives/functions/Function1/makeDataEntries.C
|
||||
primitives/functions/Function1/makeFunction1s.C
|
||||
primitives/functions/Function1/ramp/ramp.C
|
||||
primitives/functions/Function1/linearRamp/linearRamp.C
|
||||
primitives/functions/Function1/quadraticRamp/quadraticRamp.C
|
||||
|
||||
@ -127,12 +127,6 @@ public:
|
||||
//- Copy constructor
|
||||
CSV(const CSV<Type>& tbl);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new CSV<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~CSV();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -85,17 +85,20 @@ Foam::Function1Types::Constant<Type>::~Constant()
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::Constant<Type>::value(const scalar x) const
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::Constant<Type>::value
|
||||
(
|
||||
const scalarField& x
|
||||
) const
|
||||
{
|
||||
return value_;
|
||||
return tmp<Field<Type>>(new Field<Type>(x.size(), value_));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::Constant<Type>::integrate
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::Constant<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const
|
||||
{
|
||||
return (x2 - x1)*value_;
|
||||
|
||||
@ -106,16 +106,34 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return constant value
|
||||
Type value(const scalar) const;
|
||||
virtual inline Type value(const scalar) const;
|
||||
|
||||
//- Integrate between two values
|
||||
Type integrate(const scalar x1, const scalar x2) const;
|
||||
virtual inline Type integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
virtual tmp<Field<Type>> value(const scalarField& x) const;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual tmp<Field<Type>> integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const;
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
tmp<Field<label>> Function1Types::Constant<label>::integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
@ -123,6 +141,8 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "ConstantI.H"
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "Constant.C"
|
||||
#include "Function1New.C"
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "Constant.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::Constant<Type>::value(const scalar x) const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::Constant<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
return (x2 - x1)*value_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -82,8 +82,9 @@ Type Foam::Function1<Type>::integrate(const scalar x1, const scalar x2) const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::value
|
||||
template<class Function1Type>
|
||||
Foam::tmp<Foam::Field<typename Function1Type::returnType>>
|
||||
Foam::FieldFunction1<Function1Type>::value
|
||||
(
|
||||
const scalarField& x
|
||||
) const
|
||||
@ -93,14 +94,37 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::value
|
||||
|
||||
forAll(x, i)
|
||||
{
|
||||
fld[i] = this->value(x[i]);
|
||||
fld[i] = Function1Type::value(x[i]);
|
||||
}
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::integrate
|
||||
template<class Function1Type>
|
||||
Foam::FieldFunction1<Function1Type>::FieldFunction1
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Function1Type(entryName, dict)
|
||||
{}
|
||||
|
||||
|
||||
template<class Function1Type>
|
||||
Foam::tmp<Foam::Function1<typename Function1Type::returnType>>
|
||||
Foam::FieldFunction1<Function1Type>::clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>
|
||||
(
|
||||
new FieldFunction1<Function1Type>(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Function1Type>
|
||||
Foam::tmp<Foam::Field<typename Function1Type::returnType>>
|
||||
Foam::FieldFunction1<Function1Type>::integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
@ -111,8 +135,9 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::integrate
|
||||
|
||||
forAll(x1, i)
|
||||
{
|
||||
fld[i] = this->integrate(x1[i], x2[i]);
|
||||
fld[i] = Function1Type::integrate(x1[i], x2[i]);
|
||||
}
|
||||
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ template<class Type> class Function1;
|
||||
template<class Type> Ostream& operator<<(Ostream&, const Function1<Type>&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Function1 Declaration
|
||||
Class Function1 Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
@ -79,6 +79,8 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
typedef Type returnType;
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("Function1")
|
||||
|
||||
@ -96,13 +98,13 @@ public:
|
||||
);
|
||||
|
||||
|
||||
// Constructor
|
||||
// Constructors
|
||||
|
||||
//- Construct from entry name
|
||||
Function1(const word& entryName);
|
||||
|
||||
//- Copy constructor
|
||||
Function1(const Function1<Type>& de);
|
||||
Function1(const Function1<Type>& f1);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const = 0;
|
||||
@ -140,7 +142,7 @@ public:
|
||||
virtual Type value(const scalar x) const;
|
||||
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
virtual tmp<Field<Type>> value(const scalarField& x) const;
|
||||
virtual tmp<Field<Type>> value(const scalarField& x) const = 0;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual Type integrate(const scalar x1, const scalar x2) const;
|
||||
@ -150,7 +152,7 @@ public:
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const;
|
||||
) const = 0;
|
||||
|
||||
|
||||
// I/O
|
||||
@ -167,6 +169,54 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class FieldFunction1 Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Function1Type>
|
||||
class FieldFunction1
|
||||
:
|
||||
public Function1Type
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
typedef typename Function1Type::returnType Type;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from entry name and dictionary
|
||||
FieldFunction1(const word& entryName, const dictionary& dict);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const;
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~FieldFunction1()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Evaluation
|
||||
|
||||
using Function1Type::value;
|
||||
using Function1Type::integrate;
|
||||
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
virtual tmp<Field<Type>> value(const scalarField& x) const;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual tmp<Field<Type>> integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
@ -188,7 +238,8 @@ public:
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(Function1Types::SS<Type>, 0); \
|
||||
\
|
||||
Function1<Type>::adddictionaryConstructorToTable<Function1Types::SS<Type>> \
|
||||
Function1<Type>::adddictionaryConstructorToTable \
|
||||
<FieldFunction1<Function1Types::SS<Type>>> \
|
||||
add##SS##Type##ConstructorToTable_;
|
||||
|
||||
|
||||
@ -196,7 +247,7 @@ public:
|
||||
\
|
||||
defineTypeNameAndDebug(SS, 0); \
|
||||
\
|
||||
Function1<scalar>::adddictionaryConstructorToTable<SS> \
|
||||
Function1<scalar>::adddictionaryConstructorToTable<FieldFunction1<SS>> \
|
||||
add##SS##ConstructorToTable_;
|
||||
|
||||
|
||||
|
||||
@ -55,17 +55,20 @@ Foam::Function1Types::OneConstant<Type>::~OneConstant()
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::OneConstant<Type>::value(const scalar x) const
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::OneConstant<Type>::value
|
||||
(
|
||||
const scalarField& x
|
||||
) const
|
||||
{
|
||||
return pTraits<Type>::one;
|
||||
return tmp<Field<Type>>(new Field<Type>(x.size(), pTraits<Type>::one));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::OneConstant<Type>::integrate
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::OneConstant<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const
|
||||
{
|
||||
return (x2 - x1)*pTraits<Type>::one;
|
||||
|
||||
@ -92,10 +92,20 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return constant value
|
||||
Type value(const scalar) const;
|
||||
virtual inline Type value(const scalar) const;
|
||||
|
||||
//- Integrate between two values
|
||||
Type integrate(const scalar x1, const scalar x2) const;
|
||||
virtual inline Type integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
virtual tmp<Field<Type>> value(const scalarField& x) const;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual tmp<Field<Type>> integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const;
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
@ -109,6 +119,8 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "OneConstantI.H"
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "OneConstant.C"
|
||||
#endif
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "OneConstant.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::OneConstant<Type>::value(const scalar x) const
|
||||
{
|
||||
return pTraits<Type>::one;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::OneConstant<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
return (x2 - x1)*pTraits<Type>::one;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -100,12 +100,6 @@ public:
|
||||
//- Copy constructor
|
||||
Polynomial(const Polynomial& poly);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new Polynomial(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Polynomial();
|
||||
@ -122,10 +116,10 @@ public:
|
||||
// Evaluation
|
||||
|
||||
//- Return Polynomial value
|
||||
Type value(const scalar x) const;
|
||||
virtual Type value(const scalar x) const;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
Type integrate(const scalar x1, const scalar x2) const;
|
||||
virtual Type integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
|
||||
//- Write in dictionary format
|
||||
|
||||
@ -66,13 +66,6 @@ Foam::Function1Types::Scale<Type>::~Scale()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::Scale<Type>::value(const scalar t) const
|
||||
{
|
||||
return scale_->value(t)*value_->value(t);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Scale<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
|
||||
@ -126,12 +126,6 @@ public:
|
||||
//- Copy constructor
|
||||
Scale(const Scale<Type>& se);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new Scale<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Scale();
|
||||
@ -140,7 +134,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return value for time t
|
||||
Type value(const scalar t) const;
|
||||
virtual inline Type value(const scalar t) const;
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
@ -154,6 +148,8 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "ScaleI.H"
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "Scale.C"
|
||||
#endif
|
||||
|
||||
37
src/OpenFOAM/primitives/functions/Function1/Scale/ScaleI.H
Normal file
37
src/OpenFOAM/primitives/functions/Function1/Scale/ScaleI.H
Normal file
@ -0,0 +1,37 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "Scale.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::Scale<Type>::value(const scalar t) const
|
||||
{
|
||||
return scale_->value(t)*value_->value(t);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,7 +24,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Sine.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -73,17 +72,6 @@ Foam::Function1Types::Sine<Type>::~Sine()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::Sine<Type>::value(const scalar t) const
|
||||
{
|
||||
return
|
||||
amplitude_->value(t)
|
||||
*sin(constant::mathematical::twoPi*frequency_->value(t)*(t - t0_))
|
||||
*scale_->value(t)
|
||||
+ level_->value(t);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Sine<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
|
||||
@ -138,12 +138,6 @@ public:
|
||||
//- Copy constructor
|
||||
Sine(const Sine<Type>& se);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new Sine<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Sine();
|
||||
@ -152,7 +146,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return value for time t
|
||||
Type value(const scalar t) const;
|
||||
virtual inline Type value(const scalar t) const;
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
@ -166,6 +160,8 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "SineI.H"
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "Sine.C"
|
||||
#endif
|
||||
|
||||
42
src/OpenFOAM/primitives/functions/Function1/Sine/SineI.H
Normal file
42
src/OpenFOAM/primitives/functions/Function1/Sine/SineI.H
Normal file
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "Sine.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::Sine<Type>::value(const scalar t) const
|
||||
{
|
||||
return
|
||||
amplitude_->value(t)
|
||||
*sin(constant::mathematical::twoPi*frequency_->value(t)*(t - t0_))
|
||||
*scale_->value(t)
|
||||
+ level_->value(t);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -74,29 +74,6 @@ Foam::Function1Types::Square<Type>::~Square()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::Square<Type>::value(const scalar t) const
|
||||
{
|
||||
// Number of waves including fractions
|
||||
scalar waves = frequency_->value(t)*(t - t0_);
|
||||
|
||||
// Number of complete waves
|
||||
scalar nWaves;
|
||||
|
||||
// Fraction of last incomplete wave
|
||||
scalar waveFrac = std::modf(waves, &nWaves);
|
||||
|
||||
// Mark fraction of a wave
|
||||
scalar markFrac = markSpace_/(1.0 + markSpace_);
|
||||
|
||||
return
|
||||
amplitude_->value(t)
|
||||
*(waveFrac < markFrac ? 1 : -1)
|
||||
*scale_->value(t)
|
||||
+ level_->value(t);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Square<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
|
||||
@ -145,12 +145,6 @@ public:
|
||||
//- Copy constructor
|
||||
Square(const Square<Type>& se);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new Square<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Square();
|
||||
@ -159,7 +153,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return value for time t
|
||||
Type value(const scalar t) const;
|
||||
virtual inline Type value(const scalar t) const;
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
@ -173,6 +167,8 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "SquareI.H"
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "Square.C"
|
||||
#endif
|
||||
|
||||
53
src/OpenFOAM/primitives/functions/Function1/Square/SquareI.H
Normal file
53
src/OpenFOAM/primitives/functions/Function1/Square/SquareI.H
Normal file
@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "Square.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::Square<Type>::value(const scalar t) const
|
||||
{
|
||||
// Number of waves including fractions
|
||||
scalar waves = frequency_->value(t)*(t - t0_);
|
||||
|
||||
// Number of complete waves
|
||||
scalar nWaves;
|
||||
|
||||
// Fraction of last incomplete wave
|
||||
scalar waveFrac = std::modf(waves, &nWaves);
|
||||
|
||||
// Mark fraction of a wave
|
||||
scalar markFrac = markSpace_/(1.0 + markSpace_);
|
||||
|
||||
return
|
||||
amplitude_->value(t)
|
||||
*(waveFrac < markFrac ? 1 : -1)
|
||||
*scale_->value(t)
|
||||
+ level_->value(t);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -86,12 +86,6 @@ public:
|
||||
//- Copy constructor
|
||||
Table(const Table<Type>& tbl);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new Table<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Table();
|
||||
|
||||
@ -101,12 +101,6 @@ public:
|
||||
//- Copy constructor
|
||||
TableFile(const TableFile<Type>& tbl);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new TableFile<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~TableFile();
|
||||
|
||||
@ -47,24 +47,6 @@ Foam::Function1Types::ZeroConstant<Type>::~ZeroConstant()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::ZeroConstant<Type>::value(const scalar x) const
|
||||
{
|
||||
return pTraits<Type>::zero;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::ZeroConstant<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
return pTraits<Type>::zero;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::ZeroConstant<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
|
||||
@ -75,12 +75,6 @@ public:
|
||||
//- Construct from entry name and dictionary
|
||||
ZeroConstant(const word& entryName, const dictionary& dict);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new ZeroConstant<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ZeroConstant();
|
||||
@ -89,10 +83,10 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return constant value
|
||||
Type value(const scalar) const;
|
||||
virtual inline Type value(const scalar) const;
|
||||
|
||||
//- Integrate between two values
|
||||
Type integrate(const scalar x1, const scalar x2) const;
|
||||
virtual inline Type integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
@ -106,6 +100,8 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "ZeroConstantI.H"
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "ZeroConstant.C"
|
||||
#endif
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "ZeroConstant.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::ZeroConstant<Type>::value
|
||||
(
|
||||
const scalar x
|
||||
) const
|
||||
{
|
||||
return pTraits<Type>::zero;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::ZeroConstant<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
return pTraits<Type>::zero;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,7 +24,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "halfCosineRamp.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -55,12 +54,4 @@ Foam::Function1Types::halfCosineRamp::~halfCosineRamp()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::Function1Types::halfCosineRamp::value(const scalar t) const
|
||||
{
|
||||
return 0.5*(1 - cos(constant::mathematical::pi*linearRamp(t)));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -77,12 +77,6 @@ public:
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<scalar>> clone() const
|
||||
{
|
||||
return tmp<Function1<scalar>>(new halfCosineRamp(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~halfCosineRamp();
|
||||
@ -91,7 +85,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return value for time t
|
||||
scalar value(const scalar t) const;
|
||||
virtual inline scalar value(const scalar t) const;
|
||||
};
|
||||
|
||||
|
||||
@ -102,6 +96,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "halfCosineRampI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "halfCosineRamp.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::halfCosineRamp::value
|
||||
(
|
||||
const scalar t
|
||||
) const
|
||||
{
|
||||
return 0.5*(1 - cos(constant::mathematical::pi*linearRamp(t)));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -54,12 +54,4 @@ Foam::Function1Types::linearRamp::~linearRamp()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::Function1Types::linearRamp::value(const scalar t) const
|
||||
{
|
||||
return ramp::linearRamp(t);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -77,12 +77,6 @@ public:
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<scalar>> clone() const
|
||||
{
|
||||
return tmp<Function1<scalar>>(new linearRamp(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~linearRamp();
|
||||
@ -91,7 +85,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return value for time t
|
||||
scalar value(const scalar t) const;
|
||||
virtual inline scalar value(const scalar t) const;
|
||||
};
|
||||
|
||||
|
||||
@ -102,6 +96,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "linearRampI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "linearRamp.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::linearRamp::value
|
||||
(
|
||||
const scalar t
|
||||
) const
|
||||
{
|
||||
return ramp::linearRamp(t);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -55,8 +55,6 @@ namespace Foam
|
||||
{
|
||||
makeFunction1(label);
|
||||
makeFunction1Type(Constant, label);
|
||||
// Polynomial functions and interpolation do evaluate to label
|
||||
// Instead evaluate a scalar and convert to label as appropriate
|
||||
|
||||
makeFunction1s(scalar);
|
||||
makeFunction1s(vector);
|
||||
@ -66,4 +64,17 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::tmp<Foam::Field<Foam::label>>
|
||||
Foam::Function1Types::Constant<Foam::label>::integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return tmp<Field<label>>(new Field<label>(x1.size()));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -54,12 +54,4 @@ Foam::Function1Types::quadraticRamp::~quadraticRamp()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::Function1Types::quadraticRamp::value(const scalar t) const
|
||||
{
|
||||
return sqr(linearRamp(t));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -77,12 +77,6 @@ public:
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<scalar>> clone() const
|
||||
{
|
||||
return tmp<Function1<scalar>>(new quadraticRamp(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~quadraticRamp();
|
||||
@ -91,7 +85,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return value for time t
|
||||
scalar value(const scalar t) const;
|
||||
virtual inline scalar value(const scalar t) const;
|
||||
};
|
||||
|
||||
|
||||
@ -102,6 +96,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "quadraticRampI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "quadraticRamp.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::quadraticRamp::value
|
||||
(
|
||||
const scalar t
|
||||
) const
|
||||
{
|
||||
return sqr(linearRamp(t));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,7 +24,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "quarterCosineRamp.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -55,15 +54,4 @@ Foam::Function1Types::quarterCosineRamp::~quarterCosineRamp()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::Function1Types::quarterCosineRamp::value
|
||||
(
|
||||
const scalar t
|
||||
) const
|
||||
{
|
||||
return 1 - cos(0.5*constant::mathematical::pi*linearRamp(t));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -77,12 +77,6 @@ public:
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<scalar>> clone() const
|
||||
{
|
||||
return tmp<Function1<scalar>>(new quarterCosineRamp(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~quarterCosineRamp();
|
||||
@ -91,7 +85,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return value for time t
|
||||
scalar value(const scalar t) const;
|
||||
virtual inline scalar value(const scalar t) const;
|
||||
};
|
||||
|
||||
|
||||
@ -102,6 +96,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "quarterCosineRampI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "quarterCosineRamp.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::quarterCosineRamp::value
|
||||
(
|
||||
const scalar t
|
||||
) const
|
||||
{
|
||||
return 1 - cos(0.5*constant::mathematical::pi*linearRamp(t));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,7 +24,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "quarterSineRamp.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -55,12 +54,4 @@ Foam::Function1Types::quarterSineRamp::~quarterSineRamp()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::Function1Types::quarterSineRamp::value(const scalar t) const
|
||||
{
|
||||
return sin(0.5*constant::mathematical::pi*linearRamp(t));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -77,12 +77,6 @@ public:
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<scalar>> clone() const
|
||||
{
|
||||
return tmp<Function1<scalar>>(new quarterSineRamp(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~quarterSineRamp();
|
||||
@ -91,7 +85,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return value for time t
|
||||
scalar value(const scalar t) const;
|
||||
virtual inline scalar value(const scalar t) const;
|
||||
};
|
||||
|
||||
|
||||
@ -102,6 +96,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "quarterSineRampI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "quarterSineRamp.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::quarterSineRamp::value
|
||||
(
|
||||
const scalar t
|
||||
) const
|
||||
{
|
||||
return sin(0.5*constant::mathematical::pi*linearRamp(t));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -131,7 +131,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return value for time t
|
||||
scalar value(const scalar t) const = 0;
|
||||
virtual scalar value(const scalar t) const = 0;
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
|
||||
@ -77,41 +77,7 @@ Foam::fanFvPatchField<Foam::scalar>::fanFvPatchField
|
||||
{
|
||||
if (this->cyclicPatch().owner())
|
||||
{
|
||||
if (dict.found("f"))
|
||||
{
|
||||
// Backwards compatibility
|
||||
Istream& is = dict.lookup("f");
|
||||
is.format(IOstream::ASCII);
|
||||
scalarList f(is);
|
||||
|
||||
label nPows = 0;
|
||||
forAll(f, powI)
|
||||
{
|
||||
if (mag(f[powI]) > VSMALL)
|
||||
{
|
||||
nPows++;
|
||||
}
|
||||
}
|
||||
List<Tuple2<scalar, scalar>> coeffs(nPows);
|
||||
nPows = 0;
|
||||
forAll(f, powI)
|
||||
{
|
||||
if (mag(f[powI]) > VSMALL)
|
||||
{
|
||||
coeffs[nPows++] = Tuple2<scalar, scalar>(f[powI], powI);
|
||||
}
|
||||
}
|
||||
|
||||
this->jumpTable_.reset
|
||||
(
|
||||
new Function1Types::Polynomial<scalar>("jumpTable", coeffs)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Generic input constructed from dictionary
|
||||
this->jumpTable_ = Function1<scalar>::New("jumpTable", dict);
|
||||
}
|
||||
this->jumpTable_ = Function1<scalar>::New("jumpTable", dict);
|
||||
}
|
||||
|
||||
if (dict.found("value"))
|
||||
|
||||
Reference in New Issue
Block a user