mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: surfaceFieldValue - simplified by making use of new field.oriented() functionality
This commit is contained in:
@ -154,7 +154,7 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
|
|||||||
|
|
||||||
DynamicList<label> faceIds(fZone.size());
|
DynamicList<label> faceIds(fZone.size());
|
||||||
DynamicList<label> facePatchIds(fZone.size());
|
DynamicList<label> facePatchIds(fZone.size());
|
||||||
DynamicList<bool> faceFlip(fZone.size());
|
DynamicList<bool> faceFlip(fZone.size());
|
||||||
|
|
||||||
forAll(fZone, i)
|
forAll(fZone, i)
|
||||||
{
|
{
|
||||||
@ -459,7 +459,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea() const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
totalArea = gSum(filterField(mesh_.magSf(), false));
|
totalArea = gSum(filterField(mesh_.magSf()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return totalArea;
|
return totalArea;
|
||||||
@ -479,10 +479,13 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::needsSf() const
|
|||||||
case opAverage:
|
case opAverage:
|
||||||
case opMin:
|
case opMin:
|
||||||
case opMax:
|
case opMax:
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,10 +499,13 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::needsWeight() const
|
|||||||
case opWeightedAverage:
|
case opWeightedAverage:
|
||||||
case opWeightedAreaAverage:
|
case opWeightedAreaAverage:
|
||||||
case opWeightedAreaIntegrate:
|
case opWeightedAreaIntegrate:
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,7 +602,6 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
|
|||||||
|
|
||||||
|
|
||||||
weightFieldName_ = "none";
|
weightFieldName_ = "none";
|
||||||
orientWeightField_ = false;
|
|
||||||
if (needsWeight())
|
if (needsWeight())
|
||||||
{
|
{
|
||||||
if (dict.readIfPresent("weightField", weightFieldName_))
|
if (dict.readIfPresent("weightField", weightFieldName_))
|
||||||
@ -610,41 +615,21 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
|
|||||||
|
|
||||||
Info<< " weight field = " << weightFieldName_ << nl;
|
Info<< " weight field = " << weightFieldName_ << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dict.found("orientedWeightField"))
|
|
||||||
{
|
|
||||||
if (regionType_ == stSurface || regionType_ == stSampledSurface)
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "Cannot use orientedWeightField "
|
|
||||||
<< "for surface/sampledSurface"
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (weightFieldName_ == "none")
|
|
||||||
{
|
|
||||||
dict.lookup("orientedWeightField") >> weightFieldName_;
|
|
||||||
orientWeightField_ = true;
|
|
||||||
|
|
||||||
Info<< " weight field = " << weightFieldName_ << nl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "Cannot specify both weightField and orientedWeightField"
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Backwards compatibility for v1612+ and older
|
||||||
List<word> orientedFields;
|
List<word> orientedFields;
|
||||||
orientedFieldsStart_ = labelMax;
|
|
||||||
if (dict.readIfPresent("orientedFields", orientedFields))
|
if (dict.readIfPresent("orientedFields", orientedFields))
|
||||||
{
|
{
|
||||||
orientedFieldsStart_ = fields_.size();
|
WarningInFunction
|
||||||
|
<< "The 'orientedFields' option is deprecated. These fields can "
|
||||||
|
<< "and have been added to the standard 'fields' list."
|
||||||
|
<< endl;
|
||||||
|
|
||||||
fields_.append(orientedFields);
|
fields_.append(orientedFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
surfaceWriterPtr_.clear();
|
surfaceWriterPtr_.clear();
|
||||||
if (writeFields_)
|
if (writeFields_)
|
||||||
{
|
{
|
||||||
@ -854,8 +839,6 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
|
|||||||
[dict.lookupOrDefault<word>("postOperation", "none")]
|
[dict.lookupOrDefault<word>("postOperation", "none")]
|
||||||
),
|
),
|
||||||
weightFieldName_("none"),
|
weightFieldName_("none"),
|
||||||
orientWeightField_(false),
|
|
||||||
orientedFieldsStart_(labelMax),
|
|
||||||
writeArea_(dict.lookupOrDefault("writeArea", false)),
|
writeArea_(dict.lookupOrDefault("writeArea", false)),
|
||||||
nFaces_(0),
|
nFaces_(0),
|
||||||
faceId_(),
|
faceId_(),
|
||||||
@ -883,8 +866,6 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
|
|||||||
[dict.lookupOrDefault<word>("postOperation", "none")]
|
[dict.lookupOrDefault<word>("postOperation", "none")]
|
||||||
),
|
),
|
||||||
weightFieldName_("none"),
|
weightFieldName_("none"),
|
||||||
orientWeightField_(false),
|
|
||||||
orientedFieldsStart_(labelMax),
|
|
||||||
writeArea_(dict.lookupOrDefault("writeArea", false)),
|
writeArea_(dict.lookupOrDefault("writeArea", false)),
|
||||||
nFaces_(0),
|
nFaces_(0),
|
||||||
faceId_(),
|
faceId_(),
|
||||||
@ -959,7 +940,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Sf = filterField(mesh_.Sf(), true); // Oriented Sf
|
Sf = filterField(mesh_.Sf());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -988,12 +969,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
|
|||||||
{
|
{
|
||||||
scalarField weightField
|
scalarField weightField
|
||||||
(
|
(
|
||||||
getFieldValues<scalar>
|
getFieldValues<scalar>(weightFieldName_, true)
|
||||||
(
|
|
||||||
weightFieldName_,
|
|
||||||
true,
|
|
||||||
orientWeightField_
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Process the fields
|
// Process the fields
|
||||||
@ -1003,12 +979,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
|
|||||||
{
|
{
|
||||||
vectorField weightField
|
vectorField weightField
|
||||||
(
|
(
|
||||||
getFieldValues<vector>
|
getFieldValues<vector>(weightFieldName_, true)
|
||||||
(
|
|
||||||
weightFieldName_,
|
|
||||||
true,
|
|
||||||
orientWeightField_
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Process the fields
|
// Process the fields
|
||||||
|
|||||||
@ -91,7 +91,6 @@ Usage
|
|||||||
orientedWeightField | name of oriented field to apply weighting | no |
|
orientedWeightField | name of oriented field to apply weighting | no |
|
||||||
scaleFactor | scale factor | no | 1
|
scaleFactor | scale factor | no | 1
|
||||||
fields | list of fields to operate on | yes |
|
fields | list of fields to operate on | yes |
|
||||||
orientedFields | list of oriented fields to operate on | no |
|
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
Where \c regionType is defined by
|
Where \c regionType is defined by
|
||||||
@ -130,8 +129,6 @@ Note
|
|||||||
- faces on empty patches get ignored
|
- faces on empty patches get ignored
|
||||||
- if the field is a volField the \c faceZone can only consist of boundary
|
- if the field is a volField the \c faceZone can only consist of boundary
|
||||||
faces
|
faces
|
||||||
- the `oriented' entries relate to mesh-oriented fields, such as the
|
|
||||||
flux, phi. These fields will be oriented according to the face normals.
|
|
||||||
- Using \c surface:
|
- Using \c surface:
|
||||||
- The keyword %subRegion should not be used to select surfaces.
|
- The keyword %subRegion should not be used to select surfaces.
|
||||||
Specify instead the regionType 'surface' and provide the surface name.
|
Specify instead the regionType 'surface' and provide the surface name.
|
||||||
@ -285,12 +282,6 @@ protected:
|
|||||||
//- Weight field name - optional
|
//- Weight field name - optional
|
||||||
word weightFieldName_;
|
word weightFieldName_;
|
||||||
|
|
||||||
//- Flag to indicate if flipMap should be applied to the weight field
|
|
||||||
bool orientWeightField_;
|
|
||||||
|
|
||||||
//- Start index of fields that require application of flipMap
|
|
||||||
label orientedFieldsStart_;
|
|
||||||
|
|
||||||
//- Total area of the surfaceFieldValue
|
//- Total area of the surfaceFieldValue
|
||||||
scalar totalArea_;
|
scalar totalArea_;
|
||||||
|
|
||||||
@ -353,8 +344,7 @@ protected:
|
|||||||
tmp<Field<Type>> getFieldValues
|
tmp<Field<Type>> getFieldValues
|
||||||
(
|
(
|
||||||
const word& fieldName,
|
const word& fieldName,
|
||||||
const bool mustGet = false,
|
const bool mustGet = false
|
||||||
const bool applyOrientation = false
|
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Apply the 'operation' to the values. Operation must preserve Type.
|
//- Apply the 'operation' to the values. Operation must preserve Type.
|
||||||
@ -380,16 +370,14 @@ protected:
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
tmp<Field<Type>> filterField
|
tmp<Field<Type>> filterField
|
||||||
(
|
(
|
||||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& field,
|
const GeometricField<Type, fvsPatchField, surfaceMesh>& field
|
||||||
const bool applyOrientation
|
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Filter a volume field according to faceIds
|
//- Filter a volume field according to faceIds
|
||||||
template<class Type>
|
template<class Type>
|
||||||
tmp<Field<Type>> filterField
|
tmp<Field<Type>> filterField
|
||||||
(
|
(
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& field,
|
const GeometricField<Type, fvPatchField, volMesh>& field
|
||||||
const bool applyOrientation
|
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Weighting factor
|
//- Weighting factor
|
||||||
@ -424,7 +412,6 @@ protected:
|
|||||||
const word& fieldName,
|
const word& fieldName,
|
||||||
const vectorField& Sf,
|
const vectorField& Sf,
|
||||||
const Field<WeightType>& weightField,
|
const Field<WeightType>& weightField,
|
||||||
const bool orient,
|
|
||||||
const meshedSurf& surfToWrite
|
const meshedSurf& surfToWrite
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -57,8 +57,7 @@ Foam::tmp<Foam::Field<Type>>
|
|||||||
Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
|
Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
|
||||||
(
|
(
|
||||||
const word& fieldName,
|
const word& fieldName,
|
||||||
const bool mustGet,
|
const bool mustGet
|
||||||
const bool applyOrientation
|
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
|
||||||
@ -71,7 +70,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
|
|||||||
}
|
}
|
||||||
else if (regionType_ != stSampledSurface && foundObject<sf>(fieldName))
|
else if (regionType_ != stSampledSurface && foundObject<sf>(fieldName))
|
||||||
{
|
{
|
||||||
return filterField(lookupObject<sf>(fieldName), applyOrientation);
|
return filterField(lookupObject<sf>(fieldName));
|
||||||
}
|
}
|
||||||
else if (foundObject<vf>(fieldName))
|
else if (foundObject<vf>(fieldName))
|
||||||
{
|
{
|
||||||
@ -112,7 +111,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return filterField(fld, applyOrientation);
|
return filterField(fld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +139,9 @@ processSameTypeValues
|
|||||||
switch (operation_)
|
switch (operation_)
|
||||||
{
|
{
|
||||||
case opNone:
|
case opNone:
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case opSum:
|
case opSum:
|
||||||
{
|
{
|
||||||
result = gSum(values);
|
result = gSum(values);
|
||||||
@ -258,8 +259,10 @@ processSameTypeValues
|
|||||||
|
|
||||||
case opAreaNormalAverage:
|
case opAreaNormalAverage:
|
||||||
case opAreaNormalIntegrate:
|
case opAreaNormalIntegrate:
|
||||||
// handled in specializations only
|
{
|
||||||
|
// Handled in specializations only
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -302,30 +305,17 @@ Foam::label Foam::functionObjects::fieldValues::surfaceFieldValue::writeAll
|
|||||||
forAll(fields_, i)
|
forAll(fields_, i)
|
||||||
{
|
{
|
||||||
const word& fieldName = fields_[i];
|
const word& fieldName = fields_[i];
|
||||||
const bool orient = (i >= orientedFieldsStart_);
|
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
writeValues<scalar>
|
writeValues<scalar>(fieldName, Sf, weightField, surfToWrite)
|
||||||
(
|
|| writeValues<vector>(fieldName, Sf, weightField, surfToWrite)
|
||||||
fieldName, Sf, weightField, orient, surfToWrite
|
|
||||||
)
|
|
||||||
|| writeValues<vector>
|
|
||||||
(
|
|
||||||
fieldName, Sf, weightField, orient, surfToWrite
|
|
||||||
)
|
|
||||||
|| writeValues<sphericalTensor>
|
|| writeValues<sphericalTensor>
|
||||||
(
|
(
|
||||||
fieldName, Sf, weightField, orient, surfToWrite
|
fieldName, Sf, weightField, surfToWrite
|
||||||
)
|
|
||||||
|| writeValues<symmTensor>
|
|
||||||
(
|
|
||||||
fieldName, Sf, weightField, orient, surfToWrite
|
|
||||||
)
|
|
||||||
|| writeValues<tensor>
|
|
||||||
(
|
|
||||||
fieldName, Sf, weightField, orient, surfToWrite
|
|
||||||
)
|
)
|
||||||
|
|| writeValues<symmTensor>(fieldName, Sf, weightField, surfToWrite)
|
||||||
|
|| writeValues<tensor>(fieldName, Sf, weightField, surfToWrite)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
++nProcessed;
|
++nProcessed;
|
||||||
@ -349,7 +339,6 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
|
|||||||
const word& fieldName,
|
const word& fieldName,
|
||||||
const vectorField& Sf,
|
const vectorField& Sf,
|
||||||
const Field<WeightType>& weightField,
|
const Field<WeightType>& weightField,
|
||||||
const bool orient,
|
|
||||||
const meshedSurf& surfToWrite
|
const meshedSurf& surfToWrite
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -357,7 +346,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
|
|||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
Field<Type> values(getFieldValues<Type>(fieldName, true, orient));
|
Field<Type> values(getFieldValues<Type>(fieldName, true));
|
||||||
|
|
||||||
// Write raw values on surface if specified
|
// Write raw values on surface if specified
|
||||||
if (surfaceWriterPtr_.valid())
|
if (surfaceWriterPtr_.valid())
|
||||||
@ -389,7 +378,9 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
|
|||||||
switch (postOperation_)
|
switch (postOperation_)
|
||||||
{
|
{
|
||||||
case postOpNone:
|
case postOpNone:
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case postOpSqrt:
|
case postOpSqrt:
|
||||||
{
|
{
|
||||||
// sqrt: component-wise - doesn't change the type
|
// sqrt: component-wise - doesn't change the type
|
||||||
@ -438,8 +429,7 @@ template<class Type>
|
|||||||
Foam::tmp<Foam::Field<Type>>
|
Foam::tmp<Foam::Field<Type>>
|
||||||
Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
|
Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
|
||||||
(
|
(
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& field,
|
const GeometricField<Type, fvPatchField, volMesh>& field
|
||||||
const bool applyOrientation
|
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size()));
|
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size()));
|
||||||
@ -464,16 +454,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (applyOrientation)
|
// No need to flip values - all boundary faces point outwards
|
||||||
{
|
|
||||||
forAll(values, i)
|
|
||||||
{
|
|
||||||
if (faceFlip_[i])
|
|
||||||
{
|
|
||||||
values[i] *= -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tvalues;
|
return tvalues;
|
||||||
}
|
}
|
||||||
@ -483,8 +464,7 @@ template<class Type>
|
|||||||
Foam::tmp<Foam::Field<Type>>
|
Foam::tmp<Foam::Field<Type>>
|
||||||
Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
|
Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
|
||||||
(
|
(
|
||||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& field,
|
const GeometricField<Type, fvsPatchField, surfaceMesh>& field
|
||||||
const bool applyOrientation
|
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size()));
|
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size()));
|
||||||
@ -504,7 +484,13 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (applyOrientation)
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "field " << field.name() << " oriented: "
|
||||||
|
<< field.oriented()() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field.oriented()())
|
||||||
{
|
{
|
||||||
forAll(values, i)
|
forAll(values, i)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user