Commit 9157364a authored by Mark Olesen's avatar Mark Olesen
Browse files

Merge commit 'OpenCFD/master' into olesenm

parents b3cdac4b 33947e73
......@@ -99,7 +99,7 @@
and a csh/tcsh example:
+ setenv FOAM_INST_DIR /data/app/OpenFOAM
+ foamDotFile=$FOAM_INST_DIR/OpenFOAM-1.6/etc/bashrc
+ foamDotFile=$FOAM_INST_DIR/OpenFOAM-1.6/etc/cshrc
+ if ( -f $foamDotFile ) source $foamDotFile
The value set in '$FOAM_INST_DIR' will be used to locate the remaining parts
......
......@@ -45,7 +45,7 @@ Description
so cannot have any cells in any other zone.
- useCellZonesOnly does not do a walk and uses the cellZones only. Use
this if you don't mind having disconnected domains in a single region.
This option requires all cells to be in one (and one only) region.
This option requires all cells to be in one (and one only) cellZone.
\*---------------------------------------------------------------------------*/
......
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lincompressibleRASModels \
-lincompressibleTransportModels \
-lgenericPatchFields \
-lmeshTools
......@@ -37,6 +37,8 @@ Description
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "RASModel.H"
#include "wallDist.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -52,54 +54,14 @@ int main(int argc, char *argv[])
argList::validOptions.insert("Cbl", "scalar");
argList::validOptions.insert("writenut", "");
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "createFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
mesh
);
# include "createPhi.H"
Info<< "Calculating wall distance field" << endl;
volScalarField y = wallDist(mesh).y();
// Set the mean boundary-layer thickness
dimensionedScalar ybl("ybl", dimLength, 0);
if (args.optionFound("ybl"))
{
// If the boundary-layer thickness is provided use it
ybl.value() = args.optionRead<scalar>("ybl");
}
else if (args.optionFound("Cbl"))
{
// Calculate boundary layer thickness as Cbl * mean distance to wall
ybl.value() = gAverage(y) * args.optionRead<scalar>("Cbl");
}
else
{
FatalErrorIn(args.executable())
<< "Neither option 'ybl' or 'Cbl' have been provided to calculate"
" the boundary-layer thickness"
<< exit(FatalError);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nCreating boundary-layer for U of thickness "
<< ybl.value() << " m" << nl << endl;
Info<< "Time = " << runTime.timeName() << nl << endl;
// Modify velocity by applying a 1/7th power law boundary-layer
// u/U0 = (y/ybl)^(1/7)
......@@ -114,58 +76,88 @@ int main(int argc, char *argv[])
}
}
Info<< "Writing U" << endl;
Info<< "Writing U\n" << endl;
U.write();
// Update/re-write phi
phi = fvc::interpolate(U) & mesh.Sf();
phi.write();
// Read and modify turbulence fields if present
// Calculate nut
tmp<volScalarField> tnut = turbulence->nut();
volScalarField& nut = tnut();
volScalarField S = mag(dev(symm(fvc::grad(U))));
nut = sqr(kappa*min(y, ybl))*::sqrt(2)*S;
IOobject epsilonHeader
(
"epsilon",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
if (args.optionFound("writenut"))
{
Info<< "Writing nut" << endl;
nut.write();
}
// Create G field - used by RAS wall functions
volScalarField G("RASModel::G", nut*2*sqr(S));
//--- Read and modify turbulence fields
// Turbulence k
tmp<volScalarField> tk = turbulence->k();
volScalarField& k = tk();
scalar ck0 = pow025(Cmu)*kappa;
k = sqr(nut/(ck0*min(y, ybl)));
k.correctBoundaryConditions();
Info<< "Writing k\n" << endl;
k.write();
IOobject kHeader
// Turbulence epsilon
tmp<volScalarField> tepsilon = turbulence->epsilon();
volScalarField& epsilon = tepsilon();
scalar ce0 = ::pow(Cmu, 0.75)/kappa;
epsilon = ce0*k*sqrt(k)/min(y, ybl);
epsilon.correctBoundaryConditions();
Info<< "Writing epsilon\n" << endl;
epsilon.write();
// Turbulence omega
IOobject omegaHeader
(
"k",
"omega",
runTime.timeName(),
mesh,
IOobject::MUST_READ
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
if (omegaHeader.headerOk())
{
volScalarField omega(omegaHeader, mesh);
omega = epsilon/(Cmu*k);
omega.correctBoundaryConditions();
Info<< "Writing omega\n" << endl;
omega.write();
}
// Turbulence nuTilda
IOobject nuTildaHeader
(
"nuTilda",
runTime.timeName(),
mesh,
IOobject::MUST_READ
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
// First calculate nut
volScalarField nut
(
"nut",
sqr(kappa*min(y, ybl))*::sqrt(2)*mag(dev(symm(fvc::grad(U))))
);
if (args.optionFound("writenut"))
{
Info<< "Writing nut" << endl;
nut.write();
}
// Read and modify turbulence fields if present
if (nuTildaHeader.headerOk())
{
Info<< "Reading field nuTilda\n" << endl;
volScalarField nuTilda(nuTildaHeader, mesh);
nuTilda = nut;
nuTilda.correctBoundaryConditions();
......@@ -174,28 +166,6 @@ int main(int argc, char *argv[])
nuTilda.write();
}
if (kHeader.headerOk() && epsilonHeader.headerOk())
{
Info<< "Reading field k\n" << endl;
volScalarField k(kHeader, mesh);
Info<< "Reading field epsilon\n" << endl;
volScalarField epsilon(epsilonHeader, mesh);
scalar ck0 = ::pow(Cmu, 0.25)*kappa;
k = sqr(nut/(ck0*min(y, ybl)));
k.correctBoundaryConditions();
scalar ce0 = ::pow(Cmu, 0.75)/kappa;
epsilon = ce0*k*sqrt(k)/min(y, ybl);
epsilon.correctBoundaryConditions();
Info<< "Writing k\n" << endl;
k.write();
Info<< "Writing epsilon\n" << endl;
epsilon.write();
}
Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
mesh
);
#include "createPhi.H"
singlePhaseTransportModel laminarTransport(U, phi);
autoPtr<incompressible::RASModel> turbulence
(
incompressible::RASModel::New(U, phi, laminarTransport)
);
Info<< "Calculating wall distance field" << endl;
volScalarField y = wallDist(mesh).y();
// Set the mean boundary-layer thickness
dimensionedScalar ybl("ybl", dimLength, 0);
if (args.optionFound("ybl"))
{
// If the boundary-layer thickness is provided use it
ybl.value() = args.optionRead<scalar>("ybl");
}
else if (args.optionFound("Cbl"))
{
// Calculate boundary layer thickness as Cbl * mean distance to wall
ybl.value() = gAverage(y)*args.optionRead<scalar>("Cbl");
}
else
{
FatalErrorIn(args.executable())
<< "Neither option 'ybl' or 'Cbl' have been provided to calculate "
<< "the boundary-layer thickness"
<< exit(FatalError);
}
Info<< "\nCreating boundary-layer for U of thickness "
<< ybl.value() << " m" << nl << endl;
// ************************************************************************* //
......@@ -206,6 +206,21 @@ done
cmd=""
if [ .$WM_MPLIB = .OPENMPI ]; then
cmd="mpirun -app $PWD/mpirun.schema </dev/null"
elif [ .$WM_MPLIB = .MPICH ]; then
cmd="mpiexec"
for ((proc=0; proc<$nProcs; proc++))
do
read procCmd
procXtermCmdFile="$PWD/processor${proc}Xterm.sh"
echo "#!/bin/sh" > $procXtermCmdFile
echo "$procCmd" >> $procXtermCmdFile
chmod +x $procXtermCmdFile
if [ $proc -ne 0 ]; then
cmd="${cmd} :"
fi
cmd="${cmd} -n 1 ${procXtermCmdFile}"
done < $PWD/mpirun.schema
fi
echo "Constructed $PWD/mpirun.schema file."
......
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
# \\/ 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 2 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, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
# paraview/bashrc
#
# Description
# Setup file for paraview-2.x
# Sourced from OpenFOAM-*/etc/bashrc
#
#------------------------------------------------------------------------------
# determine the cmake to be used
unset CMAKE_HOME
for cmake in cmake-2.6.4 cmake-2.6.2 cmake-2.4.6
do
cmake=$WM_THIRD_PARTY_DIR/$cmake/platforms/$WM_ARCH
if [ -r $cmake ]
then
export CMAKE_HOME=$cmake
export PATH=$CMAKE_HOME/bin:$PATH
break
fi
done
paraviewMajor=paraview-2.4
export ParaView_VERSION=2.4.4
export ParaView_INST_DIR=$WM_THIRD_PARTY_DIR/ParaView$ParaView_VERSION
export ParaView_DIR=$ParaView_INST_DIR/lib/$paraviewMajor
if [ -r $ParaView_INST_DIR ]
then
export PV_INTERFACE_PATH=$FOAM_UTILITIES/postProcessing/graphics/PVFoamReader/PVFoamReader/Make
export PATH=$ParaView_INST_DIR/bin:$PATH
export LD_LIBRARY_PATH=${ParaView_INST_DIR}/lib:${ParaView_INST_DIR}/lib/vtk:${LD_LIBRARY_PATH}
fi
if [ -r $ParaView_DIR ]
then
export VTK_DIR=$ParaView_DIR/VTK
fi
unset cmake paraviewMajor
# -----------------------------------------------------------------------------
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
# \\/ 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 2 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, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
# paraview/cshrc
#
# Description
# Setup file for paraview-2.x
# Sourced from OpenFOAM-*/etc/cshrc
#
#------------------------------------------------------------------------------
# determine the cmake to be used
unsetenv CMAKE_HOME
foreach cmake ( cmake-2.6.4 cmake-2.6.2 cmake-2.4.6 )
set cmake=$WM_THIRD_PARTY_DIR/$cmake/platforms/$WM_ARCH
if ( -r $cmake ) then
setenv CMAKE_HOME $cmake
set path=($CMAKE_HOME/bin $path)
break
endif
end
set paraviewMajor=paraview-2.4
setenv ParaView_VERSION 2.4.4
setenv ParaView_INST_DIR $WM_THIRD_PARTY_DIR/ParaView$ParaView_VERSION
setenv ParaView_DIR $ParaView_INST_DIR/lib/$paraviewMajor
if ( -r $ParaView_INST_DIR ) then
setenv PV_INTERFACE_PATH $FOAM_UTILITIES/postProcessing/graphics/PVFoamReader/PVFoamReader/Make
set path=($ParaView_INST_DIR/bin $path)
setenv LD_LIBRARY_PATH ${ParaView_INST_DIR}/lib:${ParaView_INST_DIR}/lib/vtk:${LD_LIBRARY_PATH}
endif
if ( -r $ParaView_DIR ) then
setenv VTK_DIR $ParaView_DIR/VTK
endif
unset cmake paraviewMajor
# -----------------------------------------------------------------------------
......@@ -46,21 +46,22 @@ do
fi
done
paraviewMajor=paraview-3.6
export ParaView_VERSION=3.6.1
# set MAJOR and VERSION variables if not already set
[ -z "$ParaView_MAJOR" ] && export ParaView_MAJOR=paraview-3.6
[ -z "$ParaView_VERSION" ] && export ParaView_VERSION=3.6.1
export ParaView_INST_DIR=$WM_THIRD_PARTY_DIR/paraview-$ParaView_VERSION
export ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER
# add in python libraries if required
paraviewPython=$ParaView_DIR/Utilities/VTKPythonWrapping
if [ -r $paraviewPython ]
ParaView_PYTHON_DIR=$ParaView_DIR/Utilities/VTKPythonWrapping
if [ -r $ParaView_PYTHON_DIR ]
then
if [ "$PYTHONPATH" ]
then
export PYTHONPATH=$PYTHONPATH:$paraviewPython:$ParaView_DIR/lib/$paraviewMajor
export PYTHONPATH=$PYTHONPATH:$ParaView_PYTHON_DIR:$ParaView_DIR/lib/$ParaView_MAJOR
else
export PYTHONPATH=$paraviewPython:$ParaView_DIR/lib/$paraviewMajor
export PYTHONPATH=$ParaView_PYTHON_DIR:$ParaView_DIR/lib/$ParaView_MAJOR
fi
fi
......@@ -70,5 +71,5 @@ then
export PV_PLUGIN_PATH=$FOAM_LIBBIN
fi
unset cmake paraviewMajor paraviewPython
unset cmake ParaView_PYTHON_DIR
# -----------------------------------------------------------------------------
......@@ -184,6 +184,12 @@ public:
// an out-of-range element returns false without any ill-effects
inline const T& operator[](const label) const;
//- Return last element of UList.
inline T& last();
//- Return last element of UList.
inline const T& last() const;
//- Allow cast to a const List<T>&
inline operator const Foam::List<T>&() const;
......
......@@ -114,6 +114,20 @@ inline void Foam::UList<T>::checkIndex(const label i) const
}
template<class T>
inline T& Foam::UList<T>::last()
{
return this->operator[](this->size()-1);
}
template<class T>
inline const T& Foam::UList<T>::last() const
{
return this->operator[](this->size()-1);
}
template<class T>
inline const T* Foam::UList<T>::cdata() const
{
......
......@@ -82,9 +82,6 @@ void Foam::PstreamBuffers::finishedSends(labelListList& sizes, const bool block)
if (commsType_ == UPstream::nonBlocking)
{
labelListList sizes;
labelListList send,recv;
Pstream::exchange<DynamicList<char>, char>
(
sendBuf_,
......@@ -96,20 +93,30 @@ void Foam::PstreamBuffers::finishedSends(labelListList& sizes, const bool block)
}
else
{
sizes.setSize(UPstream::nProcs());
labelList& nsTransPs = sizes[UPstream::myProcNo()];
nsTransPs.setSize(UPstream::nProcs());
forAll(sendBuf_, procI)
{
nsTransPs[procI] = sendBuf_[procI].size();
}
// Send sizes across.
int oldTag = UPstream::msgType();
UPstream::msgType() = tag_;
combineReduce(sizes, UPstream::listEq());
UPstream::msgType() = oldTag;
FatalErrorIn
(
"PstreamBuffers::finishedSends(labelListList&, const bool)"
) << "Obtaining sizes not supported in "
<< UPstream::commsTypeNames[commsType_] << endl
<< " since transfers already in progress. Use non-blocking instead."
<< exit(FatalError);
// Note: possible only if using different tag from write started
// by ~UOPstream. Needs some work.
//sizes.setSize(UPstream::nProcs());
//labelList& nsTransPs = sizes[UPstream::myProcNo()];
//nsTransPs.setSize(UPstream::nProcs());
//
//forAll(sendBuf_, procI)
//{
// nsTransPs[procI] = sendBuf_[procI].size();
//}