Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
0a43d605
Commit
0a43d605
authored
May 22, 2016
by
Henry Weller
Browse files
functionObjects::pressureTools: simplified, standardized, rationalized and renamed 'pressure'
parent
e134af2a
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/postProcessing/functionObjects/field/Make/files
View file @
0a43d605
...
...
@@ -42,5 +42,6 @@ Lambda2/Lambda2.C
CourantNo/CourantNo.C
PecletNo/PecletNo.C
blendingFactor/blendingFactor.C
pressure/pressure.C
LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects
src/postProcessing/functionObjects/f
orces
/pressure
Tools
/pressure
Tools
.C
→
src/postProcessing/functionObjects/f
ield
/pressure/pressure.C
View file @
0a43d605
...
...
@@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "pressure
Tools
.H"
#include "pressure.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
...
...
@@ -33,172 +33,150 @@ namespace Foam
{
namespace
functionObjects
{
defineTypeNameAndDebug
(
pressure
Tools
,
0
);
addToRunTimeSelectionTable
(
functionObject
,
pressure
Tools
,
dictionary
);
defineTypeNameAndDebug
(
pressure
,
0
);
addToRunTimeSelectionTable
(
functionObject
,
pressure
,
dictionary
);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam
::
word
Foam
::
functionObjects
::
pressure
Tools
::
p
Name
()
const
Foam
::
word
Foam
::
functionObjects
::
pressure
::
result
Name
()
const
{
word
fieldName
=
pName_
;
word
rName
;
if
(
calcTotal_
)
{
field
Name
=
"total("
+
fieldName
+
")"
;
r
Name
=
"total("
+
fieldName
_
+
")"
;
}
else
{
field
Name
=
"static("
+
fieldName
+
")"
;
r
Name
=
"static("
+
fieldName
_
+
")"
;
}
if
(
calcCoeff_
)
{
fieldName
=
fieldName
+
"_coeff"
;
rName
+=
"_coeff"
;
}
return
field
Name
;
return
r
Name
;
}
Foam
::
dimensionedScalar
Foam
::
functionObjects
::
pressure
Tools
::
rhoScale
Foam
::
tmp
<
Foam
::
volScalarField
>
Foam
::
functionObjects
::
pressure
::
rhoScale
(
const
volScalarField
&
p
)
const
{
if
(
p
.
dimensions
()
==
dimPressure
)
{
return
dimensionedScalar
(
"1"
,
dimless
,
1
.
0
)
;
return
p
;
}
else
{
return
dimensionedScalar
(
"rho
Re
f"
,
dimDensity
,
rhoInf_
);
return
dimensionedScalar
(
"rho
In
f"
,
dimDensity
,
rhoInf_
)
*
p
;
}
}
Foam
::
tmp
<
Foam
::
volScalarField
>
Foam
::
functionObjects
::
pressure
Tools
::
rho
Foam
::
tmp
<
Foam
::
volScalarField
>
Foam
::
functionObjects
::
pressure
::
rho
Scale
(
const
volScalarField
&
p
const
volScalarField
&
p
,
const
tmp
<
volScalarField
>&
tsf
)
const
{
if
(
p
.
dimensions
()
==
dimPressure
)
{
return
p
.
mesh
().
lookupObject
<
volScalarField
>
(
rhoName_
);
return
lookupField
<
volScalarField
>
(
rhoName_
)
*
tsf
;
}
else
{
return
tmp
<
volScalarField
>
(
new
volScalarField
(
IOobject
(
"rho"
,
p
.
mesh
().
time
().
timeName
(),
p
.
mesh
(),
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
p
.
mesh
(),
dimensionedScalar
(
"zero"
,
dimDensity
,
rhoInf_
)
)
);
return
dimensionedScalar
(
"rhoInf"
,
dimDensity
,
rhoInf_
)
*
tsf
;
}
}
Foam
::
dimensionedScalar
Foam
::
functionObjects
::
pressureTools
::
pRef
()
const
Foam
::
tmp
<
Foam
::
volScalarField
>
Foam
::
functionObjects
::
pressure
::
pRef
(
const
tmp
<
volScalarField
>&
tp
)
const
{
dimensionedScalar
value
(
"pRef"
,
dimPressure
,
0
.
0
);
if
(
calcTotal_
)
{
value
.
value
()
+=
pRef_
;
return
tp
+
dimensionedScalar
(
"pRef"
,
dimPressure
,
pRef_
);
}
else
{
return
tmp
<
volScalarField
>
(
tp
.
ptr
());
}
return
value
;
}
Foam
::
tmp
<
Foam
::
volScalarField
>
Foam
::
functionObjects
::
pressure
Tools
::
pDyn
Foam
::
tmp
<
Foam
::
volScalarField
>
Foam
::
functionObjects
::
pressure
::
pDyn
(
const
volScalarField
&
p
const
volScalarField
&
p
,
const
tmp
<
volScalarField
>&
tp
)
const
{
tmp
<
volScalarField
>
tpDyn
(
new
volScalarField
(
IOobject
(
"pDyn"
,
mesh_
.
time
().
timeName
(),
mesh_
,
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
mesh_
,
dimensionedScalar
(
"zero"
,
dimPressure
,
0
.
0
)
)
);
if
(
calcTotal_
)
{
const
volVectorField
&
U
=
obr_
.
lookupObject
<
volVectorField
>
(
UName_
);
tpDyn
.
ref
()
==
rho
(
p
)
*
0
.
5
*
magSqr
(
U
);
return
tp
+
rhoScale
(
p
,
0
.
5
*
magSqr
(
lookupField
<
volVectorField
>
(
UName_
)));
}
else
{
return
tmp
<
volScalarField
>
(
tp
.
ptr
());
}
return
tpDyn
;
}
Foam
::
tmp
<
Foam
::
volScalarField
>
Foam
::
functionObjects
::
pressure
Tools
::
convertToC
oeff
Foam
::
functionObjects
::
pressure
::
c
oeff
(
const
volScalarField
&
p
const
tmp
<
volScalarField
>
&
t
p
)
const
{
tmp
<
volScalarField
>
tCoeff
(
p
);
if
(
calcCoeff_
)
{
tCoeff
.
ref
()
-=
dimensionedScalar
(
"pInf"
,
dimPressure
,
pInf_
);
tmp
<
volScalarField
>
tpCoeff
(
tp
.
ptr
());
volScalarField
&
pCoeff
=
tpCoeff
.
ref
();
const
dimensionedScalar
p0
(
"p0"
,
dimPressure
,
SMALL
);
pCoeff
-=
dimensionedScalar
(
"pInf"
,
dimPressure
,
pInf_
);
const
dimensionedScalar
pSmall
(
"pSmall"
,
dimPressure
,
SMALL
);
const
dimensionedVector
U
(
"U"
,
dimVelocity
,
UInf_
);
const
dimensionedScalar
rho
(
"rho"
,
dimDensity
,
rhoInf_
);
tCoeff
.
ref
()
/=
0
.
5
*
rho
*
magSqr
(
U
)
+
p0
;
}
pCoeff
/=
0
.
5
*
rho
*
magSqr
(
U
)
+
pSmall
;
return
tCoeff
;
return
tpCoeff
;
}
else
{
return
tmp
<
volScalarField
>
(
tp
.
ptr
());
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam
::
functionObjects
::
pressure
Tools
::
pressure
Tools
Foam
::
functionObjects
::
pressure
::
pressure
(
const
word
&
name
,
const
Time
&
runTime
,
const
dictionary
&
dict
)
:
fvMeshFunctionObject
(
name
,
runTime
,
dict
),
pName_
(
"p"
),
fieldExpression
(
name
,
runTime
,
dict
,
"p"
),
UName_
(
"U"
),
rhoName_
(
"rho"
),
calcTotal_
(
false
),
pRef_
(
0
.
0
),
pRef_
(
0
),
calcCoeff_
(
false
),
pInf_
(
0
.
0
),
pInf_
(
0
),
UInf_
(
Zero
),
rhoInf_
(
0
.
0
)
rhoInf_
(
1
)
{
read
(
dict
);
...
...
@@ -208,39 +186,19 @@ Foam::functionObjects::pressureTools::pressureTools
{
pDims
/=
dimPressure
;
}
volScalarField
*
pPtr
(
new
volScalarField
(
IOobject
(
pName
(),
mesh_
.
time
().
timeName
(),
mesh_
,
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
mesh_
,
dimensionedScalar
(
"0"
,
pDims
,
0
.
0
)
)
);
mesh_
.
objectRegistry
::
store
(
pPtr
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam
::
functionObjects
::
pressure
Tools
::~
pressure
Tools
()
Foam
::
functionObjects
::
pressure
::~
pressure
()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool
Foam
::
functionObjects
::
pressure
Tools
::
read
(
const
dictionary
&
dict
)
bool
Foam
::
functionObjects
::
pressure
::
read
(
const
dictionary
&
dict
)
{
dict
.
readIfPresent
(
"p"
,
pName_
);
dict
.
readIfPresent
(
"U"
,
UName_
);
dict
.
readIfPresent
(
"rho"
,
rhoName_
);
...
...
@@ -274,37 +232,28 @@ bool Foam::functionObjects::pressureTools::read(const dictionary& dict)
}
}
return
true
;
}
bool
Foam
::
functionObjects
::
pressureTools
::
execute
(
const
bool
postProcess
)
{
const
volScalarField
&
p
=
obr_
.
lookupObject
<
volScalarField
>
(
pName_
);
volScalarField
&
pResult
=
const_cast
<
volScalarField
&>
(
obr_
.
lookupObject
<
volScalarField
>
(
pName
())
);
pResult
==
convertToCoeff
(
rhoScale
(
p
)
*
p
+
pDyn
(
p
)
+
pRef
());
resultName_
=
dict
.
lookupOrDefault
<
word
>
(
"result"
,
resultName
());
return
true
;
}
bool
Foam
::
functionObjects
::
pressure
Tools
::
wri
te
(
const
bool
postProcess
)
bool
Foam
::
functionObjects
::
pressure
::
execu
te
(
const
bool
postProcess
)
{
const
volScalarField
&
pResult
=
obr_
.
lookupObject
<
volScalarField
>
(
pName
());
Info
<<
type
()
<<
" "
<<
name
()
<<
" output:"
<<
nl
<<
" writing field "
<<
pResult
.
name
()
<<
nl
<<
endl
;
pResult
.
write
();
if
(
foundField
<
volScalarField
>
(
fieldName_
))
{
const
volScalarField
&
p
=
lookupField
<
volScalarField
>
(
fieldName_
);
return
true
;
return
store
(
resultName_
,
coeff
(
pRef
(
pDyn
(
p
,
rhoScale
(
p
))))
);
}
else
{
return
false
;
}
}
...
...
src/postProcessing/functionObjects/f
orces
/pressure
Tools
/pressure
Tools
.H
→
src/postProcessing/functionObjects/f
ield
/pressure/pressure.H
View file @
0a43d605
...
...
@@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::functionObjects::pressure
Tools
Foam::functionObjects::pressure
Group
grpForcesFunctionObjects
...
...
@@ -33,54 +33,54 @@ Description
- static pressure
\f[
p
_s
= \rho p_k
p = \rho p_k
\f]
- total pressure
\f[
p_
T
= p_{ref} + p
_s
+ 0.5 \rho |U|^2
p_
0
= p_{ref} + p + 0.5 \rho |U|^2
\f]
- static pressure coefficient
\f[
Cp
_s
= \frac{p
_s
- p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}
Cp = \frac{p - p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}
\f]
- total pressure coefficient
\f[
Cp_
T
= \frac{p_
T
- p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}
Cp_
0
= \frac{p_
0
- p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}
\f]
where
\vartable
\rho |
d
ensity [kg/m3]
U |
v
elocity [m/s]
\rho_{\inf} |
f
reestream density [kg/m3]
p_{\inf} |
f
reestream pressure [Pa]
U_{\inf} |
f
reestream velocity [m/s]
p_k |
k
inematic pressure (p/rho)[m2/s2]
p
_s
|
p
ressure [Pa]
p_
T
|
t
otal pressure [Pa]
p_{ref} |
r
eference pressure level [Pa]
Cp
_{s}
|
p
ressure coefficient
Cp_
{T}
|
t
otal pressure coefficient
\rho |
D
ensity [kg/m3]
U |
V
elocity [m/s]
\rho_{\inf} |
F
reestream density [kg/m3]
p_{\inf} |
F
reestream pressure [Pa]
U_{\inf} |
F
reestream velocity [m/s]
p_k |
K
inematic pressure (p/rho)[m2/s2]
p
|
P
ressure [Pa]
p_
0
|
T
otal pressure [Pa]
p_{ref} |
R
eference pressure level [Pa]
Cp
|
P
ressure coefficient
Cp_
0
|
T
otal pressure coefficient
\endvartable
The function object will operate on both kinematic (\f$ p_k \f$) and static
pressure (\f$ p
_s
\f$) fields, and the result is written as a
pressure (\f$ p \f$) fields, and the result is written as a
volScalarField.
The modes of operation are:
\table
Mode | calcTotal | calcCoeff
s
tatic pressure | no | no
t
otal pressure | yes | no
p
ressure coefficient | no | yes
t
otal pressure coefficient | yes | yes
S
tatic pressure | no | no
T
otal pressure | yes | no
P
ressure coefficient | no | yes
T
otal pressure coefficient | yes | yes
\endtable
Example of function object specification to calculate pressure coefficient:
\verbatim
pressure
Tools
1
pressure1
{
type pressure
Tools
;
type pressure;
libs ("libutilityFunctionObjects.so");
...
calcTotal no;
...
...
@@ -90,28 +90,33 @@ Description
\heading Function object usage
\table
Property | Description | Required | Default value
type | type name: pressureTools| yes |
calcTotal | Calculate total coefficient | yes |
pRef | Reference pressure for total pressure | no | 0.0
Property | Description | Required | Default value
type | type name: pressure | yes |
field | Name of the pressure field | no | p
U | Name of the velocity field | no | U
rho | Name of the density field | no | rho
result | Name of the resulting field | no | derived from p
calcTotal | Calculate total coefficient | yes |
pRef | Reference pressure for total pressure | no | 0
calcCoeff | Calculate pressure coefficient | yes |
pInf | Freestream pressure for coefficient calculation | no |
UInf | Freestream velocity for coefficient calculation | no |
rhoInf | Freestream density for coefficient calculation | no |
rhoInf | Freestream density for coefficient calculation
| no |
\endtable
SeeAlso
Foam::functionObjects::fieldExpression
Foam::functionObjects::fvMeshFunctionObject
SourceFiles
pressure
Tools
.C
pressure.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_pressure
Tools
_H
#define functionObjects_pressure
Tools
_H
#ifndef functionObjects_pressure_H
#define functionObjects_pressure_H
#include "f
vMeshFunctionObject
.H"
#include "f
ieldExpression
.H"
#include "volFieldsFwd.H"
#include "dimensionedScalar.H"
...
...
@@ -123,18 +128,15 @@ namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class pressure
Tools
Declaration
Class pressure Declaration
\*---------------------------------------------------------------------------*/
class
pressure
Tools
class
pressure
:
public
f
vMeshFunctionObject
public
f
ieldExpression
{
// Private data
//- Name of pressure field, default is "p"
word
pName_
;
//- Name of velocity field, default is "U"
word
UName_
;
...
...
@@ -169,40 +171,42 @@ class pressureTools
// Private Member Functions
//- Return the name of the derived pressure field
word
p
Name
()
const
;
word
result
Name
()
const
;
//-
Return the density scaling if supplied with kinematic press
ur
e
dimensionedScalar
rhoScale
(
const
volScalarField
&
p
)
const
;
//-
Multiply the static pressure p by rhoInf if necessary and ret
ur
n
tmp
<
volScalarField
>
rhoScale
(
const
volScalarField
&
p
)
const
;
//- Return the density field
tmp
<
volScalarField
>
rho
(
const
volScalarField
&
p
)
const
;
//- Multiply the given field by rho or rhoInf as appropriate and return
tmp
<
volScalarField
>
rhoScale
(
const
volScalarField
&
p
,
const
tmp
<
volScalarField
>&
tsf
)
const
;
//- Return the reference pressure
dimensionedScalar
pRef
(
)
const
;
tmp
<
volScalarField
>
pRef
(
const
tmp
<
volScalarField
>&
tp
)
const
;
//- Calculate and return the dynamic pressure
tmp
<
volScalarField
>
pDyn
(
const
volScalarField
&
p
)
const
;
tmp
<
volScalarField
>
pDyn
(
const
volScalarField
&
p
,
const
tmp
<
volScalarField
>&
tp
)
const
;
//- Convert to coeff by applying the freestream dynamic pressure scaling
tmp
<
volScalarField
>
convertToCoeff
(
const
volScalarField
&
p
)
const
;
//- Disallow default bitwise copy construct
pressureTools
(
const
pressureTools
&
);
//- Disallow default bitwise assignment
void
operator
=
(
const
pressureTools
&
);
tmp
<
volScalarField
>
coeff
(
const
tmp
<
volScalarField
>&
tp
)
const
;
public:
//- Runtime type information
TypeName
(
"pressure
Tools
"
);
TypeName
(
"pressure"
);
// Constructors
//- Construct from Time and dictionary
pressure
Tools
pressure
(
const
word
&
name
,
const
Time
&
runTime
,
...
...
@@ -211,19 +215,16 @@ public:
//- Destructor
virtual
~
pressure
Tools
();
virtual
~
pressure
();
// Member Functions
//- Read the pressure
Tools
data
//- Read the pressure data
virtual
bool
read
(
const
dictionary
&
);
//-
Execute, currently does nothing
//-
Calculate the selected pressure form
virtual
bool
execute
(
const
bool
postProcess
=
false
);
//- Calculate the pressureTools and write
virtual
bool
write
(
const
bool
postProcess
=
false
);
};
...
...
src/postProcessing/functionObjects/forces/Make/files
View file @
0a43d605
pressureTools/pressureTools.C
wallShearStress/wallShearStress.C
forces/forces.C
forceCoeffs/forceCoeffs.C
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment