mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: a weighted operation without a weightField is an error (issue #583)
- affects surfaceFieldValue, volFieldValue. Use 'none' (if desired) to explicitly suppress the weightField, but generally better to use a different operation.
This commit is contained in:
@ -571,17 +571,33 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
|
|||||||
|
|
||||||
|
|
||||||
weightFieldName_ = "none";
|
weightFieldName_ = "none";
|
||||||
if (usesWeight() && dict.readIfPresent("weightField", weightFieldName_))
|
if (usesWeight())
|
||||||
{
|
{
|
||||||
if (regionType_ == stSampledSurface)
|
if (regionType_ == stSampledSurface)
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(dict)
|
FatalIOErrorInFunction(dict)
|
||||||
<< "Cannot use weightField for sampledSurface"
|
<< "Cannot use weighted operation '"
|
||||||
|
<< operationTypeNames_[operation_]
|
||||||
|
<< "' for sampledSurface"
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dict.readIfPresent("weightField", weightFieldName_))
|
||||||
|
{
|
||||||
Info<< " weight field = " << weightFieldName_ << nl;
|
Info<< " weight field = " << weightFieldName_ << nl;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Suggest possible alternative unweighted operation?
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "The '" << operationTypeNames_[operation_]
|
||||||
|
<< "' operation is missing a weightField." << nl
|
||||||
|
<< "Either provide the weightField, "
|
||||||
|
<< "use weightField 'none' to suppress weighting," << nl
|
||||||
|
<< "or use a different operation."
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Backwards compatibility for v1612+ and older
|
// Backwards compatibility for v1612+ and older
|
||||||
List<word> orientedFields;
|
List<word> orientedFields;
|
||||||
|
|||||||
@ -114,10 +114,24 @@ void Foam::functionObjects::fieldValues::volFieldValue::initialise
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
weightFieldName_ = "none";
|
weightFieldName_ = "none";
|
||||||
if (usesWeight() && dict.readIfPresent("weightField", weightFieldName_))
|
if (usesWeight())
|
||||||
|
{
|
||||||
|
if (dict.readIfPresent("weightField", weightFieldName_))
|
||||||
{
|
{
|
||||||
Info<< " weight field = " << weightFieldName_;
|
Info<< " weight field = " << weightFieldName_;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Suggest possible alternative unweighted operation?
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "The '" << operationTypeNames_[operation_]
|
||||||
|
<< "' operation is missing a weightField." << nl
|
||||||
|
<< "Either provide the weightField, "
|
||||||
|
<< "use weightField 'none' to suppress weighting," << nl
|
||||||
|
<< "or use a different operation."
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Info<< nl << endl;
|
Info<< nl << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user