ENH: avoid deprecated resource xml when building paraview plugins (fixes #181)

- remove old VTK_CONVEX_POINT_SET code, since VTK_POLYHEDRON exists
  since several years

ENH: improve robustness of paraFoam script

- only check the relevant plugin types,
  fallback to native reader if needed/possible.
This commit is contained in:
Mark Olesen 2016-07-12 11:17:57 +02:00
parent a9fed233db
commit ecfbdce3da
7 changed files with 65 additions and 82 deletions

View File

@ -47,11 +47,14 @@ QT4_WRAP_CPP(MOC_SRCS pqPVFoamReaderPanel.h)
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
CLASS_NAME pqPVFoamReaderPanel CLASS_NAME pqPVFoamReaderPanel
XML_NAME PVFoamReader # name of SourceProxy in *SM.xml XML_NAME PVFoamReader # name of SourceProxy in *SM.xml
XML_GROUP sources 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( ADD_PARAVIEW_PLUGIN(
PVFoamReader_SM "1.0" PVFoamReader_SM "1.0"
SERVER_MANAGER_XML PVFoamReader_SM.xml SERVER_MANAGER_XML PVFoamReader_SM.xml
@ -61,7 +64,7 @@ IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS} ${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
GUI_RESOURCE_FILES PVFoamReader.xml GUI_RESOURCE_FILES PVFoamReader.xml
) )
ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0) ELSE()
ADD_PARAVIEW_PLUGIN( ADD_PARAVIEW_PLUGIN(
PVFoamReader_SM "1.0" PVFoamReader_SM "1.0"
SERVER_MANAGER_XML PVFoamReader_SM.xml SERVER_MANAGER_XML PVFoamReader_SM.xml
@ -70,7 +73,7 @@ ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
GUI_SOURCES pqPVFoamReaderPanel.cxx GUI_SOURCES pqPVFoamReaderPanel.cxx
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS} ${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
) )
ENDIF("${PARAVIEW_VERSION_MINOR}" EQUAL 0) ENDIF()
TARGET_LINK_LIBRARIES( TARGET_LINK_LIBRARIES(
PVFoamReader_SM PVFoamReader_SM

View File

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

View File

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

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.
@ -275,7 +275,6 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
// Polyhedral cell - use VTK_POLYHEDRON // Polyhedral cell - use VTK_POLYHEDRON
const labelList& cFaces = mesh.cells()[cellI]; const labelList& cFaces = mesh.cells()[cellI];
#ifdef HAS_VTK_POLYHEDRON
vtkIdType nFaces = cFaces.size(); vtkIdType nFaces = cFaces.size();
vtkIdType nLabels = nFaces; vtkIdType nLabels = nFaces;
@ -320,33 +319,6 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
} }
vtkmesh->InsertNextCell(VTK_POLYHEDRON, nFaces, faceStream.data()); 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 else
{ {

View File

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

View File

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

View File

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