ENH: add isTrue function to RunFunctions

- check if the first argument corresponds to an OpenFOAM value for
  'true' (as per Switch).
  True == 't', 'y', 'true', 'yes', 'on'. Everything else is not true.

- when the first argument is '-dict', it initializes the value
  with a query via foamDictionary.
  Eg,
       isTrue -dict mydict -entry parallel

   ==> value=$(foamDictionary mydict -entry parallel -value)
       isTrue $value

   a missing entry is silently treated as false.

ENH: add getNumberOfPatchFaces function in RunFunctions

- simple extraction of nFaces from boundary file for given patch/region
This commit is contained in:
Mark Olesen
2018-11-30 19:29:49 +01:00
parent f2e88645c2
commit c5beee63f3
3 changed files with 134 additions and 28 deletions

View File

@ -1,12 +1,14 @@
#!/bin/sh
#
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
# Dummy external solver to communicate with OpenFOAM via externalCoupled
# functionObject
#
# Functionality is hard-coded for this particular test case
# - patch temperatures increased by 1K on each step
#
cd ${0%/*} || exit 1 # Run from this directory
# -----------------------------------------------------------------------------
# Check for unassigned variables
set -u
@ -53,28 +55,44 @@ stopMasterNow()
}
# Patch size (heater/minY)
nFaces1=$(getNumberOfPatchFaces minY heater) || exit $?
# Patch size (topAir/minX)
nFaces2=$(getNumberOfPatchFaces minX topAir) || exit $?
init()
{
log "init - creating ${dataFile}.in"
cat /dev/null >| "${dataFile}.in"
# Hard-coded for patch of size 8 (heater/minY)
local n1=8
local refValue1=500
# Local face counter, Local refValue
local nFaces refValue
log "init - adding $n1 data elements with refValue $refValue1"
for i in $(seq 1 $n1)
# Patch (heater/minY)
nFaces="$nFaces1"
refValue=500
log "init - adding $nFaces data elements with refValue $refValue"
while [ "$nFaces" -gt 0 ]
do
echo "$refValue1 $refGrad $valueFraction"
nFaces=$((nFaces - 1))
echo "$refValue $refGrad $valueFraction"
done >> "${dataFile}.in"
# Hard-coded for patch of size 40 (topAir/minX)
local n2=40
local refValue2=300
log "init - adding $n2 data elements with refValue $refValue2"
for i in $(seq 1 $n2)
# Patch (topAir/minX)
nFaces="$nFaces2"
refValue=300
log "init - adding $nFaces data elements with refValue $refValue"
while [ "$nFaces" -gt 0 ]
do
echo "$refValue2 $refGrad $valueFraction"
nFaces=$((nFaces - 1))
echo "$refValue $refGrad $valueFraction"
done >> "${dataFile}.in"
# Verify line count?

View File

@ -1,12 +1,14 @@
#!/bin/sh
#
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
# Dummy external solver to communicate with OpenFOAM via externalCoupled
# functionObject
#
# Functionality is hard-coded for this particular test case
# - patch temperatures increased by 1K on each step
#
cd ${0%/*} || exit 1 # Run from this directory
# -----------------------------------------------------------------------------
# Check for unassigned variables
set -u
@ -53,28 +55,44 @@ stopMasterNow()
}
# Patch size (heater/minY)
nFaces1=$(getNumberOfPatchFaces minY heater) || exit $?
# Patch size (topAir/minX)
nFaces2=$(getNumberOfPatchFaces minX topAir) || exit $?
init()
{
log "init - creating ${dataFile}.in"
cat /dev/null >| "${dataFile}.in"
# Hard-coded for patch of size 8 (heater/minY)
local n1=8
local refValue1=500
# Local face counter, Local refValue
local nFaces refValue
log "init - adding $n1 data elements with refValue $refValue1"
for i in $(seq 1 $n1)
# Patch (heater/minY)
nFaces="$nFaces1"
refValue=500
log "init - adding $nFaces data elements with refValue $refValue"
while [ "$nFaces" -gt 0 ]
do
echo "$refValue1 $refGrad $valueFraction"
nFaces=$((nFaces - 1))
echo "$refValue $refGrad $valueFraction"
done >> "${dataFile}.in"
# Hard-coded for patch of size 40 (topAir/minX)
local n2=40
local refValue2=300
log "init - adding $n2 data elements with refValue $refValue2"
for i in $(seq 1 $n2)
# Patch (topAir/minX)
nFaces="$nFaces2"
refValue=300
log "init - adding $nFaces data elements with refValue $refValue"
while [ "$nFaces" -gt 0 ]
do
echo "$refValue2 $refGrad $valueFraction"
nFaces=$((nFaces - 1))
echo "$refValue $refGrad $valueFraction"
done >> "${dataFile}.in"
# Verify line count?