Skip to content
Snippets Groups Projects
Commit 04a985cc authored by mattijs's avatar mattijs
Browse files

ENH: ConstantField: allow nonuniform. See #1046.

parent 6f2376a6
Branches
Tags
No related merge requests found
......@@ -70,11 +70,44 @@ Foam::Field<Type> Foam::PatchFunction1Types::ConstantField<Type>::getValue
fld.setSize(len);
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
{
FatalIOErrorInFunction(dict)
<< "expected keyword 'uniform' or 'constant', found "
<< firstToken.wordToken()
<< "expected keyword 'uniform', 'nonuniform' or 'constant'"
<< ", found " << firstToken.wordToken()
<< exit(FatalIOError);
}
}
......
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