mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add construct ConstantField with uniform value
This commit is contained in:
@ -52,7 +52,7 @@ Foam::Function1Types::Constant<Type>::Constant
|
||||
Function1<Type>(entryName),
|
||||
value_(Zero)
|
||||
{
|
||||
Istream& is(dict.lookup(entryName));
|
||||
Istream& is = dict.lookup(entryName);
|
||||
word entryType(is);
|
||||
is >> value_;
|
||||
}
|
||||
@ -78,13 +78,6 @@ Foam::Function1Types::Constant<Type>::Constant(const Constant<Type>& cnst)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Constant<Type>::~Constant()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
|
||||
@ -103,7 +103,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Constant();
|
||||
virtual ~Constant() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -103,6 +103,7 @@ protected:
|
||||
//- Name of entry
|
||||
const word name_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- No copy assignment
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,10 +28,11 @@ License
|
||||
|
||||
#include "Constant.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::autoPtr<Foam::Function1<Type>> Foam::Function1<Type>::New
|
||||
Foam::autoPtr<Foam::Function1<Type>>
|
||||
Foam::Function1<Type>::New
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
@ -86,10 +87,14 @@ Foam::autoPtr<Foam::Function1<Type>> Foam::Function1<Type>::New
|
||||
|
||||
if (!firstToken.isWord())
|
||||
{
|
||||
// Backwards-compatibility for reading straight fields
|
||||
is.putBack(firstToken);
|
||||
|
||||
const Type constValue = pTraits<Type>(is);
|
||||
|
||||
return autoPtr<Function1<Type>>
|
||||
(
|
||||
new Function1Types::Constant<Type>(entryName, is)
|
||||
new Function1Types::Constant<Type>(entryName, constValue)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user