mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'feature-function1-fields' into 'develop'
ENH: refactor Function1 to enable fields See merge request Development/openfoam!435
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -90,16 +90,6 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1Types::Constant<Type>::value
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::Constant<Type>::integrate
|
|
||||||
(
|
|
||||||
const scalarField& x1,
|
|
||||||
const scalarField& x2
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return (x2 - x1)*value_;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::Function1Types::Constant<Type>::writeData(Ostream& os) const
|
void Foam::Function1Types::Constant<Type>::writeData(Ostream& os) const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -73,7 +73,6 @@ public:
|
|||||||
TypeName("constant");
|
TypeName("constant");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Generated Methods
|
// Generated Methods
|
||||||
|
|
||||||
//- No copy assignment
|
//- No copy assignment
|
||||||
@ -118,26 +117,11 @@ public:
|
|||||||
//- Return value as a function of (scalar) independent variable
|
//- 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;
|
||||||
|
|
||||||
//- Integrate between two (scalar) values
|
|
||||||
virtual tmp<Field<Type>> integrate
|
|
||||||
(
|
|
||||||
const scalarField& x1,
|
|
||||||
const scalarField& x2
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Write in dictionary format
|
//- Write in dictionary format
|
||||||
virtual void writeData(Ostream& os) const;
|
virtual void writeData(Ostream& os) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<>
|
|
||||||
tmp<Field<label>> Function1Types::Constant<label>::integrate
|
|
||||||
(
|
|
||||||
const scalarField& x1,
|
|
||||||
const scalarField& x2
|
|
||||||
) const;
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Function1Types
|
} // End namespace Function1Types
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017 OpenFOAM Foundation
|
Copyright (C) 2017 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -43,7 +44,7 @@ inline Type Foam::Function1Types::Constant<Type>::integrate
|
|||||||
const scalar x2
|
const scalar x2
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return (x2 - x1)*value_;
|
return Type((x2 - x1)*value_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2020 OpenCFD Ltd.
|
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -60,7 +60,7 @@ template<class Type>
|
|||||||
Type Foam::Function1<Type>::value(const scalar x) const
|
Type Foam::Function1<Type>::value(const scalar x) const
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
return Zero;
|
return Type();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ template<class Type>
|
|||||||
Type Foam::Function1<Type>::integrate(const scalar x1, const scalar x2) const
|
Type Foam::Function1<Type>::integrate(const scalar x1, const scalar x2) const
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
return Zero;
|
return Type();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -285,7 +285,7 @@ Type Foam::Function1Types::TableBase<Type>::value(const scalar x) const
|
|||||||
// Use interpolator
|
// Use interpolator
|
||||||
interpolator().valueWeights(xDash, currentIndices_, currentWeights_);
|
interpolator().valueWeights(xDash, currentIndices_, currentWeights_);
|
||||||
|
|
||||||
Type t = currentWeights_[0]*table_[currentIndices_[0]].second();
|
Type t(currentWeights_[0]*table_[currentIndices_[0]].second());
|
||||||
for (label i = 1; i < currentIndices_.size(); i++)
|
for (label i = 1; i < currentIndices_.size(); i++)
|
||||||
{
|
{
|
||||||
t += currentWeights_[i]*table_[currentIndices_[i]].second();
|
t += currentWeights_[i]*table_[currentIndices_[i]].second();
|
||||||
@ -305,7 +305,7 @@ Type Foam::Function1Types::TableBase<Type>::integrate
|
|||||||
// Use interpolator
|
// Use interpolator
|
||||||
interpolator().integrationWeights(x1, x2, currentIndices_, currentWeights_);
|
interpolator().integrationWeights(x1, x2, currentIndices_, currentWeights_);
|
||||||
|
|
||||||
Type sum = currentWeights_[0]*table_[currentIndices_[0]].second();
|
Type sum(currentWeights_[0]*table_[currentIndices_[0]].second());
|
||||||
for (label i = 1; i < currentIndices_.size(); i++)
|
for (label i = 1; i < currentIndices_.size(); i++)
|
||||||
{
|
{
|
||||||
sum += currentWeights_[i]*table_[currentIndices_[i]].second();
|
sum += currentWeights_[i]*table_[currentIndices_[i]].second();
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2020 OpenCFD Ltd.
|
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -59,6 +59,13 @@ License
|
|||||||
makeFunction1Type(Scale, Type); \
|
makeFunction1Type(Scale, Type); \
|
||||||
makeFunction1Type(LimitRange, Type);
|
makeFunction1Type(LimitRange, Type);
|
||||||
|
|
||||||
|
#define makeFieldFunction1s(Type) \
|
||||||
|
makeFunction1(Type); \
|
||||||
|
makeFunction1Type(Constant, Type); \
|
||||||
|
makeFunction1Type(Uniform, Type); \
|
||||||
|
makeFunction1Type(Table, Type); \
|
||||||
|
makeFunction1Type(TableFile, Type); \
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
makeFunction1(label);
|
makeFunction1(label);
|
||||||
@ -69,19 +76,8 @@ namespace Foam
|
|||||||
makeFunction1s(sphericalTensor);
|
makeFunction1s(sphericalTensor);
|
||||||
makeFunction1s(symmTensor);
|
makeFunction1s(symmTensor);
|
||||||
makeFunction1s(tensor);
|
makeFunction1s(tensor);
|
||||||
}
|
|
||||||
|
|
||||||
|
makeFieldFunction1s(scalarField);
|
||||||
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(x1.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user