diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C index db92766baee54c0f8b0e2de27640d6d15467d95e..fdcfdf3a9583ca005d1791e58375645c84ca90fb 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C @@ -571,16 +571,32 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise weightFieldName_ = "none"; - if (usesWeight() && dict.readIfPresent("weightField", weightFieldName_)) + if (usesWeight()) { if (regionType_ == stSampledSurface) { FatalIOErrorInFunction(dict) - << "Cannot use weightField for sampledSurface" + << "Cannot use weighted operation '" + << operationTypeNames_[operation_] + << "' for sampledSurface" << exit(FatalIOError); } - Info<< " weight field = " << weightFieldName_ << nl; + if (dict.readIfPresent("weightField", weightFieldName_)) + { + 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 diff --git a/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.C b/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.C index eafef810961ef773c4456aa176bf457eb8a706cb..fb72fcadee1eaddda207d7db780ce97e7b21c017 100644 --- a/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.C +++ b/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.C @@ -114,9 +114,23 @@ void Foam::functionObjects::fieldValues::volFieldValue::initialise ) { weightFieldName_ = "none"; - if (usesWeight() && dict.readIfPresent("weightField", weightFieldName_)) + if (usesWeight()) { - Info<< " weight field = " << weightFieldName_; + if (dict.readIfPresent("weightField", 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;