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

This commit is contained in:
sergio 2016-07-27 08:56:24 -07:00
commit 466a2631c7
56 changed files with 1313 additions and 488 deletions

View File

@ -30,7 +30,8 @@ writeInterval #codeStream
codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
#};
localCode

View File

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

View File

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

View File

@ -0,0 +1,99 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Description
Test some string functionality
\*---------------------------------------------------------------------------*/
#include "CStringList.H"
#include "DynamicList.H"
#include "IOstreams.H"
#include "fileNameList.H"
#include "stringList.H"
#include "wordList.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int print(int argc, char *argv[])
{
Info<< "argc=" << argc << endl;
for (int i=0; i<argc; ++i)
{
Info<< " argv[" << i << "] = \"" << argv[i] << "\"" << endl;
}
return argc;
}
int print(const CStringList& cstrLst)
{
return print(cstrLst.size(), cstrLst.strings());
}
// Main program:
int main(int argc, char *argv[])
{
DynamicList<string> dynlst;
dynlst.reserve(16);
dynlst.append("string1 with content");
dynlst.append("string2 other content");
dynlst.append("string3 done");
{
CStringList inC(dynlst);
Info<< "input: " << dynlst << endl;
print(inC);
}
Info<<"command-line with " << CStringList::count(argv) << " items"<< endl;
print(argc, argv);
{
dynlst.clear();
for (int i=0; i<argc; ++i)
{
dynlst.append(argv[i]);
}
Info<< "input: " << dynlst << endl;
CStringList inC(dynlst);
inC.reset(dynlst);
print(inC);
Info<< "length: " << inC.length() << endl;
std::cout.write(inC.data(), inC.length());
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,6 +34,7 @@ Description
#include "IOobject.H"
#include "IOstreams.H"
#include "OSspecific.H"
#include "POSIX.H"
using namespace Foam;
@ -99,6 +100,98 @@ int main()
}
// Test some copying and deletion
{
const fileName dirA("dirA");
const fileName lnA("lnA");
const fileName lnB("lnB");
const fileName dirB("dirB");
Foam::rmDir(dirA);
Foam::rm(lnA);
Foam::rm(lnB);
Foam::rmDir(dirB);
Info<< "Creating directory " << dirA << endl;
Foam::mkDir(dirA);
const int oldPosix = POSIX::debug;
POSIX::debug = 1;
// Create link and test it
Info<< "Creating softlink " << lnA << endl;
Foam::ln(dirA, lnA);
fileName::Type lnAType = lnA.type(false);
if (lnAType != fileName::LINK)
{
FatalErrorIn("Test-fileName") << "Type of softlink " << lnA
<< " should be " << fileName::LINK
<< " but is " << lnAType << exit(FatalError);
}
fileName::Type dirAType = lnA.type(true);
if (dirAType != fileName::DIRECTORY)
{
FatalErrorIn("Test-fileName") << "Type of what softlink " << lnA
<< " points to should be " << fileName::DIRECTORY
<< " but is " << dirAType << exit(FatalError);
}
// Copy link only
{
Info<< "Copying (non-follow) softlink " << lnA << " to " << lnB
<< endl;
Foam::cp(lnA, lnB, false);
if (lnB.type(false) != fileName::LINK)
{
FatalErrorIn("Test-fileName") << "Type of softlink " << lnB
<< " should be " << fileName::LINK
<< " but is " << lnB.type(false) << exit(FatalError);
}
if (lnB.type(true) != fileName::DIRECTORY)
{
FatalErrorIn("Test-fileName") << "Type of softlink " << lnB
<< " should be " << fileName::DIRECTORY
<< " but is " << lnB.type(true) << exit(FatalError);
}
// Delete
Foam::rm(lnB);
}
// Copy contents of link
{
Info<< "Copying (contents of) softlink " << lnA << " to " << lnB
<< endl;
Foam::cp(lnA, lnB, true);
if (lnB.type(false) != fileName::DIRECTORY)
{
FatalErrorIn("Test-fileName") << "Type of softlink " << lnB
<< " should be " << fileName::DIRECTORY
<< " but is " << lnB.type(false) << exit(FatalError);
}
// Delete
Foam::rm(lnB);
}
POSIX::debug = oldPosix;
Foam::rmDir(dirA);
Foam::rm(lnA);
}
// test findEtcFile
Info<< "\n\nfindEtcFile tests:" << nl
<< " controlDict => " << findEtcFile("controlDict") << nl

View File

@ -151,7 +151,7 @@ void Foam::helpType::displayDoc
Info<< "Source file: " << classDirectory.c_str() << classFile << nl
<< endl;
system(docBrowser);
Foam::system(docBrowser);
}
else
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -23,6 +23,8 @@ License
Application
foamInfoExec
To simplify parsing of the output, The normal banner information
is suppressed.
Group
grpMiscUtilities

View File

@ -1309,7 +1309,7 @@ int main(int argc, char *argv[])
+ "_"
+ procFile.name()
);
if (system(cmd.c_str()) == -1)
if (Foam::system(cmd.c_str()) == -1)
{
WarningInFunction
<< "Could not execute command " << cmd << endl;

View File

@ -47,11 +47,14 @@ QT4_WRAP_CPP(MOC_SRCS pqPVFoamReaderPanel.h)
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
CLASS_NAME pqPVFoamReaderPanel
XML_NAME PVFoamReader # name of SourceProxy in *SM.xml
XML_NAME PVFoamReader # name of SourceProxy in *SM.xml
XML_GROUP sources
)
IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
# Separate GUI_RESOURCE_FILES deprecated with paraview 4.3
# so check if version < 4.4
IF(("${PARAVIEW_VERSION_MAJOR}" LESS 5) AND ("${PARAVIEW_VERSION_MINOR}" LESS 4))
ADD_PARAVIEW_PLUGIN(
PVFoamReader_SM "1.0"
SERVER_MANAGER_XML PVFoamReader_SM.xml
@ -61,7 +64,7 @@ IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
GUI_RESOURCE_FILES PVFoamReader.xml
)
ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
ELSE()
ADD_PARAVIEW_PLUGIN(
PVFoamReader_SM "1.0"
SERVER_MANAGER_XML PVFoamReader_SM.xml
@ -70,7 +73,7 @@ ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
GUI_SOURCES pqPVFoamReaderPanel.cxx
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
)
ENDIF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
ENDIF()
TARGET_LINK_LIBRARIES(
PVFoamReader_SM

View File

@ -1,4 +1,5 @@
<ParaViewReaders>
<!-- deprecated with paraview-4.3, use hints in *SM.xml -->
<Reader name="PVFoamReader"
extensions="OpenFOAM"
file_description="OpenFOAM Reader">

View File

@ -1,18 +1,12 @@
/* Note: enable vtkPolyhedron when available */
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I../../vtkPVReaders/lnInclude \
-I../PVFoamReader \
-I$(ParaView_INCLUDE_DIR) \
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \
$(shell \
test -f $(ParaView_INCLUDE_DIR)/vtkPolyhedron.h && \
echo "-DHAS_VTK_POLYHEDRON" || echo "-UHAS_VTK_POLYHEDRON" \
)
-I../../vtkPVReaders/lnInclude \
-I../PVFoamReader
LIB_LIBS = \
-lmeshTools \

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -275,7 +275,6 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
// Polyhedral cell - use VTK_POLYHEDRON
const labelList& cFaces = mesh.cells()[cellI];
#ifdef HAS_VTK_POLYHEDRON
vtkIdType nFaces = cFaces.size();
vtkIdType nLabels = nFaces;
@ -320,33 +319,6 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
}
vtkmesh->InsertNextCell(VTK_POLYHEDRON, nFaces, faceStream.data());
#else
// this is a horrible substitute
// but avoids crashes when there is no vtkPolyhedron support
// establish unique node ids used
HashSet<vtkIdType, Hash<label>> hashUniqId(2*256);
forAll(cFaces, cFaceI)
{
const face& f = mesh.faces()[cFaces[cFaceI]];
forAll(f, fp)
{
hashUniqId.insert(f[fp]);
}
}
// use face stream to store unique node ids:
faceStream = hashUniqId.sortedToc();
vtkmesh->InsertNextCell
(
VTK_CONVEX_POINT_SET,
vtkIdType(faceStream.size()),
faceStream.data()
);
#endif
}
else
{

View File

@ -46,13 +46,16 @@ QT4_WRAP_CPP(MOC_SRCS pqPVblockMeshReaderPanel.h)
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
CLASS_NAME pqPVblockMeshReaderPanel
XML_NAME PVblockMeshReader # name of SourceProxy in *SM.xml
XML_NAME PVblockMeshReader # name of SourceProxy in *SM.xml
XML_GROUP sources
)
IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
ADD_PARAVIEW_PLUGIN(
PVblockMeshReader_SM "1.0"
# Separate GUI_RESOURCE_FILES deprecated with paraview 4.3
# so check if version < 4.4
IF(("${PARAVIEW_VERSION_MAJOR}" LESS 5) AND ("${PARAVIEW_VERSION_MINOR}" LESS 4))
ADD_PARAVIEW_PLUGIN(
PVblockMeshReader_SM "1.0"
SERVER_MANAGER_XML PVblockMeshReader_SM.xml
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
GUI_INTERFACES ${IFACES}
@ -60,16 +63,16 @@ IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
GUI_RESOURCE_FILES PVblockMeshReader.xml
)
ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
ADD_PARAVIEW_PLUGIN(
PVblockMeshReader_SM "1.0"
ELSE()
ADD_PARAVIEW_PLUGIN(
PVblockMeshReader_SM "1.0"
SERVER_MANAGER_XML PVblockMeshReader_SM.xml
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
GUI_INTERFACES ${IFACES}
GUI_SOURCES pqPVblockMeshReaderPanel.cxx
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
)
ENDIF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
ENDIF()
# Build the client-side plugin

View File

@ -1,4 +1,5 @@
<ParaViewReaders>
<!-- deprecated with paraview-4.3, use hints in *SM.xml -->
<Reader name="PVblockMeshReader"
extensions="blockMesh"
file_description="OpenFOAM blockMesh reader">

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,6 +29,8 @@ Group
Description
List times using timeSelector.
To simplify parsing of the output, the normal banner information
is suppressed.
Usage

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -191,9 +191,15 @@ void writeRays
str << "l " << vertI-1 << ' ' << vertI << nl;
}
}
string cmd("objToVTK " + fName + " " + fName.lessExt() + ".vtk");
Pout<< "cmd:" << cmd << endl;
system(cmd);
str.flush();
DynamicList<string> cmd(3);
cmd.append("objToVTK");
cmd.append(fName);
cmd.append(fName.lessExt() + ".vtk");
Pout<< "cmd: objToVTK " << fName.c_str() << endl;
Foam::system(cmd);
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,6 +29,8 @@ Group
Description
Miscellaneous information about surface meshes.
To simplify parsing of the output, the normal banner information
is suppressed.
Usage
- surfaceMeshInfo surfaceFile [OPTION]

View File

@ -1,61 +0,0 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# engridFoam
#
# Description
# start engrid using the paraview libraries from OpenFOAM
#
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: ${0##*/} [OPTION]
options:
-help
* start engrid using the paraview-$ParaView_MAJOR libraries
passes through engrid options unmodified
USAGE
exit 1
}
# report usage
[ "$1" = "-h" -o "$1" = "-help" ] && usage
bindir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/engrid
libdir="$ParaView_DIR/lib/paraview-${ParaView_MAJOR:-unknown}"
[ -x $bindir/engrid ] || usage "engrid executable not found in $bindir"
[ -d $libdir ] || usage "paraview libraries not found"
export LD_LIBRARY_PATH=$libdir:$LD_LIBRARY_PATH
echo "starting $bindir/engrid $@"
eval "exec $bindir/engrid $@ &"
#------------------------------------------------------------------------------

View File

@ -4,7 +4,7 @@
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation |
# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
@ -40,17 +40,18 @@ usage() {
Usage: ${0##*/} [OPTION] [PARAVIEW_OPTION]
options:
-block use blockMesh reader (uses .blockMesh extension)
-builtin use VTK builtin OpenFOAM reader (uses .foam extension)
-case <dir> specify alternative case directory, default is the cwd
-region <name> specify alternative mesh region
-touch only create the file (eg, .blockMesh, .OpenFOAM, etc)
-touchAll create .blockMesh, .OpenFOAM files (and for all regions)
-vtk | -builtin use VTK builtin OpenFOAM reader (uses .foam extension)
-help print the usage
Paraview options start with a double dashes.
paraview options start with a double dashes
* start paraview with the OpenFOAM libraries
* start paraview $ParaView_VERSION with the OpenFOAM libraries
paraview=$(command -v paraview)
USAGE
exit 1
@ -67,10 +68,9 @@ unset regionName optTouch
# already 2010-07)
export LC_ALL=C
# Reader extension
# Reader extension and plugin
extension=OpenFOAM
requirePV=1
plugin=PVFoamReader
# Parse options
while [ "$#" -gt 0 ]
@ -81,11 +81,12 @@ do
;;
-block | -blockMesh)
extension=blockMesh
plugin=PVblockMeshReader
shift
;;
-builtin)
-builtin | -vtk)
extension=foam
requirePV=0
unset plugin
shift
;;
-case)
@ -100,12 +101,12 @@ do
;;
-touch)
optTouch=true
requirePV=0
unset plugin
shift
;;
-touchAll)
optTouch=all
requirePV=0
unset plugin
shift
;;
--)
@ -116,26 +117,34 @@ do
break # Stop here, treat this and balance as paraview options
;;
*)
usage "unknown option/argument: '$*'"
usage "unknown option/argument: '$1'"
;;
esac
done
# Check that reader module has been built
if [ $requirePV -eq 1 -a ! -f $PV_PLUGIN_PATH/libPVFoamReader_SM.so ]
then
cat<< BUILDREADER
FATAL ERROR: ParaView reader module libraries do not exist
# If a reader module is needed, check that it exists
[ -z "$plugin" -o -f $PV_PLUGIN_PATH/lib${plugin}_SM.so ] || {
cat<< BUILDREADER 1>&2
ERROR: ParaView reader module library ($plugin) does not exist
Please build the reader module before continuing:
cd \$FOAM_UTILITIES/postProcessing/graphics/PVReaders
./Allwclean
./Allwmake
cd \$FOAM_UTILITIES/postProcessing/graphics/PVReaders
./Allwclean
./Allwmake
BUILDREADER
exit 1
fi
# Fallback to native reader, if possible
if [ "$extension" = OpenFOAM ]
then
extension=foam
echo "Using the native VTK/OpenFOAM reader instead" 1>&2
else
exit 1
fi
}
# Check for --data=... argument
hasDataArg()
@ -165,7 +174,7 @@ if [ -n "$regionName" ]
then
if [ ! -d constant/$regionName ]
then
echo "FATAL ERROR: Region $regionName does not exist"
echo "FATAL ERROR: Region $regionName does not exist" 1>&2
exit 1
else
caseFile="$caseName{$regionName}.$extension"
@ -179,10 +188,10 @@ all)
if [ -f system/blockMeshDict -o -f constant/polyMesh/blockMeshDict ]
then
touch "$caseName.blockMesh"
echo "Created '$caseName.blockMesh'"
echo "Created '$caseName.blockMesh'" 1>&2
fi
touch "$caseName.$extension"
echo "Created '$caseName.$extension'"
echo "Created '$caseName.$extension'" 1>&2
# Discover probable regions
for region in constant/*
do
@ -190,14 +199,14 @@ all)
then
regionName=${region##*/}
touch "$caseName{$regionName}.$extension"
echo "Created '$caseName{$regionName}.$extension'"
echo "Created '$caseName{$regionName}.$extension'" 1>&2
fi
done
exit 0
;;
true)
touch "$caseFile"
echo "Created '$caseFile'"
echo "Created '$caseFile'" 1>&2
exit 0
;;
esac
@ -222,14 +231,14 @@ else
warn="WARN file does not exist:"
case $extension in
blockMesh)
blockMeshDictDir=system/blockMeshDict
blockMeshDict=system/blockMeshDict
if [ -f constant/polyMesh/blockMeshDict ]
then
blockMeshDictDir=constant/polyMesh/blockMeshDict
blockMeshDict=constant/polyMesh/blockMeshDict
fi
for check in \
system/controlDict \
$blockMeshDictDir \
$blockMeshDict \
;
do
[ -s "$parentDir/$check" ] || {
@ -240,7 +249,7 @@ else
done
;;
builtin | OpenFOAM)
OpenFOAM)
for check in \
system/controlDict \
$fvControls/fvSchemes \
@ -268,7 +277,7 @@ else
[ -e $caseFile ] || {
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch "$caseFile"
echo "Created temporary '$caseFile'"
echo "Created temporary '$caseFile'" 1>&2
}
# For now filter out any ld.so errors. Caused by non-system compiler?

View File

@ -208,7 +208,7 @@ unsetenv GMP_ARCH_PATH MPFR_ARCH_PATH
# Location of compiler installation
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ( ! $?WM_COMPILER_TYPE ) then
set WM_COMPILER_TYPE=system
setenv WM_COMPILER_TYPE system
echo "Warning in $WM_PROJECT_DIR/etc/config.csh/settings:"
echo " WM_COMPILER_TYPE not set, using '$WM_COMPILER_TYPE'"
endif

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -38,6 +38,8 @@ Description
#include "timer.H"
#include "IFstream.H"
#include "DynamicList.H"
#include "CStringList.H"
#include "SubList.H"
#include <fstream>
#include <cstdlib>
@ -49,6 +51,7 @@ Description
#include <pwd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netdb.h>
@ -593,9 +596,9 @@ bool Foam::chMod(const fileName& name, const mode_t m)
}
mode_t Foam::mode(const fileName& name)
mode_t Foam::mode(const fileName& name, const bool followLink)
{
fileStat fileStatus(name);
fileStat fileStatus(name, followLink);
if (fileStatus.isValid())
{
return fileStatus.status().st_mode;
@ -607,14 +610,18 @@ mode_t Foam::mode(const fileName& name)
}
Foam::fileName::Type Foam::type(const fileName& name)
Foam::fileName::Type Foam::type(const fileName& name, const bool followLink)
{
mode_t m = mode(name);
mode_t m = mode(name, followLink);
if (S_ISREG(m))
{
return fileName::FILE;
}
else if (S_ISLNK(m))
{
return fileName::LINK;
}
else if (S_ISDIR(m))
{
return fileName::DIRECTORY;
@ -626,27 +633,39 @@ Foam::fileName::Type Foam::type(const fileName& name)
}
bool Foam::exists(const fileName& name, const bool checkGzip)
bool Foam::exists
(
const fileName& name,
const bool checkGzip,
const bool followLink
)
{
return mode(name) || isFile(name, checkGzip);
return mode(name, followLink) || isFile(name, checkGzip, followLink);
}
bool Foam::isDir(const fileName& name)
bool Foam::isDir(const fileName& name, const bool followLink)
{
return S_ISDIR(mode(name));
return S_ISDIR(mode(name, followLink));
}
bool Foam::isFile(const fileName& name, const bool checkGzip)
bool Foam::isFile
(
const fileName& name,
const bool checkGzip,
const bool followLink
)
{
return S_ISREG(mode(name)) || (checkGzip && S_ISREG(mode(name + ".gz")));
return
S_ISREG(mode(name, followLink))
|| (checkGzip && S_ISREG(mode(name + ".gz", followLink)));
}
off_t Foam::fileSize(const fileName& name)
off_t Foam::fileSize(const fileName& name, const bool followLink)
{
fileStat fileStatus(name);
fileStat fileStatus(name, followLink);
if (fileStatus.isValid())
{
return fileStatus.status().st_size;
@ -658,9 +677,9 @@ off_t Foam::fileSize(const fileName& name)
}
time_t Foam::lastModified(const fileName& name)
time_t Foam::lastModified(const fileName& name, const bool followLink)
{
fileStat fileStatus(name);
fileStat fileStatus(name, followLink);
if (fileStatus.isValid())
{
return fileStatus.status().st_mtime;
@ -676,7 +695,8 @@ Foam::fileNameList Foam::readDir
(
const fileName& directory,
const fileName::Type type,
const bool filtergz
const bool filtergz,
const bool followLink
)
{
// Initial filename list size
@ -717,10 +737,10 @@ Foam::fileNameList Foam::readDir
{
fileName fName(list->d_name);
// ignore files begining with ., i.e. '.', '..' and '.*'
// ignore files beginning with ., i.e. '.', '..' and '.*'
if (fName.size() && fName[0] != '.')
{
word fExt = fName.ext();
const word fExt = fName.ext();
if
(
@ -736,7 +756,7 @@ Foam::fileNameList Foam::readDir
)
)
{
if ((directory/fName).type() == type)
if ((directory/fName).type(followLink) == type)
{
if (nEntries >= dirEntries.size())
{
@ -766,7 +786,7 @@ Foam::fileNameList Foam::readDir
}
bool Foam::cp(const fileName& src, const fileName& dest)
bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
{
// Make sure source exists.
if (!exists(src))
@ -777,7 +797,8 @@ bool Foam::cp(const fileName& src, const fileName& dest)
fileName destFile(dest);
// Check type of source file.
if (src.type() == fileName::FILE)
const fileName::Type srcType = src.type(followLink);
if (srcType == fileName::FILE)
{
// If dest is a directory, create the destination file name.
if (destFile.type() == fileName::DIRECTORY)
@ -817,7 +838,23 @@ bool Foam::cp(const fileName& src, const fileName& dest)
return false;
}
}
else if (src.type() == fileName::DIRECTORY)
else if (srcType == fileName::LINK)
{
// If dest is a directory, create the destination file name.
if (destFile.type() == fileName::DIRECTORY)
{
destFile = destFile/src.name();
}
// Make sure the destination directory exists.
if (!isDir(destFile.path()) && !mkDir(destFile.path()))
{
return false;
}
ln(src, destFile);
}
else if (srcType == fileName::DIRECTORY)
{
// If dest is a directory, create the destination file name.
if (destFile.type() == fileName::DIRECTORY)
@ -832,7 +869,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
}
// Copy files
fileNameList contents = readDir(src, fileName::FILE, false);
fileNameList contents = readDir(src, fileName::FILE, false, followLink);
forAll(contents, i)
{
if (POSIX::debug)
@ -843,11 +880,17 @@ bool Foam::cp(const fileName& src, const fileName& dest)
}
// File to file.
cp(src/contents[i], destFile/contents[i]);
cp(src/contents[i], destFile/contents[i], followLink);
}
// Copy sub directories.
fileNameList subdirs = readDir(src, fileName::DIRECTORY);
fileNameList subdirs = readDir
(
src,
fileName::DIRECTORY,
false,
followLink
);
forAll(subdirs, i)
{
if (POSIX::debug)
@ -858,9 +901,13 @@ bool Foam::cp(const fileName& src, const fileName& dest)
}
// Dir to Dir.
cp(src/subdirs[i], destFile);
cp(src/subdirs[i], destFile, followLink);
}
}
else
{
return false;
}
return true;
}
@ -903,7 +950,7 @@ bool Foam::ln(const fileName& src, const fileName& dst)
}
bool Foam::mv(const fileName& src, const fileName& dst)
bool Foam::mv(const fileName& src, const fileName& dst, const bool followLink)
{
if (POSIX::debug)
{
@ -914,7 +961,7 @@ bool Foam::mv(const fileName& src, const fileName& dst)
if
(
dst.type() == fileName::DIRECTORY
&& src.type() != fileName::DIRECTORY
&& src.type(followLink) != fileName::DIRECTORY
)
{
const fileName dstName(dst/src.name());
@ -1016,7 +1063,7 @@ bool Foam::rmDir(const fileName& directory)
{
fileName path = directory/fName;
if (path.type() == fileName::DIRECTORY)
if (path.type(false) == fileName::DIRECTORY)
{
if (!rmDir(path))
{
@ -1166,9 +1213,153 @@ bool Foam::ping(const string& hostname, const label timeOut)
}
namespace Foam
{
//! \cond fileScope
static int waitpid(const pid_t pid)
{
// child status, return code from the exec etc.
int status = 0;
// in parent - blocking wait
// modest treatment of signals (in child)
// treat 'stopped' like exit (suspend/continue)
while (true)
{
pid_t wpid = ::waitpid(pid, &status, WUNTRACED);
if (wpid == -1)
{
FatalErrorInFunction
<< "some error occurred in child"
<< exit(FatalError);
break;
}
if (WIFEXITED(status))
{
// child exited, get its return status
return WEXITSTATUS(status);
}
if (WIFSIGNALED(status))
{
// child terminated by some signal
return WTERMSIG(status);
}
if (WIFSTOPPED(status))
{
// child stopped by some signal
return WSTOPSIG(status);
}
FatalErrorInFunction
<< "programming error, status from waitpid() not handled: "
<< status
<< exit(FatalError);
}
return -1; // should not happen
}
//! \endcond
}
int Foam::system(const std::string& command)
{
return ::system(command.c_str());
if (command.empty())
{
// Treat an empty command as a successful no-op.
// From 'man sh' POSIX (man sh):
// "If the command_string operand is an empty string,
// sh shall exit with a zero exit status."
return 0;
}
pid_t child_pid = ::vfork(); // NB: vfork, not fork!
if (child_pid == -1)
{
FatalErrorInFunction
<< "vfork() failed for system command " << command
<< exit(FatalError);
}
if (child_pid == 0)
{
// in child
// execl uses the current environ
(void) ::execl
(
"/bin/sh", // Path of the shell
"sh", // Command-name (name for the shell)
"-c", // Read commands from the command_string operand.
command.c_str(), // Command string
reinterpret_cast<char *>(0)
);
// obviously failed, since exec should not return at all
FatalErrorInFunction
<< "exec failed: " << command
<< exit(FatalError);
}
// in parent - blocking wait
return waitpid(child_pid);
}
int Foam::system(const Foam::UList<Foam::string>& command)
{
const int argc = command.size();
if (!argc)
{
// Treat an empty command as a successful no-op.
// For consistency with POSIX (man sh) behaviour for (sh -c command),
// which is what is mostly being replicated here.
return 0;
}
// NB: use vfork, not fork!
// vfork behaves more like a thread and avoids copy-on-write problems
// triggered by fork.
// The normal system() command has a fork buried in it that causes
// issues with infiniband and openmpi etc.
pid_t child_pid = ::vfork();
if (child_pid == -1)
{
FatalErrorInFunction
<< "vfork() failed for system command " << command[0]
<< exit(FatalError);
}
if (child_pid == 0)
{
// in child:
// Need command and arguments separately.
// args is a NULL-terminated list of c-strings
CStringList args(SubList<string>(command, 0));
if (argc > 1)
{
args.reset(SubList<string>(command, argc-1, 1));
}
// execvp uses the current environ
(void) ::execvp(command[0].c_str(), args.strings());
// obviously failed, since exec should not return at all
FatalErrorInFunction
<< "exec(" << command[0] << ", ...) failed"
<< exit(FatalError);
}
// in parent - blocking wait
return waitpid(child_pid);
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,6 +29,7 @@ License
#include <signal.h>
#include <unistd.h>
#include <sys/sysmacros.h>
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -38,7 +39,12 @@ Foam::fileStat::fileStat()
{}
Foam::fileStat::fileStat(const fileName& fName, const unsigned int maxTime)
Foam::fileStat::fileStat
(
const fileName& fName,
const bool followLink,
const unsigned int maxTime
)
{
// Work on volatile
volatile bool locIsValid = false;
@ -47,13 +53,13 @@ Foam::fileStat::fileStat(const fileName& fName, const unsigned int maxTime)
if (!timedOut(myTimer))
{
if (::stat(fName.c_str(), &status_) != 0)
if (followLink)
{
locIsValid = false;
locIsValid = (::stat(fName.c_str(), &status_) == 0);
}
else
{
locIsValid = true;
locIsValid = (::lstat(fName.c_str(), &status_) == 0);
}
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,7 +25,7 @@ Class
Foam::fileStat
Description
Wrapper for stat() system call.
Wrapper for stat() and lstat() system calls.
Warning
on Linux (an maybe on others) a stat() of an nfs mounted (remote)
@ -79,8 +79,21 @@ public:
//- Empty constructor
fileStat();
//- Construct from components
fileStat(const fileName& fName, const unsigned int maxTime=0);
//- Construct from components.
// \param fName \n
// The file name or directory name to stat.
//
// \param followLink \n
// If it is a link, get the status of the source file/directory.
//
// \param maxTime \n
// The timeout value.
fileStat
(
const fileName& fName,
const bool followLink = true,
const unsigned int maxTime = 0
);
//- Construct from Istream
fileStat(Istream&);
@ -96,7 +109,7 @@ public:
return status_;
}
//- Did constructor fail
//- Was file-stat successful?
bool isValid() const
{
return isValid_;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -2535,16 +2535,6 @@ Foam::labelBits Foam::indexedOctree<Type>::findNode
const node& nod = nodes_[nodeI];
if (debug)
{
if (!nod.bb_.contains(sample))
{
FatalErrorInFunction
<< "Cannot find " << sample << " in node " << nodeI
<< abort(FatalError);
}
}
direction octant = nod.bb_.subOctant(sample);
labelBits index = nod.subNodes_[octant];

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,6 +30,7 @@ License
#include "dlLibraryTable.H"
#include "PstreamReduceOps.H"
#include "OSspecific.H"
#include "Ostream.H"
#include "regIOobject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -42,6 +43,45 @@ namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
namespace Foam
{
//! \cond fileScope
static inline void writeEntryIfPresent
(
Ostream& os,
const dictionary& dict,
const word& key
)
{
// non-recursive like dictionary::found, but no pattern-match either
const entry* ptr = dict.lookupEntryPtr(key, false, false);
if (ptr)
{
os.writeKeyword(key)
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(ptr->stream()), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
}
//! \endcond
}
void Foam::codedBase::writeCodeDict(Ostream& os, const dictionary& dict)
{
writeEntryIfPresent(os, dict, "codeInclude");
writeEntryIfPresent(os, dict, "localCode");
writeEntryIfPresent(os, dict, "code");
writeEntryIfPresent(os, dict, "codeOptions");
writeEntryIfPresent(os, dict, "codeLibs");
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void* Foam::codedBase::loadLibrary
(
const fileName& libPath,
@ -165,8 +205,6 @@ void Foam::codedBase::unloadLibrary
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::codedBase::createLibrary
(
dynamicCode& dynCode,

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,6 +43,7 @@ namespace Foam
{
// Forward declaration of classes
class Ostream;
class dynamicCode;
class dynamicCodeContext;
class dlLibraryTable;
@ -83,14 +84,17 @@ class codedBase
void createLibrary(dynamicCode&, const dynamicCodeContext&) const;
//- Disallow default bitwise copy construct
codedBase(const codedBase&);
codedBase(const codedBase&) = delete;
//- Disallow default bitwise assignment
void operator=(const codedBase&);
void operator=(const codedBase&) = delete;
protected:
//- Write code-dictionary contents
static void writeCodeDict(Ostream&, const dictionary&);
//- Update library as required
void updateLibrary
(

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -493,10 +493,17 @@ bool Foam::dynamicCode::copyOrCreateFiles(const bool verbose) const
bool Foam::dynamicCode::wmakeLibso() const
{
const Foam::string wmakeCmd("wmake -s libso " + this->codePath());
Info<< "Invoking " << wmakeCmd << endl;
DynamicList<string> cmd(4);
cmd.append("wmake");
cmd.append("-s");
cmd.append("libso");
cmd.append(this->codePath());
if (Foam::system(wmakeCmd))
// NOTE: could also resolve wmake command explicitly
// cmd[0] = stringOps::expand("$WM_PROJECT_DIR/wmake/wmake");
Info<< "Invoking wmake libso " << this->codePath().c_str() << endl;
if (Foam::system(cmd))
{
return false;
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -115,7 +115,7 @@ bool Foam::regIOobject::read
}
// Send to my downstairs neighbours
forAll(myComm.below(), belowI)
forAllReverse(myComm.below(), belowI)
{
OPstream toBelow
(

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -331,55 +331,7 @@ void Foam::codedFixedValuePointPatchField<Type>::write(Ostream& os) const
os.writeKeyword("redirectType") << redirectType_
<< token::END_STATEMENT << nl;
if (dict_.found("codeInclude"))
{
os.writeKeyword("codeInclude")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["codeInclude"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
if (dict_.found("localCode"))
{
os.writeKeyword("localCode")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["localCode"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
if (dict_.found("code"))
{
os.writeKeyword("code")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["code"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
if (dict_.found("codeOptions"))
{
os.writeKeyword("codeOptions")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["codeOptions"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
if (dict_.found("codeLibs"))
{
os.writeKeyword("codeLibs")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["codeLibs"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
codedBase::writeCodeDict(os, dict_);
}

View File

@ -1170,7 +1170,7 @@ void Foam::argList::displayDoc(bool source) const
Info<< "Show documentation: " << docBrowser.c_str() << endl;
system(docBrowser);
Foam::system(docBrowser);
}
else
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,6 +37,7 @@ SourceFiles
#define OSspecific_H
#include "fileNameList.H"
#include "stringList.H"
#include <sys/types.h>
@ -132,44 +133,60 @@ bool mkDir(const fileName&, mode_t=0777);
bool chMod(const fileName&, const mode_t);
//- Return the file mode
mode_t mode(const fileName&);
mode_t mode(const fileName&, const bool followLink=true);
//- Return the file type: DIRECTORY or FILE
fileName::Type type(const fileName&);
fileName::Type type(const fileName&, const bool followLink=true);
//- Does the name exist (as DIRECTORY or FILE) in the file system?
// Optionally enable/disable check for gzip file.
bool exists(const fileName&, const bool checkGzip=true);
bool exists
(
const fileName&,
const bool checkGzip=true,
const bool followLink=true
);
//- Does the name exist as a DIRECTORY in the file system?
bool isDir(const fileName&);
bool isDir(const fileName&, const bool followLink=true);
//- Does the name exist as a FILE in the file system?
// Optionally enable/disable check for gzip file.
bool isFile(const fileName&, const bool checkGzip=true);
bool isFile
(
const fileName&,
const bool checkGzip=true,
const bool followLink=true
);
//- Return size of file
off_t fileSize(const fileName&);
off_t fileSize(const fileName&, const bool followLink=true);
//- Return time of last file modification
time_t lastModified(const fileName&);
time_t lastModified(const fileName&, const bool followLink=true);
//- Read a directory and return the entries as a string list
fileNameList readDir
(
const fileName&,
const fileName::Type=fileName::FILE,
const bool filtergz=true
const bool filtergz=true,
const bool followLink=true
);
//- Copy, recursively if necessary, the source to the destination
bool cp(const fileName& src, const fileName& dst);
bool cp(const fileName& src, const fileName& dst, const bool followLink=true);
//- Create a softlink. dst should not exist. Returns true if successful.
bool ln(const fileName& src, const fileName& dst);
//- Rename src to dst
bool mv(const fileName& src, const fileName& dst);
bool mv
(
const fileName& src,
const fileName& dst,
const bool followLink=false
);
//- Rename to a corresponding backup file
// If the backup file already exists, attempt with "01" .. "99" suffix
@ -193,9 +210,15 @@ bool ping(const string&, const label port, const label timeOut);
//- Check if machine is up by pinging port 22 (ssh) and 222 (rsh)
bool ping(const string&, const label timeOut=10);
//- Execute the specified command
//- Execute the specified command via the shell.
// Uses vfork/execl internally.
// Where possible, use the list version instead.
int system(const std::string& command);
//- Execute the specified command with arguments.
// Uses vfork/execvp internally
int system(const UList<string>& command);
//- Open a shared library. Return handle to library. Print error message
// if library cannot be loaded (check = true)
void* dlOpen(const fileName& lib, const bool check = true);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1130,6 +1130,21 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
geometricD_ = Zero;
solutionD_ = Zero;
// Reset cell tree - it gets built from mesh geometry so might have
// wrong boxes. It is correct as long as none of the cells leaves
// the boxes it is in which most likely is almost never the case except
// for tiny displacements. An alternative is to check the displacements
// to see if they are tiny - imagine a big windtunnel with a small rotating
// object. In this case the processors without the rotating object wouldn't
// have to clear any geometry. However your critical path still stays the
// same so no time would be gained (unless the decomposition gets weighted).
// Small benefit for lots of scope for problems so not done.
cellTreePtr_.clear();
// Note: tet-base decomposition does not get cleared. Ideally your face
// decomposition should not change during mesh motion ...
meshObject::movePoints<polyMesh>(*this);
meshObject::movePoints<pointMesh>(*this);

View File

@ -118,6 +118,12 @@ Foam::genericPolyPatch::~genericPolyPatch()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::word& Foam::genericPolyPatch::actualType() const
{
return actualTypeName_;
}
void Foam::genericPolyPatch::write(Ostream& os) const
{
os.writeKeyword("type") << actualTypeName_ << token::END_STATEMENT << nl;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,8 +25,9 @@ Class
Foam::genericPolyPatch
Description
Substitute for unknown patches. Used for postprocessing when only
basic polyPatch info is needed.
Substitute for unknown patches.
Used for postprocessing when only basic polyPatch info is needed
or if the real patch type is unavailable.
Note
Storage is not optimal. It stores all face centres and cells on all
@ -57,7 +58,7 @@ class genericPolyPatch
{
// Private data
word actualTypeName_;
const word actualTypeName_;
dictionary dict_;
public:
@ -162,6 +163,9 @@ public:
// Member functions
//- Return the actual type
const word& actualType() const;
//- Write the polyPatch data as a dictionary
virtual void write(Ostream&) const;
};

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -48,9 +48,9 @@ Foam::fileName::fileName(const wordList& lst)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName::Type Foam::fileName::type() const
Foam::fileName::Type Foam::fileName::type(const bool followLink) const
{
return ::Foam::type(*this);
return ::Foam::type(*this, followLink);
}
@ -94,6 +94,7 @@ bool Foam::fileName::clean()
(
string::size_type src = nChar;
src < maxLen;
/*nil*/
)
{
char c = operator[](src++);

View File

@ -154,8 +154,9 @@ public:
// Interrogation
//- Return the file type: FILE, DIRECTORY or UNDEFINED
Type type() const;
//- Return the file type: FILE, DIRECTORY, UNDEFINED or
// LINK (only if followLink=false)
Type type(const bool followLink = true) const;
//- Return true if file name is absolute
bool isAbsolute() const;

View File

@ -0,0 +1,175 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::CStringList
Description
An adapter for copying a list of C++ strings into a list of C-style
strings for passing to C code that expects argc/argv parameters.
In addition to providing a C-compatible list of C-strings,
the string lists are flattened into a single string of data that can be
also be passed en mass.
Example use:
\code
wordList myStrings; ...
CStringList cstr(myStrings);
// pass as argc, argv:
someMain(cstr.size(), cstr.strings());
// access the raw characters:
os.write(cstr.data(), cstr.length());
\endcode
\*---------------------------------------------------------------------------*/
#ifndef CStringList_H
#define CStringList_H
#include "fileNameList.H"
#include "stringList.H"
#include "wordList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class CStringList Declaration
\*---------------------------------------------------------------------------*/
class CStringList
{
// Private data
//- Number of strings
int argc_;
//- Overall length of the raw content
// Does not include the final nul-character
size_t len_;
//- List of strings, including trailing NULL pointer
char** argv_;
//- Flattened content with interspersed nul-characters
char* data_;
// Private Member Functions
//- Disallow default bitwise copy construct
CStringList(const CStringList&) = delete;
//- Disallow default bitwise assignment
void operator=(const CStringList&) = delete;
public:
// Constructors
//- Construct empty, adding content later (via reset).
inline CStringList();
//- Construct from a list of strings
// Copies the input characters.
template<class StringType>
CStringList(const UList<StringType>& input);
//- Destructor
inline ~CStringList();
// Public Members
//- Count the number of parameters until the first NULL pointer.
// Return 0 if argv is NULL.
static inline int count(const char * const argv[]);
// Access
//- Return the number of C-strings (ie, argc)
inline int size() const;
//- Return the list of C-strings (ie, argv)
// The position at argc is a NULL pointer
inline char** strings() const;
//- Overall length of the flattened character (data) content
inline size_t length() const;
//- The flattened character content, with interspersed nul-chars
inline char* data() const;
// Edit
//- Clear contents and free memory
inline void clear();
//- Copy the input list of strings.
template<class StringType>
void reset(const UList<StringType>& input);
// Other
//- Create a list from argc/argv parameters.
// A null pointer for argv is permissible when argc is zero.
template<class StringType>
static List<StringType> asList(int argc, const char * const argv[]);
//- Create a list from a NULL-terminated list of argv parameters.
// A null pointer for argv is permissible.
template<class StringType>
static inline List<StringType> asList(const char * const argv[]);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "CStringListI.H"
#ifdef NoRepository
# include "CStringListTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,106 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
inline int Foam::CStringList::count(const char * const argv[])
{
int nElem = 0;
if (argv)
{
while (argv[nElem])
{
++nElem;
}
}
return nElem;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::CStringList::CStringList()
:
argc_(0),
len_(0),
argv_(0),
data_(0)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
inline Foam::CStringList::~CStringList()
{
clear();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline void Foam::CStringList::clear()
{
argc_ = 0;
len_ = 0;
if (data_)
{
delete[] data_;
data_ = 0;
}
if (argv_)
{
delete[] argv_;
argv_ = 0;
}
}
inline int Foam::CStringList::size() const
{
return argc_;
}
inline size_t Foam::CStringList::length() const
{
return len_;
}
inline char** Foam::CStringList::strings() const
{
return argv_;
}
inline char* Foam::CStringList::data() const
{
return data_;
}
// ************************************************************************* //

View File

@ -0,0 +1,115 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class StringType>
Foam::CStringList::CStringList
(
const UList<StringType>& input
)
:
argc_(0),
len_(0),
argv_(0),
data_(0)
{
reset(input);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class StringType>
void Foam::CStringList::reset
(
const UList<StringType>& input
)
{
clear();
argc_ = input.size();
forAll(input, argI)
{
len_ += input[argI].size();
++len_; // nul terminator for C-strings
}
argv_ = new char*[argc_+1];
argv_[argc_] = NULL; // extra terminator
if (argc_ > 0)
{
// allocation includes final nul terminator,
// but overall count does not
data_ = new char[len_--];
char* ptr = data_;
forAll(input, argI)
{
argv_[argI] = ptr;
const std::string& str =
static_cast<const std::string&>(input[argI]);
for
(
std::string::const_iterator iter = str.begin();
iter != str.end();
++iter
)
{
*(ptr++) = *iter;
}
*(ptr++) = '\0';
}
}
}
template<class StringType>
Foam::List<StringType>
Foam::CStringList::asList(int argc, const char * const argv[])
{
List<StringType> lst(argc);
for (int i=0; i < argc; ++i)
{
lst[i] = argv[i];
}
return lst;
}
template<class StringType>
Foam::List<StringType>
Foam::CStringList::asList(const char * const argv[])
{
return asList<StringType>(count(argv), argv);
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -329,55 +329,7 @@ void Foam::codedFixedValueFvPatchField<Type>::write(Ostream& os) const
os.writeKeyword("redirectType") << redirectType_
<< token::END_STATEMENT << nl;
if (dict_.found("codeInclude"))
{
os.writeKeyword("codeInclude")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["codeInclude"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
if (dict_.found("localCode"))
{
os.writeKeyword("localCode")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["localCode"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
if (dict_.found("code"))
{
os.writeKeyword("code")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["code"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
if (dict_.found("codeOptions"))
{
os.writeKeyword("codeOptions")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["codeOptions"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
if (dict_.found("codeLibs"))
{
os.writeKeyword("codeLibs")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["codeLibs"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
codedBase::writeCodeDict(os, dict_);
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -341,55 +341,7 @@ void Foam::codedMixedFvPatchField<Type>::write(Ostream& os) const
os.writeKeyword("redirectType") << redirectType_
<< token::END_STATEMENT << nl;
if (dict_.found("codeInclude"))
{
os.writeKeyword("codeInclude")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["codeInclude"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
if (dict_.found("localCode"))
{
os.writeKeyword("localCode")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["localCode"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
if (dict_.found("code"))
{
os.writeKeyword("code")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["code"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
if (dict_.found("codeOptions"))
{
os.writeKeyword("codeOptions")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["codeOptions"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
if (dict_.found("codeLibs"))
{
os.writeKeyword("codeLibs")
<< token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(string(dict_["codeLibs"]), false)
<< token::HASH << token::END_BLOCK
<< token::END_STATEMENT << nl;
}
codedBase::writeCodeDict(os, dict_);
}

View File

@ -55,10 +55,11 @@ Description
jumpTable csvFile;
csvFileCoeffs
{
hasHeaderLine 1;
nHeaderLine 1;
refColumn 0;
componentColumns 1(1);
separator ",";
mergeSeparators no;
fileName "$FOAM_CASE/constant/pressureVsU";
}
value uniform 0;
@ -69,7 +70,7 @@ Description
the jump condition.
Note
The underlying \c patchType should be set to \c cyclic
The underlying \c patchType should be set to \c cyclic
SeeAlso
Foam::Function1Types

View File

@ -848,7 +848,7 @@ turbulentDFSEMInletFvPatchVectorField
eddy::debug = debug;
// Set UMean as patch area average value
UMean_ = gSum(U_*patch().magSf())/gSum(patch().magSf());
UMean_ = gSum(U_*patch().magSf())/(gSum(patch().magSf()) + ROOTVSMALL);
}

View File

@ -764,6 +764,13 @@ Foam::genericFvPatchField<Type>::gradientBoundaryCoeffs() const
}
template<class Type>
const Foam::word& Foam::genericFvPatchField<Type>::actualType() const
{
return actualTypeName_;
}
template<class Type>
void Foam::genericFvPatchField<Type>::write(Ostream& os) const
{

View File

@ -59,7 +59,7 @@ class genericFvPatchField
{
// Private data
word actualTypeName_;
const word actualTypeName_;
dictionary dict_;
HashPtrTable<scalarField> scalarFields_;
@ -179,6 +179,9 @@ public:
tmp<Field<Type>> gradientBoundaryCoeffs() const;
//- Return the actual type
const word& actualType() const;
//- Write
virtual void write(Ostream&) const;
};

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -557,6 +557,13 @@ void Foam::genericPointPatchField<Type>::rmap
}
template<class Type>
const Foam::word& Foam::genericPointPatchField<Type>::actualType() const
{
return actualTypeName_;
}
template<class Type>
void Foam::genericPointPatchField<Type>::write(Ostream& os) const
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -55,7 +55,7 @@ class genericPointPatchField
{
// Private data
word actualTypeName_;
const word actualTypeName_;
dictionary dict_;
HashPtrTable<scalarField> scalarFields_;
@ -151,6 +151,9 @@ public:
);
//- Return the actual type
const word& actualType() const;
//- Write
virtual void write(Ostream&) const;
};

View File

@ -25,12 +25,17 @@ Class
Foam::EulerCoordinateRotation
Description
A coordinateRotation defined in the z-x-y Euler convention.
A coordinateRotation defined in the z-x-z (intrinsic) Euler convention.
The 3 rotations are defined in the Euler intrinsic convention
(around Z, around X' and around Z'').
The order of the parameter arguments matches this rotation order.
The 3 rotations are defined in the Euler convention
(around Z, around X' and around Z').
For reference and illustration, see
http://mathworld.wolfram.com/EulerAngles.html
and
https://en.wikipedia.org/wiki/Euler_angles#Conventions
Note, however, that it is the reverse transformation
(local->global) that is defined here.

View File

@ -43,6 +43,7 @@ License
#include "vtkSphereSource.h"
#include "vtkTextActor.h"
#include "vtkTextProperty.h"
#include "vtkCellDataToPointData.h"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -151,6 +152,9 @@ void Foam::fieldVisualisationBase::addScalarBar
const vector textColour = colours_["text"]->value(position);
// Work-around to supply our own scalarbar title
// - Default scalar bar title text is scales by the scalar bar box
// dimensions so if the title is a long string, the text is shrunk to fit
// Instead, suppress title and set the title using a vtkTextActor
vtkSmartPointer<vtkTextActor> titleActor =
vtkSmartPointer<vtkTextActor>::New();
sbar->SetTitle(" ");
@ -170,19 +174,18 @@ void Foam::fieldVisualisationBase::addScalarBar
titleActor->GetPositionCoordinate()->
SetCoordinateSystemToNormalizedViewport();
/*
sbar->SetTitle(scalarBar_.title_.c_str());
sbar->GetTitleTextProperty()->SetColor
(
textColour[0],
textColour[1],
textColour[2]
);
sbar->GetTitleTextProperty()->SetFontSize(scalarBar_.fontSize_);
sbar->GetTitleTextProperty()->ShadowOff();
sbar->GetTitleTextProperty()->BoldOn();
sbar->GetTitleTextProperty()->ItalicOff();
*/
// How to use the standard scalar bar text
// sbar->SetTitle(scalarBar_.title_.c_str());
// sbar->GetTitleTextProperty()->SetColor
// (
// textColour[0],
// textColour[1],
// textColour[2]
// );
// sbar->GetTitleTextProperty()->SetFontSize(scalarBar_.fontSize_);
// sbar->GetTitleTextProperty()->ShadowOff();
// sbar->GetTitleTextProperty()->BoldOn();
// sbar->GetTitleTextProperty()->ItalicOff();
sbar->GetLabelTextProperty()->SetColor
(
@ -217,8 +220,8 @@ void Foam::fieldVisualisationBase::addScalarBar
sbar->SetWidth(0.75);
sbar->SetHeight(0.07);
sbar->SetBarRatio(0.5);
// sbar->SetHeight(0.1);
// sbar->SetTitleRatio(0.01);
// sbar->SetHeight(0.1);
// sbar->SetTitleRatio(0.01);
sbar->SetTextPositionToPrecedeScalarBar();
}
@ -228,10 +231,10 @@ void Foam::fieldVisualisationBase::addScalarBar
scalarBar_.position_.second() + sbar->GetHeight()
);
// sbar->DrawFrameOn();
// sbar->DrawBackgroundOn();
// sbar->UseOpacityOff();
// sbar->VisibilityOff();
// sbar->DrawFrameOn();
// sbar->DrawBackgroundOn();
// sbar->UseOpacityOff();
// sbar->VisibilityOff();
sbar->VisibilityOn();
renderer->AddActor(sbar);
@ -268,25 +271,7 @@ void Foam::fieldVisualisationBase::setField
// Configure the mapper
mapper->SelectColorArray(colourFieldName.c_str());
mapper->SetScalarRange(range_.first(), range_.second());
// Set to use either cell or point data
const char* fieldName = colourFieldName.c_str();
if (pData->GetCellData()->HasArray(fieldName) == 1)
{
mapper->SetScalarModeToUseCellFieldData();
}
else if (pData->GetPointData()->HasArray(fieldName) == 1)
{
mapper->SetScalarModeToUsePointFieldData();
}
else
{
WarningInFunction
<< "Unable to determine cell or point data type "
<< "- assuming point data";
mapper->SetScalarModeToUsePointFieldData();
}
mapper->SetScalarModeToDefault(); // try points, then cells
mapper->SetColorModeToMapScalars();
mapper->SetLookupTable(lut);
mapper->ScalarVisibilityOn();
@ -322,9 +307,37 @@ void Foam::fieldVisualisationBase::addGlyphs
glyph->ScalingOn();
bool ok = true;
label nComponents =
data->GetPointData()->GetArray(scaleFieldName.c_str())
->GetNumberOfComponents();
// Determine whether we have scalar or vector data
label nComponents = -1;
const char* scaleFieldNameChar = scaleFieldName.c_str();
if (data->GetPointData()->HasArray(scaleFieldNameChar) == 1)
{
nComponents =
data->GetPointData()->GetArray(scaleFieldNameChar)
->GetNumberOfComponents();
}
else if (data->GetCellData()->HasArray(scaleFieldNameChar) == 1)
{
// Need to convert cell data to point data
vtkSmartPointer<vtkCellDataToPointData> cellToPoint =
vtkSmartPointer<vtkCellDataToPointData>::New();
cellToPoint->SetInputData(data);
cellToPoint->Update();
vtkDataSet* pds = cellToPoint->GetOutput();
vtkDataArray* pData = pds->GetPointData()->GetArray(scaleFieldNameChar);
// Store in main vtkPolyData
data->GetPointData()->AddArray(pData);
nComponents = pData->GetNumberOfComponents();
}
else
{
WarningInFunction
<< "Glyphs can only be added to scalar or vector data. "
<< "Unable to process field " << scaleFieldName << endl;
return;
}
if (nComponents == 1)
{
@ -332,9 +345,10 @@ void Foam::fieldVisualisationBase::addGlyphs
vtkSmartPointer<vtkSphereSource>::New();
sphere->SetCenter(0, 0, 0);
sphere->SetRadius(0.5);
// Setting higher resolution slows the rendering significantly
// sphere->SetPhiResolution(20);
// sphere->SetThetaResolution(20);
// Setting higher resolution slows the rendering significantly
// sphere->SetPhiResolution(20);
// sphere->SetThetaResolution(20);
glyph->SetSourceConnection(sphere->GetOutputPort());
@ -342,18 +356,18 @@ void Foam::fieldVisualisationBase::addGlyphs
{
double range[2];
// Can use values to find range
// vtkDataArray* values =
// data->GetPointData()->GetScalars(scaleFieldName.c_str());
// values->GetRange(range);
// Can use values to find range
// vtkDataArray* values =
// data->GetPointData()->GetScalars(scaleFieldNameChar);
// values->GetRange(range);
// set range accoding to user-supplied limits
// Set range accoding to user-supplied limits
range[0] = range_.first();
range[1] = range_.second();
glyph->ClampingOn();
glyph->SetRange(range);
// if range[0] != min(value), maxGlyphLength behaviour will not
// If range[0] != min(value), maxGlyphLength behaviour will not
// be correct...
glyph->SetScaleFactor(maxGlyphLength);
}
@ -370,7 +384,7 @@ void Foam::fieldVisualisationBase::addGlyphs
0,
0,
vtkDataObject::FIELD_ASSOCIATION_POINTS,
scaleFieldName.c_str()
scaleFieldNameChar
);
}
else if (nComponents == 3)
@ -388,21 +402,21 @@ void Foam::fieldVisualisationBase::addGlyphs
if (maxGlyphLength > 0)
{
vtkDataArray* values =
data->GetPointData()->GetVectors(scaleFieldName.c_str());
data->GetPointData()->GetVectors(scaleFieldNameChar);
double range[6];
values->GetRange(range);
/*
// Attempt to set range for vectors...
scalar x0 = sqrt(sqr(range_.first())/3.0);
scalar x1 = sqrt(sqr(range_.second())/3.0);
range[0] = x0;
range[1] = x0;
range[2] = x0;
range[3] = x1;
range[4] = x1;
range[5] = x1;
*/
// scalar x0 = sqrt(sqr(range_.first())/3.0);
// scalar x1 = sqrt(sqr(range_.second())/3.0);
// range[0] = x0;
// range[1] = x0;
// range[2] = x0;
// range[3] = x1;
// range[4] = x1;
// range[5] = x1;
glyph->ClampingOn();
glyph->SetRange(range);
glyph->SetScaleFactor(maxGlyphLength);
@ -421,7 +435,7 @@ void Foam::fieldVisualisationBase::addGlyphs
0,
0,
vtkDataObject::FIELD_ASSOCIATION_POINTS,
scaleFieldName.c_str()
scaleFieldNameChar
);
}
else

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -770,7 +770,7 @@ void Foam::externalCoupledFunctionObject::initialise()
// Wait for initial data to be made available
wait();
// Eead data passed back from external source
// Read data passed back from external source
readData();
}

View File

@ -62,14 +62,15 @@ functions
// called at the end of the run
endCalls
(
"echo \*\*\* writing .bashrc \*\*\*"
"cat ~/.bashrc"
"echo \*\*\* done \*\*\*"
// Note: single quotes to avoid shell expansion
"echo '*** listing ~/.bashrc ***'"
"cat ~/.bashrc; echo '*** done ***'"
);
// called every ouput time
// called every output time
writeCalls
(
// Note: can also backslash to escape shell meta-characters
"echo \*\*\* writing data \*\*\*"
);
}

View File

@ -122,6 +122,13 @@ class mapFieldsFO
//- Helper function to create the mesh-to-mesh interpolation
void createInterpolation(const dictionary& dict);
//- Helper function to evaluate constraint patches after mapping
template<class Type>
void evaluateConstraintTypes
(
GeometricField<Type, fvPatchField, volMesh>& fld
) const;
//- Helper function to interpolate and write the fied
template<class Type>
bool writeFieldType() const;

View File

@ -25,6 +25,91 @@ License
#include "meshToMesh.H"
template<class Type>
void Foam::mapFieldsFO::evaluateConstraintTypes
(
GeometricField<Type, fvPatchField, volMesh>& fld
) const
{
typename GeometricField<Type, fvPatchField, volMesh>::
GeometricBoundaryField& fldBf = fld.boundaryField();
if
(
Pstream::defaultCommsType == Pstream::blocking
|| Pstream::defaultCommsType == Pstream::nonBlocking
)
{
label nReq = Pstream::nRequests();
forAll(fldBf, patchi)
{
fvPatchField<Type>& tgtField = fldBf[patchi];
if
(
tgtField.type() == tgtField.patch().patch().type()
&& polyPatch::constraintType(tgtField.patch().patch().type())
)
{
tgtField.initEvaluate(Pstream::defaultCommsType);
}
}
// Block for any outstanding requests
if
(
Pstream::parRun()
&& Pstream::defaultCommsType == Pstream::nonBlocking
)
{
Pstream::waitRequests(nReq);
}
forAll(fldBf, patchi)
{
fvPatchField<Type>& tgtField = fldBf[patchi];
if
(
tgtField.type() == tgtField.patch().patch().type()
&& polyPatch::constraintType(tgtField.patch().patch().type())
)
{
tgtField.evaluate(Pstream::defaultCommsType);
}
}
}
else if (Pstream::defaultCommsType == Pstream::scheduled)
{
const lduSchedule& patchSchedule =
fld.mesh().globalData().patchSchedule();
forAll(patchSchedule, patchEvali)
{
label patchi = patchSchedule[patchEvali].patch;
fvPatchField<Type>& tgtField = fldBf[patchi];
if
(
tgtField.type() == tgtField.patch().patch().type()
&& polyPatch::constraintType(tgtField.patch().patch().type())
)
{
if (patchSchedule[patchEvali].init)
{
tgtField.initEvaluate(Pstream::scheduled);
}
else
{
tgtField.evaluate(Pstream::scheduled);
}
}
}
}
}
template<class Type>
bool Foam::mapFieldsFO::writeFieldType() const
{
@ -53,6 +138,9 @@ bool Foam::mapFieldsFO::writeFieldType() const
if (log_) Info<< ": interpolated";
FieldType fieldMapRegion(mapRegionIO, tfieldMapRegion);
evaluateConstraintTypes(fieldMapRegion);
fieldMapRegion.write();
if (log_) Info<< " and written" << nl;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -62,9 +62,15 @@ void Foam::faceShading::writeRays
vertI++;
str << "l " << vertI-1 << ' ' << vertI << nl;
}
string cmd("objToVTK " + fName + " " + fName.lessExt() + ".vtk");
Pout<< "cmd:" << cmd << endl;
system(cmd);
str.flush();
DynamicList<string> cmd(3);
cmd.append("objToVTK");
cmd.append(fName);
cmd.append(fName.lessExt() + ".vtk");
Pout<< "cmd: objToVTK " << fName.c_str() << endl;
Foam::system(cmd);
}

View File

@ -1,4 +1,5 @@
#-------------------------------*- makefile -*---------------------------------
WM_VERSION = OPENFOAM_PLUS=1606
AR = ar
ARFLAGS = cr
@ -6,7 +7,7 @@ RANLIB = ranlib
CPP = cpp
LD = ld
GFLAGS = -D$(WM_ARCH) -DWM_ARCH_OPTION=$(WM_ARCH_OPTION) \
GFLAGS = -D$(WM_VERSION) -D$(WM_ARCH) -DWM_ARCH_OPTION=$(WM_ARCH_OPTION) \
-DWM_$(WM_PRECISION_OPTION) -DWM_LABEL_SIZE=$(WM_LABEL_SIZE)
GINC =
GLIBS = -lm

View File

@ -3,8 +3,8 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
# \\/ M anipulation |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
@ -72,7 +72,6 @@ do
;;
-c | -check)
checkOnly=true
shift
;;
-major)
echo ${WM_PROJECT_VERSION:-unknown}
@ -80,27 +79,26 @@ do
;;
-u | -update)
update=true
shift
;;
-pkg | -package)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
# Mark empty as 'none', disallow '!' in string
package=$(echo "${2:-none}" | sed -e 's/!//g')
shift 2
shift
;;
-short)
shortOpt=true
shift
;;
-v | -version)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
version="$2"
shift 2
shift
;;
*)
usage "unknown option/argument: '$*'"
usage "unknown option/argument: '$1'"
;;
esac
shift
done
#------------------------------------------------------------------------------
@ -146,12 +144,12 @@ then
# Specified a version - no error possible
rc=0
else
# Get the head SHA1 when building under git
# if there are multiple values (eg, HEAD, origin/HEAD, ...)
# Get the head SHA1 (first 12 chars) when building under git.
# If there are multiple values (eg, HEAD, origin/HEAD, ...)
# only take the first one, which is 'HEAD'
version=$(
cd $WM_PROJECT_DIR 2>/dev/null && \
git show-ref --hash=12 --head HEAD 2>/dev/null | head -1
git --git-dir=$WM_PROJECT_DIR/.git show-ref --head HEAD 2>/dev/null |\
sed -ne '1s@^\(.\{12\}\).*$@\1@p'
)
if [ -n "$version" ]
@ -205,10 +203,11 @@ then
else
echo "version changed from previous build" 1>&2
fi
exit $rc
else
echo "no git description found" 1>&2
exit 0
fi
exit $rc
fi