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

This commit is contained in:
mattijs
2016-12-01 14:32:02 +00:00
49 changed files with 1156 additions and 641 deletions

View File

@ -0,0 +1,3 @@
Test-objectRegistry.C
EXE = $(FOAM_USER_APPBIN)/Test-objectRegistry

View File

@ -0,0 +1,2 @@
/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
/* EXE_LIBS = -lfiniteVolume */

View File

@ -0,0 +1,278 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 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 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/>.
Application
Test-objectRegistry
Description
Simple test of objectRegistry functionality.
Particular focus on the behaviour of subRegistry.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "polyMesh.H"
#include "IOstreams.H"
#include "objectRegistry.H"
#include "hashedWordList.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// file variable, needed for switching the default in lookupObject etc.
bool recursive = false;
template<class Type>
Foam::Ostream& printList(Foam::Ostream& os, const UList<Type>& list)
{
// list with out any linebreaks
os << '(';
forAll(list, i)
{
if (i) os << ' ';
os << list[i];
}
os << ')';
return os;
}
void printRegistry
(
Foam::Ostream& os,
const Foam::objectRegistry& obr,
Foam::label indent = 4
);
void printRegistry
(
Foam::Ostream& os,
const Foam::objectRegistry& obr,
Foam::label indent
)
{
hashedWordList regs = obr.names<objectRegistry>();
regs.sort();
wordList names = obr.sortedNames();
std::string prefix;
for (label i=indent; i; --i)
{
prefix += ' ';
}
os << '#' << prefix.c_str() << obr.name()
<< " parent:" << obr.parent().name() << nl;
// all names
{
os << ' ' << prefix.c_str() << "objects: ";
printList(os, names) << nl;
}
// sub-registry names
{
os << ' ' << prefix.c_str() << "registries: ";
printList(os, regs) << nl;
}
// Print, but skip expansion of sub-registries for now
forAll(names, i)
{
const word& name = names[i];
os << (regs.found(name) ? '-' : ' ')
<< prefix.c_str() << name << " => " << obr[name]->type() << nl;
}
for (label i=indent; i; --i)
{
os << '-'; // divider
}
os << '\n';
// Now descend into the sub-registries
forAll(regs, i)
{
const word& name = regs[i];
const objectRegistry& next = obr.lookupObject<objectRegistry>
(
name
);
os << prefix.c_str()
<< "current:" << obr.name() << " next:"
<< next.name() << " next-parent:" << next.parent().name() << nl;
os << prefix.c_str() << name << " => " << obr[name]->type();
if ("dictionary" == obr[name]->type())
{
os << " (skip dictionary)" << nl;
}
else
{
os << nl;
printRegistry(os, next, indent + 4);
}
}
}
// Main program:
int main(int argc, char *argv[])
{
argList::noBanner();
argList::noParallel();
argList::addBoolOption
(
"mesh",
"test with polyMesh objectRegistry instead of runTime"
);
argList::addBoolOption
(
"skip",
"skip some parts"
);
// argList::validArgs.append("recursive (true|false)");
#include "setRootCase.H"
#include "createTime.H"
#include "createPolyMesh.H"
// recursive = Switch(args[1]);
const bool optMesh = args.optionFound("mesh");
const bool optSkip = args.optionFound("skip");
const objectRegistry& db = (optMesh ? mesh.thisDb() : runTime);
Info<<"## start ##" << nl;
printRegistry(Info, db);
Info<< nl;
const label nRegs = 3;
// Add some items
for (label j = 0; j < 3; ++j)
{
word entryName = "entry" + name(j);
db.subRegistry
(
entryName,
true
);
}
Info<<"## initally populated ##" << nl;
printRegistry(Info, db);
Info<< nl;
// create a few sub-registries
for (label i = 0; i < nRegs; ++i)
{
word regName = "subreg" + name(i);
const objectRegistry& subreg = db.subRegistry
(
regName,
true
);
for (label j = 0; j < 3; ++j)
{
word entryName = "entry" + name(j);
subreg.subRegistry
(
entryName,
true
);
subreg.subRegistry
(
"$" + entryName, // qualified to avoid collisions
true
);
}
}
Info<<"## after adding sub-registries" << nl;
printRegistry(Info, db);
Info<< nl;
// Add further items into top-level
for (label j = 0; j < 6; ++j)
{
word entryName = "entry" + name(j);
db.subRegistry
(
entryName,
true
);
}
Info<< "after adding some entries, top-level now contains: ";
printList(Info, db.names()) << endl;
Info<<"## Now attempt to add a few more entries ##" << nl;
// Try adding the same items into sub registry
// create a few sub-registries
for (label i = 0; i < nRegs; ++i)
{
word regName = "subreg" + name(i);
const objectRegistry& subreg = db.subRegistry
(
regName,
false
);
if (!optSkip)
{
for (label j = 0; j < 6; ++j)
{
word entryName = "entry" + name(j);
subreg.subRegistry
(
entryName,
true
);
}
}
}
Info<<"## Complete picture ##" << nl;
printRegistry(Info, db);
Info<< nl;
return 0;
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -148,6 +148,15 @@ int main(int argc, char *argv[])
dictPath = dictPath =
runTime.constant() runTime.constant()
/regionPath/polyMesh::meshSubDir/dictName; /regionPath/polyMesh::meshSubDir/dictName;
// Warn that constant/polyMesh/blockMesh was selected instead of
// system/blockMesh
WarningIn(args[0])
<< "Using the old blockMeshDict location: "
<< dictPath << nl
<< " instead of the default location: "
<< runTime.system()/regionPath/dictName << nl
<< endl;
} }
// Otherwise assume the dictionary is present in the system directory // Otherwise assume the dictionary is present in the system directory
else else

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory cd ${0%/*} || exit 1 # Run from this directory
set -x #set -x
wclean libso vtkPVReaders wclean libso vtkPVReaders
PVblockMeshReader/Allwclean PVblockMeshReader/Allwclean

View File

@ -4,7 +4,7 @@ cd ${0%/*} || exit 1 # Run from this directory
# Source the wmake functions # Source the wmake functions
. $WM_DIR/scripts/wmakeFunctions . $WM_DIR/scripts/wmakeFunctions
set -x #set -x
# deal with client/server vs combined plugins # deal with client/server vs combined plugins
rm -f $FOAM_LIBBIN/libPVFoamReader* 2>/dev/null rm -f $FOAM_LIBBIN/libPVFoamReader* 2>/dev/null

View File

@ -7,29 +7,49 @@ cd ${0%/*} || exit 1 # Run from this directory
# Source the wmake functions # Source the wmake functions
. $WM_DIR/scripts/wmakeFunctions . $WM_DIR/scripts/wmakeFunctions
# ensure CMake gets the correct C/C++ compilers # Ensure CMake gets the correct C/C++ compilers
[ -n "$WM_CC" ] && export CC="$WM_CC" [ -n "$WM_CC" ] && export CC="$WM_CC"
[ -n "$WM_CXX" ] && export CXX="$WM_CXX" [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
set -x
if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] # CMake into objectsDir,
# with an additional attempt if (possibly incorrect) CMakeCache.txt existed
doCmake()
{
local sourceDir="$1"
findObjectDir $sourceDir # Where are generated files stored?
test -f "$objectsDir/CMakeCache.txt"
retry=$? # CMakeCache.txt exists, but sources may have moved
mkdir -p $objectsDir && \
(
cd $objectsDir || exit 1
cmake $sourceDir || {
if [ $retry -eq 0 ]
then
echo "Removing CMakeCache.txt and attempt again"
rm -f CMakeCache.txt
cmake $sourceDir
else
exit 1
fi
} && make
)
}
if [ -d "$ParaView_DIR" ]
then then
wmake $targetType vtkPVFoam wmake $targetType vtkPVFoam
if [ "$targetType" != "objects" ] if [ "$targetType" != objects ]
then then
sourceDir=$PWD/PVFoamReader doCmake $PWD/PVFoamReader || {
echo
# Where are any generated files stored? echo " WARNING: incomplete build of ParaView OpenFOAM plugin"
findObjectDir $sourceDir
(
mkdir -p $objectsDir \
&& cd $objectsDir \
&& cmake $sourceDir \
&& make
) || {
echo echo
echo "WARNING: incomplete build of ParaView OpenFOAM plugin"
} }
fi fi
fi fi

View File

@ -1,4 +1,5 @@
EXE_INC = \ EXE_INC = \
${c++LESSWARN} \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \

View File

@ -4,7 +4,7 @@ cd ${0%/*} || exit 1 # Run from this directory
# Source the wmake functions # Source the wmake functions
. $WM_DIR/scripts/wmakeFunctions . $WM_DIR/scripts/wmakeFunctions
set -x #set -x
# deal with client/server vs combined plugins # deal with client/server vs combined plugins
rm -f $FOAM_LIBBIN/libPVblockMeshReader* 2>/dev/null rm -f $FOAM_LIBBIN/libPVblockMeshReader* 2>/dev/null

View File

@ -11,25 +11,45 @@ cd ${0%/*} || exit 1 # Run from this directory
[ -n "$WM_CC" ] && export CC="$WM_CC" [ -n "$WM_CC" ] && export CC="$WM_CC"
[ -n "$WM_CXX" ] && export CXX="$WM_CXX" [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
set -x
if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] # CMake into objectsDir,
# with an additional attempt if (possibly incorrect) CMakeCache.txt existed
doCmake()
{
local sourceDir="$1"
findObjectDir $sourceDir # Where are generated files stored?
test -f "$objectsDir/CMakeCache.txt"
retry=$? # CMakeCache.txt exists, but sources may have moved
mkdir -p $objectsDir && \
(
cd $objectsDir || exit 1
cmake $sourceDir || {
if [ $retry -eq 0 ]
then
echo "Removing CMakeCache.txt and attempt again"
rm -f CMakeCache.txt
cmake $sourceDir
else
exit 1
fi
} && make
)
}
if [ -d "$ParaView_DIR" ]
then then
wmake $targetType vtkPVblockMesh wmake $targetType vtkPVblockMesh
if [ "$targetType" != "objects" ] if [ "$targetType" != objects ]
then then
sourceDir=$PWD/PVblockMeshReader doCmake $PWD/PVblockMeshReader || {
echo
# Where are any generated files stored? echo " WARNING: incomplete build of ParaView BlockMesh plugin"
findObjectDir $sourceDir
(
mkdir -p $objectsDir \
&& cd $objectsDir \
&& cmake $sourceDir \
&& make
) || {
echo echo
echo "WARNING: incomplete build of ParaView BlockMesh plugin"
} }
fi fi
fi fi

View File

@ -1,4 +1,5 @@
EXE_INC = \ EXE_INC = \
${c++LESSWARN} \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \ -I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/mesh/blockMesh/lnInclude \ -I$(LIB_SRC)/mesh/blockMesh/lnInclude \

View File

@ -1,4 +1,5 @@
EXE_INC = \ EXE_INC = \
${c++LESSWARN} \
-I$(ParaView_INCLUDE_DIR) \ -I$(ParaView_INCLUDE_DIR) \
-I$(ParaView_INCLUDE_DIR)/vtkkwiml -I$(ParaView_INCLUDE_DIR)/vtkkwiml

View File

@ -35,7 +35,7 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# #
# Use other (shipped) paraview.csh with a different ParaView_VERSION # Use other (shipped) paraview with a different ParaView_VERSION
# #
set foamFile=`$WM_PROJECT_DIR/bin/foamEtcFile -mode o config.csh/paraview` set foamFile=`$WM_PROJECT_DIR/bin/foamEtcFile -mode o config.csh/paraview`

View File

@ -60,6 +60,12 @@ case OPENMPI:
# Tell OpenMPI where to find its install directory # Tell OpenMPI where to find its install directory
setenv OPAL_PREFIX $MPI_ARCH_PATH setenv OPAL_PREFIX $MPI_ARCH_PATH
if ($?FOAM_VERBOSE && $?prompt) then
echo "Using OPENMPI:"
echo " OPAL_PREFIX : $OPAL_PREFIX"
echo " FOAM_MPI : $FOAM_MPI"
endif
_foamAddPath $MPI_ARCH_PATH/bin _foamAddPath $MPI_ARCH_PATH/bin
_foamAddLib $MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH _foamAddLib $MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
_foamAddMan $MPI_ARCH_PATH/share/man _foamAddMan $MPI_ARCH_PATH/share/man
@ -111,8 +117,8 @@ case SYSTEMMPI:
case MPICH: case MPICH:
setenv FOAM_MPI mpich2-1.1.1p1 setenv FOAM_MPI mpich2-1.1.1p1
setenv MPI_HOME $WM_THIRD_PARTY_DIR/$FOAM_MPI
setenv MPI_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$FOAM_MPI setenv MPI_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$FOAM_MPI
setenv MPI_HOME $MPI_ARCH_PATH
_foamAddPath $MPI_ARCH_PATH/bin _foamAddPath $MPI_ARCH_PATH/bin

View File

@ -41,17 +41,17 @@
# If using a central installation not located under ThirdParty, you will # If using a central installation not located under ThirdParty, you will
# need to set some environment values directly. For example, # need to set some environment values directly. For example,
# #
# setenv ParaView_DIR /opt/paraview/paraview-5.2.0 # setenv ParaView_DIR /opt/paraview/paraview-5.0.1
# setenv ParaView_INCLUDE_DIR $ParaView_DIR/include/paraview-5.2 # setenv ParaView_INCLUDE_DIR $ParaView_DIR/include/paraview-5.0
# setenv PV_PLUGIN_PATH $FOAM_LIBBIN/paraview-5.2 # setenv PV_PLUGIN_PATH $FOAM_LIBBIN/paraview-5.0
# #
# setenv PATH ${ParaView_DIR}/bin:${PATH} # setenv PATH ${ParaView_DIR}/bin:${PATH}
# setenv LD_LIBRARY_PATH ${ParaView_DIR}/lib/paraview-5.2:${LD_LIBRARY_PATH} # setenv LD_LIBRARY_PATH ${ParaView_DIR}/lib/paraview-5.0:${LD_LIBRARY_PATH}
# unsetenv ParaView_VERSION # avoid using ThirdParty settings # unsetenv ParaView_VERSION # avoid using ThirdParty settings
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
setenv ParaView_VERSION 5.2.0 setenv ParaView_VERSION 5.0.1
setenv ParaView_MAJOR detect # Automatically determine major version setenv ParaView_MAJOR detect # Automatically determine major version
set cmake_version=cmake-system set cmake_version=cmake-system
@ -66,7 +66,8 @@ if ( $status == 0 ) setenv PATH $cleaned
# ThirdParty cmake # ThirdParty cmake
set cmake=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cmake_version set cmake=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cmake_version
if ( -r $cmake/bin/cmake ) then if ( -r $cmake/bin/cmake ) then
_foamAddPath $cmake/bin # _foamAddPath not available when foamPV alias is used
setenv PATH $cmake/bin:${PATH}
endif endif
# Evaluate command-line parameters for ParaView # Evaluate command-line parameters for ParaView
@ -101,12 +102,11 @@ if ( $?ParaView_VERSION ) then
set pvName=ParaView-$ParaView_VERSION set pvName=ParaView-$ParaView_VERSION
set pvMajor=paraview-$ParaView_MAJOR set pvMajor=paraview-$ParaView_MAJOR
set pvSrcDir=$WM_THIRD_PARTY_DIR/$pvName
setenv ParaView_DIR $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$pvName setenv ParaView_DIR $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$pvName
# Set paths if binaries or source are present # Set paths if binaries are present
if ( -r $ParaView_DIR || -r $pvSrcDir ) then if ( -r $ParaView_DIR ) then
set pvLibDir=${ParaView_DIR}/lib/$pvMajor set pvLibDir=${ParaView_DIR}/lib/$pvMajor
set pvPython=$ParaView_DIR/Utilities/VTKPythonWrapping set pvPython=$ParaView_DIR/Utilities/VTKPythonWrapping
@ -132,13 +132,18 @@ if ( $?ParaView_VERSION ) then
echo " PV_PLUGIN_PATH : $PV_PLUGIN_PATH" echo " PV_PLUGIN_PATH : $PV_PLUGIN_PATH"
endif endif
else else
if ($?FOAM_VERBOSE && $?prompt) then
echo "No paraview found"
echo " ParaView_DIR : $ParaView_DIR"
endif
unsetenv ParaView_INCLUDE_DIR PV_PLUGIN_PATH unsetenv ParaView_INCLUDE_DIR PV_PLUGIN_PATH
setenv ParaView_DIR # Defined but empty (used by foamPV alias) setenv ParaView_DIR # Defined but empty (used by foamPV alias)
endif endif
endif endif
unset cleaned cmake cmake_version pvName pvMajor pvSrcDir pvLibDir pvPython unset cleaned cmake cmake_version pvName pvMajor pvLibDir pvPython
unsetenv ParaView_VERSION ParaView_MAJOR unsetenv ParaView_MAJOR ParaView_VERSION
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -63,6 +63,13 @@ OPENMPI)
# Tell OpenMPI where to find its install directory # Tell OpenMPI where to find its install directory
export OPAL_PREFIX=$MPI_ARCH_PATH export OPAL_PREFIX=$MPI_ARCH_PATH
if [ "$FOAM_VERBOSE" -a "$PS1" ]
then
echo "Using OPENMPI:" 1>&2
echo " OPAL_PREFIX : $OPAL_PREFIX" 1>&2
echo " FOAM_MPI : $FOAM_MPI" 1>&2
fi
_foamAddPath $MPI_ARCH_PATH/bin _foamAddPath $MPI_ARCH_PATH/bin
_foamAddLib $MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH _foamAddLib $MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
_foamAddMan $MPI_ARCH_PATH/share/man _foamAddMan $MPI_ARCH_PATH/share/man
@ -118,8 +125,8 @@ SYSTEMMPI)
MPICH) MPICH)
export FOAM_MPI=mpich2-1.1.1p1 export FOAM_MPI=mpich2-1.1.1p1
export MPI_HOME=$WM_THIRD_PARTY_DIR/$FOAM_MPI
export MPI_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$FOAM_MPI export MPI_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$FOAM_MPI
export MPI_HOME=$MPI_ARCH_PATH
_foamAddPath $MPI_ARCH_PATH/bin _foamAddPath $MPI_ARCH_PATH/bin

View File

@ -41,17 +41,20 @@
# If using a central installation not located under ThirdParty, you will # If using a central installation not located under ThirdParty, you will
# need to set some environment values directly. For example, # need to set some environment values directly. For example,
# #
# export ParaView_DIR=/opt/paraview/paraview-5.2.0 # export ParaView_DIR=/opt/paraview/paraview-5.0.1
# export ParaView_INCLUDE_DIR=$ParaView_DIR/include/paraview-5.2 # export ParaView_INCLUDE_DIR=$ParaView_DIR/include/paraview-5.0
# export PV_PLUGIN_PATH=$FOAM_LIBBIN/paraview-5.2 # export PV_PLUGIN_PATH=$FOAM_LIBBIN/paraview-5.0
# #
# export PATH=$ParaView_DIR/bin:$PATH # export PATH=$ParaView_DIR/bin:$PATH
# export LD_LIBRARY_PATH=$ParaView_DIR/lib/paraview-5.2:$LD_LIBRARY_PATH # export LD_LIBRARY_PATH=$ParaView_DIR/lib/paraview-5.0:$LD_LIBRARY_PATH
# unset ParaView_VERSION # avoid using ThirdParty settings # unset ParaView_VERSION # avoid using ThirdParty settings
# #
# Note
# When _foamAddLib is unset (eg, called from makeParaView or from foamPV):
# - the ParaView_VERSION variable is retained.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
ParaView_VERSION=5.2.0 ParaView_VERSION=5.0.1
ParaView_MAJOR=detect # Automatically determine major version ParaView_MAJOR=detect # Automatically determine major version
cmake_version=cmake-system cmake_version=cmake-system
@ -70,7 +73,8 @@ cleaned=$($WM_PROJECT_DIR/bin/foamCleanPath "$PATH" \
cmake=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cmake_version cmake=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cmake_version
if [ -r $cmake/bin/cmake ] if [ -r $cmake/bin/cmake ]
then then
_foamAddPath $cmake/bin # _foamAddPath not available when foamPV function is used
PATH=$cmake/bin:$PATH
fi fi
# Evaluate command-line parameters for ParaView # Evaluate command-line parameters for ParaView
@ -112,12 +116,11 @@ then
pvName=ParaView-$ParaView_VERSION pvName=ParaView-$ParaView_VERSION
pvMajor=paraview-$ParaView_MAJOR pvMajor=paraview-$ParaView_MAJOR
pvSrcDir=$WM_THIRD_PARTY_DIR/$pvName
export ParaView_DIR=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$pvName export ParaView_DIR=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$pvName
# Set paths if binaries or source are present # Set paths if binaries or source are present
if [ -r $ParaView_DIR -o -r $pvSrcDir ] if [ -r $ParaView_DIR ]
then then
pvLibDir=$ParaView_DIR/lib/$pvMajor pvLibDir=$ParaView_DIR/lib/$pvMajor
pvPython=$ParaView_DIR/Utilities/VTKPythonWrapping pvPython=$ParaView_DIR/Utilities/VTKPythonWrapping
@ -147,13 +150,24 @@ then
echo " PV_PLUGIN_PATH : $PV_PLUGIN_PATH" echo " PV_PLUGIN_PATH : $PV_PLUGIN_PATH"
fi fi
else else
if [ "$FOAM_VERBOSE" -a "$PS1" ]
then
echo "No paraview found"
echo " ParaView_DIR : $ParaView_DIR"
fi
unset ParaView_DIR ParaView_INCLUDE_DIR PV_PLUGIN_PATH unset ParaView_DIR ParaView_INCLUDE_DIR PV_PLUGIN_PATH
fi fi
fi fi
unset -f _foamParaviewEval unset -f _foamParaviewEval
unset cleaned cmake cmake_version pvName pvMajor pvSrcDir pvLibDir pvPython unset cleaned cmake cmake_version pvName pvMajor pvLibDir pvPython
unset ParaView_VERSION ParaView_MAJOR unset ParaView_MAJOR
if type _foamAddLib > /dev/null 2>&1 # normal sourcing
then
unset ParaView_VERSION
fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -76,8 +76,6 @@ template<class T> class IndirectList;
template<class T> class UIndirectList; template<class T> class UIndirectList;
template<class T> class BiIndirectList; template<class T> class BiIndirectList;
typedef UList<label> unallocLabelList;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class List Declaration Class List Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -77,7 +77,8 @@ Foam::functionObjects::timeControl::timeControl
), ),
executeControl_(t, dict, "execute"), executeControl_(t, dict, "execute"),
writeControl_(t, dict, "write"), writeControl_(t, dict, "write"),
foPtr_(functionObject::New(name, t, dict_)) foPtr_(functionObject::New(name, t, dict_)),
executeTimeIndex_(-1)
{ {
readControls(); readControls();
} }
@ -89,6 +90,7 @@ bool Foam::functionObjects::timeControl::execute()
{ {
if (active() && (postProcess || executeControl_.execute())) if (active() && (postProcess || executeControl_.execute()))
{ {
executeTimeIndex_ = time_.timeIndex();
foPtr_->execute(); foPtr_->execute();
} }
@ -100,6 +102,13 @@ bool Foam::functionObjects::timeControl::write()
{ {
if (active() && (postProcess || writeControl_.execute())) if (active() && (postProcess || writeControl_.execute()))
{ {
// Ensure written results reflect the current state
if (executeTimeIndex_ != time_.timeIndex())
{
executeTimeIndex_ = time_.timeIndex();
foPtr_->execute();
}
foPtr_->write(); foPtr_->write();
} }

View File

@ -99,6 +99,9 @@ class timeControl
//- The functionObject to execute //- The functionObject to execute
autoPtr<functionObject> foPtr_; autoPtr<functionObject> foPtr_;
//- Time index of the last execute call
label executeTimeIndex_;
// Private Member Functions // Private Member Functions

View File

@ -202,7 +202,7 @@ void Foam::LduMatrix<Type, DType, LUType>::sumA
{ {
if (interfaces_.set(patchi)) if (interfaces_.set(patchi))
{ {
const unallocLabelList& pa = lduAddr().patchAddr(patchi); const labelUList& pa = lduAddr().patchAddr(patchi);
const Field<LUType>& pCoeffs = interfacesUpper_[patchi]; const Field<LUType>& pCoeffs = interfacesUpper_[patchi];
forAll(pa, face) forAll(pa, face)

View File

@ -34,8 +34,8 @@ void Foam::LduMatrix<Type, DType, LUType>::sumDiag()
const Field<LUType>& Upper = const_cast<const LduMatrix&>(*this).upper(); const Field<LUType>& Upper = const_cast<const LduMatrix&>(*this).upper();
Field<DType>& Diag = diag(); Field<DType>& Diag = diag();
const unallocLabelList& l = lduAddr().lowerAddr(); const labelUList& l = lduAddr().lowerAddr();
const unallocLabelList& u = lduAddr().upperAddr(); const labelUList& u = lduAddr().upperAddr();
for (label face=0; face<l.size(); face++) for (label face=0; face<l.size(); face++)
{ {
@ -52,8 +52,8 @@ void Foam::LduMatrix<Type, DType, LUType>::negSumDiag()
const Field<LUType>& Upper = const_cast<const LduMatrix&>(*this).upper(); const Field<LUType>& Upper = const_cast<const LduMatrix&>(*this).upper();
Field<DType>& Diag = diag(); Field<DType>& Diag = diag();
const unallocLabelList& l = lduAddr().lowerAddr(); const labelUList& l = lduAddr().lowerAddr();
const unallocLabelList& u = lduAddr().upperAddr(); const labelUList& u = lduAddr().upperAddr();
for (label face=0; face<l.size(); face++) for (label face=0; face<l.size(); face++)
{ {
@ -72,8 +72,8 @@ void Foam::LduMatrix<Type, DType, LUType>::sumMagOffDiag
const Field<LUType>& Lower = const_cast<const LduMatrix&>(*this).lower(); const Field<LUType>& Lower = const_cast<const LduMatrix&>(*this).lower();
const Field<LUType>& Upper = const_cast<const LduMatrix&>(*this).upper(); const Field<LUType>& Upper = const_cast<const LduMatrix&>(*this).upper();
const unallocLabelList& l = lduAddr().lowerAddr(); const labelUList& l = lduAddr().lowerAddr();
const unallocLabelList& u = lduAddr().upperAddr(); const labelUList& u = lduAddr().upperAddr();
for (label face = 0; face < l.size(); face++) for (label face = 0; face < l.size(); face++)
{ {
@ -135,9 +135,9 @@ Foam::LduMatrix<Type, DType, LUType>::faceH(const Field<Type>& psi) const
const Field<LUType>& Lower = const_cast<const LduMatrix&>(*this).lower(); const Field<LUType>& Lower = const_cast<const LduMatrix&>(*this).lower();
const Field<LUType>& Upper = const_cast<const LduMatrix&>(*this).upper(); const Field<LUType>& Upper = const_cast<const LduMatrix&>(*this).upper();
// Take refereces to addressing // Take references to addressing
const unallocLabelList& l = lduAddr().lowerAddr(); const labelUList& l = lduAddr().lowerAddr();
const unallocLabelList& u = lduAddr().upperAddr(); const labelUList& u = lduAddr().upperAddr();
tmp<Field<Type>> tfaceHpsi(new Field<Type> (Lower.size())); tmp<Field<Type>> tfaceHpsi(new Field<Type> (Lower.size()));
Field<Type> & faceHpsi = tfaceHpsi(); Field<Type> & faceHpsi = tfaceHpsi();
@ -413,8 +413,8 @@ void Foam::LduMatrix<Type, DType, LUType>::operator*=
Field<LUType>& upper = this->upper(); Field<LUType>& upper = this->upper();
Field<LUType>& lower = this->lower(); Field<LUType>& lower = this->lower();
const unallocLabelList& l = lduAddr().lowerAddr(); const labelUList& l = lduAddr().lowerAddr();
const unallocLabelList& u = lduAddr().upperAddr(); const labelUList& u = lduAddr().upperAddr();
for (label face=0; face<upper.size(); face++) for (label face=0; face<upper.size(); face++)
{ {

View File

@ -113,9 +113,6 @@ protected:
//- Build primitive patch //- Build primitive patch
void calcFaceZonePatch() const; void calcFaceZonePatch() const;
//- Return map of local face indices
const Map<label>& faceLookupMap() const;
//- Calculate master and slave face layer //- Calculate master and slave face layer
void calcCellLayers() const; void calcCellLayers() const;

View File

@ -204,7 +204,8 @@ Foam::Function1Types::CSV<Type>::CSV
( (
const word& entryName, const word& entryName,
const dictionary& dict, const dictionary& dict,
const word& ext const word& ext,
const fileName& fName
) )
: :
TableBase<Type>(entryName, dict.subDict(entryName + ext)), TableBase<Type>(entryName, dict.subDict(entryName + ext)),
@ -214,7 +215,7 @@ Foam::Function1Types::CSV<Type>::CSV
componentColumns_(coeffs_.lookup("componentColumns")), componentColumns_(coeffs_.lookup("componentColumns")),
separator_(coeffs_.lookupOrDefault<string>("separator", string(","))[0]), separator_(coeffs_.lookupOrDefault<string>("separator", string(","))[0]),
mergeSeparators_(readBool(coeffs_.lookup("mergeSeparators"))), mergeSeparators_(readBool(coeffs_.lookup("mergeSeparators"))),
fName_(coeffs_.lookup("fileName")) fName_(fName != fileName::null ? fName : coeffs_.lookup("fileName"))
{ {
if (componentColumns_.size() != pTraits<Type>::nComponents) if (componentColumns_.size() != pTraits<Type>::nComponents)
{ {

View File

@ -122,7 +122,8 @@ public:
( (
const word& entryName, const word& entryName,
const dictionary& dict, const dictionary& dict,
const word& ext = "Coeffs" const word& ext = "Coeffs",
const fileName& fName = fileName::null
); );
//- Copy constructor //- Copy constructor

View File

@ -258,9 +258,9 @@ void Foam::ensightMesh::correct()
Foam::sort(selectZones); Foam::sort(selectZones);
// Count face types in each selected faceZone // Count face types in each selected faceZone
forAll(selectZones, zoneI) forAll(selectZones, zonei)
{ {
const word& zoneName = selectZones[zoneI]; const word& zoneName = selectZones[zonei];
const label zoneID = mesh_.faceZones().findZoneID(zoneName); const label zoneID = mesh_.faceZones().findZoneID(zoneName);
const faceZone& fz = mesh_.faceZones()[zoneID]; const faceZone& fz = mesh_.faceZones()[zoneID];
@ -342,12 +342,12 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
( (
pp.meshPoints(), pp.meshPoints(),
pp.meshPointMap(), pp.meshPointMap(),
pointToGlobal, pointToGlobal, // local patch point to unique global index
uniqueMeshPointLabels uniqueMeshPointLabels // unique global points
); );
pointField uniquePoints(mesh_.points(), uniqueMeshPointLabels); // Renumber the patch faces,
// Renumber the patch faces // from local patch indexing to unique global index
faceList patchFaces(pp.localFaces()); faceList patchFaces(pp.localFaces());
forAll(patchFaces, i) forAll(patchFaces, i)
{ {
@ -359,7 +359,7 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
ensFaces.index(), ensFaces.index(),
patchName, patchName,
globalPointsPtr().size(), globalPointsPtr().size(),
uniquePoints, pointField(mesh_.points(), uniqueMeshPointLabels),
os os
); );
@ -391,30 +391,28 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
uniqueMeshPointLabels uniqueMeshPointLabels
); );
pointField uniquePoints(mesh_.points(), uniqueMeshPointLabels); // Make a copy in the proper order
primitiveFacePatch pp
primitiveFacePatch facePatch
( (
faceList(mesh_.faces(), ensFaces.faceIds()), faceList(mesh_.faces(), ensFaces.faceIds()),
mesh_.points() mesh_.points()
); );
const boolList& flip = ensFaces.flipMap(); const boolList& flip = ensFaces.flipMap();
forAll(facePatch[faceI], faceI) forAll(pp, facei)
{ {
if (flip[faceI]) if (flip[facei])
{ {
facePatch[faceI].flip(); pp[facei].flip();
} }
} }
// Faces belonging to the faceZone, in local numbering // Renumber the faces belonging to the faceZone,
faceList localFaces(facePatch.localFaces()); // from local numbering to unique global index
faceList patchFaces(pp.localFaces());
// Renumber the faceZone master faces forAll(patchFaces, i)
forAll(localFaces, i)
{ {
inplaceRenumber(pointToGlobal, localFaces[i]); inplaceRenumber(pointToGlobal, patchFaces[i]);
} }
writeAllPoints writeAllPoints
@ -422,11 +420,11 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
ensFaces.index(), ensFaces.index(),
zoneName, zoneName,
globalPointsPtr().size(), globalPointsPtr().size(),
uniquePoints, pointField(mesh_.points(), uniqueMeshPointLabels),
os os
); );
writeFaceConnectivity(ensFaces, localFaces, os, true); writeFaceConnectivity(ensFaces, patchFaces, os, true);
} }
} }

View File

@ -55,27 +55,42 @@ class ensightOutput
{ {
// Private Methods // Private Methods
template<class Type> //- Write field content (component-wise) for the given ensight element type
static void writeField template<template<typename> class FieldContainer, class Type>
static void writeFieldContent
( (
const char* key, const char* key,
const FieldContainer<Type>& fld,
ensightFile& os
);
//- Write a field of faces values as an indirect list,
// using the face ids from ensightFaces
template<class Type>
static bool writeFaceField
(
const Field<Type>& fld, const Field<Type>& fld,
const ensightFaces&,
ensightFile& os ensightFile& os
); );
//- Write a field of faces values as a sublist,
// using the sublist sizes ensightFaces
template<class Type> template<class Type>
static bool writePatchField static bool writeFaceSubField
( (
const Field<Type>& pf, const Field<Type>& fld,
const ensightFaces& ensFaces, const ensightFaces&,
ensightFile& os ensightFile& os
); );
//- Write a field of cell values as an indirect list,
// using the cell ids from ensightCells
template<class Type> template<class Type>
static bool writeVolField static bool writeCellField
( (
const Field<Type>& vf, const Field<Type>& fld,
const ensightCells& ensCells, const ensightCells&,
ensightFile& os, ensightFile& os,
const bool deprecatedOrder = false const bool deprecatedOrder = false
); );

View File

@ -41,11 +41,11 @@ License
// * * * * * * * * * * Static Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * Static Private Member Functions * * * * * * * * * * * //
template<class Type> template<template<typename> class FieldContainer, class Type>
void Foam::ensightOutput::writeField void Foam::ensightOutput::writeFieldContent
( (
const char* key, const char* key,
const Field<Type>& fld, const FieldContainer<Type>& fld,
ensightFile& os ensightFile& os
) )
{ {
@ -85,7 +85,7 @@ void Foam::ensightOutput::writeField
template<class Type> template<class Type>
bool Foam::ensightOutput::writePatchField bool Foam::ensightOutput::writeFaceField
( (
const Field<Type>& pf, const Field<Type>& pf,
const ensightFaces& ensFaces, const ensightFaces& ensFaces,
@ -99,14 +99,11 @@ bool Foam::ensightOutput::writePatchField
os.beginPart(ensFaces.index()); os.beginPart(ensFaces.index());
} }
const List<ensightFaces::elemType> enums = for (label typei=0; typei < ensightFaces::nTypes; ++typei)
ensightFaces::elemEnum.enums();
forAllConstIter(List<ensightFaces::elemType>, enums, iter)
{ {
const ensightFaces::elemType& what = *iter; const ensightFaces::elemType what = ensightFaces::elemType(typei);
writeField writeFieldContent
( (
ensightFaces::key(what), ensightFaces::key(what),
Field<Type>(pf, ensFaces.faceIds(what)), Field<Type>(pf, ensFaces.faceIds(what)),
@ -124,7 +121,47 @@ bool Foam::ensightOutput::writePatchField
template<class Type> template<class Type>
bool Foam::ensightOutput::writeVolField bool Foam::ensightOutput::writeFaceSubField
(
const Field<Type>& pf,
const ensightFaces& ensFaces,
Foam::ensightFile& os
)
{
if (ensFaces.total())
{
if (Pstream::master())
{
os.beginPart(ensFaces.index());
}
label start = 0; // start of sublist
for (label typei = 0; typei < ensightFaces::nTypes; ++typei)
{
const ensightFaces::elemType what = ensightFaces::elemType(typei);
const label size = ensFaces.faceIds(what).size();
writeFieldContent
(
ensightFaces::key(what),
SubField<Type>(pf, size, start),
os
);
start += size; // start of next sublist
}
return true;
}
else
{
return false;
}
}
template<class Type>
bool Foam::ensightOutput::writeCellField
( (
const Field<Type>& vf, const Field<Type>& vf,
const ensightCells& ensCells, const ensightCells& ensCells,
@ -151,34 +188,30 @@ bool Foam::ensightOutput::writeVolField
ensightCells::NFACED ensightCells::NFACED
}; };
for (int i=0; i < 5; ++i) for (label typei=0; typei < ensightCells::nTypes; ++typei)
{ {
const ensightCells::elemType& what = oldOrder[i]; const ensightCells::elemType& what = oldOrder[typei];
writeField writeFieldContent
( (
ensightCells::key(what), ensightCells::key(what),
Field<Type>(vf, ensCells.cellIds(what)), Field<Type>(vf, ensCells.cellIds(what)),
os os
); );
} }
return true;
} }
else
for (label typei=0; typei < ensightCells::nTypes; ++typei)
{ {
const List<ensightCells::elemType> enums = const ensightCells::elemType what = ensightCells::elemType(typei);
ensightCells::elemEnum.enums();
forAllConstIter(List<ensightCells::elemType>, enums, iter) writeFieldContent
{ (
const ensightCells::elemType& what = *iter; ensightCells::key(what),
Field<Type>(vf, ensCells.cellIds(what)),
writeField os
( );
ensightCells::key(what),
Field<Type>(vf, ensCells.cellIds(what)),
os
);
}
} }
return true; return true;
@ -209,7 +242,7 @@ bool Foam::ensightOutput::writeField
// //
if (ensMesh.useInternalMesh()) if (ensMesh.useInternalMesh())
{ {
writeVolField(vf, meshCells, os, ensMesh.deprecatedOrder()); writeCellField(vf, meshCells, os, ensMesh.deprecatedOrder());
} }
// //
@ -223,7 +256,7 @@ bool Foam::ensightOutput::writeField
const word& patchName = patchLookup[listi]; const word& patchName = patchLookup[listi];
const ensightFaces& ensFaces = patchFaces[patchName]; const ensightFaces& ensFaces = patchFaces[patchName];
writePatchField writeFaceField
( (
vf.boundaryField()[patchId], vf.boundaryField()[patchId],
ensFaces, ensFaces,
@ -303,7 +336,9 @@ bool Foam::ensightOutput::writeField
); );
} }
writePatchField(values, ensFaces, os); // The field is already copied in the proper order
// - just need its corresponding sub-fields
writeFaceSubField(values, ensFaces, os);
} }
} }
@ -335,7 +370,7 @@ bool Foam::ensightOutput::ensightPointField
os.beginPart(0); // 0 = internalMesh os.beginPart(0); // 0 = internalMesh
} }
writeField writeFieldContent
( (
"coordinates", "coordinates",
Field<Type>(pf.internalField(), ensMesh.uniquePointMap()), Field<Type>(pf.internalField(), ensMesh.uniquePointMap()),
@ -373,7 +408,7 @@ bool Foam::ensightOutput::ensightPointField
os.beginPart(ensFaces.index()); os.beginPart(ensFaces.index());
} }
writeField writeFieldContent
( (
"coordinates", "coordinates",
Field<Type>(pf.internalField(), uniqueMeshPointLabels), Field<Type>(pf.internalField(), uniqueMeshPointLabels),
@ -417,7 +452,7 @@ bool Foam::ensightOutput::ensightPointField
os.beginPart(ensFaces.index()); os.beginPart(ensFaces.index());
} }
writeField writeFieldContent
( (
"coordinates", "coordinates",
Field<Type>(pf.internalField(), uniqueMeshPointLabels), Field<Type>(pf.internalField(), uniqueMeshPointLabels),

View File

@ -55,12 +55,12 @@ class ensightSerialOutput
{ {
// Private Methods // Private Methods
//- Write field component-wise //- Write field content (component-wise) for the given ensight element type
template<class Type> template<template<typename> class FieldContainer, class Type>
static void writeField static void writeFieldContent
( (
const word& key, const word& key,
const Field<Type>& field, const FieldContainer<Type>& fld,
ensightFile& os ensightFile& os
); );

View File

@ -31,11 +31,11 @@ License
// * * * * * * * * * * Static Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * Static Private Member Functions * * * * * * * * * * * //
template<class Type> template<template<typename> class FieldContainer, class Type>
void Foam::ensightSerialOutput::writeField void Foam::ensightSerialOutput::writeFieldContent
( (
const word& key, const word& key,
const Field<Type>& fld, const FieldContainer<Type>& fld,
ensightFile& os ensightFile& os
) )
{ {
@ -82,14 +82,11 @@ bool Foam::ensightSerialOutput::writeField
{ {
os.beginPart(part.index()); os.beginPart(part.index());
const List<ensightFaces::elemType> enums = for (label typei=0; typei < ensightFaces::nTypes; ++typei)
ensightFaces::elemEnum.enums();
forAllConstIter(List<ensightFaces::elemType>, enums, iter)
{ {
const ensightFaces::elemType what = *iter; const ensightFaces::elemType what = ensightFaces::elemType(typei);
writeField writeFieldContent
( (
ensightFaces::key(what), ensightFaces::key(what),
Field<Type>(fld, part.faceIds(what)), Field<Type>(fld, part.faceIds(what)),
@ -115,14 +112,11 @@ bool Foam::ensightSerialOutput::writeField
{ {
os.beginPart(part.index()); os.beginPart(part.index());
const List<ensightCells::elemType> enums = for (label typei=0; typei < ensightCells::nTypes; ++typei)
ensightCells::elemEnum.enums();
forAllConstIter(List<ensightCells::elemType>, enums, iter)
{ {
const ensightCells::elemType what = *iter; const ensightCells::elemType what = ensightCells::elemType(typei);
writeField writeFieldContent
( (
ensightCells::key(what), ensightCells::key(what),
Field<Type>(fld, part.cellIds(what)), Field<Type>(fld, part.cellIds(what)),

View File

@ -48,10 +48,10 @@ Foam::ensightPart::localPoints Foam::ensightPartFaces::calcLocalPoints() const
labelList& usedPoints = ptList.list; labelList& usedPoints = ptList.list;
label nPoints = 0; label nPoints = 0;
// add all points from faces // Add all points from faces
const labelUList& idList = this->faceIds(); const labelUList& idList = this->faceIds();
// add all points from faces // Add all points from faces
forAll(idList, i) forAll(idList, i)
{ {
const label id = idList[i] + start_; const label id = idList[i] + start_;
@ -67,7 +67,7 @@ Foam::ensightPart::localPoints Foam::ensightPartFaces::calcLocalPoints() const
} }
// this is not absolutely necessary, but renumber anyhow // This is not absolutely necessary, but renumber anyhow
nPoints = 0; nPoints = 0;
forAll(usedPoints, ptI) forAll(usedPoints, ptI)
{ {
@ -101,7 +101,7 @@ Foam::ensightPartFaces::ensightPartFaces
points_(points), points_(points),
contiguousPoints_(contiguousPoints) contiguousPoints_(contiguousPoints)
{ {
// classify the face shapes // Classify the face shapes
classify(faces); classify(faces);
} }
@ -121,7 +121,7 @@ Foam::ensightPartFaces::ensightPartFaces
points_(mesh.points()), points_(mesh.points()),
contiguousPoints_(false) contiguousPoints_(false)
{ {
// classify the face shapes // Classify the face shapes
classify(patch); classify(patch);
} }
@ -149,10 +149,10 @@ void Foam::ensightPartFaces::writeConnectivity
os.write(idList.size()); os.write(idList.size());
os.newline(); os.newline();
// write (polygon) face sizes // Write (polygon) face sizes
if (key == "nsided") if (key == "nsided")
{ {
// write the number of points per face // Write the number of points per face
forAll(idList, i) forAll(idList, i)
{ {
const label id = idList[i] + start_; const label id = idList[i] + start_;
@ -163,13 +163,13 @@ void Foam::ensightPartFaces::writeConnectivity
} }
} }
// write the points describing the face // Write the points describing the face
forAll(idList, i) forAll(idList, i)
{ {
const label id = idList[i] + start_; const label id = idList[i] + start_;
const face& f = faces[id]; const face& f = faces[id];
// convert global -> local index // Convert global -> local index
// (note: Ensight indices start with 1) // (note: Ensight indices start with 1)
forAll(f, fp) forAll(f, fp)
{ {
@ -205,7 +205,7 @@ void Foam::ensightPartFaces::write
const pointField& points const pointField& points
) const ) const
{ {
if (ensightPart::size()) if (size())
{ {
const localPoints ptList = calcLocalPoints(); const localPoints ptList = calcLocalPoints();
const labelUList& pointMap = ptList.list; const labelUList& pointMap = ptList.list;

View File

@ -138,44 +138,43 @@ public:
// Member Functions // Member Functions
// Access // Access
//- Part index (0-based) //- Part index (0-based)
virtual label index() const virtual label index() const
{ {
return ensightFaces::index(); return ensightFaces::index();
} }
//- Number of elements in this part //- Number of elements in this part
virtual label size() const virtual label size() const
{ {
return ensightFaces::size(); return ensightFaces::size();
} }
//- Return the patch index, -1 when not in use. //- Return the patch index, -1 when not in use.
inline label patchIndex() const inline label patchIndex() const
{ {
return patchIndex_; return patchIndex_;
} }
// Output // Output
//- Write summary information about the object //- Write summary information about the object
virtual void writeSummary(Ostream&) const; virtual void writeSummary(Ostream&) const;
//- Write geometry //- Write geometry
virtual void write(ensightGeoFile&) const; virtual void write(ensightGeoFile&) const;
//- Helper: write geometry given the pointField //- Helper: write geometry given the pointField
virtual void write(ensightGeoFile&, const pointField&) const; virtual void write(ensightGeoFile&, const pointField&) const;
//- Print various types of debugging information //- Print various types of debugging information
virtual void dumpInfo(Ostream&) const; virtual void dumpInfo(Ostream&) const;
}; };

View File

@ -191,10 +191,7 @@ void Foam::ensightCells::sort()
{ {
forAll(lists_, typeI) forAll(lists_, typeI)
{ {
if (lists_[typeI]) Foam::sort(*(lists_[typeI]));
{
Foam::sort(*(lists_[typeI]));
}
} }
} }

View File

@ -233,28 +233,25 @@ void Foam::ensightFaces::sort()
{ {
if (flipMap_.size() == address_.size()) if (flipMap_.size() == address_.size())
{ {
// sort flip too // sort flip map too
labelList order; labelList order;
label start = 0; label start = 0;
forAll(lists_, typeI) forAll(lists_, typeI)
{ {
if (lists_[typeI]) SubList<label>& idLst = *(lists_[typeI]);
const label sz = idLst.size();
if (sz)
{ {
SubList<label>& idLst = *(lists_[typeI]); SubList<bool> flip(flipMap_, sz, start);
const label sz = idLst.size(); start += sz; // for next sub-list
if (sz) Foam::sortedOrder(idLst, order);
{
SubList<bool> flip(flipMap_, sz, start);
start += sz; // for next sub-list
sortedOrder(idLst, order); idLst = reorder<labelList>(order, idLst);
flip = reorder<boolList>(order, flip);
idLst = reorder<labelList>(order, idLst);
flip = reorder<boolList>(order, flip);
}
} }
} }
} }
@ -263,16 +260,9 @@ void Foam::ensightFaces::sort()
// no flip-maps, simpler to sort // no flip-maps, simpler to sort
forAll(lists_, typeI) forAll(lists_, typeI)
{ {
if (lists_[typeI]) Foam::sort(*(lists_[typeI]));
{
SubList<label>& idLst = *(lists_[typeI]);
const label sz = idLst.size();
if (sz)
{
Foam::sort(idLst);
}
}
} }
flipMap_.clear(); // for safety
} }
} }

View File

@ -132,83 +132,82 @@ public:
// Member Functions // Member Functions
// Access // Access
//- The index in a list. //- The index in a list.
inline label index() const; inline label index() const;
//- The index in a list, non-const access. //- The index in a list, non-const access.
inline label& index(); inline label& index();
//- The processor local size of all elements. //- The processor local size of all elements.
inline label size() const; inline label size() const;
//- The global number of the specified element type. //- The global number of the specified element type.
// This value is only meaningful after a reduce operation. // This value is only meaningful after a reduce operation.
inline label total(const enum elemType) const; inline label total(const enum elemType) const;
//- The global number of all element types. //- The global number of all element types.
// This value is only meaningful after a reduce operation. // This value is only meaningful after a reduce operation.
label total() const; label total() const;
//- The processor local sizes per element type. //- The processor local sizes per element type.
FixedList<label, 3> sizes() const; FixedList<label, 3> sizes() const;
//- The global numbers per element type. //- The global numbers per element type.
// This value is only meaningful after a reduce operation. // This value is only meaningful after a reduce operation.
const FixedList<label, 3>& totals() const; const FixedList<label, 3>& totals() const;
//- Return the (local) face ids of the specified element type //- Return the (local) face ids of the specified element type
inline const labelUList& faceIds(const enum elemType) const; inline const labelUList& faceIds(const enum elemType) const;
//- Return the face ids of all elements //- Return the face ids of all elements
inline const labelUList& faceIds() const; inline const labelUList& faceIds() const;
//- Return the flip-map of all elements //- Return the flip-map of all elements
inline const boolList& flipMap() const; inline const boolList& flipMap() const;
//- Starting offset of element type. //- Starting offset of element type.
label offset(const enum elemType what) const; label offset(const enum elemType what) const;
// Edit // Edit
//- Classify the face types, set element list. //- Classify the face types, set element list.
void classify(const faceList& faces); void classify(const faceList& faces);
//- Classify the face types, set element list. //- Classify the face types, set element list.
// The indirect addressing can be used when classifying groups of // The indirect addressing can be used when classifying groups of
// face (eg, from a faceZone etc) with an optional flipMap. // face (eg, from a faceZone etc) with an optional flipMap.
// The optional exclude marker can be used to skip faces on particular // The optional exclude marker can be used to skip faces on particular
// boundary types or regions. // boundary types or regions.
void classify void classify
( (
const faceList& faces, const faceList& faces,
const labelUList& addressing, const labelUList& addressing,
const boolList& flipMap = boolList(), const boolList& flipMap = boolList(),
const PackedBoolList& exclude = PackedBoolList() const PackedBoolList& exclude = PackedBoolList()
); );
//- Set addressable sizes to zero, free up addressing memory. //- Set addressable sizes to zero, free up addressing memory.
void clear(); void clear();
//- Sum element counts across all processes. //- Sum element counts across all processes.
void reduce(); void reduce();
//- Sort element lists numerically. //- Sort element lists numerically.
void sort(); void sort();
// Member operators // Member operators
//- Return element from linear-list. //- Return element from linear-list.
inline label operator[](const label i) const; inline label operator[](const label i) const;
}; };

View File

@ -112,7 +112,6 @@ Foam::functionObjects::ddt2::ddt2
) )
: :
fvMeshFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
prevTimeIndex_(-1),
selectFields_(), selectFields_(),
resultName_(word::null), resultName_(word::null),
blacklist_(), blacklist_(),
@ -218,20 +217,12 @@ bool Foam::functionObjects::ddt2::execute()
<< "Unprocessed field " << ignored << endl; << "Unprocessed field " << ignored << endl;
} }
// Update time index
prevTimeIndex_ = obr_.time().timeIndex();
return true; return true;
} }
bool Foam::functionObjects::ddt2::write() bool Foam::functionObjects::ddt2::write()
{ {
if (prevTimeIndex_ < obr_.time().timeIndex())
{
// Ensure written results reflect the current state
execute();
}
if (results_.size()) if (results_.size())
{ {
Log << type() << ' ' << name() << " write:" << endl; Log << type() << ' ' << name() << " write:" << endl;

View File

@ -101,9 +101,6 @@ class ddt2
{ {
// Private data // Private data
//- Time at last execute, ensures write uses up-to-date values
label prevTimeIndex_;
//- Name of fields to process //- Name of fields to process
wordReList selectFields_; wordReList selectFields_;

View File

@ -100,7 +100,6 @@ Foam::functionObjects::zeroGradient::zeroGradient
) )
: :
fvMeshFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
prevTimeIndex_(-1),
selectFields_(), selectFields_(),
resultName_(string::null), resultName_(string::null),
results_() results_()
@ -175,20 +174,12 @@ bool Foam::functionObjects::zeroGradient::execute()
<< "Unprocessed field " << ignored << endl; << "Unprocessed field " << ignored << endl;
} }
// Update time index
prevTimeIndex_ = obr_.time().timeIndex();
return true; return true;
} }
bool Foam::functionObjects::zeroGradient::write() bool Foam::functionObjects::zeroGradient::write()
{ {
if (prevTimeIndex_ < obr_.time().timeIndex())
{
// Ensure written results reflect the current state
execute();
}
if (results_.size()) if (results_.size())
{ {
Log << type() << ' ' << name() << " write:" << endl; Log << type() << ' ' << name() << " write:" << endl;

View File

@ -95,9 +95,6 @@ class zeroGradient
{ {
// Private data // Private data
//- Time at last execute, ensures write uses up-to-date values
label prevTimeIndex_;
//- Name of fields to process //- Name of fields to process
wordReList selectFields_; wordReList selectFields_;

View File

@ -4,37 +4,58 @@ cd ${0%/*} || exit 1 # Run from this directory
# Source the wmake functions # Source the wmake functions
. $WM_DIR/scripts/wmakeFunctions . $WM_DIR/scripts/wmakeFunctions
# The source directory # Ensure CMake gets the correct C/C++ compilers
sourceDir=$PWD [ -n "$WM_CC" ] && export CC="$WM_CC"
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
# Where are any generated files stored?
findObjectDir $sourceDir
depDir="$objectsDir"
echo echo
echo "======================================================================" echo "======================================================================"
echo "${PWD##*/} : $PWD" echo "${PWD##*/} : $PWD"
echo echo
# CMake into objectsDir,
# with an additional attempt if (possibly incorrect) CMakeCache.txt existed
doCmake()
{
local sourceDir="$1"
findObjectDir $sourceDir # Where are generated files stored?
test -f "$objectsDir/CMakeCache.txt"
retry=$? # CMakeCache.txt exists, but sources may have moved
mkdir -p $objectsDir && \
(
cd $objectsDir || exit 1
cmake $sourceDir || {
if [ $retry -eq 0 ]
then
echo "Removing CMakeCache.txt and attempt again"
rm -f CMakeCache.txt
cmake $sourceDir
else
exit 1
fi
} && make
)
}
if [ -d "$VTK_DIR" -o -d "$ParaView_DIR" ] if [ -d "$VTK_DIR" -o -d "$ParaView_DIR" ]
then then
# ensure CMake gets the correct C/C++ compilers if [ "$targetType" != objects ]
[ -n "$WM_CC" ] && export CC="$WM_CC"
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
if type cmake > /dev/null 2>&1
then then
( if type cmake > /dev/null 2>&1
mkdir -p $depDir \ then
&& cd $depDir \ doCmake $PWD || {
&& cmake $sourceDir \ echo
&& make echo " WARNING: incomplete build of VTK-based post-processing"
) || { echo
echo }
echo "WARNING: incomplete build of VTK-based post-processing" else
} echo "WARNING: skipped - needs cmake"
else fi
echo "WARNING: skipped - needs cmake"
fi fi
else else
echo "WARNING: skipped - needs a VTK or a ParaView installation" echo "WARNING: skipped - needs a VTK or a ParaView installation"
@ -45,4 +66,4 @@ fi
echo "======================================================================" echo "======================================================================"
echo echo
# ----------------------------------------------------------------- end-of-file # -----------------------------------------------------------------------------

View File

@ -94,17 +94,41 @@ Foam::label Foam::noiseModel::findStartTimeIndex
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::noiseModel::noiseModel(const dictionary& dict) Foam::noiseModel::noiseModel(const dictionary& dict, const bool readFields)
: :
dict_(dict), dict_(dict),
rhoRef_(dict.lookupOrDefault<scalar>("rhoRef", 1)), rhoRef_(1),
nSamples_(dict.lookupOrDefault<label>("N", 65536)), nSamples_(65536),
fLower_(dict.lookupOrDefault<scalar>("fl", 25)), fLower_(25),
fUpper_(dict.lookupOrDefault<scalar>("fu", 10000)), fUpper_(10000),
startTime_(dict.lookupOrDefault<scalar>("startTime", 0)), startTime_(0),
windowModelPtr_(windowModel::New(dict, nSamples_)), windowModelPtr_(),
graphFormat_(dict.lookupOrDefault<word>("graphFormat", "raw")) graphFormat_("raw")
{ {
if (readFields)
{
read(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::noiseModel::~noiseModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::noiseModel::read(const dictionary& dict)
{
dict.readIfPresent("rhoRef", rhoRef_);
dict.readIfPresent("N", nSamples_);
dict.readIfPresent("fl", fLower_);
dict.readIfPresent("fu", fUpper_);
dict.readIfPresent("startTime", startTime_);
dict.readIfPresent("graphFormat", graphFormat_);
// Check number of samples - must be a power of 2 for our FFT // Check number of samples - must be a power of 2 for our FFT
bool powerOf2 = ((nSamples_ != 0) && !(nSamples_ & (nSamples_ - 1))); bool powerOf2 = ((nSamples_ != 0) && !(nSamples_ & (nSamples_ - 1)));
if (!powerOf2) if (!powerOf2)
@ -139,13 +163,11 @@ Foam::noiseModel::noiseModel(const dictionary& dict)
<< exit(FatalIOError); << exit(FatalIOError);
} }
windowModelPtr_ = windowModel::New(dict, nSamples_);
return true;
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::noiseModel::~noiseModel()
{}
// ************************************************************************* // // ************************************************************************* //

View File

@ -124,7 +124,7 @@ protected:
scalar checkUniformTimeStep scalar checkUniformTimeStep
( (
const scalarList& times const scalarList& times
) const; ) const;
//- Find and return start time index //- Find and return start time index
label findStartTimeIndex label findStartTimeIndex
@ -139,7 +139,7 @@ public:
//- Runtime type information //- Runtime type information
TypeName("noiseModel"); TypeName("noiseModel");
//- Run time selection table //- Run time selection table
declareRunTimeSelectionTable declareRunTimeSelectionTable
( (
autoPtr, autoPtr,
@ -155,7 +155,7 @@ public:
static autoPtr<noiseModel> New(const dictionary& dict); static autoPtr<noiseModel> New(const dictionary& dict);
//- Constructor //- Constructor
noiseModel(const dictionary& dict); noiseModel(const dictionary& dict, const bool readFields = true);
//- Destructor //- Destructor
virtual ~noiseModel(); virtual ~noiseModel();
@ -163,6 +163,9 @@ public:
// Public Member Functions // Public Member Functions
//- Read from dictionary
virtual bool read(const dictionary& dict);
//- Abstract call to calculate //- Abstract call to calculate
virtual void calculate() = 0; virtual void calculate() = 0;
}; };

View File

@ -43,14 +43,12 @@ addToRunTimeSelectionTable(noiseModel, pointNoise, dictionary);
void pointNoise::filterTimeData void pointNoise::filterTimeData
( (
const Function1Types::CSV<scalar>& pData, const scalarField& t0,
const scalarField& p0,
scalarField& t, scalarField& t,
scalarField& p scalarField& p
) ) const
{ {
const scalarField t0(pData.x());
const scalarField p0(pData.y());
DynamicList<scalar> tf(t0.size()); DynamicList<scalar> tf(t0.size());
DynamicList<scalar> pf(t0.size()); DynamicList<scalar> pf(t0.size());
@ -68,23 +66,15 @@ void pointNoise::filterTimeData
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void pointNoise::processData(const Function1Types::CSV<scalar>& data)
void pointNoise::calculate()
{ {
// Point data only handled by master Info<< "Reading data file " << data.fName() << endl;
if (!Pstream::master())
{
return;
}
Info<< "Reading data file" << endl; const fileName fNameBase = data.fName().name(true);
Function1Types::CSV<scalar> pData("pressure", dict_, "Data");
// Time and pressure history data // Time and pressure history data
scalarField t, p; scalarField t, p;
filterTimeData(pData, t, p); filterTimeData(data.x(), data.y(), t, p);
p *= rhoRef_; p *= rhoRef_;
Info<< " read " << t.size() << " values" << nl << endl; Info<< " read " << t.size() << " values" << nl << endl;
@ -96,7 +86,7 @@ void pointNoise::calculate()
windowModelPtr_->validate(t.size()); windowModelPtr_->validate(t.size());
const windowModel& win = windowModelPtr_(); const windowModel& win = windowModelPtr_();
const scalar deltaf = 1.0/(deltaT*win.nSamples()); const scalar deltaf = 1.0/(deltaT*win.nSamples());
fileName outDir(fileName("postProcessing")/"noise"/typeName); fileName outDir(fileName("postProcessing")/"noise"/typeName/fNameBase);
// Create the fft // Create the fft
noiseFFT nfft(deltaT, p); noiseFFT nfft(deltaT, p);
@ -185,12 +175,45 @@ void pointNoise::calculate()
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void pointNoise::calculate()
{
// Point data only handled by master
if (!Pstream::master())
{
return;
}
if (inputFileNames_.size())
{
forAll(inputFileNames_, i)
{
const fileName fName = inputFileNames_[i].expand();
Function1Types::CSV<scalar> data("pressure", dict_, "Data", fName);
processData(data);
}
}
else
{
Function1Types::CSV<scalar> data("pressure", dict_, "Data");
processData(data);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
pointNoise::pointNoise(const dictionary& dict) pointNoise::pointNoise(const dictionary& dict, const bool readFields)
: :
noiseModel(dict) noiseModel(dict)
{} {
if (readFields)
{
read(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -199,6 +222,18 @@ pointNoise::~pointNoise()
{} {}
bool pointNoise::read(const dictionary& dict)
{
if (noiseModel::read(dict))
{
dict.readIfPresent("inputFiles", inputFileNames_);
return true;
}
return false;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace noiseModels } // End namespace noiseModels

View File

@ -76,8 +76,8 @@ SeeAlso
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef pointNoise_H #ifndef noiseModels_pointNoise_H
#define pointNoise_H #define noiseModels_pointNoise_H
#include "noiseModel.H" #include "noiseModel.H"
#include "CSV.H" #include "CSV.H"
@ -100,14 +100,24 @@ class pointNoise
protected: protected:
// Protected data
//- Input file names - optional
List<fileName> inputFileNames_;
// Protected Member Functions // Protected Member Functions
void filterTimeData void filterTimeData
( (
const Function1Types::CSV<scalar>& pData, const scalarField& t0,
const scalarField& p0,
scalarField& t, scalarField& t,
scalarField& p scalarField& p
); ) const;
//- Process the CSV data
void processData(const Function1Types::CSV<scalar>& data);
public: public:
@ -116,7 +126,7 @@ public:
TypeName("pointNoise"); TypeName("pointNoise");
//- Constructor //- Constructor
pointNoise(const dictionary& dict); pointNoise(const dictionary& dict, const bool readFields = true);
//- Destructor //- Destructor
virtual ~pointNoise(); virtual ~pointNoise();
@ -124,6 +134,9 @@ public:
// Public Member Functions // Public Member Functions
//- Read from dictionary
virtual bool read(const dictionary& dict);
//- Calculate //- Calculate
virtual void calculate(); virtual void calculate();

View File

@ -44,12 +44,9 @@ addToRunTimeSelectionTable(noiseModel, surfaceNoise, dictionary);
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void surfaceNoise::initialise(const dictionary& dict) void surfaceNoise::initialise(const fileName& fName)
{ {
dict.lookup("inputFile") >> inputFileName_; Info<< "Reading data file " << fName << endl;
inputFileName_.expand();
dict.readIfPresent("fftWriteInterval", fftWriteInterval_);
label nAvailableTimes = 0; label nAvailableTimes = 0;
@ -57,17 +54,15 @@ void surfaceNoise::initialise(const dictionary& dict)
if (Pstream::master()) if (Pstream::master())
{ {
// Create the surface reader // Create the surface reader
const word readerType(dict.lookup("reader")); readerPtr_ = surfaceReader::New(readerType_, fName);
readerPtr_.reset(surfaceReader::New(readerType, inputFileName_).ptr());
// Find the index of the pressure data // Find the index of the pressure data
const word pName(dict.lookupOrDefault<word>("p", "p"));
const List<word> fieldNames(readerPtr_->fieldNames(0)); const List<word> fieldNames(readerPtr_->fieldNames(0));
pIndex_ = findIndex(fieldNames, pName); pIndex_ = findIndex(fieldNames, pName_);
if (pIndex_ == -1) if (pIndex_ == -1)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unable to find pressure field name " << pName << "Unable to find pressure field name " << pName_
<< " in list of available fields: " << fieldNames << " in list of available fields: " << fieldNames
<< exit(FatalError); << exit(FatalError);
} }
@ -76,12 +71,6 @@ void surfaceNoise::initialise(const dictionary& dict)
// - Could be done later, but since this utility can process a lot of // - Could be done later, but since this utility can process a lot of
// data we can ensure that the user-input is correct prior to doing // data we can ensure that the user-input is correct prior to doing
// the heavy lifting // the heavy lifting
const word writerType(dict.lookup("writer"));
dictionary optDict
(
dict.subOrEmptyDict("writeOptions").subOrEmptyDict(writerType)
);
writerPtr_.reset(surfaceWriter::New(writerType, optDict).ptr());
// Set the time range // Set the time range
const instantList allTimes = readerPtr_->times(); const instantList allTimes = readerPtr_->times();
@ -404,18 +393,25 @@ Foam::scalar surfaceNoise::surfaceAverage
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
surfaceNoise::surfaceNoise(const dictionary& dict) surfaceNoise::surfaceNoise(const dictionary& dict, const bool readFields)
: :
noiseModel(dict), noiseModel(dict, false),
inputFileName_("unknown-inputFile"), inputFileNames_(),
pName_("p"),
pIndex_(0), pIndex_(0),
times_(), times_(),
deltaT_(0), deltaT_(0),
startTimeIndex_(0), startTimeIndex_(0),
nFace_(0), nFace_(0),
fftWriteInterval_(1) fftWriteInterval_(1),
readerType_(word::null),
readerPtr_(nullptr),
writerPtr_(nullptr)
{ {
initialise(dict); if (readFields)
{
read(dict);
}
} }
@ -427,271 +423,316 @@ surfaceNoise::~surfaceNoise()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool surfaceNoise::read(const dictionary& dict)
{
if (noiseModel::read(dict))
{
if (dict.found("inputFile"))
{
inputFileNames_.setSize(1);
dict.lookup("inputFile") >> inputFileNames_[0];
}
else
{
dict.lookup("inputFiles") >> inputFileNames_;
}
dict.readIfPresent("fftWriteInterval", fftWriteInterval_);
dict.readIfPresent("p", pName_);
dict.lookup("reader") >> readerType_;
word writerType(dict.lookup("writer"));
dictionary optDict
(
dict.subOrEmptyDict("writeOptions").subOrEmptyDict(writerType)
);
writerPtr_ = surfaceWriter::New(writerType, optDict);
return true;
}
return false;
}
void surfaceNoise::calculate() void surfaceNoise::calculate()
{ {
// Container for pressure time history data per face forAll(inputFileNames_, i)
List<scalarField> pData;
// Processor procFaceOffsets
labelList procFaceOffset;
if (Pstream::parRun())
{ {
const label nProcs = Pstream::nProcs(); fileName fName = inputFileNames_[i];
const label nFacePerProc = floor(nFace_/nProcs) + 1;
procFaceOffset.setSize(nProcs + 1, 0); initialise(fName.expand());
for (label i = 1; i < procFaceOffset.size(); i++)
// Container for pressure time history data per face
List<scalarField> pData;
// Processor procFaceOffsets
labelList procFaceOffset;
if (Pstream::parRun())
{ {
procFaceOffset[i] = min(i*nFacePerProc, nFace_); const label nProcs = Pstream::nProcs();
const label nFacePerProc = floor(nFace_/nProcs) + 1;
procFaceOffset.setSize(nProcs + 1, 0);
for (label i = 1; i < procFaceOffset.size(); i++)
{
procFaceOffset[i] = min(i*nFacePerProc, nFace_);
}
} }
} else
else
{
procFaceOffset.setSize(1, nFace_);
}
// Read pressure data from file
readSurfaceData(procFaceOffset, pData);
// Process the pressure data, and store results as surface values per
// frequency so that it can be output using the surface writer
Info<< "Creating noise FFTs" << endl;
// Storage for FFT data
const label nLocalFace = pData.size();
const scalarField freq1(noiseFFT::frequencies(nSamples_, deltaT_));
const label nFFT = freq1.size()/fftWriteInterval_;
List<scalarField> surfPrmsf(nFFT);
List<scalarField> surfPSDf(nFFT);
forAll(surfPrmsf, freqI)
{
surfPrmsf[freqI].setSize(nLocalFace);
surfPSDf[freqI].setSize(nLocalFace);
}
// Storage for 1/3 octave data
labelList octave13BandIDs;
scalarField octave13FreqCentre;
noiseFFT::octaveBandInfo
(
freq1,
fLower_,
fUpper_,
3,
octave13BandIDs,
octave13FreqCentre
);
label bandSize = 0;
if (octave13BandIDs.empty())
{
WarningInFunction
<< "Ocatve band calculation failed (zero sized). "
<< "please check your input data"
<< endl;
}
else
{
bandSize = octave13BandIDs.size() - 1;
}
List<scalarField> surfPSD13f(bandSize);
List<scalarField> surfPrms13f2(bandSize);
forAll(surfPSD13f, freqI)
{
surfPSD13f[freqI].setSize(nLocalFace);
surfPrms13f2[freqI].setSize(nLocalFace);
}
const windowModel& win = windowModelPtr_();
forAll(pData, faceI)
{
const scalarField& p = pData[faceI];
noiseFFT nfft(deltaT_, p);
graph Prmsf(nfft.RMSmeanPf(win));
graph PSDf(nfft.PSDf(win));
// Store the frequency results in slot for face of surface
forAll(surfPrmsf, i)
{ {
label freqI = (i + 1)*fftWriteInterval_ - 1; procFaceOffset.setSize(1, nFace_);
surfPrmsf[i][faceI] = Prmsf.y()[freqI];
surfPSDf[i][faceI] = PSDf.y()[freqI];
} }
// PSD [Pa^2/Hz] // Read pressure data from file
graph PSD13f(nfft.octaves(PSDf, octave13BandIDs, false)); readSurfaceData(procFaceOffset, pData);
// Integrated PSD = P(rms)^2 [Pa^2] // Process the pressure data, and store results as surface values per
graph Prms13f2(nfft.octaves(PSDf, octave13BandIDs, true)); // frequency so that it can be output using the surface writer
// Store the 1/3 octave results in slot for face of surface Info<< "Creating noise FFTs" << endl;
// Storage for FFT data
const label nLocalFace = pData.size();
const scalarField freq1(noiseFFT::frequencies(nSamples_, deltaT_));
const label nFFT = freq1.size()/fftWriteInterval_;
List<scalarField> surfPrmsf(nFFT);
List<scalarField> surfPSDf(nFFT);
forAll(surfPrmsf, freqI)
{
surfPrmsf[freqI].setSize(nLocalFace);
surfPSDf[freqI].setSize(nLocalFace);
}
// Storage for 1/3 octave data
labelList octave13BandIDs;
scalarField octave13FreqCentre;
noiseFFT::octaveBandInfo
(
freq1,
fLower_,
fUpper_,
3,
octave13BandIDs,
octave13FreqCentre
);
label bandSize = 0;
if (octave13BandIDs.empty())
{
WarningInFunction
<< "Ocatve band calculation failed (zero sized). "
<< "please check your input data"
<< endl;
}
else
{
bandSize = octave13BandIDs.size() - 1;
}
List<scalarField> surfPSD13f(bandSize);
List<scalarField> surfPrms13f2(bandSize);
forAll(surfPSD13f, freqI) forAll(surfPSD13f, freqI)
{ {
surfPSD13f[freqI][faceI] = PSD13f.y()[freqI]; surfPSD13f[freqI].setSize(nLocalFace);
surfPrms13f2[freqI][faceI] = Prms13f2.y()[freqI]; surfPrms13f2[freqI].setSize(nLocalFace);
} }
}
// Output directory for graphs const windowModel& win = windowModelPtr_();
fileName outDir(fileName("postProcessing")/"noise"/typeName);
const scalar deltaf = 1.0/(deltaT_*win.nSamples()); forAll(pData, faceI)
Info<< "Writing fft surface data" << endl;
{
scalarField PrmsfAve(surfPrmsf.size(), 0);
scalarField PSDfAve(surfPrmsf.size(), 0);
scalarField fOut(surfPrmsf.size(), 0);
forAll(surfPrmsf, i)
{ {
label freqI = i*fftWriteInterval_; const scalarField& p = pData[faceI];
fOut[i] = freq1[freqI];
const word& fName = inputFileName_.name(true);
const word gName = "fft";
PrmsfAve[i] = writeSurfaceData
(
fName,
gName,
"Prmsf",
freq1[freqI],
surfPrmsf[i],
procFaceOffset
);
PSDfAve[i] = writeSurfaceData noiseFFT nfft(deltaT_, p);
( graph Prmsf(nfft.RMSmeanPf(win));
fName, graph PSDf(nfft.PSDf(win));
gName,
"PSDf", // Store the frequency results in slot for face of surface
freq1[freqI], forAll(surfPrmsf, i)
surfPSDf[i], {
procFaceOffset label freqI = (i + 1)*fftWriteInterval_ - 1;
); surfPrmsf[i][faceI] = Prmsf.y()[freqI];
writeSurfaceData surfPSDf[i][faceI] = PSDf.y()[freqI];
( }
fName,
gName, // PSD [Pa^2/Hz]
"PSD", graph PSD13f(nfft.octaves(PSDf, octave13BandIDs, false));
freq1[freqI],
noiseFFT::PSD(surfPSDf[i]), // Integrated PSD = P(rms)^2 [Pa^2]
procFaceOffset graph Prms13f2(nfft.octaves(PSDf, octave13BandIDs, true));
);
writeSurfaceData // Store the 1/3 octave results in slot for face of surface
( forAll(surfPSD13f, freqI)
fName, {
gName, surfPSD13f[freqI][faceI] = PSD13f.y()[freqI];
"SPL", surfPrms13f2[freqI][faceI] = Prms13f2.y()[freqI];
freq1[freqI], }
noiseFFT::SPL(surfPSDf[i]*deltaf),
procFaceOffset
);
} }
graph Prmsfg const word& fNameBase = fName.name(true);
// Output directory for graphs
fileName outDir
( (
"Average Prms(f)", fileName("postProcessing")/"noise"/typeName/fNameBase
"f [Hz]",
"P(f) [Pa]",
fOut,
PrmsfAve
); );
Prmsfg.write(outDir, graph::wordify(Prmsfg.title()), graphFormat_);
graph PSDfg const scalar deltaf = 1.0/(deltaT_*win.nSamples());
( Info<< "Writing fft surface data" << endl;
"Average PSD_f(f)",
"f [Hz]",
"PSD(f) [PaPa_Hz]",
fOut,
PSDfAve
);
PSDfg.write(outDir, graph::wordify(PSDfg.title()), graphFormat_);
graph PSDg
(
"Average PSD_dB_Hz(f)",
"f [Hz]",
"PSD(f) [dB_Hz]",
fOut,
noiseFFT::PSD(PSDfAve)
);
PSDg.write(outDir, graph::wordify(PSDg.title()), graphFormat_);
graph SPLg
(
"Average SPL_dB(f)",
"f [Hz]",
"SPL(f) [dB]",
fOut,
noiseFFT::SPL(PSDfAve*deltaf)
);
SPLg.write(outDir, graph::wordify(SPLg.title()), graphFormat_);
}
Info<< "Writing one-third octave surface data" << endl;
{
scalarField PSDfAve(surfPSD13f.size(), 0);
scalarField Prms13f2Ave(surfPSD13f.size(), 0);
forAll(surfPSD13f, i)
{ {
const word& fName = inputFileName_.name(true); scalarField PrmsfAve(surfPrmsf.size(), 0);
const word gName = "oneThirdOctave"; scalarField PSDfAve(surfPrmsf.size(), 0);
PSDfAve[i] = writeSurfaceData scalarField fOut(surfPrmsf.size(), 0);
(
fName,
gName,
"PSD13f",
octave13FreqCentre[i],
surfPSD13f[i],
procFaceOffset
);
writeSurfaceData
(
fName,
gName,
"PSD13",
octave13FreqCentre[i],
noiseFFT::PSD(surfPSD13f[i]),
procFaceOffset
);
writeSurfaceData
(
fName,
gName,
"SPL13",
octave13FreqCentre[i],
noiseFFT::SPL(surfPrms13f2[i]),
procFaceOffset
);
Prms13f2Ave[i] = surfaceAverage(surfPrms13f2[i], procFaceOffset); forAll(surfPrmsf, i)
{
label freqI = i*fftWriteInterval_;
fOut[i] = freq1[freqI];
const word gName = "fft";
PrmsfAve[i] = writeSurfaceData
(
fNameBase,
gName,
"Prmsf",
freq1[freqI],
surfPrmsf[i],
procFaceOffset
);
PSDfAve[i] = writeSurfaceData
(
fNameBase,
gName,
"PSDf",
freq1[freqI],
surfPSDf[i],
procFaceOffset
);
writeSurfaceData
(
fNameBase,
gName,
"PSD",
freq1[freqI],
noiseFFT::PSD(surfPSDf[i]),
procFaceOffset
);
writeSurfaceData
(
fNameBase,
gName,
"SPL",
freq1[freqI],
noiseFFT::SPL(surfPSDf[i]*deltaf),
procFaceOffset
);
}
graph Prmsfg
(
"Average Prms(f)",
"f [Hz]",
"P(f) [Pa]",
fOut,
PrmsfAve
);
Prmsfg.write(outDir, graph::wordify(Prmsfg.title()), graphFormat_);
graph PSDfg
(
"Average PSD_f(f)",
"f [Hz]",
"PSD(f) [PaPa_Hz]",
fOut,
PSDfAve
);
PSDfg.write(outDir, graph::wordify(PSDfg.title()), graphFormat_);
graph PSDg
(
"Average PSD_dB_Hz(f)",
"f [Hz]",
"PSD(f) [dB_Hz]",
fOut,
noiseFFT::PSD(PSDfAve)
);
PSDg.write(outDir, graph::wordify(PSDg.title()), graphFormat_);
graph SPLg
(
"Average SPL_dB(f)",
"f [Hz]",
"SPL(f) [dB]",
fOut,
noiseFFT::SPL(PSDfAve*deltaf)
);
SPLg.write(outDir, graph::wordify(SPLg.title()), graphFormat_);
} }
graph PSD13g
(
"Average PSD13_dB_Hz(fm)",
"fm [Hz]",
"PSD(fm) [dB_Hz]",
octave13FreqCentre,
noiseFFT::PSD(PSDfAve)
);
PSD13g.write(outDir, graph::wordify(PSD13g.title()), graphFormat_);
graph SPL13g Info<< "Writing one-third octave surface data" << endl;
( {
"Average SPL13_dB(fm)", scalarField PSDfAve(surfPSD13f.size(), 0);
"fm [Hz]", scalarField Prms13f2Ave(surfPSD13f.size(), 0);
"SPL(fm) [dB]",
octave13FreqCentre, forAll(surfPSD13f, i)
noiseFFT::SPL(Prms13f2Ave) {
); const word gName = "oneThirdOctave";
SPL13g.write(outDir, graph::wordify(SPL13g.title()), graphFormat_); PSDfAve[i] = writeSurfaceData
(
fNameBase,
gName,
"PSD13f",
octave13FreqCentre[i],
surfPSD13f[i],
procFaceOffset
);
writeSurfaceData
(
fNameBase,
gName,
"PSD13",
octave13FreqCentre[i],
noiseFFT::PSD(surfPSD13f[i]),
procFaceOffset
);
writeSurfaceData
(
fNameBase,
gName,
"SPL13",
octave13FreqCentre[i],
noiseFFT::SPL(surfPrms13f2[i]),
procFaceOffset
);
Prms13f2Ave[i] =
surfaceAverage(surfPrms13f2[i], procFaceOffset);
}
graph PSD13g
(
"Average PSD13_dB_Hz(fm)",
"fm [Hz]",
"PSD(fm) [dB_Hz]",
octave13FreqCentre,
noiseFFT::PSD(PSDfAve)
);
PSD13g.write(outDir, graph::wordify(PSD13g.title()), graphFormat_);
graph SPL13g
(
"Average SPL13_dB(fm)",
"fm [Hz]",
"SPL(fm) [dB]",
octave13FreqCentre,
noiseFFT::SPL(Prms13f2Ave)
);
SPL13g.write(outDir, graph::wordify(SPL13g.title()), graphFormat_);
}
} }
} }

View File

@ -53,7 +53,7 @@ Description
} }
// Input file // Input file
inputFile "postProcessing/faceSource1/surface/patch/patch.case"; inputFiles ("postProcessing/faceSource1/surface/patch/patch.case");
// Write interval for FFT data, default = 1 // Write interval for FFT data, default = 1
fftWriteInterval 100; fftWriteInterval 100;
@ -83,8 +83,8 @@ SeeAlso
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef surfaceNoise_H #ifndef noiseModels_surfaceNoise_H
#define surfaceNoise_H #define noiseModels_surfaceNoise_H
#include "noiseModel.H" #include "noiseModel.H"
#include "labelList.H" #include "labelList.H"
@ -115,8 +115,11 @@ protected:
// Protected Data // Protected Data
//- Input file name //- Input file names
fileName inputFileName_; List<fileName> inputFileNames_;
//- Name of pressure field
word pName_;
//- Index of pressure field in reader field list //- Index of pressure field in reader field list
label pIndex_; label pIndex_;
@ -138,17 +141,20 @@ protected:
// result in a very large number of output files (1 per frequency) // result in a very large number of output files (1 per frequency)
label fftWriteInterval_; label fftWriteInterval_;
//- Reader type
word readerType_;
//- Pointer to the surface reader //- Pointer to the surface reader
mutable autoPtr<surfaceReader> readerPtr_; mutable autoPtr<surfaceReader> readerPtr_;
//- Pointer to the surface writer //- Pointer to the surface writer
autoPtr<surfaceWriter> writerPtr_; mutable autoPtr<surfaceWriter> writerPtr_;
// Protected Member Functions // Protected Member Functions
//- Initialise //- Initialise
void initialise(const dictionary& dict); void initialise(const fileName& fName);
//- Read surface data //- Read surface data
void readSurfaceData void readSurfaceData
@ -183,7 +189,7 @@ public:
TypeName("surfaceNoise"); TypeName("surfaceNoise");
//- Constructor //- Constructor
surfaceNoise(const dictionary& dict); surfaceNoise(const dictionary& dict, const bool readFields = true);
//- Destructor //- Destructor
virtual ~surfaceNoise(); virtual ~surfaceNoise();
@ -191,6 +197,9 @@ public:
// Public Member Functions // Public Member Functions
//- Read from dictionary
virtual bool read(const dictionary& dict);
//- Calculate //- Calculate
virtual void calculate(); virtual void calculate();
}; };

View File

@ -117,8 +117,8 @@ tmp<scalarField> curvatureSeparation::calcCosAngle
{ {
const fvMesh& mesh = owner().regionMesh(); const fvMesh& mesh = owner().regionMesh();
const vectorField nf(mesh.Sf()/mesh.magSf()); const vectorField nf(mesh.Sf()/mesh.magSf());
const unallocLabelList& own = mesh.owner(); const labelUList& own = mesh.owner();
const unallocLabelList& nbr = mesh.neighbour(); const labelUList& nbr = mesh.neighbour();
scalarField phiMax(mesh.nCells(), -GREAT); scalarField phiMax(mesh.nCells(), -GREAT);
scalarField cosAngle(mesh.nCells(), 0.0); scalarField cosAngle(mesh.nCells(), 0.0);

View File

@ -789,7 +789,7 @@ tmp<volScalarField::Internal> thermoSingleLayer::Srho() const
toPrimary(filmPatchi, patchMass); toPrimary(filmPatchi, patchMass);
const label primaryPatchi = primaryPatchIDs()[i]; const label primaryPatchi = primaryPatchIDs()[i];
const unallocLabelList& cells = const labelUList& cells =
primaryMesh().boundaryMesh()[primaryPatchi].faceCells(); primaryMesh().boundaryMesh()[primaryPatchi].faceCells();
forAll(patchMass, j) forAll(patchMass, j)
@ -843,7 +843,7 @@ tmp<volScalarField::Internal> thermoSingleLayer::Srho
toPrimary(filmPatchi, patchMass); toPrimary(filmPatchi, patchMass);
const label primaryPatchi = primaryPatchIDs()[i]; const label primaryPatchi = primaryPatchIDs()[i];
const unallocLabelList& cells = const labelUList& cells =
primaryMesh().boundaryMesh()[primaryPatchi].faceCells(); primaryMesh().boundaryMesh()[primaryPatchi].faceCells();
forAll(patchMass, j) forAll(patchMass, j)
@ -893,7 +893,7 @@ tmp<volScalarField::Internal> thermoSingleLayer::Sh() const
toPrimary(filmPatchi, patchEnergy); toPrimary(filmPatchi, patchEnergy);
const label primaryPatchi = primaryPatchIDs()[i]; const label primaryPatchi = primaryPatchIDs()[i];
const unallocLabelList& cells = const labelUList& cells =
primaryMesh().boundaryMesh()[primaryPatchi].faceCells(); primaryMesh().boundaryMesh()[primaryPatchi].faceCells();
forAll(patchEnergy, j) forAll(patchEnergy, j)

View File

@ -4,16 +4,8 @@
sinclude $(GENERAL_RULES)/mplib$(WM_MPLIB) sinclude $(GENERAL_RULES)/mplib$(WM_MPLIB)
sinclude $(RULES)/mplib$(WM_MPLIB) sinclude $(RULES)/mplib$(WM_MPLIB)
ADIOS_INC = -I$(ADIOS_ARCH_PATH)/include # Obtain compile/link flags via adios_config
ADIOS_INC := $(shell $(ADIOS_ARCH_PATH)/bin/adios_config -c)
ADIOS_LIBS := \ ADIOS_LIBS := $(shell $(ADIOS_ARCH_PATH)/bin/adios_config -l)
-L$(ADIOS_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
-ladios_$(FOAM_MPI)
# ADIOS dependent libraries. Eg, after -L/usr/lib64 ...
# Query as sequential to reduce mpi-dependencies
ADIOS_LIBS +=
$(shell $(ADIOS_ARCH_PATH)/bin/adios_config -s -l | sed -e 's@^.*-L/usr/lib[^ ]*@@')
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------