ENH: ConstantField: allow nonuniform. See #1046.

This commit is contained in:
mattijs
2018-10-30 13:37:54 +00:00
parent 6f2376a649
commit 04a985ccb3

View File

@ -70,11 +70,44 @@ Foam::Field<Type> Foam::PatchFunction1Types::ConstantField<Type>::getValue
fld.setSize(len); fld.setSize(len);
fld = pTraits<Type>(is); fld = pTraits<Type>(is);
} }
else if (firstToken.wordToken() == "nonuniform")
{
List<Type>& list = fld;
is >> list;
label currentSize = fld.size();
if (currentSize != len)
{
if
(
len < currentSize
&& FieldBase::allowConstructFromLargerSize
)
{
#ifdef FULLDEBUG
IOWarningInFunction(dict)
<< "Sizes do not match. "
<< "Re-sizing " << currentSize
<< " entries to " << len
<< endl;
#endif
// Resize the data
fld.setSize(len);
}
else
{
FatalIOErrorInFunction(dict)
<< "size " << fld.size()
<< " is not equal to the given value of " << len
<< exit(FatalIOError);
}
}
}
else else
{ {
FatalIOErrorInFunction(dict) FatalIOErrorInFunction(dict)
<< "expected keyword 'uniform' or 'constant', found " << "expected keyword 'uniform', 'nonuniform' or 'constant'"
<< firstToken.wordToken() << ", found " << firstToken.wordToken()
<< exit(FatalIOError); << exit(FatalIOError);
} }
} }