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> facePatchIds(fZone.size());
|
||||
DynamicList<bool> faceFlip(fZone.size());
|
||||
DynamicList<bool> faceFlip(fZone.size());
|
||||
|
||||
forAll(fZone, i)
|
||||
{
|
||||
@ -459,7 +459,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea() const
|
||||
}
|
||||
else
|
||||
{
|
||||
totalArea = gSum(filterField(mesh_.magSf(), false));
|
||||
totalArea = gSum(filterField(mesh_.magSf()));
|
||||
}
|
||||
|
||||
return totalArea;
|
||||
@ -479,10 +479,13 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::needsSf() const
|
||||
case opAverage:
|
||||
case opMin:
|
||||
case opMax:
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
default:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -496,10 +499,13 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::needsWeight() const
|
||||
case opWeightedAverage:
|
||||
case opWeightedAreaAverage:
|
||||
case opWeightedAreaIntegrate:
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -596,7 +602,6 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
|
||||
|
||||
|
||||
weightFieldName_ = "none";
|
||||
orientWeightField_ = false;
|
||||
if (needsWeight())
|
||||
{
|
||||
if (dict.readIfPresent("weightField", weightFieldName_))
|
||||
@ -610,41 +615,21 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
|
||||
|
||||
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;
|
||||
orientedFieldsStart_ = labelMax;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
surfaceWriterPtr_.clear();
|
||||
if (writeFields_)
|
||||
{
|
||||
@ -854,8 +839,6 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
|
||||
[dict.lookupOrDefault<word>("postOperation", "none")]
|
||||
),
|
||||
weightFieldName_("none"),
|
||||
orientWeightField_(false),
|
||||
orientedFieldsStart_(labelMax),
|
||||
writeArea_(dict.lookupOrDefault("writeArea", false)),
|
||||
nFaces_(0),
|
||||
faceId_(),
|
||||
@ -883,8 +866,6 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
|
||||
[dict.lookupOrDefault<word>("postOperation", "none")]
|
||||
),
|
||||
weightFieldName_("none"),
|
||||
orientWeightField_(false),
|
||||
orientedFieldsStart_(labelMax),
|
||||
writeArea_(dict.lookupOrDefault("writeArea", false)),
|
||||
nFaces_(0),
|
||||
faceId_(),
|
||||
@ -959,7 +940,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
|
||||
}
|
||||
else
|
||||
{
|
||||
Sf = filterField(mesh_.Sf(), true); // Oriented Sf
|
||||
Sf = filterField(mesh_.Sf());
|
||||
}
|
||||
}
|
||||
|
||||
@ -988,12 +969,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
|
||||
{
|
||||
scalarField weightField
|
||||
(
|
||||
getFieldValues<scalar>
|
||||
(
|
||||
weightFieldName_,
|
||||
true,
|
||||
orientWeightField_
|
||||
)
|
||||
getFieldValues<scalar>(weightFieldName_, true)
|
||||
);
|
||||
|
||||
// Process the fields
|
||||
@ -1003,12 +979,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
|
||||
{
|
||||
vectorField weightField
|
||||
(
|
||||
getFieldValues<vector>
|
||||
(
|
||||
weightFieldName_,
|
||||
true,
|
||||
orientWeightField_
|
||||
)
|
||||
getFieldValues<vector>(weightFieldName_, true)
|
||||
);
|
||||
|
||||
// Process the fields
|
||||
|
||||
@ -91,7 +91,6 @@ Usage
|
||||
orientedWeightField | name of oriented field to apply weighting | no |
|
||||
scaleFactor | scale factor | no | 1
|
||||
fields | list of fields to operate on | yes |
|
||||
orientedFields | list of oriented fields to operate on | no |
|
||||
\endtable
|
||||
|
||||
Where \c regionType is defined by
|
||||
@ -130,8 +129,6 @@ Note
|
||||
- faces on empty patches get ignored
|
||||
- if the field is a volField the \c faceZone can only consist of boundary
|
||||
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:
|
||||
- The keyword %subRegion should not be used to select surfaces.
|
||||
Specify instead the regionType 'surface' and provide the surface name.
|
||||
@ -285,12 +282,6 @@ protected:
|
||||
//- Weight field name - optional
|
||||
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
|
||||
scalar totalArea_;
|
||||
|
||||
@ -353,8 +344,7 @@ protected:
|
||||
tmp<Field<Type>> getFieldValues
|
||||
(
|
||||
const word& fieldName,
|
||||
const bool mustGet = false,
|
||||
const bool applyOrientation = false
|
||||
const bool mustGet = false
|
||||
) const;
|
||||
|
||||
//- Apply the 'operation' to the values. Operation must preserve Type.
|
||||
@ -380,16 +370,14 @@ protected:
|
||||
template<class Type>
|
||||
tmp<Field<Type>> filterField
|
||||
(
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& field,
|
||||
const bool applyOrientation
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& field
|
||||
) const;
|
||||
|
||||
//- Filter a volume field according to faceIds
|
||||
template<class Type>
|
||||
tmp<Field<Type>> filterField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field,
|
||||
const bool applyOrientation
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field
|
||||
) const;
|
||||
|
||||
//- Weighting factor
|
||||
@ -424,7 +412,6 @@ protected:
|
||||
const word& fieldName,
|
||||
const vectorField& Sf,
|
||||
const Field<WeightType>& weightField,
|
||||
const bool orient,
|
||||
const meshedSurf& surfToWrite
|
||||
);
|
||||
|
||||
|
||||
@ -57,8 +57,7 @@ Foam::tmp<Foam::Field<Type>>
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
|
||||
(
|
||||
const word& fieldName,
|
||||
const bool mustGet,
|
||||
const bool applyOrientation
|
||||
const bool mustGet
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
|
||||
@ -71,7 +70,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
|
||||
}
|
||||
else if (regionType_ != stSampledSurface && foundObject<sf>(fieldName))
|
||||
{
|
||||
return filterField(lookupObject<sf>(fieldName), applyOrientation);
|
||||
return filterField(lookupObject<sf>(fieldName));
|
||||
}
|
||||
else if (foundObject<vf>(fieldName))
|
||||
{
|
||||
@ -112,7 +111,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
|
||||
}
|
||||
else
|
||||
{
|
||||
return filterField(fld, applyOrientation);
|
||||
return filterField(fld);
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,7 +139,9 @@ processSameTypeValues
|
||||
switch (operation_)
|
||||
{
|
||||
case opNone:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case opSum:
|
||||
{
|
||||
result = gSum(values);
|
||||
@ -258,8 +259,10 @@ processSameTypeValues
|
||||
|
||||
case opAreaNormalAverage:
|
||||
case opAreaNormalIntegrate:
|
||||
// handled in specializations only
|
||||
{
|
||||
// Handled in specializations only
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -302,30 +305,17 @@ Foam::label Foam::functionObjects::fieldValues::surfaceFieldValue::writeAll
|
||||
forAll(fields_, i)
|
||||
{
|
||||
const word& fieldName = fields_[i];
|
||||
const bool orient = (i >= orientedFieldsStart_);
|
||||
|
||||
if
|
||||
(
|
||||
writeValues<scalar>
|
||||
(
|
||||
fieldName, Sf, weightField, orient, surfToWrite
|
||||
)
|
||||
|| writeValues<vector>
|
||||
(
|
||||
fieldName, Sf, weightField, orient, surfToWrite
|
||||
)
|
||||
writeValues<scalar>(fieldName, Sf, weightField, surfToWrite)
|
||||
|| writeValues<vector>(fieldName, Sf, weightField, surfToWrite)
|
||||
|| writeValues<sphericalTensor>
|
||||
(
|
||||
fieldName, Sf, weightField, orient, surfToWrite
|
||||
)
|
||||
|| writeValues<symmTensor>
|
||||
(
|
||||
fieldName, Sf, weightField, orient, surfToWrite
|
||||
)
|
||||
|| writeValues<tensor>
|
||||
(
|
||||
fieldName, Sf, weightField, orient, surfToWrite
|
||||
fieldName, Sf, weightField, surfToWrite
|
||||
)
|
||||
|| writeValues<symmTensor>(fieldName, Sf, weightField, surfToWrite)
|
||||
|| writeValues<tensor>(fieldName, Sf, weightField, surfToWrite)
|
||||
)
|
||||
{
|
||||
++nProcessed;
|
||||
@ -349,7 +339,6 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
|
||||
const word& fieldName,
|
||||
const vectorField& Sf,
|
||||
const Field<WeightType>& weightField,
|
||||
const bool orient,
|
||||
const meshedSurf& surfToWrite
|
||||
)
|
||||
{
|
||||
@ -357,7 +346,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
|
||||
|
||||
if (ok)
|
||||
{
|
||||
Field<Type> values(getFieldValues<Type>(fieldName, true, orient));
|
||||
Field<Type> values(getFieldValues<Type>(fieldName, true));
|
||||
|
||||
// Write raw values on surface if specified
|
||||
if (surfaceWriterPtr_.valid())
|
||||
@ -389,7 +378,9 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
|
||||
switch (postOperation_)
|
||||
{
|
||||
case postOpNone:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case postOpSqrt:
|
||||
{
|
||||
// sqrt: component-wise - doesn't change the type
|
||||
@ -438,8 +429,7 @@ template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field,
|
||||
const bool applyOrientation
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field
|
||||
) const
|
||||
{
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size()));
|
||||
@ -464,16 +454,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
|
||||
}
|
||||
}
|
||||
|
||||
if (applyOrientation)
|
||||
{
|
||||
forAll(values, i)
|
||||
{
|
||||
if (faceFlip_[i])
|
||||
{
|
||||
values[i] *= -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// No need to flip values - all boundary faces point outwards
|
||||
|
||||
return tvalues;
|
||||
}
|
||||
@ -483,8 +464,7 @@ template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
|
||||
(
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& field,
|
||||
const bool applyOrientation
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& field
|
||||
) const
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user