Merge branch 'feature-function1-fields' into 'develop'
ENH: refactor Function1 to enable fields See merge request Development/openfoam!435
This commit is contained in:
commit
8abac1dc4d
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
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>
|
||||
void Foam::Function1Types::Constant<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -73,7 +73,6 @@ public:
|
||||
TypeName("constant");
|
||||
|
||||
|
||||
|
||||
// Generated Methods
|
||||
|
||||
//- No copy assignment
|
||||
@ -118,26 +117,11 @@ public:
|
||||
//- 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
|
||||
|
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -43,7 +44,7 @@ inline Type Foam::Function1Types::Constant<Type>::integrate
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
return (x2 - x1)*value_;
|
||||
return Type((x2 - x1)*value_);
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -60,7 +60,7 @@ template<class Type>
|
||||
Type Foam::Function1<Type>::value(const scalar x) const
|
||||
{
|
||||
NotImplemented;
|
||||
return Zero;
|
||||
return Type();
|
||||
}
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ template<class Type>
|
||||
Type Foam::Function1<Type>::integrate(const scalar x1, const scalar x2) const
|
||||
{
|
||||
NotImplemented;
|
||||
return Zero;
|
||||
return Type();
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -285,7 +285,7 @@ Type Foam::Function1Types::TableBase<Type>::value(const scalar x) const
|
||||
// Use interpolator
|
||||
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++)
|
||||
{
|
||||
t += currentWeights_[i]*table_[currentIndices_[i]].second();
|
||||
@ -305,7 +305,7 @@ Type Foam::Function1Types::TableBase<Type>::integrate
|
||||
// Use interpolator
|
||||
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++)
|
||||
{
|
||||
sum += currentWeights_[i]*table_[currentIndices_[i]].second();
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -59,6 +59,13 @@ License
|
||||
makeFunction1Type(Scale, Type); \
|
||||
makeFunction1Type(LimitRange, Type);
|
||||
|
||||
#define makeFieldFunction1s(Type) \
|
||||
makeFunction1(Type); \
|
||||
makeFunction1Type(Constant, Type); \
|
||||
makeFunction1Type(Uniform, Type); \
|
||||
makeFunction1Type(Table, Type); \
|
||||
makeFunction1Type(TableFile, Type); \
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeFunction1(label);
|
||||
@ -69,19 +76,8 @@ namespace Foam
|
||||
makeFunction1s(sphericalTensor);
|
||||
makeFunction1s(symmTensor);
|
||||
makeFunction1s(tensor);
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
makeFieldFunction1s(scalarField);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user