mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Field - read error if insufficient values provided, but allow if more are available
This commit is contained in:
@ -198,22 +198,35 @@ Foam::Field<Type>::Field
|
|||||||
else if (firstToken.wordToken() == "nonuniform")
|
else if (firstToken.wordToken() == "nonuniform")
|
||||||
{
|
{
|
||||||
is >> static_cast<List<Type>&>(*this);
|
is >> static_cast<List<Type>&>(*this);
|
||||||
if (this->size() != len)
|
label currentSize = this->size();
|
||||||
|
if (currentSize != len)
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction
|
if (len < currentSize && allowConstructFromLargerSize)
|
||||||
(
|
{
|
||||||
dict
|
#ifdef FULLDEBUG
|
||||||
) << "size " << this->size()
|
IOWarningInFunction(dict)
|
||||||
|
<< "Sizes do not match. "
|
||||||
|
<< "Re-sizing " << currentSize
|
||||||
|
<< " entries to " << len
|
||||||
|
<< endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Resize the data
|
||||||
|
this->setSize(len);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "size " << this->size()
|
||||||
<< " is not equal to the given value of " << len
|
<< " is not equal to the given value of " << len
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction
|
FatalIOErrorInFunction(dict)
|
||||||
(
|
<< "expected keyword 'uniform' or 'nonuniform', found "
|
||||||
dict
|
|
||||||
) << "expected keyword 'uniform' or 'nonuniform', found "
|
|
||||||
<< firstToken.wordToken()
|
<< firstToken.wordToken()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,5 +29,7 @@ License
|
|||||||
|
|
||||||
const char* const Foam::FieldBase::typeName("Field");
|
const char* const Foam::FieldBase::typeName("Field");
|
||||||
|
|
||||||
|
bool Foam::FieldBase::allowConstructFromLargerSize = false;
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -57,6 +57,8 @@ public:
|
|||||||
//- Typename for Field
|
//- Typename for Field
|
||||||
static const char* const typeName;
|
static const char* const typeName;
|
||||||
|
|
||||||
|
static bool allowConstructFromLargerSize;
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user