Commit ed183b7c authored by sergio's avatar sergio
Browse files

Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

parents 709d2f43 c6433e32
......@@ -7,34 +7,28 @@
# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
#
# Script
# foamEtcFile
#
# Description
# Locate user/group/other files with semantics similar to the
# ~OpenFOAM/fileName expansion.
# Locate user/group/other file as per '#includeEtc'.
#
# The -mode option can be used to allow chaining from
# personal settings to site-wide settings.
# The -mode option can be used to allow chaining from personal settings
# to site-wide settings.
#
# For example, within the user ~/.OpenFOAM/<VER>/config.sh/compiler:
# \code
# eval $(foamEtcFile -sh -mode=go config.sh/compiler)
# \endcode
#
# For example, within the user ~/.OpenFOAM/<VER>/prefs.sh:
# The -mode option is similarly used within etc/{bashrc,cshrc} to ensure
# that system prefs are respected:
# \code
# eval $(foamEtcFile -sh -mode=go prefs.sh)
# eval $(foamEtcFile -sh -mode=o prefs.sh)
# eval $(foamEtcFile -sh -mode=ug prefs.sh)
# \endcode
#
# Environment
......@@ -49,37 +43,34 @@
# - $WM_PROJECT_INST_DIR/openfoam<VERSION>/bin (debian version)
#
#-------------------------------------------------------------------------------
unset optQuiet optSilent
usage() {
[ "${optQuiet:-$optSilent}" = true ] && exit 1
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
printHelp() {
cat<<USAGE
Usage: foamEtcFile [OPTION] fileName
foamEtcFile [OPTION] [-list|-list-test] [fileName]
options:
-a, -all Return all files (otherwise stop after the first match)
-l, -list List directories or files to be checked
-all (-a) Return all files (otherwise stop after the first match)
-list (-l) List directories or files to be checked
-list-test List (existing) directories or files to be checked
-mode=MODE Any combination of u(user), g(group), o(other)
-prefix=DIR Specify an alternative installation prefix
-version=VER Specify alternative OpenFOAM version (eg, 3.0, 1612, ...)
-csh | -sh Produce output suitable for a csh or sh 'eval'
-csh-verbose | -sh-verbose
As per -csh | -sh, with additional verbosity
-q, -quiet Suppress all normal output
-s, -silent Suppress stderr, except -csh-verbose, -sh-verbose output
-csh Produce output suitable for a csh or sh 'eval'
-csh-verbose As per -csh with additional verbosity
-sh Produce output suitable for a csh or sh 'eval'
-sh-verbose As per -sh with additional verbosity
-quiet (-q) Suppress all normal output
-silent (-s) Suppress stderr, except -csh-verbose, -sh-verbose output
-help Print the usage
Locate user/group/other file with semantics similar to the
~OpenFOAM/fileName expansion.
Locate user/group/other file as per '#includeEtc'
Single character options must not be grouped. Equivalent options:
-mode=MODE, -mode MODE, -m MODE
-prefix=DIR, -prefix DIR, -p DIR
-version=VER, -version VER, -v VER
Do not group single character options.
Equivalent options:
| -mode=MODE | -mode MODE | -m MODE
| -prefix=DIR | -prefix DIR | -p DIR
| -version=VER | -version VER | -v VER
Exit status
0 when the file is found. Print resolved path to stdout.
......@@ -87,9 +78,11 @@ Exit status
2 when the file is not found.
USAGE
exit 1
exit 0 # A clean exit
}
unset optQuiet optSilent
# Report error and exit
die()
{
......@@ -197,7 +190,7 @@ while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*)
usage
printHelp
;;
-a | -all)
optAll=true
......
......@@ -78,7 +78,7 @@ unset regionName optTouch
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help-*)
-h | -help*)
printHelp
;;
-block*)
......
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# rmcore
#
# Description
# remove all core files
#------------------------------------------------------------------------------
case "$1" in
-h | -help*)
exec 1>&2
echo "Usage: ${0##*/} [dir1] .. [dirN]"
echo " remove all core files"
exit 1
;;
esac
# Default is pwd
[ "$#" -gt 0 ] || set -- .
for i
do
if [ -d "$i" ]
then
echo "removing all core files: $i" 1>&2
find $i \( -name core -o -name 'core.[1-9]*' -o -name 'vgcore.*' \) -type f -delete
else
echo "no directory: $i" 1>&2
fi
done
#------------------------------------------------------------------------------
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# rm~all
#
# Description
# remove all *~ files
#------------------------------------------------------------------------------
case "$1" in
-h | -help*)
exec 1>&2
echo "Usage: ${0##*/} [dir1] .. [dirN]"
echo " remove all *~ files"
exit 1
;;
esac
# default is pwd
[ "$#" -gt 0 ] || set -- .
for i
do
if [ -d "$i" ]
then
echo "removing all *~ files: $i" 1>&2
find $i \( -name '*~' -o -name '.*~' \) -type f -delete -print
else
echo "no directory: $i" 1>&2
fi
done
#------------------------------------------------------------------------------
......@@ -7,20 +7,8 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
#
# Script
# foamCreateCompletionCache
......@@ -150,7 +138,8 @@ HEADER
extractOptions()
{
local appName="$1"
local helpText=$($appName -help 2>/dev/null | sed -ne '/^ *-/p')
local helpText=$($appName -help-full 2>/dev/null | \
sed -n -e 's/,/ /g' -e 's/=.*$/=/' -e '/^ *-/p')
[ -n "$helpText" ] || {
echo "Error calling $appName" 1>&2
......@@ -169,7 +158,8 @@ extractOptions()
}
#------------------------------------------------------------------------------
[ "$#" -gt 0 ] || set -- ${searchDirs}
# Default to standard search directories and a few scripts from bin/
[ "$#" -gt 0 ] || set -- ${searchDirs} paraFoam
for item
do
......
......@@ -41,8 +41,8 @@ then
fi
# Add completion for command or directory of commands
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Add completion for commands, directories of commands
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
unset -f foamAddCompletion 2>/dev/null
foamAddCompletion()
{
......@@ -134,7 +134,10 @@ _of_complete_()
# Not in cache, obtain by parsing application -help-full
if [ -z "$choices" ]
then
local helpText=$($appName -help-full 2>/dev/null | sed -ne '/^ *-/p')
# Treat ',' like space so '-a, -all' parses like '-a | -all'
# Options with '=' (Eg, -mode=ugo) are not handled very well.
local helpText=$($appName -help-full 2>/dev/null | \
sed -n -e 's/,/ /g' -e 's/=.*$/=/' -e '/^ *-/p')
if [ -n "$helpText" ]
then
......@@ -206,6 +209,8 @@ then
# Generate completions for predefined directories
foamAddCompletion $FOAM_APPBIN
# And a few scripts from bin/
foamAddCompletion paraFoam
fi
else
# Bash version is too old.
......
This diff is collapsed.
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -142,6 +142,10 @@ Foam::fv::effectivenessHeatExchangerSource::effectivenessHeatExchangerSource
secondaryInletT_(0),
primaryInletT_(0),
userPrimaryInletT_(false),
targetQdotActive_(false),
targetQdot_(0),
targetQdotCalcInterval_(5),
targetQdotRelax_(0.5),
eTable_(),
UName_("U"),
TName_("T"),
......@@ -225,48 +229,52 @@ void Foam::fv::effectivenessHeatExchangerSource::addSup
reduce(CpfMean, sumOp<scalar>());
reduce(sumPhi, sumOp<scalar>());
reduce(sumMagPhi, sumOp<scalar>());
reduce(primaryInletTfMean, sumOp<scalar>());
primaryInletTfMean /= sumMagPhi + ROOTVSMALL;
CpfMean /= sumMagPhi + ROOTVSMALL;
scalar primaryInletT = primaryInletT_;
if (!userPrimaryInletT_)
{
primaryInletT = primaryInletTfMean;
reduce(primaryInletTfMean, sumOp<scalar>());
primaryInletT = primaryInletTfMean/(sumMagPhi + ROOTVSMALL);
}
scalar Qt =
const scalar alpha =
eTable_()(mag(sumPhi), secondaryMassFlowRate_)
*(secondaryInletT_ - primaryInletT)
*CpfMean*mag(sumPhi);
const scalarField TCells(T, cells_);
scalar Tref = 0;
if (Qt > 0)
{
Tref = max(TCells);
reduce(Tref, maxOp<scalar>());
}
else
const scalar Qt = alpha*(secondaryInletT_ - primaryInletT);
if
(
targetQdotActive_
&& (mesh_.time().timeIndex() % targetQdotCalcInterval_ == 0)
)
{
Tref = min(TCells);
reduce(Tref, minOp<scalar>());
scalar dT = (targetQdot_ - Qt)/(alpha + ROOTVSMALL);
secondaryInletT_ += targetQdotRelax_*dT;
}
const scalarField TCells(T, cells_);
scalar Tref = 0;
scalarField deltaTCells(cells_.size(), 0);
forAll(deltaTCells, i)
if (Qt > 0)
{
if (Qt > 0)
Tref = gMax(TCells);
forAll(deltaTCells, i)
{
deltaTCells[i] = max(Tref - TCells[i], 0.0);
}
else
}
else
{
Tref = gMin(TCells);
forAll(deltaTCells, i)
{
deltaTCells[i] = max(TCells[i] - Tref, 0.0);
}
}
const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
const scalarField& V = mesh_.V();
scalar sumWeight = 0;
......@@ -293,6 +301,7 @@ void Foam::fv::effectivenessHeatExchangerSource::addSup
Info<< type() << ": " << name() << nl << incrIndent
<< indent << "Net mass flux [Kg/s] : " << sumPhi << nl
<< indent << "Total energy exchange [W] : " << Qt << nl
<< indent << "Secondary inlet T [K] : " << secondaryInletT_ << nl
<< indent << "Tref [K] : " << Tref << nl
<< indent << "Effectiveness : "
<< eTable_()(mag(sumPhi), secondaryMassFlowRate_) << decrIndent
......@@ -314,7 +323,7 @@ bool Foam::fv::effectivenessHeatExchangerSource::read(const dictionary& dict)
if (coeffs_.readIfPresent("primaryInletT", primaryInletT_))
{
Info<< type() << " " << this->name() << ": "
Info<< type() << " " << this->name() << ": " << indent << nl
<< "employing user-specified primary flow inlet temperature: "
<< primaryInletT_ << endl;
......@@ -322,11 +331,33 @@ bool Foam::fv::effectivenessHeatExchangerSource::read(const dictionary& dict)
}
else
{
Info<< type() << " " << this->name() << ": "
Info<< type() << " " << this->name() << ": " << indent << nl
<< "employing flux-weighted primary flow inlet temperature"
<< endl;
}
if (coeffs_.readIfPresent("targetQdot", targetQdot_))
{
targetQdotActive_ = true;
Info<< indent << "employing target heat rejection of "
<< targetQdot_ << nl;
coeffs_.readIfPresent
(
"targetQdotCalcInterval",
targetQdotCalcInterval_
);
Info<< indent << "updating secondary inlet temperature every "
<< targetQdotCalcInterval_ << " iterations" << nl;
coeffs_.readIfPresent("targetQdotRelax", targetQdotRelax_);
Info<< indent << "temperature relaxation: "
<< targetQdotRelax_ << endl;
}
return true;
}
else
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -28,8 +28,8 @@ Group
grpFvOptionsSources
Description
Heat exchanger source model, in which the heat exchanger is defined as a
selection of cells.
Heat exchanger source model, in which the heat exchanger is defined as an
energy source using a selection of cells.
The total heat exchange source is given by:
\f[
......@@ -75,13 +75,21 @@ Usage
secondaryMassFlowRate 1.0;
secondaryInletT 336;
// primaryInletT 293; // Constrain to this T if present
faceZone facesZoneInletOriented;
outOfBounds clamp;
file "effTable";
// Optional
// primaryInletT 293;
// targetQdot 1500;
}
\endverbatim
Optional entries:
- \c primaryInletT : sets the primary inlet temperature. If not set, the
flux-averaged temperature is used.
- \c targetQdot : target heat rejection
The effectiveness table is described in terms of the primary and secondary
mass flow rates. For example, the table:
......@@ -95,7 +103,7 @@ Usage
\endverbatim
Is specified by the following:
is specified by the following:
\verbatim
(
......@@ -121,9 +129,9 @@ Usage
\endverbatim
Note
- the table with name "file" should have the same units as the
- the table with name \c file should have the same units as the
secondary mass flow rate and kg/s for phi
- faceZone is the faces at the inlet of the cellzone, it needs to be
- \c faceZone is the faces at the inlet of the \c cellzone, it needs to be
created with flip map flags. It is used to integrate the net mass flow
rate into the heat exchanger
......@@ -133,8 +141,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef effectivenessHeatExchangerSource_H
#define effectivenessHeatExchangerSource_H
#ifndef fv_effectivenessHeatExchangerSource_H
#define fv_effectivenessHeatExchangerSource_H
#include "cellSetOption.H"
#include "autoPtr.H"
......@@ -172,6 +180,18 @@ protected:
//- Flag to use a user-specified primary inlet temperature
bool userPrimaryInletT_;
//- Flag to use target heat rejection
bool targetQdotActive_;
//- Target heat rejection
scalar targetQdot_;
//- Target heat rejection calculation interval
label targetQdotCalcInterval_;
//- Target heat rejection temperature under-relaxation coefficient
scalar targetQdotRelax_;
//- 2D look up table efficiency = function of primary and secondary
// mass flow rates [kg/s]
autoPtr<interpolation2DTable<scalar>> eTable_;
......@@ -214,7 +234,7 @@ private:
//- Initialise heat exchanger source model
void initialise();
//- Calculate total area of faceZone accross processors
//- Calculate total area of faceZone across processors
void calculateTotalArea(scalar& area);
......@@ -237,8 +257,7 @@ public:
//- Destructor
virtual ~effectivenessHeatExchangerSource()
{}
virtual ~effectivenessHeatExchangerSource() = default;
// Member Functions
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment