ENH: support preloading fields for setExpr* utilities (#2014)

- can use either command-line option "-load-fields" or dictionary
  entry "readFields" to specify field names to be preloaded.

  Essentially the same functionality as with a readFields function
  object but with a lot less typing.

- tutorial examples provided by Ryan Danks <ryan.danks@rwdi.com>
  illustrate using setExpr* utilities to calculate a quantity
  as a post-processing step.
This commit is contained in:
Mark Olesen
2021-03-17 21:10:10 +01:00
parent 6ccc587bea
commit cd1350a87f
9 changed files with 538 additions and 24 deletions

View File

@ -28,4 +28,8 @@ runApplication reconstructParMesh -constant
runApplication reconstructPar
runApplication setExprFields -latestTime ## -load-fields U
runApplication setExprBoundaryFields -latestTime ## -load-fields '(U)'
#------------------------------------------------------------------------------

View File

@ -0,0 +1,41 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object setExprBoundaryFieldsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Preload any required fields (optional)
readFields ( U );
updateBCs
{
field windPowerDensity;
_value1
{
target value;
variables ( "rho=1.2" );
expression #{ 0.5*rho*cbrt(mag(U)) #};
}
expressions
(
{ $_value1; patch inlet; }
{ $_value1; patch outlet; }
{ $_value1; patch sides; }
{ $_value1; patch top; }
);
}
// ************************************************************************* //

View File

@ -0,0 +1,37 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object setExprFieldsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Preload any required fields (optional)
readFields ( U );
_value1
{
variables ( "rho=1.2" );
expression #{ 0.5*rho*cbrt(mag(U)) #};
}
expressions
(
windPowerDensity
{
field windPowerDensity;
create yes;
$_value1;
}
);
// ************************************************************************* //