ENH: support operations on surfFields in surfaceFieldValue

- this makes it possible to perform additional operations
  on surface values that have been previously sampled.

- support vectorField for weighting operations.

- reduce overhead by avoiding creation of weight fields, Sf fields
  and combined surface geometries unless they are actually required.

- extend some similar concepts and operations to volFieldValue
This commit is contained in:
Mark Olesen
2017-03-02 14:50:36 +01:00
parent 3f1c72356f
commit 2853678a60
45 changed files with 130798 additions and 374 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -87,7 +87,7 @@ protected:
);
//- The region or sub-region registry being used
const objectRegistry& obr() const;
virtual const objectRegistry& obr() const;
//- Find object (eg, a field) in the (sub) objectRegistry
@ -176,7 +176,7 @@ public:
// Member Functions
//- Read optional controls
virtual bool read(const dictionary&);
virtual bool read(const dictionary& dict) override;
};

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,6 +31,7 @@ License
#include "mergePoints.H"
#include "indirectPrimitivePatch.H"
#include "PatchTools.H"
#include "meshedSurfRef.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -52,11 +53,12 @@ template<>
const char* Foam::NamedEnum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes,
3
4
>::names[] =
{
"faceZone",
"patch",
"surface",
"sampledSurface"
};
@ -64,12 +66,13 @@ template<>
const char* Foam::NamedEnum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
16
17
>::names[] =
{
"none",
"sum",
"sumMag",
"weightedSum",
"sumDirection",
"sumDirectionBalance",
"average",
@ -100,13 +103,13 @@ const char* Foam::NamedEnum
const Foam::NamedEnum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes,
3
4
> Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypeNames_;
const Foam::NamedEnum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
16
17
> Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_;
const Foam::NamedEnum
@ -119,9 +122,23 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationTypeNames_;
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
const Foam::objectRegistry&
Foam::functionObjects::fieldValues::surfaceFieldValue::obr() const
{
if (regionType_ == stSurface)
{
return mesh_.lookupObject<objectRegistry>(regionName_);
}
else
{
return mesh_;
}
}
void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
{
label zoneId = mesh_.faceZones().findZoneID(regionName_);
const label zoneId = mesh_.faceZones().findZoneID(regionName_);
if (zoneId < 0)
{
@ -137,11 +154,11 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
DynamicList<label> faceIds(fZone.size());
DynamicList<label> facePatchIds(fZone.size());
DynamicList<label> faceSigns(fZone.size());
DynamicList<bool> faceFlip(fZone.size());
forAll(fZone, i)
{
label facei = fZone[i];
const label facei = fZone[i];
label faceId = -1;
label facePatchId = -1;
@ -178,22 +195,15 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
if (faceId >= 0)
{
if (fZone.flipMap()[i])
{
faceSigns.append(-1);
}
else
{
faceSigns.append(1);
}
faceIds.append(faceId);
facePatchIds.append(facePatchId);
faceFlip.append(fZone.flipMap()[i] ? true : false);
}
}
faceId_.transfer(faceIds);
facePatchId_.transfer(facePatchIds);
faceSign_.transfer(faceSigns);
faceFlip_.transfer(faceFlip);
nFaces_ = returnReduce(faceId_.size(), sumOp<label>());
if (debug)
@ -229,34 +239,18 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setPatchFaces()
faceId_.setSize(nFaces);
facePatchId_.setSize(nFaces);
faceSign_.setSize(nFaces);
faceFlip_.setSize(nFaces);
nFaces_ = returnReduce(faceId_.size(), sumOp<label>());
forAll(faceId_, facei)
{
faceId_[facei] = facei;
facePatchId_[facei] = patchid;
faceSign_[facei] = 1;
faceFlip_[facei] = false;
}
}
void Foam::functionObjects::fieldValues::surfaceFieldValue::sampledSurfaceFaces
(
const dictionary& dict
)
{
surfacePtr_ = sampledSurface::New
(
name(),
mesh_,
dict.subDict("sampledSurfaceDict")
);
surfacePtr_().update();
nFaces_ = returnReduce(surfacePtr_().faces().size(), sumOp<label>());
}
void Foam::functionObjects::fieldValues::surfaceFieldValue::combineMeshGeometry
(
faceList& faces,
@ -385,14 +379,44 @@ combineSurfaceGeometry
pointField& points
) const
{
if (surfacePtr_.valid())
if (regionType_ == stSurface)
{
const surfMesh& s = dynamicCast<const surfMesh>(obr());
if (Pstream::parRun())
{
// Dimension as fraction of surface
const scalar mergeDim = 1e-10*boundBox(s.points(), true).mag();
labelList pointsMap;
PatchTools::gatherAndMerge
(
mergeDim,
primitivePatch
(
SubList<face>(s.faces(), s.faces().size()),
s.points()
),
points,
faces,
pointsMap
);
}
else
{
faces = s.faces();
points = s.points();
}
}
else if (surfacePtr_.valid())
{
const sampledSurface& s = surfacePtr_();
if (Pstream::parRun())
{
// Dimension as fraction of mesh bounding box
scalar mergeDim = 1e-10*mesh_.bounds().mag();
const scalar mergeDim = 1e-10*mesh_.bounds().mag();
labelList pointsMap;
@ -423,7 +447,13 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea() const
{
scalar totalArea;
if (surfacePtr_.valid())
if (regionType_ == stSurface)
{
const surfMesh& s = dynamicCast<const surfMesh>(obr());
totalArea = gSum(s.magSf());
}
else if (surfacePtr_.valid())
{
totalArea = gSum(surfacePtr_().magSf());
}
@ -438,6 +468,42 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea() const
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
bool Foam::functionObjects::fieldValues::surfaceFieldValue::needsSf() const
{
// Many operations use the Sf field
switch (operation_)
{
case opNone:
case opSum:
case opSumMag:
case opAverage:
case opMin:
case opMax:
return false;
default:
return true;
}
}
bool Foam::functionObjects::fieldValues::surfaceFieldValue::needsWeight() const
{
// Only a few operations use weight field
switch (operation_)
{
case opWeightedSum:
case opWeightedAverage:
case opWeightedAreaAverage:
case opWeightedAreaIntegrate:
return true;
default:
return false;
}
}
void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
(
const dictionary& dict
@ -450,16 +516,42 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
case stFaceZone:
{
setFaceZoneFaces();
surfacePtr_.clear();
break;
}
case stPatch:
{
setPatchFaces();
surfacePtr_.clear();
break;
}
case stSurface:
{
const surfMesh& s = dynamicCast<const surfMesh>(obr());
nFaces_ = returnReduce(s.size(), sumOp<label>());
faceId_.clear();
facePatchId_.clear();
faceFlip_.clear();
surfacePtr_.clear();
break;
}
case stSampledSurface:
{
sampledSurfaceFaces(dict);
faceId_.clear();
facePatchId_.clear();
faceFlip_.clear();
surfacePtr_ = sampledSurface::New
(
name(),
mesh_,
dict.subDict("sampledSurfaceDict")
);
surfacePtr_().update();
nFaces_ =
returnReduce(surfacePtr_().faces().size(), sumOp<label>());
break;
}
default:
@ -488,51 +580,78 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
totalArea_ = totalArea();
Info<< type() << " " << name() << ":" << nl
<< " total faces = " << nFaces_ << nl
<< " operation = ";
if (postOperation_ != postOpNone)
{
Info<< postOperationTypeNames_[postOperation_] << '('
<< operationTypeNames_[operation_] << ')' << nl;
}
else
{
Info<< operationTypeNames_[operation_] << nl;
}
Info<< " total faces = " << nFaces_ << nl
<< " total area = " << totalArea_ << nl;
weightFieldName_ = "none";
orientWeightField_ = false;
if (needsWeight())
{
if (dict.readIfPresent("weightField", weightFieldName_))
{
Info<< " weight field = " << weightFieldName_ << nl;
if (regionType_ == stSampledSurface)
{
FatalIOErrorInFunction(dict)
<< "Cannot use weightField for a sampledSurface"
<< "Cannot use weightField for sampledSurface"
<< exit(FatalIOError);
}
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_;
Info<< " weight field = " << weightFieldName_ << nl;
orientWeightField_ = true;
Info<< " weight field = " << weightFieldName_ << nl;
}
else
{
FatalIOErrorInFunction(dict)
<< "Either weightField or orientedWeightField can be supplied, "
<< "but not both"
<< "Cannot specify both weightField and orientedWeightField"
<< exit(FatalIOError);
}
}
}
List<word> orientedFields;
orientedFieldsStart_ = labelMax;
if (dict.readIfPresent("orientedFields", orientedFields))
{
orientedFieldsStart_ = fields_.size();
fields_.append(orientedFields);
}
Info<< nl << endl;
surfaceWriterPtr_.clear();
if (writeFields_)
{
const word surfaceFormat(dict.lookup("surfaceFormat"));
if (surfaceFormat != "none")
{
surfaceWriterPtr_.reset
(
surfaceWriter::New
@ -542,7 +661,12 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
subOrEmptyDict(surfaceFormat)
).ptr()
);
Info<< " surfaceFormat = " << surfaceFormat << nl;
}
}
Info<< nl << endl;
}
@ -583,8 +707,8 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::writeFileHeader
template<>
Foam::scalar Foam::functionObjects::fieldValues::surfaceFieldValue::
processValues
Foam::scalar
Foam::functionObjects::fieldValues::surfaceFieldValue::processValues
(
const Field<scalar>& values,
const vectorField& Sf,
@ -615,8 +739,8 @@ processValues
template<>
Foam::vector Foam::functionObjects::fieldValues::surfaceFieldValue::
processValues
Foam::vector
Foam::functionObjects::fieldValues::surfaceFieldValue::processValues
(
const Field<vector>& values,
const vectorField& Sf,
@ -629,27 +753,27 @@ processValues
{
vector n(dict_.lookup("direction"));
n /= mag(n) + ROOTVSMALL;
const scalarField nv(n & values);
const scalarField nv(n & values);
return gSum(pos(nv)*n*(nv));
}
case opSumDirectionBalance:
{
vector n(dict_.lookup("direction"));
n /= mag(n) + ROOTVSMALL;
const scalarField nv(n & values);
const scalarField nv(n & values);
return gSum(pos(nv)*n*(nv));
}
case opAreaNormalAverage:
{
scalar result = gSum(values & Sf)/gSum(mag(Sf));
return vector(result, 0.0, 0.0);
const scalar val = gSum(values & Sf)/gSum(mag(Sf));
return vector(val, 0, 0);
}
case opAreaNormalIntegrate:
{
scalar result = gSum(values & Sf);
return vector(result, 0.0, 0.0);
const scalar val = gSum(values & Sf);
return vector(val, 0, 0);
}
default:
{
@ -660,6 +784,58 @@ processValues
}
template<>
Foam::tmp<Foam::scalarField>
Foam::functionObjects::fieldValues::surfaceFieldValue::weightingFactor
(
const Field<scalar>& weightField
)
{
// pass through
return weightField;
}
template<>
Foam::tmp<Foam::scalarField>
Foam::functionObjects::fieldValues::surfaceFieldValue::weightingFactor
(
const Field<scalar>& weightField,
const vectorField& Sf
)
{
// scalar * Area
if (returnReduce(weightField.empty(), andOp<bool>()))
{
return mag(Sf);
}
else
{
return weightField * mag(Sf);
}
}
template<>
Foam::tmp<Foam::scalarField>
Foam::functionObjects::fieldValues::surfaceFieldValue::weightingFactor
(
const Field<vector>& weightField,
const vectorField& Sf
)
{
// vector (dot) Area
if (returnReduce(weightField.empty(), andOp<bool>()))
{
return mag(Sf);
}
else
{
return weightField & Sf;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
@ -670,7 +846,6 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
)
:
fieldValue(name, runTime, dict, typeName),
surfaceWriterPtr_(nullptr),
regionType_(regionTypeNames_.read(dict.lookup("regionType"))),
operation_(operationTypeNames_.read(dict.lookup("operation"))),
postOperation_
@ -685,7 +860,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
nFaces_(0),
faceId_(),
facePatchId_(),
faceSign_()
faceFlip_()
{
read(dict);
writeFileHeader(file());
@ -700,7 +875,6 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
)
:
fieldValue(name, obr, dict, typeName),
surfaceWriterPtr_(nullptr),
regionType_(regionTypeNames_.read(dict.lookup("regionType"))),
operation_(operationTypeNames_.read(dict.lookup("operation"))),
postOperation_
@ -715,7 +889,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
nFaces_(0),
faceId_(),
facePatchId_(),
faceSign_()
faceFlip_()
{
read(dict);
writeFileHeader(file());
@ -744,66 +918,111 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::read
bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
{
if (operation_ != opNone)
{
fieldValue::write();
}
if (surfacePtr_.valid())
{
surfacePtr_().update();
}
if (operation_ != opNone && Pstream::master())
if (operation_ != opNone)
{
fieldValue::write();
if (Pstream::master())
{
writeTime(file());
}
}
if (writeArea_)
{
totalArea_ = totalArea();
Log << " total area = " << totalArea_ << endl;
if (operation_ != opNone && Pstream::master())
{
file() << tab << totalArea_;
}
Log << " total area = " << totalArea_ << endl;
}
// Construct weight field. Note: zero size means weight = 1
scalarField weightField;
// Many operations use the Sf field
vectorField Sf;
if (needsSf())
{
if (regionType_ == stSurface)
{
const surfMesh& s = dynamicCast<const surfMesh>(obr());
Sf = s.Sf();
}
else if (surfacePtr_.valid())
{
Sf = surfacePtr_().Sf();
}
else
{
Sf = filterField(mesh_.Sf(), true); // Oriented Sf
}
}
// Faces and points for surface format (if specified)
faceList faces;
pointField points;
if (surfaceWriterPtr_.valid())
{
if (regionType_ == stSurface || surfacePtr_.valid())
{
combineSurfaceGeometry(faces, points);
}
else
{
combineMeshGeometry(faces, points);
}
}
meshedSurfRef surfToWrite(points, faces);
// Only a few weight types (scalar, vector)
if (weightFieldName_ != "none")
{
weightField =
getFieldValues<scalar>
if (validField<scalar>(weightFieldName_))
{
scalarField weightField = getFieldValues<scalar>
(
weightFieldName_,
true,
orientWeightField_
);
}
// Process the fields
forAll(fields_, i)
{
const word& fieldName = fields_[i];
bool ok = false;
bool orient = i >= orientedFieldsStart_;
ok = ok || writeValues<scalar>(fieldName, weightField, orient);
ok = ok || writeValues<vector>(fieldName, weightField, orient);
ok = ok
|| writeValues<sphericalTensor>(fieldName, weightField, orient);
ok = ok || writeValues<symmTensor>(fieldName, weightField, orient);
ok = ok || writeValues<tensor>(fieldName, weightField, orient);
if (!ok)
{
WarningInFunction
<< "Requested field " << fieldName
<< " not found in database and not processed"
<< endl;
writeAll(Sf, weightField, surfToWrite);
}
else if (validField<vector>(weightFieldName_))
{
vectorField weightField = getFieldValues<vector>
(
weightFieldName_,
true,
orientWeightField_
);
// Process the fields
writeAll(Sf, weightField, surfToWrite);
}
else
{
FatalErrorInFunction
<< "weightField " << weightFieldName_
<< " not found or an unsupported type"
<< abort(FatalError);
}
}
else
{
// Default is a zero-size scalar weight field (ie, weight = 1)
scalarField weightField;
// Process the fields
writeAll(Sf, weightField, surfToWrite);
}
if (operation_ != opNone && Pstream::master())

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -98,6 +98,7 @@ Usage
\plaintable
faceZone | requires a 'name' entry to specify the faceZone
patch | requires a 'name' entry to specify the patch
surface | requires a 'name' entry to specify the surfMesh
sampledSurface | requires a 'sampledSurfaceDict' sub-dictionary
\endplaintable
@ -105,6 +106,7 @@ Usage
\plaintable
none | no operation
sum | sum
weightedSum | weighted sum
sumMag | sum of component magnitudes
sumDirection | sum values which are positive in given direction
sumDirectionBalance | sum of balance of values in given direction
@ -130,6 +132,9 @@ Note
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.
- using \c sampledSurface:
- not available for surface fields
- if interpolate=true they use \c interpolationCellPoint
@ -155,7 +160,7 @@ SourceFiles
#include "fieldValue.H"
#include "NamedEnum.H"
#include "faceList.H"
#include "meshedSurf.H"
#include "surfaceMesh.H"
#include "fvsPatchField.H"
#include "volFieldsFwd.H"
@ -182,21 +187,21 @@ class surfaceFieldValue
:
public fieldValue
{
public:
// Public data types
//- region type enumeration
//- Region type enumeration
enum regionTypes
{
stFaceZone,
stPatch,
stSurface,
stSampledSurface
};
//- region type names
static const NamedEnum<regionTypes, 3> regionTypeNames_;
//- Region type names
static const NamedEnum<regionTypes, 4> regionTypeNames_;
//- Operation type enumeration
@ -204,6 +209,7 @@ public:
{
opNone, //!< None
opSum, //!< Sum
opWeightedSum, //!< Weighted sum
opSumMag, //!< Magnitude of sum
opSumDirection, //!< Sum in a given direction
opSumDirectionBalance, //!< Sum in a given direction for multiple
@ -221,7 +227,7 @@ public:
};
//- Operation type names
static const NamedEnum<operationType, 16> operationTypeNames_;
static const NamedEnum<operationType, 17> operationTypeNames_;
//- Post-operation type enumeration
@ -245,9 +251,6 @@ private:
//- Set faces to evaluate based on a patch
void setPatchFaces();
//- Set faces according to sampledSurface
void sampledSurfaceFaces(const dictionary&);
//- Combine mesh faces and points from multiple processors
void combineMeshGeometry
(
@ -270,10 +273,7 @@ protected:
// Protected data
//- Surface writer
autoPtr<surfaceWriter> surfaceWriterPtr_;
//- region type
//- Region type
regionTypes regionType_;
//- Operation to apply to values
@ -309,23 +309,42 @@ protected:
//- Local list of patch ID per face
labelList facePatchId_;
//- List of +1/-1 representing face flip map
// (1 use as is, -1 negate)
labelList faceSign_;
//- List representing the face flip map
// (false: use as-is, true: negate)
boolList faceFlip_;
// If operating on sampledSurface
//- Underlying sampledSurface
//- Underlying sampledSurface (if operating on sampledSurface)
autoPtr<sampledSurface> surfacePtr_;
//- Surface writer
autoPtr<surfaceWriter> surfaceWriterPtr_;
// Protected Member Functions
//- The volume mesh or surface registry being used
const objectRegistry& obr() const override;
//- Return the local list of face IDs
inline const labelList& faceId() const;
//- Return the local list of patch ID per face
inline const labelList& facePatch() const;
//- Return the local true/false list representing the face flip map
inline const boolList& faceFlip() const;
//- True if the specified operation needs a surface Sf
bool needsSf() const;
//- True if the specified operation needs a weight-field
bool needsWeight() const;
//- Initialise, e.g. face addressing
void initialise(const dictionary& dict);
//- Return true if the field name is valid
//- Return true if the field name is known and a valid type
template<class Type>
bool validField(const word& fieldName) const;
@ -338,26 +357,78 @@ protected:
const bool applyOrientation = false
) const;
//- Apply the 'operation' to the values. Operation has to
// preserve Type.
template<class Type>
//- Apply the 'operation' to the values. Operation must preserve Type.
template<class Type, class WeightType>
Type processSameTypeValues
(
const Field<Type>& values,
const vectorField& Sf,
const scalarField& weightField
const Field<WeightType>& weightField
) const;
//- Apply the 'operation' to the values. Wrapper around
// processSameTypeValues. See also template specialisation below.
template<class Type>
template<class Type, class WeightType>
Type processValues
(
const Field<Type>& values,
const vectorField& Sf,
const scalarField& weightField
const Field<WeightType>& weightField
) const;
//- Filter a surface field according to faceIds
template<class Type>
tmp<Field<Type>> filterField
(
const GeometricField<Type, fvsPatchField, surfaceMesh>& field,
const bool applyOrientation
) 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;
//- Weighting factor
template<class WeightType>
static tmp<scalarField> weightingFactor
(
const Field<WeightType>& weightField
);
//- Weighting factor, weight field with the area
template<class WeightType>
static tmp<scalarField> weightingFactor
(
const Field<WeightType>& weightField,
const vectorField& Sf
);
//- Templated helper function to output field values
template<class WeightType>
label writeAll
(
const vectorField& Sf,
const Field<WeightType>& weightField,
const meshedSurf& surfToWrite
);
//- Templated helper function to output field values
template<class Type, class WeightType>
bool writeValues
(
const word& fieldName,
const vectorField& Sf,
const Field<WeightType>& weightField,
const bool orient,
const meshedSurf& surfToWrite
);
//- Output file header information
virtual void writeFileHeader(Ostream& os) const;
@ -396,52 +467,18 @@ public:
//- Return the region type
inline const regionTypes& regionType() const;
//- Return the local list of face IDs
inline const labelList& faceId() const;
//- Return the local list of patch ID per face
inline const labelList& facePatch() const;
//- Return the list of +1/-1 representing face flip map
inline const labelList& faceSign() const;
//- Return the output directory
inline fileName outputDir() const;
//- Templated helper function to output field values
template<class Type, class WeightType>
bool writeValues
(
const word& fieldName,
const Field<WeightType>& weightField,
const bool orient
);
//- Filter a surface field according to faceIds
template<class Type>
tmp<Field<Type>> filterField
(
const GeometricField<Type, fvsPatchField, surfaceMesh>& field,
const bool applyOrientation
) 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;
//- Read from dictionary
virtual bool read(const dictionary&);
virtual bool read(const dictionary& dict) override;
//- Calculate and write
virtual bool write();
virtual bool write() override;
};
//- Specialisation for scalar
//- Specialisation for scalar fields
template<>
scalar surfaceFieldValue::processValues
(
@ -451,7 +488,7 @@ scalar surfaceFieldValue::processValues
) const;
//- Specialisation for vector
//- Specialisation for vector fields
template<>
vector surfaceFieldValue::processValues
(
@ -461,6 +498,32 @@ vector surfaceFieldValue::processValues
) const;
//- Specialisation for scalar - pass through
template<>
tmp<scalarField> surfaceFieldValue::weightingFactor
(
const Field<scalar>& weightField
);
//- Specialisation for scalar - scalar * Area
template<>
tmp<scalarField> surfaceFieldValue::weightingFactor
(
const Field<scalar>& weightField,
const vectorField& Sf
);
//- Specialisation for vector - vector (dot) Area
template<>
tmp<scalarField> surfaceFieldValue::weightingFactor
(
const Field<vector>& weightField,
const vectorField& Sf
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fieldValues

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,14 +26,7 @@ License
#include "surfaceFieldValue.H"
#include "Time.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes&
Foam::functionObjects::fieldValues::surfaceFieldValue::regionType() const
{
return regionType_;
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
inline const Foam::labelList&
Foam::functionObjects::fieldValues::surfaceFieldValue::faceId() const
@ -49,10 +42,19 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::facePatch() const
}
inline const Foam::labelList&
Foam::functionObjects::fieldValues::surfaceFieldValue::faceSign() const
inline const Foam::boolList&
Foam::functionObjects::fieldValues::surfaceFieldValue::faceFlip() const
{
return faceSign_;
return faceFlip_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes&
Foam::functionObjects::fieldValues::surfaceFieldValue::regionType() const
{
return regionType_;
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,6 +25,7 @@ License
#include "surfaceFieldValue.H"
#include "surfaceFields.H"
#include "surfFields.H"
#include "volFields.H"
#include "sampledSurface.H"
#include "surfaceWriter.H"
@ -40,17 +41,14 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::validField
{
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
typedef GeometricField<Type, fvPatchField, volMesh> vf;
typedef DimensionedField<Type, surfGeoMesh> smt;
if (regionType_ != stSampledSurface && obr_.foundObject<sf>(fieldName))
{
return true;
}
else if (obr_.foundObject<vf>(fieldName))
{
return true;
}
return false;
return
(
foundObject<smt>(fieldName)
|| foundObject<vf>(fieldName)
|| (regionType_ != stSampledSurface && foundObject<sf>(fieldName))
);
}
@ -65,14 +63,19 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
{
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
typedef GeometricField<Type, fvPatchField, volMesh> vf;
typedef DimensionedField<Type, surfGeoMesh> smt;
if (regionType_ != stSampledSurface && obr_.foundObject<sf>(fieldName))
if (foundObject<smt>(fieldName))
{
return filterField(obr_.lookupObject<sf>(fieldName), applyOrientation);
return lookupObject<smt>(fieldName);
}
else if (obr_.foundObject<vf>(fieldName))
else if (regionType_ != stSampledSurface && foundObject<sf>(fieldName))
{
const vf& fld = obr_.lookupObject<vf>(fieldName);
return filterField(lookupObject<sf>(fieldName), applyOrientation);
}
else if (foundObject<vf>(fieldName))
{
const vf& fld = lookupObject<vf>(fieldName);
if (surfacePtr_.valid())
{
@ -124,39 +127,45 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
}
template<class Type>
template<class Type, class WeightType>
Type Foam::functionObjects::fieldValues::surfaceFieldValue::
processSameTypeValues
(
const Field<Type>& values,
const vectorField& Sf,
const scalarField& weightField
const Field<WeightType>& weightField
) const
{
Type result = Zero;
switch (operation_)
{
case opNone:
break;
case opSum:
{
result = gSum(values);
break;
}
case opWeightedSum:
{
if (returnReduce(weightField.empty(), andOp<bool>()))
{
result = gSum(values);
}
else
{
tmp<scalarField> weight = weightingFactor(weightField);
result = gSum(weight*values);
}
break;
}
case opSumMag:
{
result = gSum(cmptMag(values));
break;
}
case opSumDirection:
{
FatalErrorInFunction
<< "Operation " << operationTypeNames_[operation_]
<< " not available for values of type "
<< pTraits<Type>::typeName
<< exit(FatalError);
result = Zero;
break;
}
case opSumDirectionBalance:
{
FatalErrorInFunction
@ -165,27 +174,26 @@ processSameTypeValues
<< pTraits<Type>::typeName
<< exit(FatalError);
result = Zero;
break;
}
case opAverage:
{
label n = returnReduce(values.size(), sumOp<label>());
const label n = returnReduce(values.size(), sumOp<label>());
result = gSum(values)/(scalar(n) + ROOTVSMALL);
break;
}
case opWeightedAverage:
{
if (returnReduce(weightField.size(), sumOp<label>()))
if (returnReduce(weightField.empty(), andOp<bool>()))
{
// has weights
result =
gSum(weightField*values)/(gSum(weightField) + ROOTVSMALL);
const label n = returnReduce(values.size(), sumOp<label>());
result = gSum(values)/(scalar(n) + ROOTVSMALL);
}
else
{
label n = returnReduce(values.size(), sumOp<label>());
result = gSum(values)/(scalar(n) + ROOTVSMALL);
const scalarField factor = weightingFactor(weightField);
result = gSum(factor*values)/(gSum(factor) + ROOTVSMALL);
}
break;
}
@ -198,14 +206,9 @@ processSameTypeValues
}
case opWeightedAreaAverage:
{
const scalarField factor
(
returnReduce(weightField.size(), sumOp<label>()) // has weights
? weightField*mag(Sf)
: mag(Sf)
);
const scalarField factor = weightingFactor(weightField, Sf);
result = gSum(factor*values)/gSum(factor);
result = gSum(factor*values)/gSum(factor + ROOTVSMALL);
break;
}
case opAreaIntegrate:
@ -217,12 +220,7 @@ processSameTypeValues
}
case opWeightedAreaIntegrate:
{
const scalarField factor
(
returnReduce(weightField.size(), sumOp<label>()) // has weights
? weightField*mag(Sf)
: mag(Sf)
);
const scalarField factor = weightingFactor(weightField, Sf);
result = gSum(factor*values);
break;
@ -240,16 +238,13 @@ processSameTypeValues
case opCoV:
{
const scalarField magSf(mag(Sf));
const scalar gSumMagSf = gSum(magSf);
Type meanValue = gSum(values*magSf)/gSumMagSf;
const label nComp = pTraits<Type>::nComponents;
for (direction d=0; d<nComp; ++d)
for (direction d=0; d < pTraits<Type>::nComponents; ++d)
{
scalarField vals(values.component(d));
tmp<scalarField> vals = values.component(d);
scalar mean = component(meanValue, d);
scalar& res = setComponent(result, d);
@ -260,38 +255,102 @@ processSameTypeValues
break;
}
case opAreaNormalAverage:
{}
case opAreaNormalIntegrate:
{}
case opNone:
{}
// handled in specializations only
break;
}
return result;
}
template<class Type>
template<class Type, class WeightType>
Type Foam::functionObjects::fieldValues::surfaceFieldValue::processValues
(
const Field<Type>& values,
const vectorField& Sf,
const scalarField& weightField
const Field<WeightType>& weightField
) const
{
return processSameTypeValues(values, Sf, weightField);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class WeightType>
Foam::tmp<Foam::scalarField>
Foam::functionObjects::fieldValues::surfaceFieldValue::weightingFactor
(
const Field<WeightType>& weightField
)
{
return mag(weightField);
}
template<class WeightType>
Foam::label Foam::functionObjects::fieldValues::surfaceFieldValue::writeAll
(
const vectorField& Sf,
const Field<WeightType>& weightField,
const meshedSurf& surfToWrite
)
{
label nProcessed = 0;
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<sphericalTensor>
(
fieldName, Sf, weightField, orient, surfToWrite
)
|| writeValues<symmTensor>
(
fieldName, Sf, weightField, orient, surfToWrite
)
|| writeValues<tensor>
(
fieldName, Sf, weightField, orient, surfToWrite
)
)
{
++nProcessed;
}
else
{
WarningInFunction
<< "Requested field " << fieldName
<< " not found in database and not processed"
<< endl;
}
}
return nProcessed;
}
template<class Type, class WeightType>
bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
(
const word& fieldName,
const vectorField& Sf,
const Field<WeightType>& weightField,
const bool orient
const bool orient,
const meshedSurf& surfToWrite
)
{
const bool ok = validField<Type>(fieldName);
@ -300,47 +359,19 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
{
Field<Type> values(getFieldValues<Type>(fieldName, true, orient));
vectorField Sf;
if (surfacePtr_.valid())
{
// Get oriented Sf
Sf = surfacePtr_().Sf();
}
else
{
// Get oriented Sf
Sf = filterField(mesh_.Sf(), true);
}
// Write raw values on surface if specified
if (surfaceWriterPtr_.valid())
{
Field<Type> allValues(values);
combineFields(allValues);
faceList faces;
pointField points;
if (surfacePtr_.valid())
{
combineSurfaceGeometry(faces, points);
}
else
{
combineMeshGeometry(faces, points);
}
if (Pstream::master())
{
surfaceWriterPtr_->write
(
outputDir(),
regionTypeNames_[regionType_] + ("_" + regionName_),
meshedSurfRef
(
points,
faces
),
surfToWrite,
fieldName,
allValues,
false
@ -367,20 +398,34 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
setComponent(result, d)
= sqrt(mag(component(result, d)));
}
}
break;
}
}
file()<< tab << result;
Log << " " << operationTypeNames_[operation_]
<< "(" << regionName_ << ") of " << fieldName
// Write state/results information
word prefix, suffix;
{
if (postOperation_ != postOpNone)
{
// Adjust result name to include post-operation
prefix += postOperationTypeNames_[postOperation_];
prefix += '(';
suffix += ')';
}
prefix += operationTypeNames_[operation_];
prefix += '(';
suffix += ')';
}
Log << " " << prefix << regionName_ << suffix
<< " of " << fieldName
<< " = " << result << endl;
// Write state/results information
const word& opName = operationTypeNames_[operation_];
word resultName =
opName + '(' + regionName_ + ',' + fieldName + ')';
word resultName = prefix + regionName_ + ',' + fieldName + suffix;
this->setResult(resultName, result);
}
}
@ -423,7 +468,10 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
{
forAll(values, i)
{
values[i] *= faceSign_[i];
if (faceFlip_[i])
{
values[i] *= -1;
}
}
}
@ -460,7 +508,10 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
{
forAll(values, i)
{
values[i] *= faceSign_[i];
if (faceFlip_[i])
{
values[i] *= -1;
}
}
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -48,17 +48,19 @@ const char*
Foam::NamedEnum
<
Foam::functionObjects::fieldValues::volFieldValue::operationType,
11
13
>::names[] =
{
"none",
"sum",
"weightedSum",
"sumMag",
"average",
"weightedAverage",
"volAverage",
"weightedVolAverage",
"volIntegrate",
"weightedVolIntegrate",
"min",
"max",
"CoV"
@ -67,21 +69,60 @@ Foam::NamedEnum
const Foam::NamedEnum
<
Foam::functionObjects::fieldValues::volFieldValue::operationType,
11
13
> Foam::functionObjects::fieldValues::volFieldValue::operationTypeNames_;
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
bool Foam::functionObjects::fieldValues::volFieldValue::needsVol() const
{
// Only some operations need the cell volume
switch (operation_)
{
case opVolAverage:
case opWeightedVolAverage:
case opVolIntegrate:
case opWeightedVolIntegrate:
case opCoV:
return true;
default:
return false;
}
}
bool Foam::functionObjects::fieldValues::volFieldValue::needsWeight() const
{
// Only a few operations use weight field
switch (operation_)
{
case opWeightedSum:
case opWeightedAverage:
case opWeightedVolAverage:
case opWeightedVolIntegrate:
return true;
default:
return false;
}
}
void Foam::functionObjects::fieldValues::volFieldValue::initialise
(
const dictionary& dict
)
{
weightFieldName_ = "none";
if (needsWeight())
{
if (dict.readIfPresent("weightField", weightFieldName_))
{
Info<< " weight field = " << weightFieldName_;
}
}
Info<< nl << endl;
}
@ -110,6 +151,42 @@ void Foam::functionObjects::fieldValues::volFieldValue::writeFileHeader
}
Foam::label Foam::functionObjects::fieldValues::volFieldValue::writeAll
(
const scalarField& V,
const scalarField& weightField
)
{
label nProcessed = 0;
forAll(fields_, i)
{
const word& fieldName = fields_[i];
if
(
writeValues<scalar>(fieldName, V, weightField)
|| writeValues<vector>(fieldName, V, weightField)
|| writeValues<sphericalTensor>(fieldName, V, weightField)
|| writeValues<symmTensor>(fieldName, V, weightField)
|| writeValues<tensor>(fieldName, V, weightField)
)
{
++nProcessed;
}
else
{
WarningInFunction
<< "Requested field " << fieldName
<< " not found in database and not processed"
<< endl;
}
}
return nProcessed;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
@ -159,8 +236,6 @@ bool Foam::functionObjects::fieldValues::volFieldValue::read
)
{
fieldValue::read(dict);
// No additional info to read
initialise(dict);
return true;
@ -176,37 +251,21 @@ bool Foam::functionObjects::fieldValues::volFieldValue::write()
writeTime(file());
}
// Construct weight field. Note: zero size means weight = 1
// Only some operations need the cell volume
scalarField V;
if (needsVol())
{
V = filterField(fieldValue::mesh_.V());
}
// Weight field - zero-size means weight = 1
scalarField weightField;
if (weightFieldName_ != "none")
{
weightField =
getFieldValues<scalar>
(
weightFieldName_,
true
);
weightField = getFieldValues<scalar>(weightFieldName_, true);
}
forAll(fields_, i)
{
const word& fieldName = fields_[i];
bool ok = false;
ok = ok || writeValues<scalar>(fieldName, weightField);
ok = ok || writeValues<vector>(fieldName, weightField);
ok = ok || writeValues<sphericalTensor>(fieldName, weightField);
ok = ok || writeValues<symmTensor>(fieldName, weightField);
ok = ok || writeValues<tensor>(fieldName, weightField);
if (!ok)
{
WarningInFunction
<< "Requested field " << fieldName
<< " not found in database and not processed"
<< endl;
}
}
writeAll(V, weightField);
if (Pstream::master())
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -82,12 +82,14 @@ Usage
\plaintable
none | No operation
sum | Sum
weightedSum | Weighted sum
sumMag | Sum of component magnitudes
average | Ensemble average
weightedAverage | Weighted average
volAverage | Volume weighted average
weightedVolAverage | Weighted volume average
volIntegrate | Volume integral
weightedVolIntegrate | Weighted volume integral
min | Minimum
max | Maximum
CoV | Coefficient of variation: standard deviation/mean
@ -135,21 +137,23 @@ public:
//- Operation type enumeration
enum operationType
{
opNone,
opSum,
opSumMag,
opAverage,
opWeightedAverage,
opVolAverage,
opWeightedVolAverage,
opVolIntegrate,
opMin,
opMax,
opCoV
opNone, //!< None
opSum, //!< Sum
opWeightedSum, //!< Weighted sum
opSumMag, //!< Magnitude of sum
opAverage, //!< Average
opWeightedAverage, //!< Weighted average
opVolAverage, //!< Volume average
opWeightedVolAverage, //!< Weighted volume average
opVolIntegrate, //!< Volume integral
opWeightedVolIntegrate, //!< Weighted volume integral
opMin, //!< Minimum
opMax, //!< Maximum
opCoV //!< Coefficient of variation
};
//- Operation type names
static const NamedEnum<operationType, 11> operationTypeNames_;
static const NamedEnum<operationType, 13> operationTypeNames_;
protected:
@ -165,6 +169,12 @@ protected:
// Protected Member Functions
//- True if the specified operation needs the cell-volume
bool needsVol() const;
//- True if the specified operation needs a weight-field
bool needsWeight() const;
//- Initialise, e.g. cell addressing
void initialise(const dictionary& dict);
@ -189,10 +199,30 @@ protected:
const scalarField& weightField
) const;
//- Helper function to output field values
label writeAll
(
const scalarField& V,
const scalarField& weightField
);
//- Templated helper function to output field values
template<class Type>
bool writeValues
(
const word& fieldName,
const scalarField& V,
const scalarField& weightField
);
//- Filter a field according to cellIds
template<class Type>
tmp<Field<Type>> filterField(const Field<Type>& field) const;
//- Output file header information
virtual void writeFileHeader(Ostream& os) const;
public:
//- Run-time type information
@ -224,19 +254,11 @@ public:
// Public Member Functions
//- Templated helper function to output field values
template<class Type>
bool writeValues(const word& fieldName, const scalarField& weightField);
//- Filter a field according to cellIds
template<class Type>
tmp<Field<Type>> filterField(const Field<Type>& field) const;
//- Read from dictionary
virtual bool read(const dictionary&);
virtual bool read(const dictionary& dict) override;
//- Calculate and write
virtual bool write();
virtual bool write() override;
};

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -87,6 +87,18 @@ Type Foam::functionObjects::fieldValues::volFieldValue::processValues
result = gSum(values);
break;
}
case opWeightedSum:
{
if (returnReduce(weightField.empty(), andOp<bool>()))
{
result = gSum(values);
}
else
{
result = gSum(weightField*values);
}
break;
}
case opSumMag:
{
result = gSum(cmptMag(values));
@ -94,34 +106,40 @@ Type Foam::functionObjects::fieldValues::volFieldValue::processValues
}
case opAverage:
{
label n = returnReduce(values.size(), sumOp<label>());
const label n = returnReduce(values.size(), sumOp<label>());
result = gSum(values)/(scalar(n) + ROOTVSMALL);
break;
}
case opWeightedAverage:
{
label wSize = returnReduce(weightField.size(), sumOp<label>());
if (wSize > 0)
if (returnReduce(weightField.empty(), andOp<bool>()))
{
result =
gSum(weightField*values)/(gSum(weightField) + ROOTVSMALL);
const label n = returnReduce(values.size(), sumOp<label>());
result = gSum(values)/(scalar(n) + ROOTVSMALL);
}
else
{
label n = returnReduce(values.size(), sumOp<label>());
result = gSum(values)/(scalar(n) + ROOTVSMALL);
result =
gSum(weightField*values)/(gSum(weightField) + ROOTVSMALL);
}
break;
}
case opVolAverage:
{
result = gSum(values*V)/(gSum(V) + ROOTVSMALL);
result = gSum(values*V)/gSum(V);
break;
}
case opWeightedVolAverage:
{
result = gSum(weightField*V*values)/gSum(weightField*V);
if (returnReduce(weightField.empty(), andOp<bool>()))
{
result = gSum(V*values)/(gSum(V) + ROOTVSMALL);
}
else
{
result = gSum(weightField*V*values)
/(gSum(weightField*V) + ROOTVSMALL);
}
break;
}
case opVolIntegrate:
@ -129,6 +147,18 @@ Type Foam::functionObjects::fieldValues::volFieldValue::processValues
result = gSum(V*values);
break;
}
case opWeightedVolIntegrate:
{
if (returnReduce(weightField.empty(), andOp<bool>()))
{
result = gSum(V*values);
}
else
{
result = gSum(weightField*V*values);
}
break;
}
case opMin:
{
result = gMin(values);
@ -145,9 +175,7 @@ Type Foam::functionObjects::fieldValues::volFieldValue::processValues
Type meanValue = gSum(V*values)/sumV;
const label nComp = pTraits<Type>::nComponents;
for (direction d=0; d<nComp; ++d)
for (direction d=0; d < pTraits<Type>::nComponents; ++d)
{
scalarField vals(values.component(d));
scalar mean = component(meanValue, d);
@ -172,6 +200,7 @@ template<class Type>
bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
(
const word& fieldName,
const scalarField& V,
const scalarField& weightField
)
{
@ -180,7 +209,6 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
if (ok)
{
Field<Type> values(getFieldValues<Type>(fieldName));
scalarField V(filterField(fieldValue::mesh_.V()));
if (writeFields_)
{

View File

@ -0,0 +1,41 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 1 0 0 0];
internalField uniform 300;
boundaryField
{
"inlet.*"
{
type fixedValue;
value $internalField;
}
outlet
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
".*"
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
inlet_air
{
type flowRateInletVelocity;
massFlowRate constant 0.095;
value uniform (0 0 0);
}
inlet_fuel
{
type flowRateInletVelocity;
massFlowRate constant 0.005;
value uniform (0 0 0);
}
outlet
{
type pressureInletOutletVelocity;
inletValue (0 0 0);
value $internalField;
}
"wall.*"
{
type noSlip;
}
".*"
{
type fixedValue;
value uniform (0 0 0);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,41 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object alphat;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -1 0 0 0 0];
internalField uniform 1e-3;
boundaryField
{
"inlet.*"
{
type calculated;
value $internalField;
}
outlet
{
type calculated;
value $internalField;
}
"wall.*"
{
type compressible::alphatWallFunction;
value $internalField;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -3 0 0 0 0];
internalField uniform 100;
boundaryField
{
inlet_air
{
type turbulentMixingLengthDissipationRateInlet;
mixingLength 0.005;
value $internalField;
}
inlet_fuel
{
type turbulentMixingLengthDissipationRateInlet;
mixingLength 0.001;
value $internalField;
}
outlet
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
"inlet.*"
{
type zeroGradient;
}
"wall.*"
{
type epsilonWallFunction;
value $internalField;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 6;
boundaryField
{
inlet_air
{
type turbulentIntensityKineticEnergyInlet;
intensity 0.05;
value $internalField;
}
inlet_fuel
{
type turbulentIntensityKineticEnergyInlet;
intensity 0.05;
value $internalField;
}
outlet
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
".*"
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,41 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
"inlet.*"
{
type calculated;
value $internalField;
}
outlet
{
type calculated;
value $internalField;
}
"wall.*"
{
type nutUWallFunction;
value $internalField;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,35 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -2 0 0 0 0];
internalField uniform 1e5;
boundaryField
{
outlet
{
type fixedValue;
value $internalField;
}
".*"
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,47 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object tracer0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField uniform 0;
boundaryField
{
inlet_air
{
type fixedValue;
value uniform 0;
}
inlet_fuel
{
type fixedValue;
value uniform 1;
}
outlet
{
type inletOutlet;
inletValue uniform 0;
value uniform 0;
}
".*"
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,13 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial clean functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase
rm -rf 0
rm -f constant/triSurface/*.eMesh* > /dev/null 2>&1
rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1
#------------------------------------------------------------------------------

View File

@ -0,0 +1,13 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
./Allrun.mesh
restore0Dir
runApplication decomposePar -force
runParallel rhoSimpleFoam
#------------------------------------------------------------------------------

View File

@ -0,0 +1,13 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh
runApplication surfaceFeatureExtract
runApplication snappyHexMesh -overwrite
rm -rf 0
#------------------------------------------------------------------------------

View File

@ -0,0 +1 @@
Demonstration of simple gas mixing, with processing on surface fields.

View File

@ -0,0 +1,56 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object thermophysicalProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType
{
type hePsiThermo;
mixture pureMixture;
transport sutherland;
thermo hConst;
equationOfState perfectGas;
specie specie;
energy sensibleInternalEnergy;
}
// SIMPLE
thermoType
{
type heRhoThermo;
}
mixture
{
specie
{
nMoles 1;
molWeight 28.9;
}
thermodynamics
{
Cp 1007;
Hf 0;
}
transport
{
As 1.4792e-06;
Ts 116;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,268 @@
solid fuel_inlet
facet normal 0 0 -1
outer loop
vertex 0.103873 0.00419647 0.1
vertex 0.109249 0.00380166 0.1
vertex 0.106039 -0.000293039 0.1
endloop
endfacet
facet normal 0 -0 -1
outer loop
vertex 0.107097 0.00704535 0.1
vertex 0.109249 0.00380166 0.1
vertex 0.103873 0.00419647 0.1
endloop
endfacet
facet normal 0 -0 -1
outer loop
vertex 0.103873 0.00419647 0.1
vertex 0.106039 -0.000293039 0.1
vertex 0.102084 0.000583721 0.1
endloop
endfacet
facet normal 0 -0 -1
outer loop
vertex 0.109249 0.00380166 0.1
vertex 0.11 0 0.1
vertex 0.106039 -0.000293039 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.103852 0.00922834 0.1
vertex 0.107097 0.00704535 0.1
vertex 0.103873 0.00419647 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.102084 0.000583721 0.1
vertex 0.0989737 0.00243444 0.1
vertex 0.103873 0.00419647 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.102311 -0.00254505 0.1
vertex 0.102084 0.000583721 0.1
vertex 0.106039 -0.000293039 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.11 0 0.1
vertex 0.109249 -0.00380166 0.1
vertex 0.106039 -0.000293039 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.103873 0.00419647 0.1
vertex 0.099792 0.00657993 0.1
vertex 0.103852 0.00922834 0.1
endloop
endfacet
facet normal -0 0 -1
outer loop
vertex 0.102084 0.000583721 0.1
vertex 0.0987304 -0.00168894 0.1
vertex 0.0989737 0.00243444 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.0989737 0.00243444 0.1
vertex 0.099792 0.00657993 0.1
vertex 0.103873 0.00419647 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.106039 -0.000293039 0.1
vertex 0.104805 -0.00474297 0.1
vertex 0.102311 -0.00254505 0.1
endloop
endfacet
facet normal 0 -0 -1
outer loop
vertex 0.102084 0.000583721 0.1
vertex 0.102311 -0.00254505 0.1
vertex 0.0987304 -0.00168894 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.104805 -0.00474297 0.1
vertex 0.106039 -0.000293039 0.1
vertex 0.109249 -0.00380166 0.1
endloop
endfacet
facet normal 0 -0 -1
outer loop
vertex 0.1 0.01 0.1
vertex 0.103852 0.00922834 0.1
vertex 0.099792 0.00657993 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.0989737 0.00243444 0.1
vertex 0.0987304 -0.00168894 0.1
vertex 0.0943497 0.000109063 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.0955515 0.00475557 0.1
vertex 0.099792 0.00657993 0.1
vertex 0.0989737 0.00243444 0.1
endloop
endfacet
facet normal -0 0 -1
outer loop
vertex 0.104805 -0.00474297 0.1
vertex 0.100159 -0.00601788 0.1
vertex 0.102311 -0.00254505 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.0987304 -0.00168894 0.1
vertex 0.102311 -0.00254505 0.1
vertex 0.100159 -0.00601788 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.109249 -0.00380166 0.1
vertex 0.107097 -0.00704535 0.1
vertex 0.104805 -0.00474297 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.0961732 0.0092388 0.1
vertex 0.1 0.01 0.1
vertex 0.099792 0.00657993 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.0943497 0.000109063 0.1
vertex 0.0955515 0.00475557 0.1
vertex 0.0989737 0.00243444 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.0955808 -0.00457201 0.1
vertex 0.0943497 0.000109063 0.1
vertex 0.0987304 -0.00168894 0.1
endloop
endfacet
facet normal -0 0 -1
outer loop
vertex 0.099792 0.00657993 0.1
vertex 0.0955515 0.00475557 0.1
vertex 0.0961732 0.0092388 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.100159 -0.00601788 0.1
vertex 0.104805 -0.00474297 0.1
vertex 0.103852 -0.00922834 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.100159 -0.00601788 0.1
vertex 0.0955808 -0.00457201 0.1
vertex 0.0987304 -0.00168894 0.1
endloop
endfacet
facet normal -0 0 -1
outer loop
vertex 0.107097 -0.00704535 0.1
vertex 0.103852 -0.00922834 0.1
vertex 0.104805 -0.00474297 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.0955515 0.00475557 0.1
vertex 0.0943497 0.000109063 0.1
vertex 0.0907612 0.00382683 0.1
endloop
endfacet
facet normal 0 -0 -1
outer loop
vertex 0.0943497 0.000109063 0.1
vertex 0.0955808 -0.00457201 0.1
vertex 0.0907612 -0.00382683 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.0929289 0.00707107 0.1
vertex 0.0961732 0.0092388 0.1
vertex 0.0955515 0.00475557 0.1
endloop
endfacet
facet normal -0 0 -1
outer loop
vertex 0.103852 -0.00922834 0.1
vertex 0.1 -0.01 0.1
vertex 0.100159 -0.00601788 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.0955808 -0.00457201 0.1
vertex 0.100159 -0.00601788 0.1
vertex 0.0961732 -0.0092388 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.0907612 0.00382683 0.1
vertex 0.0929289 0.00707107 0.1
vertex 0.0955515 0.00475557 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.09 -4.64102e-10 0.1
vertex 0.0907612 0.00382683 0.1
vertex 0.0943497 0.000109063 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.0907612 -0.00382683 0.1
vertex 0.09 -4.64102e-10 0.1
vertex 0.0943497 0.000109063 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.0929289 -0.00707107 0.1
vertex 0.0907612 -0.00382683 0.1
vertex 0.0955808 -0.00457201 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.1 -0.01 0.1
vertex 0.0961732 -0.0092388 0.1
vertex 0.100159 -0.00601788 0.1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0.0961732 -0.0092388 0.1
vertex 0.0929289 -0.00707107 0.1
vertex 0.0955808 -0.00457201 0.1
endloop
endfacet
endsolid fuel_inlet

View File

@ -0,0 +1,30 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType RAS;
RAS
{
RASModel kEpsilon;
turbulence on;
printCoeffs on;
}
// ************************************************************************* //

View File

@ -0,0 +1,23 @@
// -*- C++ -*-
//
// Averaging of volume fields or fields on an externally loaded surface.
avg-tracer0-0.25
{
${settings_avg}
subRegion plane-0.25;
}
avg-tracer0-0.45
{
${settings_avg}
subRegion plane-0.45;
}
avg-tracer0-0.55
{
${settings_avg}
subRegion plane-0.55;
}
// ************************************************************************* //

View File

@ -0,0 +1,40 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: http://www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
vertices
(
(-0.5 -0.125 -0.25)
(1.5 -0.125 -0.25)
(1.5 0.125 -0.25)
(-0.5 0.125 -0.25)
(-0.5 -0.125 0.25)
(1.5 -0.125 0.25)
(1.5 0.125 0.25)
(-0.5 0.125 0.25)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (32 4 8) simpleGrading (1 1 1)
);
edges
();
patches
();
// ************************************************************************* //

View File

@ -0,0 +1,72 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application rhoSimpleFoam;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 0.4;
deltaT 1e-04;
writeControl adjustableRunTime;
writeInterval 2e-3;
purgeWrite 0;
writeFormat binary;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
adjustTimeStep yes;
maxCo 0.5;
// SIMPLE
endTime 1200;
deltaT 1;
writeInterval 100;
#include "sampleControls"
functions
{
#include "scalarTransport"
#include "sampling"
}
OptimisationSwitches
{
// Force dumping (at next timestep) upon signal: 12 = USR2
writeNowSignal 12;
}
// ************************************************************************* //

View File

@ -0,0 +1,32 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 8;
method hierarchical;
hierarchicalCoeffs
{
n ( 2 2 2 );
delta 0.001;
order xyz;
}
preservePatches ();
// ************************************************************************* //

View File

@ -0,0 +1,45 @@
// -*- C++ -*-
// ************************************************************************* //
// Transcribe volume fields to surfaces.
fieldTransfer
{
type surfMeshes;
libs ("libsampling.so");
log true;
writeControl none;
createOnRead true;
executeControl timeStep;
executeInterval 1;
fields (rho U tracer0);
derived (rhoU);
baseCfg
{
type sampledTriSurfaceMesh;
source cells;
}
surfaces
(
plane-0.25
{
$baseCfg
surface plane-0.25.stl;
}
plane-0.45
{
$baseCfg
surface plane-0.45.stl;
}
plane-0.55
{
$baseCfg
surface plane-0.55.stl;
}
);
}
// ************************************************************************* //

View File

@ -0,0 +1,64 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default leastSquares;
grad(U) cellLimited Gauss linear 0.99;
}
divSchemes
{
default none;
div(phi,U) Gauss limitedLinearV 1;
div(phid,p) Gauss limitedLinear 1;
div(phi,K) Gauss limitedLinear 1;
div(phi,k) Gauss limitedLinear 1;
div(phi,h) Gauss limitedLinear 1;
div(phi,e) Gauss limitedLinear 1;
div(phi,Ekp) Gauss limitedLinear 1;
div(phi,T) Gauss limitedLinear 1;
div(phi,tracer0) Gauss limitedLinear 1;
div(phi,epsilon) Gauss limitedLinear 1;
div(R) Gauss linear;
div(U) Gauss linear;
div((Su*n)) Gauss linear;
div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear;
}
laplacianSchemes
{
default Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default corrected;
}
// ************************************************************************* //

View File

@ -0,0 +1,152 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
"(p|rho)"
{
solver GAMG;
tolerance 1e-08;
relTol 0.05;
smoother symGaussSeidel;
nCellsInCoarsestLevel 200;
}
"(U|k|epsilon|tracer0)"
{
solver smoothSolver;
smoother symGaussSeidel;
nSweeps 2;
tolerance 1e-06;
relTol 0.1;
minIter 1;
}
e
{
solver PBiCGStab;
preconditioner DILU;
nSweeps 2;
tolerance 1e-06;
relTol 0.1;
minIter 1;
}
"(p|rho)Final"
{
$p;
tolerance 1e-06;
relTol 0;
minIter 1;
}
"(U|k|epsilon|tracer0)Final"
{
$U;
tolerance 1e-05;
relTol 0;
minIter 1;
}
eFinal
{
$e;
tolerance 1e-05;
relTol 0;
minIter 1;
}
}
PIMPLE
{
nOuterCorrectors 2;
nCorrectors 1;
nNonOrthogonalCorrectors 0;
rhoMin 0.3;
rhoMax 2.0;
}
potentialFlow
{
nNonOrthogonalCorrectors 20;
}
SIMPLE
{
nNonOrthogonalCorrectors 0;
rhoMin 0.3;
rhoMax 1.4;
transonic false;
// consistent yes;
residualControl
{
p 1e-3;
U 1e-4;
e 1e-3;
// possibly check turbulence fields
"(k|epsilon|omega)" 1e-3;
}
// 2.4.x
rhoMin rhoMin [1 -3 0 0 0 0 0] 0.3;
rhoMax rhoMax [1 -3 0 0 0 0 0] 1.4;
}
relaxationFactors-SIMPLE
{
fields
{
p 0.3;
rho 0.05;
}
equations
{
U 0.7;
"(k|epsilon)" 0.7;
e 0.5;
tracer0 1;
".*Final" 1.0;
}
}
relaxationFactors-PIMPLE
{
equations
{
U 0.95;
"(k|epsilon)" 0.95;
e 0.95;
tracer0 1;
".*Final" 1.0;
}
}
// relaxationFactors { $relaxationFactors-PIMPLE }
relaxationFactors { $relaxationFactors-SIMPLE }
// ************************************************************************* //

View File

@ -0,0 +1,23 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object meshQualityDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Include defaults parameters from master dictionary
#include "$WM_PROJECT_DIR/etc/caseDicts/meshQualityDict"
maxNonOrtho 55;
// ************************************************************************* //

View File

@ -0,0 +1,101 @@
// -*- C++ -*-
// Averaging of volume fields or fields on an externally loaded surface.
//
// fields [required]
// The fields and the specification for the type of averaging needed.
//
// The 'execute' control triggers the averaging.
// The 'output/write' control is optional.
//
// The averaging can be optionally restart in two ways:
//
// periodicRestart / restartPeriod:
// - reset at defined intervals
//
// restartTime:
// - a 'one-shot' reset at a particular time
//
settings_avg
{
type fieldAverage;
libs ("libfieldFunctionObjects.so");
log on;
enabled true;
executeControl timeStep;
writeControl outputTime;
writeInterval 1;
// restart behaviour
resetOnStartUp true;
resetOnOutput false;
// periodicRestart true;
// restartPeriod 0.002;
// Use the same values for all entries
meanOnly
{
mean on;
prime2Mean off;
base time;
}
fields
(
rho
{
$meanOnly;
}
U
{
$meanOnly;
}
tracer0
{
$meanOnly;
}
);
}
// restartTime:
// - a 'one-shot' reset at a particular time
//
// fields [required]
// Pairs of fields to use for calculating the deviation.
// The fields must already exist on the surfaces.
//
// weightField [optional]
// A scalar or vector field for weighting.
//
// postOperation [optional]
// Modify the results by particular operations.
// (none | sqrt)
// The sqrt operation is useful when determining RMS values.
//
// The 'output/write' control triggers the calculation.
settings_stats
{
type surfaceFieldValue;
libs ("libfieldFunctionObjects.so");
log on;
enabled true;
writeControl timeStep;
writeInterval 1;
writeFields false;
surfaceFormat vtk;
// writeArea true;
// resetOnStartUp true;
// resetOnOutput false;
// periodicRestart true;
// restartPeriod 0.0005;
}
// ************************************************************************* //

View File

@ -0,0 +1,14 @@
// -*- C++ -*-
// ************************************************************************* //
#include "fieldTransfer"
#include "avg-tracer0"
#include "sum-tracer0"
// #include "sum-tracer0Mean"
// #include "averaging.1612" // generate time-averaged fields
// #include "spatialDeviation.1612" // spatial deviation compared to a mean field
// #include "statistics.1612" // transcribe volume fields -> surface
// ************************************************************************* //

View File

@ -0,0 +1,16 @@
// -*- C++ -*-
tracer0
{
type scalarTransport;
libs ("libsolverFunctionObjects.so");
log off;
resetOnStartUp false;
// writeControl outputTime;
// writeInterval 1;
field tracer0;
D 0.001;
}
// ************************************************************************* //

View File

@ -0,0 +1,379 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Which of the steps to run
castellatedMesh true;
snap true;
addLayers false;
// Geometry. Definition of all surfaces. All surfaces are of class
// searchableSurface.
// Surfaces are used
// - to specify refinement for any mesh cell intersecting it
// - to specify refinement for any mesh cell inside/outside/near
// - to 'snap' the mesh boundary to the surface
geometry
{
inlet_air.stl
{
type triSurfaceMesh;
name inlet_air;
}
inlet_fuel.stl
{
type triSurfaceMesh;
name inlet_fuel;
}
outlet.stl
{
type triSurfaceMesh;
name outlet;
}
entrainment.stl
{
type triSurfaceMesh;
name inlet_entrainment;
}
walls.stl
{
type triSurfaceMesh;
name walls;
}
refinementBox
{
type searchableBox;
min (-0.5 -0.125 -0.25);
max (1.5 0.125 0.25);
}
};
// Settings for the castellatedMesh generation.
castellatedMeshControls
{
// Refinement parameters
// ~~~~~~~~~~~~~~~~~~~~~
// If local number of cells is >= maxLocalCells on any processor
// switches from from refinement followed by balancing
// (current method) to (weighted) balancing before refinement.
maxLocalCells 100000;
// Overall cell limit (approximately). Refinement will stop immediately
// upon reaching this number so a refinement level might not complete.
// Note that this is the number of cells before removing the part which
// is not 'visible' from the keepPoint. The final number of cells might
// actually be a lot less.
maxGlobalCells 2000000;
// The surface refinement loop might spend lots of iterations refining just a
// few cells. This setting will cause refinement to stop if <= minimumRefine
// are selected for refinement. Note: it will at least do one iteration
// (unless the number of cells to refine is 0)
minRefinementCells 0;
// Number of buffer layers between different levels.
// 1 means normal 2:1 refinement restriction, larger means slower
// refinement.
nCellsBetweenLevels 5;
// Explicit feature edge refinement
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Specifies a level for any cell intersected by its edges.
// This is a featureEdgeMesh, read from constant/triSurface for now.
features
(
{
file "walls.eMesh";
level 0;
}
);
// Surface based refinement
// ~~~~~~~~~~~~~~~~~~~~~~~~
// Specifies two levels for every surface. The first is the minimum level,
// every cell intersecting a surface gets refined up to the minimum level.
// The second level is the maximum level. Cells that 'see' multiple
// intersections where the intersections make an
// angle > resolveFeatureAngle get refined up to the maximum level.
refinementSurfaces
{
inlet_air
{
level (4 4);
patchInfo
{
type patch;
}
}
inlet_fuel
{
level (6 6);
patchInfo
{
type patch;
}
}
outlet
{
level (4 4);
patchInfo
{
type patch;
}
}
inlet_entrainment
{
level (4 4);
patchInfo
{
type patch;
}
}
walls
{
level (4 4);
regions
{
pipe_fuel { level (6 6); }
}
patchInfo
{
type wall;
inGroups (wall);
}
}
}
resolveFeatureAngle 30;
// Region-wise refinement
// ~~~~~~~~~~~~~~~~~~~~~~
// Specifies refinement level for cells in relation to a surface. One of
// three modes
// - distance. 'levels' specifies per distance to the surface the
// wanted refinement level. The distances need to be specified in
// descending order.
// - inside. 'levels' is only one entry and only the level is used. All
// cells inside the surface get refined up to the level. The surface
// needs to be closed for this to be possible.
// - outside. Same but cells outside.
refinementRegions
{
refinementBox
{
mode inside;
levels ((4 4));
}
}
// Mesh selection
// ~~~~~~~~~~~~~~
// After refinement patches get added for all refinementSurfaces and
// all cells intersecting the surfaces get put into these patches. The
// section reachable from the locationInMesh is kept.
// NOTE: This point should never be on a face, always inside a cell, even
// after refinement.
// This is an outside point locationInMesh (-0.033 -0.033 0.0033);
locationInMesh (0.5 0.01 0.01);
// Whether any faceZones (as specified in the refinementSurfaces)
// are only on the boundary of corresponding cellZones or also allow
// free-standing zone faces. Not used if there are no faceZones.
allowFreeStandingZoneFaces false;
}
// Settings for the snapping.
snapControls
{
//- Number of patch smoothing iterations before finding correspondence
// to surface
nSmoothPatch 3;
//- Relative distance for points to be attracted by surface feature point
// or edge. True distance is this factor times local
// maximum edge length.
tolerance 1.0;
//- Number of mesh displacement relaxation iterations.
nSolveIter 300;
//- Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 5;
// Feature snapping
//- Number of feature edge snapping iterations.
// Leave out altogether to disable.
nFeatureSnapIter 10;
//- Detect (geometric) features by sampling the surface
implicitFeatureSnap true;
//- Use castellatedMeshControls::features
explicitFeatureSnap false;
//- Detect features between multiple surfaces
// (only for explicitFeatureSnap, default = false)
multiRegionFeatureSnap true;
}
// Settings for the layer addition.
addLayersControls
{
// Are the thickness parameters below relative to the undistorted
// size of the refined cell outside layer (true) or absolute sizes (false).
relativeSizes true;
// Per final patch (so not geometry!) the layer information
layers
{
"blade."
{
nSurfaceLayers 2;
}
}
// Expansion factor for layer mesh
expansionRatio 1.0;
// Wanted thickness of final added cell layer. If multiple layers
// is the thickness of the layer furthest away from the wall.
// Relative to undistorted size of cell outside layer.
// See relativeSizes parameter.
finalLayerThickness 0.25;
// Minimum thickness of cell layer. If for any reason layer
// cannot be above minThickness do not add layer.
// See relativeSizes parameter.
minThickness 0.2;
// If points get not extruded do nGrow layers of connected faces that are
// also not grown. This helps convergence of the layer addition process
// close to features.
nGrow 0;
// Advanced settings
// When not to extrude surface. 0 is flat surface, 90 is when two faces
// are perpendicular
featureAngle 30;
// Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 5;
// Number of smoothing iterations of surface normals
nSmoothSurfaceNormals 1;
// Number of smoothing iterations of interior mesh movement direction
nSmoothNormals 3;
// Smooth layer thickness over surface patches
nSmoothThickness 10;
// Stop layer growth on highly warped cells
maxFaceThicknessRatio 0.5;
// Reduce layer growth where ratio thickness to medial
// distance is large
maxThicknessToMedialRatio 0.3;
// Angle used to pick up medial axis points
minMedianAxisAngle 90;
// Create buffer region for new layer terminations
nBufferCellsNoExtrude 0;
// Overall max number of layer addition iterations. The mesher will exit
// if it reaches this number of iterations; possibly with an illegal
// mesh.
nLayerIter 50;
// Max number of iterations after which relaxed meshQuality controls
// get used. Up to nRelaxIter it uses the settings in meshQualityControls,
// after nRelaxIter it uses the values in meshQualityControls::relaxed.
nRelaxedIter 20;
}
// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
#include "meshQualityDict"
// Optional : some meshing phases allow usage of relaxed rules.
// See e.g. addLayersControls::nRelaxedIter.
relaxed
{
//- Maximum non-orthogonality allowed. Set to 180 to disable.
maxNonOrtho 75;
}
// Advanced
//- Number of error distribution iterations
nSmoothScale 4;
//- amount to scale back displacement at error points
errorReduction 0.75;
}
// Advanced
// Write flags
writeFlags
(
scalarLevels // write volScalarField with cellLevel for postprocessing
layerSets // write cellSets, faceSets of faces in layer
layerFields // write volScalarField for layer coverage
);
// Merge tolerance. Is fraction of overall bounding box of initial mesh.
// Note: the write tolerance needs to be higher than this.
mergeTolerance 1E-6;
// ************************************************************************* //

View File

@ -0,0 +1,49 @@
// -*- C++ -*-
// ************************************************************************* //
sum-tracer0-0.25
{
$settings_stats
regionType surface;
name plane-0.25;
operation weightedAreaIntegrate;
// postOperation sqrt;
weightField rhoU;
fields (tracer0);
}
sum-tracer0-0.45
{
$settings_stats
regionType surface;
name plane-0.45;
operation weightedAreaIntegrate;
// postOperation sqrt;
weightField rhoU;
fields (tracer0);
}
sum-tracer0-0.55
{
$settings_stats
regionType surface;
name plane-0.55;
operation weightedAreaIntegrate;
// postOperation sqrt;
weightField rhoU;
fields (tracer0);
}
// ************************************************************************* //

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object surfaceFeatureExtractDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
walls.stl
{
// How to obtain raw features (extractFromFile || extractFromSurface)
extractionMethod extractFromSurface;
extractFromSurfaceCoeffs
{
// Mark edges whose adjacent surface normals are at an angle less
// than includedAngle as features
// - 0 : selects no edges
// - 180: selects all edges
includedAngle 150;
}
subsetFeatures
{
// Keep nonManifold edges (edges with >2 connected faces)
nonManifoldEdges no;
// Keep open edges (edges with 1 connected face)
openEdges yes;
}
// Write options
// Write features to obj format for postprocessing
writeObj yes;
}
// ************************************************************************* //