functionObjects: fieldsExpression: Type flexibility and new operations
The fieldsExpression function has been generalised to work with a
general operator. Existing functions "add" and "subtract" have been made
to use this system, and two new operations, "multiply" and "divide",
have been added.
The functions can now handle multiple types in both input and output. A
multiply (outer product) operation on two vectors and a scalar will
result in a tensor. If the operation chain is not supported (e.g.,
division by a vector) then a warning will be generated.
In addition, a "uniform" function has been added, which will create a
uniform geometric field of a given type with specified dimensions and
calculated boundary conditions. This is mostly useful for testing
purposes and for conveniently creating simple input fields for the
operation functions described above. The function can be called by
postProcess as follows:
postProcess -func "uniform(fieldType=volScalarField, name=length, dimensions=[m], value=2)"
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -127,9 +127,38 @@ bool Foam::functionObjects::fieldsExpression::execute()
|
||||
{
|
||||
if (!calc())
|
||||
{
|
||||
Warning
|
||||
<< " functionObjects::" << type() << " " << name()
|
||||
<< " cannot find required fields " << fieldNames_ << endl;
|
||||
DynamicList<word> notFoundFieldNames;
|
||||
forAll(fieldNames_, i)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
#define findFieldType(Type, GeoField) \
|
||||
found = \
|
||||
found \
|
||||
|| mesh_.foundObject<GeoField<Type>>(fieldNames_[i]);
|
||||
FOR_ALL_FIELD_TYPES(findFieldType, VolField);
|
||||
FOR_ALL_FIELD_TYPES(findFieldType, SurfaceField);
|
||||
#undef findFieldType
|
||||
|
||||
if (!found)
|
||||
{
|
||||
notFoundFieldNames.append(fieldNames_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!notFoundFieldNames.empty())
|
||||
{
|
||||
Warning
|
||||
<< "functionObjects::" << type() << " " << name()
|
||||
<< " cannot find fields " << notFoundFieldNames << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning
|
||||
<< "functionObjects::" << type() << " " << name()
|
||||
<< " fields are not compatible with the " << type()
|
||||
<< " function" << endl;
|
||||
}
|
||||
|
||||
// Clear the result fields from the objectRegistry if present
|
||||
clear();
|
||||
|
||||
Reference in New Issue
Block a user