Commit 6f2376a6 authored by mattijs's avatar mattijs
Browse files

ENH: ConstantField: allow 'constant' keyword. See #1046.

parent 966eed30
......@@ -42,6 +42,54 @@ Foam::PatchFunction1Types::ConstantField<Type>::ConstantField
{}
template<class Type>
Foam::Field<Type> Foam::PatchFunction1Types::ConstantField<Type>::getValue
(
const word& keyword,
const dictionary& dict,
const label len
)
{
Field<Type> fld;
if (len)
{
ITstream& is = dict.lookup(keyword);
// Read first token
token firstToken(is);
if (firstToken.isWord())
{
if
(
firstToken.wordToken() == "uniform"
|| firstToken.wordToken() == "constant"
)
{
fld.setSize(len);
fld = pTraits<Type>(is);
}
else
{
FatalIOErrorInFunction(dict)
<< "expected keyword 'uniform' or 'constant', found "
<< firstToken.wordToken()
<< exit(FatalIOError);
}
}
else
{
fld.setSize(len);
is.putBack(firstToken);
fld = pTraits<Type>(is);
}
}
return fld;
}
template<class Type>
Foam::PatchFunction1Types::ConstantField<Type>::ConstantField
(
......@@ -52,7 +100,7 @@ Foam::PatchFunction1Types::ConstantField<Type>::ConstantField
)
:
PatchFunction1<Type>(pp, entryName, dict, faceValues),
value_(entryName, dict, pp.size())
value_(getValue(entryName, dict, pp.size()))
{}
......
......@@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -66,6 +66,14 @@ class ConstantField
// Private Member Functions
//- Helper to read value from dictionary
static Field<Type> getValue
(
const word& keyword,
const dictionary& dict,
const label len
);
//- No copy assignment
void operator=(const ConstantField<Type>&) = delete;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment