COMP: make ZeroConstant clonable

This commit is contained in:
Mark Olesen
2022-05-23 17:57:21 +02:00
parent 500c7047b2
commit 93dcf732dd
16 changed files with 84 additions and 134 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -148,6 +148,12 @@ public:
Sine<Type>(rhs)
{}
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const
{
return tmp<Function1<Type>>(new Cosine<Type>(*this));
}
//- Destructor
virtual ~Cosine() = default;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -71,8 +71,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef Function1_H
#define Function1_H
#ifndef Foam_Function1_H
#define Foam_Function1_H
#include "function1Base.H"
#include "Field.H"
@ -241,10 +241,7 @@ public:
// Member Functions
//- Is value constant (i.e. independent of x)
virtual bool constant() const
{
return false;
}
virtual bool constant() const { return false; }
// Evaluation

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef function1Base_H
#define function1Base_H
#ifndef Foam_function1Base_H
#define Foam_function1Base_H
#include "dictionary.H"
#include "objectRegistry.H"

View File

@ -201,6 +201,12 @@ public:
//- Copy construct
explicit InputValueMapper(const InputValueMapper<Type>& rhs);
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const
{
return tmp<Function1<Type>>(new InputValueMapper<Type>(*this));
}
//- Destructor
virtual ~InputValueMapper() = default;

View File

@ -69,8 +69,8 @@ public:
// Generated Methods
//- Default copy constructor
None(const None<Type>& rhs) = default;
//- Default copy construct
None(const None<Type>&) = default;
//- No copy assignment
void operator=(const None<Type>&) = delete;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -69,6 +69,9 @@ public:
// Generated Methods
//- Default copy construct
OneConstant(const OneConstant<Type>&) = default;
//- No copy assignment
void operator=(const OneConstant<Type>&) = delete;
@ -107,10 +110,16 @@ public:
virtual inline bool constant() const { return true; }
//- Return constant value
virtual inline Type value(const scalar) const;
virtual inline Type value(const scalar) const
{
return pTraits<Type>::one;
}
//- Integrate between two values
virtual inline Type integrate(const scalar x1, const scalar x2) const;
virtual inline Type integrate(const scalar x1, const scalar x2) const
{
return (x2 - x1)*pTraits<Type>::one;
}
//- Return value as a function of (scalar) independent variable
virtual tmp<Field<Type>> value(const scalarField& x) const;
@ -134,8 +143,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "OneConstantI.H"
#ifdef NoRepository
#include "OneConstant.C"
#endif

View File

@ -1,50 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
-------------------------------------------------------------------------------
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;
}
// ************************************************************************* //

View File

@ -133,6 +133,12 @@ public:
//- Copy construct
explicit Scale(const Scale<Type>& rhs);
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const
{
return tmp<Function1<Type>>(new Scale<Type>(*this));
}
//- Destructor
virtual ~Scale() = default;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -192,6 +192,12 @@ public:
//- Copy construct
explicit Sine(const Sine<Type>& rhs);
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const
{
return tmp<Function1<Type>>(new Sine<Type>(*this));
}
//- Destructor
virtual ~Sine() = default;

View File

@ -155,6 +155,12 @@ public:
//- Copy construct
explicit Square(const Square<Type>& rhs);
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const
{
return tmp<Function1<Type>>(new Square<Type>(*this));
}
//- Destructor
virtual ~Square() = default;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -69,8 +69,8 @@ public:
// Generated Methods
//- Copy construct
Uniform<Type>(const Uniform&) = default;
//- Default copy construct
Uniform(const Uniform<Type>&) = default;
//- No copy assignment
void operator=(const Uniform<Type>&) = delete;
@ -88,6 +88,12 @@ public:
:
Constant<Type>(entryName, dict, obrPtr)
{}
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const
{
return tmp<Function1<Type>>(new Uniform<Type>(*this));
}
};

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -78,6 +78,9 @@ public:
// Generated Methods
//- Default copy construct
ZeroConstant(const ZeroConstant<Type>&) = default;
//- No copy assignment
void operator=(const ZeroConstant<Type>&) = delete;
@ -99,6 +102,12 @@ public:
const objectRegistry* obrPtr = nullptr
);
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const
{
return tmp<Function1<Type>>(new ZeroConstant<Type>(*this));
}
//- Destructor
virtual ~ZeroConstant() = default;
@ -110,10 +119,16 @@ public:
virtual inline bool constant() const { return true; }
//- Return constant value
virtual inline Type value(const scalar) const;
virtual inline Type value(const scalar) const
{
return pTraits<Type>::zero;
}
//- Integrate between two values
virtual inline Type integrate(const scalar x1, const scalar x2) const;
virtual inline Type integrate(const scalar x1, const scalar x2) const
{
return pTraits<Type>::zero;
}
//- Write as primitive (inline) format
virtual void writeData(Ostream& os) const;
@ -127,8 +142,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "ZeroConstantI.H"
#ifdef NoRepository
#include "ZeroConstant.C"
#endif

View File

@ -1,53 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
-------------------------------------------------------------------------------
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;
}
// ************************************************************************* //

View File

@ -43,8 +43,8 @@ SeeAlso
\*---------------------------------------------------------------------------*/
#ifndef PatchFunction1_H
#define PatchFunction1_H
#ifndef Foam_PatchFunction1_H
#define Foam_PatchFunction1_H
#include "patchFunction1Base.H"
#include "coordinateScaling.H"

View File

@ -39,8 +39,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef patchFunction1Base_H
#define patchFunction1Base_H
#ifndef Foam_patchFunction1Base_H
#define Foam_patchFunction1Base_H
#include "dictionary.H"
#include "polyPatch.H"