diff --git a/src/functionObjects/Allwmake b/src/functionObjects/Allwmake index bcb29dea34..4a6d461b7f 100755 --- a/src/functionObjects/Allwmake +++ b/src/functionObjects/Allwmake @@ -11,8 +11,6 @@ wmake $targetType lagrangian wmake $targetType utilities wmake $targetType solvers -./graphics/Allwmake $targetType - ./randomProcesses/Allwmake $targetType #------------------------------------------------------------------------------ diff --git a/src/functionObjects/graphics/Allwmake b/src/functionObjects/graphics/Allwmake deleted file mode 100755 index 33fb4cf3f2..0000000000 --- a/src/functionObjects/graphics/Allwmake +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -cd "${0%/*}" || exit # Run from this directory -. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments - -#------------------------------------------------------------------------------ -if [ "$targetType" != "objects" ] -then - runTimePostProcessing/Allwmake $* -fi - -#------------------------------------------------------------------------------ diff --git a/src/functionObjects/graphics/runTimePostProcessing/Allwclean b/src/functionObjects/graphics/runTimePostProcessing/Allwclean deleted file mode 100755 index af1168f7f3..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/Allwclean +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -cd "${0%/*}" || exit # Run from this directory -. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions -#------------------------------------------------------------------------------ - -# This cleanup handles both cmake runTimePostProcessing and the dummy version - -# Cleanup library files with .so version endings -rm -f $FOAM_LIBBIN/librunTimePostProcessing* - -# Cleanup generated files - remove entire top-level -removeObjectDir "$PWD" - -#------------------------------------------------------------------------------ diff --git a/src/functionObjects/graphics/runTimePostProcessing/Allwmake b/src/functionObjects/graphics/runTimePostProcessing/Allwmake deleted file mode 100755 index b4451ae8b6..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/Allwmake +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -cd "${0%/*}" || exit # Run from this directory -. ${WM_PROJECT_DIR:?}/wmake/scripts/cmakeFunctions # Require cmake functions -# ----------------------------------------------------------------------------- - -echo "======================================================================" -echo "${PWD##*/} : $PWD" - -unset depend runTimePostProDebug - -# If available, prefer use of ParaView MESA -if [ -d "$ParaView_MESA_DIR" ] -then - export ParaView_DIR="$ParaView_MESA_DIR" -fi - -if [ -d "$VTK_DIR" ] -then - depend="VTK_DIR=$VTK_DIR" -elif [ -d "$ParaView_DIR" ] -then - depend="ParaView_DIR=$ParaView_DIR" -fi - -# Force use of dummy only -# unset depend - -# For rebuilding (on error) instead of dropping back to dummy -# runTimePostProDebug=true - -if [ "$targetType" = objects ] -then - depend=ignore -elif [ -n "$depend" ] -then - if command -v cmake >/dev/null - then - cmakeVersioned "$depend" $PWD || { - echo - echo " WARNING: incomplete build of VTK-based post-processing" - echo - if [ -z "$runTimePostProDebug" ] - then - depend="dummy" - fi - } - else - echo "==> skip runTimePostProcessing (needs cmake)" - depend="dummy" - fi -else - echo "WARNING: skip runTimePostProcessing (no VTK or ParaView)" - echo " - ParaView : export the 'ParaView_DIR' variable" - echo " - VTK : export the 'VTK_DIR' variable" -fi - -if [ "${depend:-dummy}" = dummy ] -then - echo "==> dummy runTimePostProcessing" - wmakeVersioned "vtk=dummy" $PWD dummy -fi - -echo "======================================================================" - -# ----------------------------------------------------------------------------- diff --git a/src/functionObjects/graphics/runTimePostProcessing/CMakeLists-OpenFOAM.txt b/src/functionObjects/graphics/runTimePostProcessing/CMakeLists-OpenFOAM.txt deleted file mode 100644 index 00a63cbc0d..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/CMakeLists-OpenFOAM.txt +++ /dev/null @@ -1,32 +0,0 @@ -#----------------------------------------------------------------------------- -# Standard definitions when using OpenFOAM - -if (NOT EXISTS "$ENV{WM_PROJECT_DIR}") - message(FATAL_ERROR "WM_PROJECT_DIR not set - no OpenFOAM??") -endif() - -# WM_OSTYPE env variable is optional (only POSIX anyhow) -if (EXISTS "$ENV{WM_OSTYPE}") - set(WM_OSTYPE "$ENV{WM_OSTYPE}") -else() - set(WM_OSTYPE "POSIX") -endif() - -# Convenience name, as per wmake internals -set(LIB_SRC "$ENV{WM_PROJECT_DIR}/src") - -# Needed for internal label-size, scalar-size, templates -add_definitions( - -DWM_$ENV{WM_PRECISION_OPTION} - -DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE} - -DNoRepository -) - -set(CMAKE_CXX_FLAGS_DEBUG - "-g -O0 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual" -) -set(CMAKE_CXX_FLAGS_RELEASE - "-O3 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual" -) - -#----------------------------------------------------------------------------- diff --git a/src/functionObjects/graphics/runTimePostProcessing/CMakeLists-Project.txt b/src/functionObjects/graphics/runTimePostProcessing/CMakeLists-Project.txt deleted file mode 100644 index 2748cc8693..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/CMakeLists-Project.txt +++ /dev/null @@ -1,127 +0,0 @@ -#----------------------------------------------------------------------------- -project(runTimePostProcessing) - -message("VTK version: " ${VTK_VERSION}) - -if(${VTK_VERSION_MAJOR} LESS 6) - message(FATAL_ERROR " VTK version is too old - requires VTK6 or newer") -endif() - -#----------------------------------------------------------------------------- -# Test some characteristics -set(test_file ${CMAKE_CURRENT_BINARY_DIR}/check_mpi.cxx) -file(WRITE ${test_file} - "#include \n" - "int main() {\n" - " vtkMPICommunicator* p = vtkMPICommunicator::New();\n" - " p->Delete();\n" - " return 0;\n" - "}" -) -try_compile(FOAM_USING_VTK_MPI - ${CMAKE_CURRENT_BINARY_DIR} ${test_file} - LINK_LIBRARIES vtkParallelMPI - CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${VTK_INCLUDE_DIRS}" -) -if (FOAM_USING_VTK_MPI) - add_definitions(-DFOAM_USING_VTK_MPI) - message("Building with VTK MPI") - include(vtkMPI) -else() - message(WARNING "==== Building without VTK MPI ====") -endif() - -#----------------------------------------------------------------------------- - -include_directories( - ${LIB_SRC}/OpenFOAM/include - ${LIB_SRC}/OpenFOAM/lnInclude - ${LIB_SRC}/OSspecific/${WM_OSTYPE}/lnInclude - ${LIB_SRC}/finiteVolume/lnInclude - ${LIB_SRC}/fileFormats/lnInclude - ${LIB_SRC}/conversion/lnInclude - ${LIB_SRC}/surfMesh/lnInclude - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} -) - -link_directories( - $ENV{FOAM_LIBBIN} -) - -set(CMAKE_BUILD_TYPE Release) - -# Build intermediate (library) directly into the OpenFOAM libdir -# - implies CMAKE_INSTALL_PREFIX is ignored and there is no 'install' phase -set(LIBRARY_OUTPUT_PATH $ENV{FOAM_LIBBIN} - CACHE INTERNAL - "" -) - -## Record VTK version for general bookkeeping -# file(WRITE -# ${CMAKE_BINARY_DIR}/version -# "VTK_VERSION=${VTK_VERSION}\n" -# ) - -file(GLOB SOURCE_FILES - fieldVisualisationBase.C - scalarBar.C - functionObjectBase.C - functionObjectCloud.C - functionObjectLine.C - functionObjectSurface.C - geometryBase.C - geometryCloud.C - geometryCloudGather.C - geometryPatches.C - geometryPatchesGather.C - geometrySurface.C - pathline.C - pointData.C - runTimePostProcessing.C - runTimePostProcessingFunctionObject.C - scene.C - surface.C - surfaceGather.C - text.C - contourFilter.C - cuttingPlaneFilter.C - volumeFilter.C -) - -set(OPENFOAM_LIBRARIES - OpenFOAM - finiteVolume - surfMesh - fileFormats - conversion -) - -if (FOAM_USING_VTK_MPI) - set(LINK_LIBRARIES vtkParallelMPI) -else() - set(LINK_LIBRARIES) -endif() - -add_library( - runTimePostProcessing - SHARED - ${SOURCE_FILES} -) - -set_target_properties( - runTimePostProcessing - PROPERTIES - VERSION ${VTK_VERSION} - SOVERSION ${VTK_VERSION_MAJOR} -) - -target_link_libraries( - runTimePostProcessing - ${VTK_LIBRARIES} - ${LINK_LIBRARIES} - ${OPENFOAM_LIBRARIES} -) - -#----------------------------------------------------------------------------- diff --git a/src/functionObjects/graphics/runTimePostProcessing/CMakeLists.txt b/src/functionObjects/graphics/runTimePostProcessing/CMakeLists.txt deleted file mode 100644 index 54c8f9d16e..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ -#------------------------------------------------------------------------------ -cmake_minimum_required(VERSION 2.8) -cmake_policy(SET CMP0002 NEW) # Policy CMP0002 required for for cmake >= 3 - -# Fail if not building out-of-source -if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) - message(FATAL_ERROR - "In-source builds disallowed. Use a separate build directory") -endif() - -#----------------------------------------------------------------------------- -# Simple discovery and sanity checks - -unset(VTK_VERSION) -unset(VTK_VERSION_MAJOR) - -if (EXISTS "$ENV{VTK_DIR}") - message("Building with VTK from $ENV{VTK_DIR}") - find_package(VTK REQUIRED HINTS $ENV{VTK_DIR}) -elseif (EXISTS "$ENV{ParaView_DIR}") - message("Building with Paraview from $ENV{ParaView_DIR}") - find_package(ParaView REQUIRED HINTS $ENV{ParaView_DIR}) -else() - message(FATAL_ERROR "VTK not found using VTK_DIR or ParaView_DIR") -endif() - -if (VTK_USE_FILE) - message("VTK from ${VTK_USE_FILE}") - include(${VTK_USE_FILE}) -endif() - -#----------------------------------------------------------------------------- -# Handle name changes (eg, VTK_MAJOR_VERSION to VTK_VERSION_MAJOR etc.) - -if (VTK_MAJOR_VERSION AND NOT VTK_VERSION_MAJOR) - message("Found older VTK version naming") - set(VTK_VERSION_MAJOR ${VTK_MAJOR_VERSION}) - set(VTK_VERSION_MINOR ${VTK_MINOR_VERSION}) - set(VTK_VERSION_PATCH ${VTK_BUILD_VERSION}) - - if (NOT VTK_VERSION) - set( - VTK_VERSION - "${VTK_VERSION_MAJOR}.${VTK_VERSION_MINOR}.${VTK_VERSION_PATCH}" - ) - message("Synthesized VTK version: " ${VTK_VERSION}) - endif() -endif() - -#----------------------------------------------------------------------------- - -include(CMakeLists-OpenFOAM.txt) -include(CMakeLists-Project.txt) - -#----------------------------------------------------------------------------- diff --git a/src/functionObjects/graphics/runTimePostProcessing/contourFilter.C b/src/functionObjects/graphics/runTimePostProcessing/contourFilter.C deleted file mode 100644 index 183bc91dfc..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/contourFilter.C +++ /dev/null @@ -1,311 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -// OpenFOAM includes -#include "contourFilter.H" -#include "runTimePostProcessing.H" -#include "addToRunTimeSelectionTable.H" - -// VTK includes -#include "vtkActor.h" -#include "vtkCellDataToPointData.h" -#include "vtkCompositeDataGeometryFilter.h" -#include "vtkCompositeDataSet.h" -#include "vtkCompositePolyDataMapper.h" -#include "vtkContourFilter.h" -#include "vtkMultiPieceDataSet.h" -#include "vtkPolyData.h" -#include "vtkPolyDataMapper.h" -#include "vtkRenderer.h" -#include "vtkSmartPointer.h" - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ -namespace runTimePostPro -{ - defineTypeName(contourFilter); - addToRunTimeSelectionTable(surface, contourFilter, dictionary); -} -} -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostPro::contourFilter::contourFilter -( - const runTimePostProcessing& parent, - const dictionary& dict, - const HashPtrTable>& colours -) -: - volumeFilter(parent, dict, colours), - fieldVisualisationBase(dict, colours), - colourFieldName_(dict.get("colourField")), - values_() -{ - dict.readEntry("values", values_); - - // Extra safety - if (values_.empty()) - { - values_.resize(1); - values_.first() = Zero; - } -} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -bool Foam::functionObjects::runTimePostPro::contourFilter:: -addGeometry -( - const scalar position, - vtkRenderer* renderer -) -{ - if (!visible_) - { - return false; - } - - if (needsCollective()) - { - Info<< type() << " : Not available for collective operation" << endl; - return false; - } - - DebugInfo << " Adding iso-surface" << endl; - - // Bookkeeping for vtkUnstructuredGrid - vtk::vtuAdaptor adaptor; - vtkSmartPointer multiPiece = mesh(adaptor); - - - // Add (scalar/vector) field. - // - always need field(s) for glyphs or colourByField: - - int nCmpt = 0; - { - const auto* ioptr = - parent().mesh().cfindObject(fieldName_); - - if (!nCmpt) - { - nCmpt = addDimField - ( - multiPiece, adaptor, ioptr, fieldName_ - ); - } - if (!nCmpt) - { - nCmpt = addDimField - ( - multiPiece, adaptor, ioptr, fieldName_ - ); - } - } - - - // If the input is vector, need magnitude - - word magFieldName = fieldName_; - - if (nCmpt == 3) - { - addMagField(fieldName_, multiPiece); - magFieldName = "mag(" + fieldName_ + ")"; - } - - // Colouring - nCmpt = 0; - if (colourBy_ == cbField && fieldName_ != colourFieldName_) - { - const auto* ioptr = - parent().mesh().cfindObject(fieldName_); - - if (!nCmpt) - { - nCmpt = addDimField - ( - multiPiece, adaptor, ioptr, colourFieldName_ - ); - } - if (!nCmpt) - { - nCmpt = addDimField - ( - multiPiece, adaptor, ioptr, colourFieldName_ - ); - } - } - - - // Now have a multi-piece dataset that is one of the following: - // - // - one-piece per processor (OpenFOAM = parallel, VTK=parallel) - - - // Re-query field information - we may have stored it differently - // than the original source. - - fieldSummary fieldInfo = queryFieldSummary(magFieldName, multiPiece); - fieldInfo.reduce(); - - fieldSummary colourFieldInfo = - queryFieldSummary(colourFieldName_, multiPiece); - colourFieldInfo.reduce(); - - - DebugInfo - << " Field " << fieldName_ << ' ' << fieldInfo.info() << nl - << " Field " << colourFieldName_ << ' ' << colourFieldInfo.info() - << endl; - - - // Not rendered on this processor? - // This is where we stop, but could also have an MPI barrier - if (!renderer) - { - return true; - } - - - // Rendering - { - auto contour = vtkSmartPointer::New(); - - vtkSmartPointer cellToPoint; - - // CellData - Need a cell->point filter - if (!fieldInfo.hasPointData() || !colourFieldInfo.hasPointData()) - { - cellToPoint = vtkSmartPointer::New(); - cellToPoint->SetInputData(multiPiece); - - contour->SetInputConnection(cellToPoint->GetOutputPort()); - } - else - { - contour->SetInputData(multiPiece); - } - - contour->SetNumberOfContours(values_.size()); - forAll(values_, valuei) - { - contour->SetValue(valuei, values_[valuei]); - } - - contour->SetInputArrayToProcess - ( - 0, // index: scalars(0) - 0, // port - 0, // connection - vtkDataObject::FIELD_ASSOCIATION_POINTS, - magFieldName.c_str() - ); - - contour->Modified(); - contour->Update(); - - auto polyData = vtkSmartPointer::New(); - - polyData->SetInputConnection(contour->GetOutputPort()); - polyData->Update(); - - auto mapper = vtkSmartPointer::New(); - mapper->SetInputConnection(polyData->GetOutputPort()); - - if (representation_ == rtGlyph) - { - addGlyphs - ( - position, - colourFieldName_, colourFieldInfo, // scaling - colourFieldName_, colourFieldInfo, // colouring - maxGlyphLength_, - polyData->GetOutput(), - surfaceActor_, - renderer - ); - } - else - { - setField - ( - position, - colourFieldName_, - FieldAssociation::POINT_DATA, - mapper, - renderer - ); - - surfaceActor_->SetMapper(mapper); - - setRepresentation(surfaceActor_); - - renderer->AddActor(surfaceActor_); - } - } - - return true; -} - - -void Foam::functionObjects::runTimePostPro::contourFilter:: -addGeometryToScene -( - const scalar position, - vtkRenderer* renderer -) -{ - if (visible_) - { - // Live source - if (addGeometry(position, renderer)) - { - return; - } - - WarningInFunction - << "Unsupported for OpenFOAM parallel and VTK serial" - << endl; - } -} - - -bool Foam::functionObjects::runTimePostPro::contourFilter::clear() -{ - return true; -} - - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/contourFilter.H b/src/functionObjects/graphics/runTimePostProcessing/contourFilter.H deleted file mode 100644 index ddf198df29..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/contourFilter.H +++ /dev/null @@ -1,142 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::functionObjects::runTimePostPro::contourFilter - -Description - Iso-surface contours of OpenFOAM volume fields. - - Dictionary controls - \table - Property | Description | Required | Default - type | The surface type: isoSurface | yes | - field | The field defining the surface | yes | - colourField | The field to display on the surface | yes | - values | List of iso-values to define the surface(s) | yes | - \endtable - -SourceFiles - contourFilter.C - -\*---------------------------------------------------------------------------*/ - -#ifndef functionObjects_runTimePostPro_contourFilter_H -#define functionObjects_runTimePostPro_contourFilter_H - -#include "volumeFilter.H" -#include "fieldVisualisationBase.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ -namespace runTimePostPro -{ - -/*---------------------------------------------------------------------------*\ - Class contourFilter Declaration -\*---------------------------------------------------------------------------*/ - -class contourFilter -: - public volumeFilter, - public fieldVisualisationBase -{ -protected: - - // Protected Data - - //- Name of field to colour by - word colourFieldName_; - - //- The iso values - List values_; - - - // Protected Member Functions - - //- No copy construct - contourFilter(const contourFilter&) = delete; - - //- No copy assignment - void operator=(const contourFilter&) = delete; - - -public: - - //- Run-time type information - TypeNameNoDebug("isoSurface"); - - - // Constructors - - //- Construct from dictionary - contourFilter - ( - const runTimePostProcessing& parent, - const dictionary& dict, - const HashPtrTable>& colours - ); - - - //- Destructor - virtual ~contourFilter() = default; - - - // Member Functions - - //- Add cutting planes to scene (using simulation source) - bool addGeometry - ( - const scalar position, - vtkRenderer* renderer - ); - - //- Add cutting planes to scene (using simulation source) - virtual void addGeometryToScene - ( - const scalar position, - vtkRenderer* renderer - ); - - //- Add cutting planes to scene (using simulation source) - virtual bool clear(); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace runTimePostPro -} // End namespace functionObjects -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/cuttingPlaneFilter.C b/src/functionObjects/graphics/runTimePostProcessing/cuttingPlaneFilter.C deleted file mode 100644 index 7859318384..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/cuttingPlaneFilter.C +++ /dev/null @@ -1,294 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -// OpenFOAM includes -#include "cuttingPlaneFilter.H" -#include "runTimePostProcessing.H" -#include "addToRunTimeSelectionTable.H" - -// VTK includes -#include "vtkActor.h" -#include "vtkCellDataToPointData.h" -#include "vtkCompositeDataGeometryFilter.h" -#include "vtkCompositeDataSet.h" -#include "vtkCompositePolyDataMapper.h" -#include "vtkCutter.h" -#include "vtkMultiPieceDataSet.h" -#include "vtkPlane.h" -#include "vtkPolyData.h" -#include "vtkPolyDataMapper.h" -#include "vtkRenderer.h" -#include "vtkSmartPointer.h" - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ -namespace runTimePostPro -{ - defineTypeName(cuttingPlaneFilter); - addToRunTimeSelectionTable(surface, cuttingPlaneFilter, dictionary); -} -} -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostPro::cuttingPlaneFilter::cuttingPlaneFilter -( - const runTimePostProcessing& parent, - const dictionary& dict, - const HashPtrTable>& colours -) -: - volumeFilter(parent, dict, colours), - fieldVisualisationBase(dict, colours), - plane_(dict), - values_() -{ - dict.readIfPresent("offsets", values_); - - if (values_.empty()) - { - values_.resize(1); - values_.first() = Zero; - } -} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -bool Foam::functionObjects::runTimePostPro::cuttingPlaneFilter:: -addGeometry -( - const scalar position, - vtkRenderer* renderer -) -{ - if (!visible_) - { - return false; - } - - if (needsCollective()) - { - Info<< type() << " : Not available for collective operation" << endl; - return false; - } - - DebugInfo << " Adding cutting plane" << endl; - - - // Bookkeeping for vtkUnstructuredGrid - vtk::vtuAdaptor adaptor; - vtkSmartPointer multiPiece = mesh(adaptor); - - - // Add (scalar/vector) field. - // - Need field(s) for glyphs or colourByField: - - int nCmpt = 0; - if (representation_ == rtGlyph || colourBy_ == cbField) - { - const auto* ioptr = - parent().mesh().cfindObject(fieldName_); - - if (!nCmpt) - { - nCmpt = addDimField - ( - multiPiece, adaptor, ioptr, fieldName_ - ); - } - if (!nCmpt) - { - nCmpt = addDimField - ( - multiPiece, adaptor, ioptr, fieldName_ - ); - } - } - - - // Now have a multi-piece dataset that is one of the following: - // - // - one-piece per processor (OpenFOAM = parallel, VTK=parallel) - - - // Re-query field information - we may have stored it differently - // than the original source. - - fieldSummary fieldInfo = queryFieldSummary(fieldName_, multiPiece); - fieldInfo.reduce(); - - - // Not rendered on this processor? - // This is where we stop, but could also have an MPI barrier - if (!renderer) - { - return true; - } - - - // Rendering - { - // OpenFOAM plane -> vtkPlane definition - - auto pln = vtkSmartPointer::New(); - - pln->SetNormal - ( - plane_.normal().x(), - plane_.normal().y(), - plane_.normal().z() - ); - pln->SetOrigin - ( - plane_.origin().x(), - plane_.origin().y(), - plane_.origin().z() - ); - - - // Plane cutting algorithm - - auto cutter = vtkSmartPointer::New(); - - cutter->SetInputData(multiPiece); - cutter->SetCutFunction(pln); - - cutter->SetNumberOfContours(values_.size()); - - forAll(values_, pointi) - { - cutter->SetValue(pointi, values_[pointi]); - } - - cutter->SetInputArrayToProcess - ( - (nCmpt == 3 ? 1 : 0), // index: scalars(0), vectors(1) - 0, // port - 0, // connection - vtkDataObject::FIELD_ASSOCIATION_CELLS, - fieldName_.c_str() - ); - - cutter->Modified(); - cutter->Update(); - - auto polyData = vtkSmartPointer::New(); - - polyData->SetInputConnection(cutter->GetOutputPort()); - polyData->Update(); - - auto mapper = vtkSmartPointer::New(); - mapper->SetInputConnection(polyData->GetOutputPort()); - - if (representation_ == rtGlyph) - { - addGlyphs - ( - position, - fieldName_, fieldInfo, // scaling - fieldName_, fieldInfo, // colouring - maxGlyphLength_, - polyData->GetOutput(), - surfaceActor_, - renderer - ); - } - else - { - vtkSmartPointer cellToPoint; - - // CellData - Need a cell->point filter - if (smooth_ && !fieldInfo.hasPointData()) - { - cellToPoint = vtkSmartPointer::New(); - cellToPoint->SetInputConnection(cutter->GetOutputPort()); - - polyData->SetInputConnection(cellToPoint->GetOutputPort()); - polyData->Update(); - } - - setField - ( - position, - fieldName_, - ( - smooth_ - ? FieldAssociation::POINT_DATA - : FieldAssociation(fieldInfo.association_) - ), - mapper, - renderer - ); - - surfaceActor_->SetMapper(mapper); - - setRepresentation(surfaceActor_); - - renderer->AddActor(surfaceActor_); - } - } - - return true; -} - - -void Foam::functionObjects::runTimePostPro::cuttingPlaneFilter:: -addGeometryToScene -( - const scalar position, - vtkRenderer* renderer -) -{ - if (visible_) - { - // Live source - if (addGeometry(position, renderer)) - { - return; - } - - WarningInFunction - << "Unsupported for OpenFOAM parallel and VTK serial" - << endl; - } -} - - -bool Foam::functionObjects::runTimePostPro::cuttingPlaneFilter::clear() -{ - return true; -} - - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/cuttingPlaneFilter.H b/src/functionObjects/graphics/runTimePostProcessing/cuttingPlaneFilter.H deleted file mode 100644 index 6ac489f027..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/cuttingPlaneFilter.H +++ /dev/null @@ -1,162 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::functionObjects::runTimePostPro::cuttingPlaneFilter - -Description - Cutting planes of OpenFOAM volume fields. - - Example of text object specification: - \verbatim - planes - { - type plane; - planeType pointAndNormal; - - pointAndNormalDict - { - point (0 0 0); - normal (1 0 0); - } - - offsets (0 10 20); - - field T; - } - \endverbatim - - Dictionary controls - \table - Property | Description | Required | Default - type | The surface type: plane | yes | - planeType | Selector for plane description | yes | - offsets | Offets of the origin in the normal direction | no | (0) - field | The field to display | yes | - \endtable - -SourceFiles - cuttingPlaneFilter.C - -\*---------------------------------------------------------------------------*/ - -#ifndef functionObjects_runTimePostPro_cuttingPlaneFilter_H -#define functionObjects_runTimePostPro_cuttingPlaneFilter_H - -#include "plane.H" -#include "volumeFilter.H" -#include "fieldVisualisationBase.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ -namespace runTimePostPro -{ - -/*---------------------------------------------------------------------------*\ - Class cuttingPlaneFilter Declaration -\*---------------------------------------------------------------------------*/ - -class cuttingPlaneFilter -: - public volumeFilter, - public fieldVisualisationBase -{ -protected: - - // Protected Data - - //- The definition of the plane - plane plane_; - - //- The offsets to the plane - defaults to (0). - List values_; - - - // Protected Member Functions - - //- No copy construct - cuttingPlaneFilter(const cuttingPlaneFilter&) = delete; - - //- No copy assignment - void operator=(const cuttingPlaneFilter&) = delete; - - -public: - - //- Run-time type information - TypeNameNoDebug("plane"); - - - // Constructors - - //- Construct from dictionary - cuttingPlaneFilter - ( - const runTimePostProcessing& parent, - const dictionary& dict, - const HashPtrTable>& colours - ); - - - //- Destructor - virtual ~cuttingPlaneFilter() = default; - - - // Member Functions - - //- Add cutting planes to scene (using simulation source) - bool addGeometry - ( - const scalar position, - vtkRenderer* renderer - ); - - //- Add cutting planes to scene (using simulation source) - virtual void addGeometryToScene - ( - const scalar position, - vtkRenderer* renderer - ); - - //- Cleanup files etc. - virtual bool clear(); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace runTimePostPro -} // End namespace functionObjects -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/dummy/Make/files b/src/functionObjects/graphics/runTimePostProcessing/dummy/Make/files deleted file mode 100644 index 33685ca6e5..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/dummy/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -runTimePostProcessingDummy.C - -LIB = $(FOAM_LIBBIN)/librunTimePostProcessing diff --git a/src/functionObjects/graphics/runTimePostProcessing/dummy/Make/options b/src/functionObjects/graphics/runTimePostProcessing/dummy/Make/options deleted file mode 100644 index 79be6f3a7d..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/dummy/Make/options +++ /dev/null @@ -1,3 +0,0 @@ -EXE_INC = - -LIB_LIBS = diff --git a/src/functionObjects/graphics/runTimePostProcessing/dummy/runTimePostProcessingDummy.C b/src/functionObjects/graphics/runTimePostProcessing/dummy/runTimePostProcessingDummy.C deleted file mode 100644 index e4aa981f7b..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/dummy/runTimePostProcessingDummy.C +++ /dev/null @@ -1,69 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "runTimePostProcessingDummy.H" -#include "dictionary.H" -#include "Time.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ - defineTypeNameAndDebug(runTimePostProcessingDummy, 0); - - addToRunTimeSelectionTable - ( - functionObject, - runTimePostProcessingDummy, - dictionary - ); -} -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostProcessingDummy::runTimePostProcessingDummy -( - const word& name, - const Time& runTime, - const dictionary& dict -) -: - functionObject::unavailableFunctionObject(name) -{ - carp - ( - "VTK libraries were not available at compilation time" - ); -} - - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/dummy/runTimePostProcessingDummy.H b/src/functionObjects/graphics/runTimePostProcessing/dummy/runTimePostProcessingDummy.H deleted file mode 100644 index 51d796270f..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/dummy/runTimePostProcessingDummy.H +++ /dev/null @@ -1,87 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::functionObjects::runTimePostProcessingDummy - -Group - grpGraphicsFunctionObjects - -Description - Dummy implementation of Foam::functionObjects::runTimePostProcessing - to report when the real version is unavailable. - -SourceFiles - runTimePostProcessingDummy.C - -\*---------------------------------------------------------------------------*/ - -#ifndef functionObjects_runTimePostProcessingDummy_H -#define functionObjects_runTimePostProcessingDummy_H - -#include "functionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ - -/*---------------------------------------------------------------------------*\ - Class runTimePostProcessingDummy Declaration -\*---------------------------------------------------------------------------*/ - -class runTimePostProcessingDummy -: - public functionObject::unavailableFunctionObject -{ -public: - - //- Runtime type information - TypeName("runTimePostProcessing"); - - // Constructors - - //- Construct from dictionary - runTimePostProcessingDummy - ( - const word& name, - const Time& runTime, - const dictionary& dict - ); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace functionObjects -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C b/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C deleted file mode 100644 index db0dbf57e4..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C +++ /dev/null @@ -1,808 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2015-2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -// OpenFOAM includes -#include "fieldVisualisationBase.H" -#include "runTimePostProcessing.H" - -#include "doubleVector.H" -#include "foamVtkTools.H" - -// VTK includes -#include "vtkArrowSource.h" -#include "vtkCellDataToPointData.h" -#include "vtkCellData.h" -#include "vtkColorTransferFunction.h" -#include "vtkCompositeDataSet.h" -#include "vtkDataObjectTreeIterator.h" -#include "vtkFieldData.h" -#include "vtkGlyph3D.h" -#include "vtkLookupTable.h" -#include "vtkPointData.h" -#include "vtkPolyData.h" -#include "vtkPolyDataMapper.h" -#include "vtkRenderer.h" -#include "vtkSmartPointer.h" -#include "vtkSphereSource.h" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -const Foam::Enum -< - Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: - colourByType -> -Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: -colourByTypeNames -({ - { colourByType::cbColour, "colour" }, - { colourByType::cbField, "field" }, -}); - -const Foam::Enum -< - Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: - colourMapType -> -Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: -colourMapTypeNames -({ - { colourMapType::cmCoolToWarm, "coolToWarm" }, - { colourMapType::cmCoolToWarm, "blueWhiteRed" }, - { colourMapType::cmColdAndHot, "coldAndHot" }, - { colourMapType::cmFire, "fire" }, - { colourMapType::cmRainbow, "rainbow" }, - { colourMapType::cmGreyscale, "greyscale" }, - { colourMapType::cmGreyscale, "grayscale" }, - { colourMapType::cmXray, "xray" }, -}); - - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostPro::fieldVisualisationBase::fieldSummary -Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: -queryFieldSummary -( - const word& fieldName, - vtkDataSet* dataset -) -{ - fieldSummary queried; - - if (dataset) - { - vtkDataArray* array; - - array = vtkDataArray::SafeDownCast - ( - dataset->GetCellData()->GetAbstractArray(fieldName.c_str()) - ); - - if (array) - { - queried.nComponents_ = array->GetNumberOfComponents(); - queried.association_ |= FieldAssociation::CELL_DATA; - queried.range_ += vtk::Tools::rangeOf(array); - } - - array = vtkDataArray::SafeDownCast - ( - dataset->GetPointData()->GetAbstractArray(fieldName.c_str()) - ); - - if (array) - { - queried.nComponents_ = array->GetNumberOfComponents(); - queried.association_ |= FieldAssociation::POINT_DATA; - queried.range_ += vtk::Tools::rangeOf(array); - } - } - - return queried; -} - - -Foam::functionObjects::runTimePostPro::fieldVisualisationBase::fieldSummary -Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: -queryFieldSummary -( - const word& fieldName, - vtkCompositeDataSet* data -) -{ - fieldSummary queried; - - auto iter = vtkSmartPointer::New(); - - iter->SetDataSet(data); - iter->VisitOnlyLeavesOn(); - iter->SkipEmptyNodesOn(); - - for - ( - iter->InitTraversal(); - !iter->IsDoneWithTraversal(); - iter->GoToNextItem() - ) - { - vtkDataSet* dataset = vtkDataSet::SafeDownCast - ( - iter->GetCurrentDataObject() - ); - - if (dataset) - { - fieldSummary local(queryFieldSummary(fieldName, dataset)); - - if (!queried.nComponents_) - { - queried.nComponents_ = local.nComponents_; - } - - queried.association_ |= local.association_; - queried.range_ += local.range_; - } - } - - return queried; -} - - -Foam::functionObjects::runTimePostPro::fieldVisualisationBase::FieldAssociation -Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: -queryFieldAssociation -( - const word& fieldName, - vtkDataSet* dataset -) -{ - unsigned where(FieldAssociation::NO_DATA); - - if (dataset) - { - if (dataset->GetCellData()->HasArray(fieldName.c_str())) - { - where |= FieldAssociation::CELL_DATA; - } - if (dataset->GetPointData()->HasArray(fieldName.c_str())) - { - where |= FieldAssociation::POINT_DATA; - } - } - - return FieldAssociation(where); -} - - -Foam::functionObjects::runTimePostPro::fieldVisualisationBase::FieldAssociation -Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: -queryFieldAssociation -( - const word& fieldName, - vtkCompositeDataSet* data -) -{ - unsigned where(FieldAssociation::NO_DATA); - - auto iter = vtkSmartPointer::New(); - - iter->SetDataSet(data); - iter->VisitOnlyLeavesOn(); - iter->SkipEmptyNodesOn(); - - for - ( - iter->InitTraversal(); - !iter->IsDoneWithTraversal(); - iter->GoToNextItem() - ) - { - vtkDataSet* dataset = vtkDataSet::SafeDownCast - ( - iter->GetCurrentDataObject() - ); - - where |= queryFieldAssociation(fieldName, dataset); - } - - return FieldAssociation(where); -} - - -void Foam::functionObjects::runTimePostPro::fieldVisualisationBase::addMagField -( - const word& fieldName, - vtkFieldData* fieldData -) -{ - if (!fieldData) - { - return; - } - - vtkDataArray* input = vtkDataArray::SafeDownCast - ( - fieldData->GetAbstractArray(fieldName.c_str()) - ); - - if (!input) - { - return; - } - - const word magFieldName = "mag(" + fieldName + ")"; - - vtkDataArray* output = vtkDataArray::SafeDownCast - ( - fieldData->GetAbstractArray(magFieldName.c_str()) - ); - - if (output) - { - return; - } - - - // Simplfy and only handle scalar/vector input - - const int nCmpt = input->GetNumberOfComponents(); - const vtkIdType len = input->GetNumberOfTuples(); - - if (nCmpt == 1) - { - auto data = vtkSmartPointer::New(); - - data->SetName(magFieldName.c_str()); - data->SetNumberOfComponents(1); - data->SetNumberOfTuples(len); - - double scratch; - for (vtkIdType i=0; i < len; ++i) - { - input->GetTuple(i, &scratch); - - scratch = Foam::mag(scratch); - data->SetTuple(i, &scratch); - } - - fieldData->AddArray(data); - } - else if (nCmpt == 3) - { - auto data = vtkSmartPointer::New(); - - data->SetName(magFieldName.c_str()); - data->SetNumberOfComponents(1); - data->SetNumberOfTuples(len); - - doubleVector scratch; - for (vtkIdType i=0; i < len; ++i) - { - input->GetTuple(i, scratch.v_); - - scratch.x() = Foam::mag(scratch); - - data->SetTuple(i, scratch.v_); - } - - fieldData->AddArray(data); - } -} - - -void Foam::functionObjects::runTimePostPro::fieldVisualisationBase::addMagField -( - const word& fieldName, - vtkDataSet* dataset -) -{ - if (dataset) - { - addMagField(fieldName, dataset->GetCellData()); - addMagField(fieldName, dataset->GetPointData()); - } -} - - -void Foam::functionObjects::runTimePostPro::fieldVisualisationBase::addMagField -( - const word& fieldName, - vtkCompositeDataSet* data -) -{ - auto iter = vtkSmartPointer::New(); - - iter->SetDataSet(data); - iter->VisitOnlyLeavesOn(); - iter->SkipEmptyNodesOn(); - - for - ( - iter->InitTraversal(); - !iter->IsDoneWithTraversal(); - iter->GoToNextItem() - ) - { - vtkDataSet* dataset = vtkDataSet::SafeDownCast - ( - iter->GetCurrentDataObject() - ); - addMagField(fieldName, dataset); - } -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: -fieldSummary::reduce() -{ - if (Pstream::parRun()) - { - Foam::reduce(nComponents_, maxOp()); - Foam::reduce(association_, bitOrOp()); - Foam::reduce(range_, minMaxOp()); - } -} - - -Foam::Ostream& Foam::operator<< -( - Ostream& os, - const InfoProxy - < - functionObjects::runTimePostPro::fieldVisualisationBase::fieldSummary - >& proxy -) -{ - os << "nComponents:" << proxy.t_.nComponents_ - << " association:" << label(proxy.t_.association_) - << " min/max:" << proxy.t_.range_; - - return os; -} - - -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -void Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: -setColourMap -( - vtkLookupTable* lut -) const -{ - constexpr label nColours = 256; - - lut->SetNumberOfColors(nColours); - - auto ctf = vtkSmartPointer::New(); - - switch (colourMap_) - { - case cmCoolToWarm: // ParaView: "Cool To Warm" - { - ctf->SetColorSpaceToDiverging(); - ctf->AddRGBPoint(0.0, 0.231372, 0.298039, 0.752941); - ctf->AddRGBPoint(0.5, 0.865003, 0.865003, 0.865003); - ctf->AddRGBPoint(1.0, 0.705882, 0.0156863, 0.14902); - // ctf->SetNanColor(1, 1, 0); - break; - } - - case cmColdAndHot: // ParaView : "Cold and Hot" - { - ctf->SetColorSpaceToRGB(); - ctf->AddRGBPoint(0, 0, 1, 1); - ctf->AddRGBPoint(0.45, 0, 0, 1); - ctf->AddRGBPoint(0.5, 0, 0, 0.5019608); - ctf->AddRGBPoint(0.55, 1, 0, 0); - ctf->AddRGBPoint(1, 1, 1, 0); - break; - } - - case cmFire: // ParaView: Black-Body Radiation - { - ctf->SetColorSpaceToRGB(); - ctf->AddRGBPoint(0, 0, 0, 0); - ctf->AddRGBPoint(0.4, 0.901961, 0, 0); - ctf->AddRGBPoint(0.8, 0.901961, 0.901961, 0); - ctf->AddRGBPoint(1, 1, 1, 1); - // ctf->SetNanColor(0, 0.49804, 1); - break; - } - - case cmRainbow: - { - ctf->SetColorSpaceToHSV(); - ctf->AddRGBPoint(0, 0, 0, 1); - ctf->AddRGBPoint(0.5, 0, 1, 0); - ctf->AddRGBPoint(1, 1, 0, 0); - // ctf->SetNanColor(0.498039, 0.498039, 0.498039); - break; - } - - case cmGreyscale: // ParaView: grayscale - { - ctf->SetColorSpaceToRGB(); - ctf->AddRGBPoint(0, 0, 0, 0); - ctf->AddRGBPoint(1, 1, 1, 1); - // ctf->SetNanColor(1, 0, 0); - break; - } - - case cmXray: // ParaView: "X ray" - { - ctf->SetColorSpaceToRGB(); - ctf->AddRGBPoint(0, 1, 1, 1); - ctf->AddRGBPoint(1, 0, 0, 0); - // ctf->SetNanColor(1, 0, 0); - break; - } - } - - - double rgba[4] = { 0, 0, 0, 1 }; - for (label i = 0; i < nColours; ++i) - { - ctf->GetColor(scalar(i)/scalar(nColours), rgba); - lut->SetTableValue(i, rgba); - } -} - - -void Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: -addScalarBar -( - const scalar position, - vtkRenderer* renderer, - vtkLookupTable* lut -) const -{ - // Add the scalar bar - only once! - if (renderer && Pstream::master()) - { - scalarBar_.add(colours_["text"]->value(position), renderer, lut); - } -} - - -void Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: -setField -( - const scalar position, - const word& colourFieldName, - const FieldAssociation fieldAssociation, - vtkMapper* mapper, - vtkRenderer* renderer -) const -{ - mapper->InterpolateScalarsBeforeMappingOn(); - - switch (colourBy_) - { - case cbColour: - { - mapper->ScalarVisibilityOff(); - break; - } - - case cbField: - { - // Create look-up table for colours - auto lut = vtkSmartPointer::New(); - setColourMap(lut); - lut->SetVectorMode(vtkScalarsToColors::MAGNITUDE); - lut->SetTableRange(range_.first(), range_.second()); - - // Configure the mapper - const char* fieldName = colourFieldName.c_str(); - mapper->SelectColorArray(fieldName); - - // Use either point or cell data - // - if both point and cell data exists, preferentially choose - // point data. This is often the case when using glyphs. - - if (fieldAssociation & FieldAssociation::POINT_DATA) - { - mapper->SetScalarModeToUsePointFieldData(); - } - else if (fieldAssociation & FieldAssociation::CELL_DATA) - { - mapper->SetScalarModeToUseCellFieldData(); - } - else - { - WarningInFunction - << "Unable to determine cell or point data type " - << "- assuming point data"; - mapper->SetScalarModeToUsePointFieldData(); - } - mapper->SetScalarRange(range_.first(), range_.second()); - mapper->SetColorModeToMapScalars(); - mapper->SetLookupTable(lut); - mapper->ScalarVisibilityOn(); - - // Add the scalar bar - addScalarBar(position, renderer, lut); - break; - } - } - - mapper->Modified(); -} - - -void Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: -addGlyphs -( - const scalar position, - const word& scaleFieldName, - const fieldSummary& scaleFieldInfo, - const word& colourFieldName, - const fieldSummary& colourFieldInfo, - const scalar maxGlyphLength, - - vtkPolyData* data, - vtkActor* actor, - vtkRenderer* renderer -) const -{ - // Determine whether we have CellData/PointData and (scalar/vector) - // or if we need to a cell->point data filter. - - if (!scaleFieldInfo.exists()) - { - WarningInFunction - << "Cannot add glyphs. No such cell or point field: " - << scaleFieldName << endl; - return; - } - - if (!scaleFieldInfo.isScalar() && !scaleFieldInfo.isVector()) - { - WarningInFunction - << "Glyphs can only be added to scalar or vector data. " - << "Unable to process field " << scaleFieldName << endl; - return; - } - - - // Setup glyphs - - // The min/max data range for the input data (cell or point), - // which will be slightly less after using a cell->point filter - // (since it averages), but is still essentially OK. - - - auto glyph = vtkSmartPointer::New(); - glyph->ScalingOn(); - - auto glyphMapper = vtkSmartPointer::New(); - glyphMapper->SetInputConnection(glyph->GetOutputPort()); - - vtkSmartPointer cellToPoint; - - // The data source is filtered or original (PointData) - if (!scaleFieldInfo.hasPointData() || !colourFieldInfo.hasPointData()) - { - // CellData - Need a cell->point filter - cellToPoint = vtkSmartPointer::New(); - cellToPoint->SetInputData(data); - - glyph->SetInputConnection(cellToPoint->GetOutputPort()); - } - else - { - glyph->SetInputData(data); - } - - - if (scaleFieldInfo.nComponents_ == 1) - { - auto sphere = vtkSmartPointer::New(); - sphere->SetCenter(0, 0, 0); - sphere->SetRadius(0.5); - - // Setting higher resolution slows the rendering significantly - // sphere->SetPhiResolution(20); - // sphere->SetThetaResolution(20); - - glyph->SetSourceConnection(sphere->GetOutputPort()); - - if (maxGlyphLength > 0) - { - // Using range from the data: - // glyph->SetRange - // ( - // scaleFieldInfo.range_.first(), - // scaleFieldInfo.range_.second() - // ); - - // Set range according to user-supplied limits - glyph->ClampingOn(); - glyph->SetRange(range_.first(), range_.second()); - - // If range[0] != min(value), maxGlyphLength behaviour will not - // be correct... - glyph->SetScaleFactor(maxGlyphLength); - } - else - { - glyph->SetScaleFactor(1); - } - glyph->SetScaleModeToScaleByScalar(); - glyph->OrientOff(); - glyph->SetColorModeToColorByScalar(); - glyph->SetInputArrayToProcess - ( - 0, // index (0) = scalars - 0, // port - 0, // connection - vtkDataObject::FIELD_ASSOCIATION_POINTS, - scaleFieldName.c_str() - ); - } - else if (scaleFieldInfo.nComponents_ == 3) - { - auto arrow = vtkSmartPointer::New(); - arrow->SetTipResolution(10); - arrow->SetTipRadius(0.1); - arrow->SetTipLength(0.35); - arrow->SetShaftResolution(10); - arrow->SetShaftRadius(0.03); - - glyph->SetSourceConnection(arrow->GetOutputPort()); - - if (maxGlyphLength > 0) - { - // Set range according data limits - glyph->ClampingOn(); - glyph->SetRange - ( - scaleFieldInfo.range_.first(), - scaleFieldInfo.range_.second() - ); - glyph->SetScaleFactor(maxGlyphLength); - } - else - { - glyph->SetScaleFactor(1); - } - glyph->SetScaleModeToScaleByVector(); - glyph->OrientOn(); - glyph->SetVectorModeToUseVector(); - glyph->SetColorModeToColorByVector(); - glyph->SetInputArrayToProcess - ( - 1, // index (1) = vectors - 0, // port - 0, // connection - vtkDataObject::FIELD_ASSOCIATION_POINTS, - scaleFieldName.c_str() - ); - } - - - // Apply colouring etc. - // We already established PointData, which as either in the original, - // or generated with vtkCellDataToPointData filter. - - { - glyph->Update(); - - setField - ( - position, - colourFieldName, - FieldAssociation::POINT_DATA, // Original or after filter - glyphMapper, - renderer - ); - - glyphMapper->Update(); - - actor->SetMapper(glyphMapper); - - renderer->AddActor(actor); - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: -fieldVisualisationBase -( - const dictionary& dict, - const HashPtrTable>& colours -) -: - colours_(colours), - fieldName_(dict.get("field")), - smooth_(dict.getOrDefault("smooth", false)), - colourBy_(cbColour), - colourMap_(cmRainbow), - range_(), - scalarBar_() -{ - colourByTypeNames.readEntry("colourBy", dict, colourBy_); - - switch (colourBy_) - { - case cbColour: - { - scalarBar_.hide(); - break; - } - - case cbField: - { - dict.readEntry("range", range_); - colourMapTypeNames.readIfPresent("colourMap", dict, colourMap_); - - const dictionary* sbar = dict.findDict("scalarBar"); - - if (sbar) - { - scalarBar_.read(*sbar); - } - else - { - scalarBar_.hide(); - } - break; - } - } -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostPro::fieldVisualisationBase:: -~fieldVisualisationBase() -{} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -const Foam::HashPtrTable, Foam::word>& -Foam::functionObjects::runTimePostPro::fieldVisualisationBase::colours() const -{ - return colours_; -} - - -const Foam::word& -Foam::functionObjects::runTimePostPro::fieldVisualisationBase::fieldName() -const -{ - return fieldName_; -} - - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.H b/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.H deleted file mode 100644 index 659b77c9ed..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.H +++ /dev/null @@ -1,367 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2015-2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::functionObjects::runTimePostPro::fieldVisualisationBase - -Description - Base class for scene objects - - Dictionary controls - colour by field - \table - Property | Description | Required | Default - colourBy | Colouring type (color / field) | yes | - range | Lower/upper range to display | yes | - smooth | Request smoother output | no | false - colourMap | Colour map for rendering | no | rainbow - scalarBar | Scalar-bar sub-dictionary | yes | - \endtable - -Colour maps include "coolToWarm" ("blueWhiteRed"), "coldAndHot", -"fire", "rainbow", "greyscale" ("grayscale"), "xray". For historical -reasons, the default is still "rainbow". - -SourceFiles - fieldVisualisationBase.C - -\*---------------------------------------------------------------------------*/ - -#ifndef functionObjects_fieldVisualisationBase_H -#define functionObjects_fieldVisualisationBase_H - -#include "dictionary.H" -#include "Tuple2.H" -#include "Enum.H" -#include "vector.H" -#include "MinMax.H" -#include "HashPtrTable.H" -#include "scalarBar.H" -#include "Function1.H" - -#include "vtkSmartPointer.h" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// Forward Declarations -class vtkActor; -class vtkCompositeDataSet; -class vtkCompositeDataGeometryFilter; -class vtkCompositePolyDataMapper; -class vtkDataSet; -class vtkDataSetAlgorithm; -class vtkFieldData; -class vtkLookupTable; -class vtkMapper; -class vtkPolyData; -class vtkPolyDataMapper; -class vtkRenderer; - - -namespace Foam -{ -namespace functionObjects -{ -// Forward Declarations -class runTimePostProcessing; - -namespace runTimePostPro -{ - -/*---------------------------------------------------------------------------*\ - Class fieldVisualisationBase Declaration -\*---------------------------------------------------------------------------*/ - -class fieldVisualisationBase -{ -public: - - // Public Enumerations - - //- Colouring type - enum colourByType - { - cbColour, //!< "colour" : Use specified colour - cbField //!< "field" : Use named field - }; - - //- Enumeration names for colourByType - static const Enum colourByTypeNames; - - //- Colour map enumerations - enum colourMapType - { - cmCoolToWarm, //!< ParaView "Cool To Warm" blue-white-read - cmBlueWhiteRed = cmCoolToWarm, - cmColdAndHot, //!< ParaView "Cold and Hot" - cmFire, //!< ParaView "Black-Body Radiation" - cmRainbow, //!< "rainbow" - cmGreyscale, //!< ParaView "Grayscale" - cmXray //!< ParaView "X Ray" - }; - - //- Enumeration names for colourMapType - static const Enum colourMapTypeNames; - - - //- Enumeration of the data field associations - // These values are used internally and do NOT correspond to the - // vtkDataObject::FieldAssociations enumeration. - enum FieldAssociation - { - NO_DATA = 0, //!< No associated data - CELL_DATA = 0x1, //!< Associated with cells (faces) - POINT_DATA = 0x2, //!< Associated with points - CELL_POINT_DATA = 0x3 //!< Associated with cells and/or points - }; - - - //- General field characteristics. - // For convenience, the interface is exposed but external use is - // highly discouraged. - struct fieldSummary - { - int nComponents_; - unsigned association_; - scalarMinMax range_; - - //- Construct null - fieldSummary() - : - nComponents_(0), - association_(0u), - range_() - {} - - //- Parallel reduction. A no-op if Pstream::parRun() is false - void reduce(); - - //- True if nComponents_ == 1 - bool isScalar() const - { - return nComponents_ == 1; - } - - //- True if nComponents_ == 3 - bool isVector() const - { - return nComponents_ == 3; - } - - //- True if association_ is non-zero - bool exists() const - { - return association_; - } - - //- True if there is a POINT_DATA association - bool hasPointData() const - { - return (association_ & FieldAssociation::POINT_DATA); - } - - InfoProxy info() const - { - return InfoProxy(*this); - } - }; - - -protected: - - // Protected Data - - //- Colours - const HashPtrTable>& colours_; - - //- Field name - word fieldName_; - - //- Requested smoother fields (eg, interpolate cell -> point values) - bool smooth_; - - //- Colour by type - colourByType colourBy_; - - //- Colour map type - colourMapType colourMap_; - - //- Range of values - Tuple2 range_; - - //- Scalar bar characteristics - scalarBar scalarBar_; - - - // Protected Member Functions - - //- Query DataSet for field name and its field association - static fieldSummary queryFieldSummary - ( - const word& fieldName, - vtkDataSet* dataset - ); - - //- Query composite DataSet for field name and its FieldAssociation - static fieldSummary queryFieldSummary - ( - const word& fieldName, - vtkCompositeDataSet* data - ); - - //- Query DataSet for field name and its field association - static FieldAssociation queryFieldAssociation - ( - const word& fieldName, - vtkDataSet* dataset - ); - - //- Query composite DataSet for field name and its FieldAssociation - static FieldAssociation queryFieldAssociation - ( - const word& fieldName, - vtkCompositeDataSet* data - ); - - - //- Add "mag(..)" field for filters that only accept scalars - static void addMagField - ( - const word& fieldName, - vtkFieldData* fieldData - ); - - //- Add "mag(..)" field for filters that only accept scalars - static void addMagField - ( - const word& fieldName, - vtkDataSet* dataset - ); - - //- Add "mag(..)" field for filters that only accept scalars - static void addMagField - ( - const word& fieldName, - vtkCompositeDataSet* data - ); - - - //- Set the colour map - void setColourMap(vtkLookupTable* lut) const; - - //- Add scalar bar (if visible) to renderer - void addScalarBar - ( - const scalar position, - vtkRenderer* renderer, - vtkLookupTable* lut - ) const; - - //- Set field/configure mapper, add scalar bar - void setField - ( - const scalar position, - const word& colourFieldName, - const FieldAssociation fieldAssociation, - vtkMapper* mapper, - vtkRenderer* renderer - ) const; - - //- Add glyphs - void addGlyphs - ( - const scalar position, - const word& scaleFieldName, - const fieldSummary& scaleFieldInfo, - const word& colourFieldName, - const fieldSummary& colourFieldInfo, - const scalar maxGlyphLength, - - vtkPolyData* data, - vtkActor* actor, - vtkRenderer* renderer - ) const; - - - //- No copy construct - fieldVisualisationBase(const fieldVisualisationBase&) = delete; - - //- No copy assignment - void operator=(const fieldVisualisationBase&) = delete; - - -public: - - // Constructors - - //- Construct from dictionary - fieldVisualisationBase - ( - const dictionary& dict, - const HashPtrTable>& colours - ); - - - //- Destructor - virtual ~fieldVisualisationBase(); - - - // Member Functions - - // Access - - //- Return the colours - const HashPtrTable>& colours() const; - - //- Return the field name - const word& fieldName() const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace runTimePostPro -} // End namespace functionObjects - - -// Ostream -Ostream& operator<< -( - Ostream& os, - const InfoProxy - < - functionObjects::runTimePostPro::fieldVisualisationBase::fieldSummary - >& proxy -); - - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.C b/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.C deleted file mode 100644 index 5a451aa33b..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.C +++ /dev/null @@ -1,94 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2015-2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "functionObjectBase.H" - -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -Foam::fileName -Foam::functionObjects::runTimePostPro::functionObjectBase::getFileName -( - const word& keyword, - const word& subDictName -) const -{ - dictionary dict; - state_.getObjectDict(functionObjectName_, subDictName, dict); - - fileName f; - if (dict.readIfPresent(keyword, f)) - { - f.expand(); - } - - return f; -} - - -bool Foam::functionObjects::runTimePostPro::functionObjectBase::removeFile -( - const word& keyword, - const word& subDictName -) -{ - // Foam::rm() ignores empty names etc. - - if (Pstream::master()) - { - return Foam::rm(getFileName(keyword, subDictName)); - } - - return false; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostPro::functionObjectBase::functionObjectBase -( - const stateFunctionObject& state, - const dictionary& dict, - const HashPtrTable>& colours -) -: - fieldVisualisationBase(dict, colours), - state_(state), - functionObjectName_(dict.get("functionObject")), - liveObject_(dict.getOrDefault("liveObject", true)), - clearObjects_(dict.getOrDefault("clearObjects", false)) -{} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -bool Foam::functionObjects::runTimePostPro::functionObjectBase::clear() -{ - return clearObjects_; -} - - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.H b/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.H deleted file mode 100644 index dc3a14f2c3..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.H +++ /dev/null @@ -1,163 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2015-2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::functionObjects::runTimePostPro::functionObjectBase - -Description - Base class for function object visualisation - - Dictionary controls - \table - Property | Description | Required | Default - functionObject | The data source | yes | - clearObjects | Remove file after use | no | no - liveObject | Prefer simulation data source | no | true - \endtable - - The "live" keyword indiates that from within the simulation (in memory) - is preferred over data from disk (for example). - -SourceFiles - functionObjectBase.C - -\*---------------------------------------------------------------------------*/ - -#ifndef functionObjects_runTimePostPro_functionObjectBase_H -#define functionObjects_runTimePostPro_functionObjectBase_H - -#include "fieldVisualisationBase.H" -#include "stateFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ -namespace runTimePostPro -{ - -/*---------------------------------------------------------------------------*\ - Class functionObjectBase Declaration -\*---------------------------------------------------------------------------*/ - -class functionObjectBase -: - public fieldVisualisationBase -{ -protected: - - // Protected Data - - //- Reference to the state - const stateFunctionObject& state_; - - //- The function object name that provides the source data - word functionObjectName_; - - //- Flag to indicate "live" (simulation) data source should be used - bool liveObject_; - - //- Flag to indicate that source data should be cleared after use - bool clearObjects_; - - - // Protected Member Functions - - //- Retrieve the filename used to create the scene object - //- using information stored via the stateFunctionObject. - // - // \param keyword is normally "file" - // \param subDictName is the sub-dictionary name, which is often - // the fieldName when one file is used per field. - // - // Eg, - // \verbatim - // T - // { - // file "/relpath/T_object.vtk"; - // } - // defaultCloud - // { - // file "/relpath/cloud_0001.vtp"; - // fields (T U); - // } - // \endverbatim - fileName getFileName - ( - const word& keyword, - const word& subDictName - ) const; - - //- Remove file used to create the scene object. - // Same naming semantics as getFileName. - // - // \note does not change the stateFunctionObject - bool removeFile(const word& keyword, const word& subDictName); - - - //- No copy construct - functionObjectBase(const functionObjectBase&) = delete; - - //- No copy assignment - void operator=(const functionObjectBase&) = delete; - - -public: - - // Constructors - - //- Construct from dictionary - functionObjectBase - ( - const stateFunctionObject& state, - const dictionary& dict, - const HashPtrTable>& colours - ); - - - //- Destructor - virtual ~functionObjectBase() = default; - - - // Member Functions - - //- Clear files used to create the object(s) - virtual bool clear(); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace runTimePostPro -} // End namespace functionObjects -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectCloud.C b/src/functionObjects/graphics/runTimePostProcessing/functionObjectCloud.C deleted file mode 100644 index 5fb178b497..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectCloud.C +++ /dev/null @@ -1,279 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2015-2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -// OpenFOAM includes -#include "functionObjectCloud.H" -#include "fvMesh.H" -#include "runTimePostProcessing.H" -#include "addToRunTimeSelectionTable.H" - -// VTK includes -#include "vtkActor.h" -#include "vtkPolyData.h" -#include "vtkPolyDataMapper.h" -#include "vtkProperty.h" -#include "vtkRenderer.h" -#include "vtkSmartPointer.h" - -// VTK Readers -#include "vtkPolyDataReader.h" -#include "vtkXMLPolyDataReader.h" - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ -namespace runTimePostPro -{ - defineTypeName(functionObjectCloud); - addToRunTimeSelectionTable(pointData, functionObjectCloud, dictionary); -} -} -} - - -// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // - -namespace -{ - -static vtkSmartPointer getPolyDataFile(const Foam::fileName& fName) -{ - // Very simple - we only support vtp files, which are expected to have - // the scaling and colouring fields. - - vtkSmartPointer dataset; - - if (fName.ext() == "vtp") - { - auto reader = vtkSmartPointer::New(); - - reader->SetFileName(fName.c_str()); - reader->Update(); - dataset = reader->GetOutput(); - - return dataset; - } - - return dataset; -} - -} // End anonymous namespace - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostPro::functionObjectCloud::functionObjectCloud -( - const runTimePostProcessing& parent, - const dictionary& dict, - const HashPtrTable>& colours -) -: - pointData(parent, dict, colours), - functionObjectBase(parent, dict, colours), - cloudName_(dict.get("cloud")), - inputFileName_(), - colourFieldName_(dict.get("colourField")), - actor_() -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostPro::functionObjectCloud:: -~functionObjectCloud() -{} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -bool Foam::functionObjects::runTimePostPro::functionObjectCloud:: -addGeometryFromFile -( - const scalar position, - vtkRenderer* renderer -) -{ - if (!visible_) - { - return false; - } - - vtkSmartPointer polyData; - - bool good = true; - - // The vtkCloud stores 'file' via the stateFunctionObject - // (lookup by cloudName). - // It only generates VTP format, which means there is a single file - // containing all fields. - - if (Pstream::master()) - { - inputFileName_ = getFileName("file", cloudName_); - - if (inputFileName_.size()) - { - polyData = getPolyDataFile(inputFileName_); - - if (!polyData || polyData->GetNumberOfPoints() == 0) - { - good = false; - - WarningInFunction - << "Could not read "<< inputFileName_ << nl - << "Only VTK (.vtp) files are supported" - << endl; - } - else - { - DebugInfo - << " Resolved cloud file " << inputFileName_ << endl; - } - } - else - { - good = false; - - WarningInFunction - << "Unable to find function object " << functionObjectName_ - << " output for field " << fieldName_ - << ". Cloud will not be processed" - << endl; - } - } - else - { - inputFileName_.clear(); - } - - reduce(good, andOp()); - - if (!good) - { - return false; - } - - // Only render on master - if (!renderer || !Pstream::master()) - { - return true; - } - - - // Rendering - - actor_ = vtkSmartPointer::New(); - - { - fieldSummary scaleFieldInfo = - queryFieldSummary(fieldName_, polyData); - - fieldSummary colourFieldInfo = - queryFieldSummary(colourFieldName_, polyData); - - DebugInfo - << " Field " << fieldName_ << ' ' << scaleFieldInfo.info() << nl - << " Field " << colourFieldName_ << ' ' << colourFieldInfo.info() - << endl; - - - // No reduction - - auto mapper = vtkSmartPointer::New(); - - actor_->SetMapper(mapper); - - /// dataset->Print(std::cout); - - addGlyphs - ( - position, - fieldName_, scaleFieldInfo, // scaling - colourFieldName_, colourFieldInfo, // colour - maxGlyphLength_, - polyData, - actor_, - renderer - ); - - renderer->AddActor(actor_); - } - - return true; -} - - -void Foam::functionObjects::runTimePostPro::functionObjectCloud:: -addGeometryToScene -( - const scalar position, - vtkRenderer* renderer -) -{ - // File source - addGeometryFromFile(position, renderer); -} - - -void Foam::functionObjects::runTimePostPro::functionObjectCloud::updateActors -( - const scalar position -) -{ - if (actor_) - { - const vector colour = pointColour_->value(position); - - vtkProperty* prop = actor_->GetProperty(); - - prop->SetOpacity(opacity(position)); - - prop->SetColor(colour[0], colour[1], colour[2]); - } -} - - -bool Foam::functionObjects::runTimePostPro::functionObjectCloud::clear() -{ - if (functionObjectBase::clear()) - { - if (inputFileName_.size() && Foam::rm(inputFileName_)) - { - inputFileName_.clear(); - return true; - } - } - - return false; -} - - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectCloud.H b/src/functionObjects/graphics/runTimePostProcessing/functionObjectCloud.H deleted file mode 100644 index 994eebcfc0..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectCloud.H +++ /dev/null @@ -1,152 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2015-2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::functionObjects::runTimePostPro::functionObjectCloud - -Description - Visualisation of cloud data from function object output (file-based only). - - Dictionary controls - \table - Property | Description | Required | Default - type | The point type: functionObjectCloud | yes | - functionObject | The data source | yes | - cloud | The cloud name | no | - field | The field for glyphs scaling | no | - colourField | The field to display | no | - \endtable - -SourceFiles - functionObjectCloud.C - -\*---------------------------------------------------------------------------*/ - -#ifndef functionObjects_runTimePostPro_functionObjectCloud_H -#define functionObjects_runTimePostPro_functionObjectCloud_H - -#include "pointData.H" -#include "functionObjectBase.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ -namespace runTimePostPro -{ - -/*---------------------------------------------------------------------------*\ - Class functionObjectCloud Declaration -\*---------------------------------------------------------------------------*/ - -class functionObjectCloud -: - public pointData, - public functionObjectBase -{ -protected: - - // Protected Data - - //- Name of functionObjectCloud - word cloudName_; - - //- The input filename used - fileName inputFileName_; - - //- Name of field to colour by - word colourFieldName_; - - //- Actor - vtkSmartPointer actor_; - - - // Protected Member Functions - - //- No copy construct - functionObjectCloud(const functionObjectCloud&) = delete; - - //- No copy assignment - void operator=(const functionObjectCloud&) = delete; - - -public: - - //- Run-time type information - TypeNameNoDebug("functionObjectCloud"); - - - // Constructors - - //- Construct from dictionary - functionObjectCloud - ( - const runTimePostProcessing& parent, - const dictionary& dict, - const HashPtrTable>& colours - ); - - - //- Destructor - virtual ~functionObjectCloud(); - - - // Member Functions - - //- Add cloud to scene (using file source) - bool addGeometryFromFile - ( - const scalar position, - vtkRenderer* renderer - ); - - //- Add cloud to scene - virtual void addGeometryToScene - ( - const scalar position, - vtkRenderer* renderer - ); - - //- Update actors - virtual void updateActors(const scalar position); - - //- Clear files used to create the object(s) - virtual bool clear(); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace runTimePostPro -} // End namespace functionObjects -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectLine.C b/src/functionObjects/graphics/runTimePostProcessing/functionObjectLine.C deleted file mode 100644 index 267683e784..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectLine.C +++ /dev/null @@ -1,202 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2015-2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -// OpenFOAM includes -#include "functionObjectLine.H" -#include "runTimePostProcessing.H" -#include "addToRunTimeSelectionTable.H" - -// VTK includes -#include "vtkActor.h" -#include "vtkPolyData.h" -#include "vtkPolyDataMapper.h" -#include "vtkProperty.h" -#include "vtkRenderer.h" -#include "vtkSmartPointer.h" - -// VTK Readers -#include "vtkPolyDataReader.h" -#include "vtkXMLPolyDataReader.h" - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ -namespace runTimePostPro -{ - defineTypeName(functionObjectLine); - addToRunTimeSelectionTable(pathline, functionObjectLine, dictionary); -} -} -} - - -// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // - -namespace -{ - -static vtkSmartPointer getPolyDataFile(const Foam::fileName& fName) -{ - // Not extremely elegant... - vtkSmartPointer dataset; - - if ("vtk" == fName.ext()) - { - auto reader = vtkSmartPointer::New(); - - reader->SetFileName(fName.c_str()); - reader->Update(); - dataset = reader->GetOutput(); - - return dataset; - } - - if ("vtp" == fName.ext()) - { - auto reader = vtkSmartPointer::New(); - - reader->SetFileName(fName.c_str()); - reader->Update(); - dataset = reader->GetOutput(); - - return dataset; - } - - return dataset; -} - -} // End anonymous namespace - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostPro::functionObjectLine::functionObjectLine -( - const runTimePostProcessing& parent, - const dictionary& dict, - const HashPtrTable>& colours -) -: - pathline(parent, dict, colours), - functionObjectBase(parent, dict, colours), - actor_() -{ - actor_ = vtkSmartPointer::New(); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostPro::functionObjectLine::~functionObjectLine() -{} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -void Foam::functionObjects::runTimePostPro::functionObjectLine:: -addGeometryToScene -( - const scalar position, - vtkRenderer* renderer -) -{ - // Currently master-only - if (!visible_ || !renderer || !Pstream::master()) - { - return; - } - - fileName fName = getFileName("file", fieldName_); - if (fName.empty()) - { - WarningInFunction - << "Unable to read file name from function object " - << functionObjectName_ << " for field " << fieldName_ - << ". Line will not be processed" - << endl; - return; - } - - - auto polyData = getPolyDataFile(fName); - - if (!polyData || polyData->GetNumberOfPoints() == 0) - { - WarningInFunction - << "Could not read "<< fName << nl - << "Only VTK (.vtp, .vtk) files are supported" - << endl; - return; - } - - DebugInfo << " Resolved lines " << fName << endl; - - - auto mapper = vtkSmartPointer::New(); - - setField - ( - position, - fieldName_, - queryFieldAssociation(fieldName_, polyData), - mapper, - renderer - ); - - actor_->SetMapper(mapper); - - addLines(position, actor_, polyData); - - renderer->AddActor(actor_); -} - - -void Foam::functionObjects::runTimePostPro::functionObjectLine::updateActors -( - const scalar position -) -{ - actor_->GetProperty()->SetLineWidth(2); - actor_->GetProperty()->SetOpacity(opacity(position)); -} - - -bool Foam::functionObjects::runTimePostPro::functionObjectLine::clear() -{ - if (functionObjectBase::clear()) - { - return removeFile("file", fieldName_); - } - - return false; -} - - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectLine.H b/src/functionObjects/graphics/runTimePostProcessing/functionObjectLine.H deleted file mode 100644 index 93fec9207e..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectLine.H +++ /dev/null @@ -1,132 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2015-2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::functionObjects::runTimePostPro::functionObjectLine - -Description - Visualisation of line data from function object output (file-based only). - - Dictionary controls - \table - Property | Description | Required | Default - type | The line type: functionObjectLine | yes | - \endtable - -SourceFiles - functionObjectLine.C - -\*---------------------------------------------------------------------------*/ - -#ifndef functionObjects_runTimePostPro_functionObjectLine_H -#define functionObjects_runTimePostPro_functionObjectLine_H - -#include "pathline.H" -#include "functionObjectBase.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ -namespace runTimePostPro -{ - -/*---------------------------------------------------------------------------*\ - Class functionObjectLine Declaration -\*---------------------------------------------------------------------------*/ - -class functionObjectLine -: - public pathline, - public functionObjectBase -{ -protected: - - // Protected Data - - //- Actor - vtkSmartPointer actor_; - - - // Protected Member Functions - - //- No copy construct - functionObjectLine(const functionObjectLine&) = delete; - - //- No copy assignment - void operator=(const functionObjectLine&) = delete; - - -public: - - //- Run-time type information - TypeNameNoDebug("functionObjectLine"); - - - // Constructors - - //- Construct from dictionary - functionObjectLine - ( - const runTimePostProcessing& parent, - const dictionary& dict, - const HashPtrTable>& colours - ); - - - //- Destructor - virtual ~functionObjectLine(); - - - // Member Functions - - //- Add tube(s) to scene - virtual void addGeometryToScene - ( - const scalar position, - vtkRenderer* renderer - ); - - //- Update actors - virtual void updateActors(const scalar position); - - //- Clear files used to create the object(s) - virtual bool clear(); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace runTimePostPro -} // End namespace functionObjects -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectSurface.C b/src/functionObjects/graphics/runTimePostProcessing/functionObjectSurface.C deleted file mode 100644 index 224f75e9e2..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectSurface.C +++ /dev/null @@ -1,506 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2015-2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -// OpenFOAM includes -#include "functionObjectSurface.H" -#include "runTimePostProcessing.H" -#include "addToRunTimeSelectionTable.H" - -// VTK includes -#include "vtkActor.h" -#include "vtkCellData.h" -#include "vtkCellDataToPointData.h" -#include "vtkCompositeDataGeometryFilter.h" -#include "vtkCompositeDataSet.h" -#include "vtkCompositePolyDataMapper.h" -#include "vtkMultiPieceDataSet.h" -#include "vtkPointData.h" -#include "vtkPolyData.h" -#include "vtkPolyDataMapper.h" -#include "vtkProperty.h" -#include "vtkRenderer.h" -#include "vtkSmartPointer.h" - -// VTK Readers -#include "vtkPolyDataReader.h" -#include "vtkXMLPolyDataReader.h" - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ -namespace runTimePostPro -{ - defineTypeName(functionObjectSurface); - addToRunTimeSelectionTable(surface, functionObjectSurface, dictionary); -} -} -} - - -// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // - -namespace -{ - -static vtkSmartPointer getPolyDataFile(const Foam::fileName& fName) -{ - // Not extremely elegant... - vtkSmartPointer dataset; - - if ("vtk" == fName.ext()) - { - auto reader = vtkSmartPointer::New(); - - reader->SetFileName(fName.c_str()); - reader->Update(); - dataset = reader->GetOutput(); - - return dataset; - } - - if ("vtp" == fName.ext()) - { - auto reader = vtkSmartPointer::New(); - - reader->SetFileName(fName.c_str()); - reader->Update(); - dataset = reader->GetOutput(); - - return dataset; - } - - return dataset; -} - -} // End anonymous namespace - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostPro::functionObjectSurface:: -functionObjectSurface -( - const runTimePostProcessing& parent, - const dictionary& dict, - const HashPtrTable>& colours -) -: - geometrySurface(parent, dict, colours, List()), - functionObjectBase(parent, dict, colours) -{} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -bool Foam::functionObjects::runTimePostPro::functionObjectSurface:: -addGeometry -( - const scalar position, - vtkRenderer* renderer -) -{ - if (!visible_) - { - return false; - } - - DebugInfo - << " Find surface " << functionObjectName_ << endl; - - const polySurface* surf = - ( - geometryBase::parent_.storedObjects() - .cfindObject(functionObjectName_) - ); - - // Treat surface with no faces/points like a missing surface - surf = ((surf && surf->nPoints()) ? surf : nullptr); - - bool hasSurface = surf; - - - // Retrieve the field association (CELL, POINT) for the given field - - unsigned fieldAssociation(0u); - if (surf) - { - unsigned queried = surf->queryFieldAssociation(fieldName_); - - if (queried & polySurface::FACE_DATA) - { - fieldAssociation |= FieldAssociation::CELL_DATA; - } - if (queried & polySurface::POINT_DATA) - { - fieldAssociation |= FieldAssociation::POINT_DATA; - } - } - - // Reduce the information - if (Pstream::parRun()) - { - if (!hasSurface) - { - // No geometry - set all field association bits ON to ensure - // it does not affect bitwise reduction. - fieldAssociation = (~0u); - } - - reduce(hasSurface, orOp()); - reduce(fieldAssociation, bitAndOp()); - } - - if (!hasSurface) - { - WarningInFunction - << "No functionObject surface, or has no faces: " - << functionObjectName_ - << endl; - - DebugInfo - << " Available surfaces:" << nl - << geometryBase::parent_.storedObjects() - .sortedNames() << endl; - - return false; - } - - //// Pout<< "local surface = " << (surf ? surf->nFaces() : 0) << nl; - - - // Create a vtkMultiPieceDataSet with vtkPolyData on the leaves - vtkSmartPointer multiPiece; - - // Requesting glyphs on the surface AND only have face data? - // - just use the faceCentres directly and attach fields as CellData - // (not PointData). - - if - ( - representation_ == rtGlyph - && (fieldAssociation == FieldAssociation::CELL_DATA) - ) - { - multiPiece = gatherFaceCentres(surf); - } - else - { - multiPiece = gatherSurfacePieces(surf); - } - - - // Add the field (the information is consistent after last reduction). - - // Need field(s) for glyphs or colourByField: - - if (representation_ == rtGlyph || colourBy_ == cbField) - { - if (fieldAssociation == FieldAssociation::CELL_DATA) - { - addDimField - ( - multiPiece, - surf, - fieldName_ - ); - } - else if (fieldAssociation & FieldAssociation::POINT_DATA) - { - addDimField - ( - multiPiece, - surf, - fieldName_ - ); - } - } - - - // Now have a multi-piece dataset that is one of the following: - // - // - one-piece per processor (OpenFOAM = parallel, VTK=parallel) - // - all pieces on master only (OpenFOAM = parallel, VTK=serial) - - // Re-query field information - we may have stored it differently - // than the original source. - - fieldSummary fieldInfo = queryFieldSummary(fieldName_, multiPiece); - fieldInfo.reduce(); - - DebugInfo - << " Field " << fieldName_ << ' ' << fieldInfo.info() << endl; - - - // Not rendered on this processor? - // This is where we stop, but could also have an MPI barrier - if (!renderer) - { - return true; - } - - - // Rendering - - { - auto polyData = vtkSmartPointer::New(); - - polyData->SetInputData(multiPiece); - polyData->Update(); - - if (representation_ == rtGlyph) - { - addGlyphs - ( - position, - fieldName_, fieldInfo, // scaling - fieldName_, fieldInfo, // colouring - maxGlyphLength_, - polyData->GetOutput(), - surfaceActor_, - renderer - ); - } - else - { - vtkSmartPointer cellToPoint; - - // CellData - Need a cell->point filter - if (smooth_ && !fieldInfo.hasPointData()) - { - cellToPoint = vtkSmartPointer::New(); - cellToPoint->SetInputData(multiPiece); - - polyData->SetInputConnection(cellToPoint->GetOutputPort()); - } - else - { - polyData->SetInputData(multiPiece); - } - polyData->Update(); - - - if (!smooth_) - { - addFeatureEdges(renderer, polyData); - } - - auto mapper = vtkSmartPointer::New(); - mapper->SetInputConnection(polyData->GetOutputPort()); - - setField - ( - position, - fieldName_, - ( - smooth_ - ? FieldAssociation::POINT_DATA - : FieldAssociation(fieldInfo.association_) - ), - mapper, - renderer - ); - - surfaceActor_->SetMapper(mapper); - - setRepresentation(surfaceActor_); - - renderer->AddActor(surfaceActor_); - } - } - - return true; -} - - -bool Foam::functionObjects::runTimePostPro::functionObjectSurface:: -addGeometryFromFile -( - const scalar position, - vtkRenderer* renderer -) -{ - if (!visible_) - { - return false; - } - - vtkSmartPointer polyData; - - bool good = true; - - // File reading is serial (master only) - if (Pstream::master()) - { - fileName fName = getFileName("file", fieldName_); - - if (fName.size()) - { - polyData = getPolyDataFile(fName); - - if (!polyData || polyData->GetNumberOfPoints() == 0) - { - good = false; - - WarningInFunction - << "Could not read "<< fName << nl - << "Only VTK (.vtp, .vtk) files are supported" - << endl; - } - else - { - DebugInfo - << " Resolved surface " << fName << endl; - } - } - else - { - good = false; - - WarningInFunction - << "Unable to read file name from function object " - << functionObjectName_ << " for field " << fieldName_ - << ". Surface will not be processed" - << endl; - } - } - - reduce(good, andOp()); - - if (!good) - { - return false; - } - - // Only render on master - if (!renderer || !Pstream::master()) - { - return true; - } - - fieldSummary fieldInfo = queryFieldSummary(fieldName_, polyData); - // No reduction (serial) - - DebugInfo - << " Field " << fieldName_ << ' ' << fieldInfo.info() << endl; - - - // Render - - if (representation_ == rtGlyph) - { - addGlyphs - ( - position, - fieldName_, fieldInfo, // scaling - fieldName_, fieldInfo, // colouring - maxGlyphLength_, - polyData, - surfaceActor_, - renderer - ); - } - else - { - addFeatureEdges(renderer, polyData); - - auto mapper = vtkSmartPointer::New(); - mapper->SetInputData(polyData); - - setField - ( - position, - fieldName_, - queryFieldAssociation(fieldName_, polyData), - mapper, - renderer - ); - - surfaceActor_->SetMapper(mapper); - - setRepresentation(surfaceActor_); - - renderer->AddActor(surfaceActor_); - } - - return true; -} - - -void Foam::functionObjects::runTimePostPro::functionObjectSurface:: -addGeometryToScene -( - const scalar position, - vtkRenderer* renderer -) -{ - if (!visible_) - { - return; - } - - if (liveObject_) - { - // Live source - if (addGeometry(position, renderer)) - { - return; - } - - WarningInFunction - << "No functionObject live source, or is empty: " - << functionObjectName_ - << " ... attempting with file source" - << endl; - } - else - { - DebugInfo - << "Using file source only" << nl; - } - - // File source - addGeometryFromFile(position, renderer); -} - - -bool Foam::functionObjects::runTimePostPro::functionObjectSurface::clear() -{ - if (functionObjectBase::clear()) - { - // Even for a "live" data source we allow file cleanup - // (eg, from a previous run, etc) - return removeFile("file", fieldName_); - } - - return false; -} - - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectSurface.H b/src/functionObjects/graphics/runTimePostProcessing/functionObjectSurface.H deleted file mode 100644 index 8b162789e4..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectSurface.H +++ /dev/null @@ -1,146 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2015-2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::functionObjects::runTimePostPro::functionObjectSurface - -Description - Visualisation of surface data from function object output, - typically the result of a prior sampled surfaces operation. - - Operates in a "live" mode, in which the previously sampled surfaces - are retrieved from the functionObject registry. - Or in the traditional file-based mode, in which the sampling is used - to generate a file and its name is retrieved from the functionObject - properties. - - File-based import is restricted to "vtk" and "vtp" formats. - - Dictionary controls - \table - Property | Description | Required | Default - type | The type: functionObjectSurface | yes | - \endtable - -SourceFiles - functionObjectfunctionObjectSurface.C - -\*---------------------------------------------------------------------------*/ - -#ifndef functionObjects_runTimePostPro_functionObjectSurface_H -#define functionObjects_runTimePostPro_functionObjectSurface_H - -#include "geometrySurface.H" -#include "functionObjectBase.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ -namespace runTimePostPro -{ - -/*---------------------------------------------------------------------------*\ - Class functionObjectSurface Declaration -\*---------------------------------------------------------------------------*/ - -class functionObjectSurface -: - public geometrySurface, - public functionObjectBase -{ -protected: - - // Protected Member Functions - - //- No copy construct - functionObjectSurface(const functionObjectSurface&) = delete; - - //- No copy assignment - void operator=(const functionObjectSurface&) = delete; - - -public: - - //- Run-time type information - TypeNameNoDebug("functionObjectSurface"); - - - // Constructors - - //- Construct from dictionary - functionObjectSurface - ( - const runTimePostProcessing& parent, - const dictionary& dict, - const HashPtrTable>& colours - ); - - - //- Destructor - virtual ~functionObjectSurface() = default; - - - // Member Functions - - //- Add functionObjectSurface to scene (using simulation source) - bool addGeometry - ( - const scalar position, - vtkRenderer* renderer - ); - - //- Add functionObjectSurface to scene (using file source) - bool addGeometryFromFile - ( - const scalar position, - vtkRenderer* renderer - ); - - //- Add functionObjectSurface(s) to scene - virtual void addGeometryToScene - ( - const scalar position, - vtkRenderer* renderer - ); - - //- Clear files used to create the object(s) - virtual bool clear(); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace runTimePostPro -} // End namespace functionObjects -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/geometryBase.C b/src/functionObjects/graphics/runTimePostProcessing/geometryBase.C deleted file mode 100644 index cca1287cb0..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/geometryBase.C +++ /dev/null @@ -1,177 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2015-2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "geometryBase.H" -#include "runTimePostProcessing.H" -#include "Constant.H" - -// VTK includes -#include "vtkActor.h" -#include "vtkProperty.h" - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ -namespace runTimePostPro -{ - defineDebugSwitchWithName(geometryBase, "runTimePostPro::geometryBase", 0); -} -} -} - -const Foam::Enum -< - Foam::functionObjects::runTimePostPro::geometryBase::renderModeType -> -Foam::functionObjects::runTimePostPro::geometryBase::renderModeTypeNames -({ - { renderModeType::rmFlat, "flat" }, - { renderModeType::rmGouraud, "gouraud" }, - { renderModeType::rmPhong, "phong" }, -}); - - -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -void Foam::functionObjects::runTimePostPro::geometryBase::initialiseActor -( - vtkActor* actor -) const -{ - actor->GetProperty()->SetSpecular(0); - actor->GetProperty()->SetSpecularPower(20); - - switch (renderMode_) - { - case rmFlat: - { - actor->GetProperty()->SetInterpolationToFlat(); - break; - } - case rmGouraud: - { - actor->GetProperty()->SetInterpolationToGouraud(); - break; - } - case rmPhong: - { - actor->GetProperty()->SetInterpolationToPhong(); - break; - } - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostPro::geometryBase::geometryBase -( - const runTimePostProcessing& parent, - const dictionary& dict, - const HashPtrTable>& colours -) -: - parent_(parent), - name_(dict.dictName()), - visible_(dict.getOrDefault("visible", true)), - parallel_ - ( - // User input can only disable parallel here - #ifdef FOAM_USING_VTK_MPI - Pstream::parRun() && parent.parallel() - && dict.getOrDefault("parallel", parent.parallel()) - #else - false - #endif - ), - renderMode_ - ( - renderModeTypeNames.getOrDefault("renderMode", dict, rmGouraud) - ), - opacity_(nullptr), - colours_(colours) -{ - if (dict.found("opacity")) - { - opacity_.reset(Function1::New("opacity", dict)); - } - else - { - opacity_.reset(new Function1Types::Constant("opacity", 1.0)); - } -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostPro::geometryBase::~geometryBase() -{} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -const Foam::functionObjects::runTimePostProcessing& -Foam::functionObjects::runTimePostPro::geometryBase::parent() const -{ - return parent_; -} - - -bool Foam::functionObjects::runTimePostPro::geometryBase:: -needsCollective() const -{ - return Pstream::parRun() && (!parent_.parallel() || !parallel_); -} - - -const Foam::word& -Foam::functionObjects::runTimePostPro::geometryBase::name() const -{ - return name_; -} - - -Foam::scalar Foam::functionObjects::runTimePostPro::geometryBase::opacity -( - const scalar position -) const -{ - return opacity_->value(position); -} - - -const Foam::HashPtrTable, Foam::word>& -Foam::functionObjects::runTimePostPro::geometryBase::colours() const -{ - return colours_; -} - - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/geometryBase.H b/src/functionObjects/graphics/runTimePostProcessing/geometryBase.H deleted file mode 100644 index 46aa99bc12..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/geometryBase.H +++ /dev/null @@ -1,211 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2015-2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::functionObjects::runTimePostPro::geometryBase - -Description - Base class for surface, text handling etc. - - Dictionary controls - \table - Property | Description | Required | Default - visible | Display the object | no | yes - renderMode | Shading (flat/gouraud/phong) | no | gouraud - opacity | Object opacity | no | 1.0 - parallel | Allow parallel rendering | no | true - \endtable - -SourceFiles - geometryBase.C - -\*---------------------------------------------------------------------------*/ - -#ifndef functionObjects_runTimePostPro_geometryBase_H -#define functionObjects_runTimePostPro_geometryBase_H - -#include "dictionary.H" -#include "vector.H" -#include "Function1.H" -#include "HashPtrTable.H" -#include "Enum.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// Forward Declarations (VTK) -class vtkRenderer; -class vtkActor; - -namespace Foam -{ -namespace functionObjects -{ - -// Forward Declarations -class runTimePostProcessing; - -namespace runTimePostPro -{ - - -/*---------------------------------------------------------------------------*\ - Class geometryBase Declaration -\*---------------------------------------------------------------------------*/ - -class geometryBase -{ -public: - - // Public Enumerations - - //- Surface shading types - enum renderModeType - { - rmFlat, //!< Flat shading - rmGouraud, //!< Gouraud shading - rmPhong //!< Phong shading - }; - - //- Names for surface shading types - static const Enum renderModeTypeNames; - - -protected: - - // Protected data - - //- Reference to the parent function object - const runTimePostProcessing& parent_; - - //- The surface name - word name_; - - //- Visible flag - bool visible_; - - //- Allow parallel rendering - bool parallel_; - - //- Render mode - renderModeType renderMode_; - - //- Opacity - autoPtr> opacity_; - - //- Reference to the colours - const HashPtrTable>& colours_; - - - // Protected Functions - - //- Initialise actor - void initialiseActor(vtkActor* actor) const; - - //- No copy construct - geometryBase(const geometryBase&) = delete; - - //- No copy assignment - void operator=(const geometryBase&) = delete; - - -public: - - //- Debug switch - static int debug; - - // Constructors - - //- Construct from dictionary - geometryBase - ( - const runTimePostProcessing& parent_, - const dictionary& dict, - const HashPtrTable>& colours - ); - - - //- Destructor - virtual ~geometryBase(); - - - // Member Functions - - //- Return the reference to the parent function object - const runTimePostProcessing& parent() const; - - //- May need to gather geometry parts to render on single-processor - // True when OpenFOAM is running in parallel but VTK is not. - bool needsCollective() const; - - //- Return the name - const word& name() const; - - //- Return the visible flag - bool visible() const - { - return visible_; - } - - //- Allow parallel rendering - bool parallel() const - { - return parallel_; - } - - //- Return the opacity - scalar opacity(const scalar position) const; - - //- Return reference to the colours - const HashPtrTable>& colours() const; - - - // Scene Interaction - - //- Add geometry to scene - virtual void addGeometryToScene - ( - const scalar position, - vtkRenderer* renderer - ) = 0; - - //- Update the actors - virtual void updateActors(const scalar position) = 0; - - //- Clear any files used to create the object(s) - virtual bool clear() = 0; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace runTimePostPro -} // End namespace functionObjects -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/geometryCloud.C b/src/functionObjects/graphics/runTimePostProcessing/geometryCloud.C deleted file mode 100644 index df30f1b690..0000000000 --- a/src/functionObjects/graphics/runTimePostProcessing/geometryCloud.C +++ /dev/null @@ -1,268 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -// OpenFOAM includes -#include "geometryCloud.H" -#include "cloud.H" -#include "fvMesh.H" -#include "runTimePostProcessing.H" -#include "addToRunTimeSelectionTable.H" - -// VTK includes -#include "vtkActor.h" -#include "vtkCompositeDataGeometryFilter.h" -#include "vtkCompositeDataSet.h" -#include "vtkCompositePolyDataMapper.h" -#include "vtkPolyData.h" -#include "vtkPolyDataMapper.h" -#include "vtkProperty.h" -#include "vtkRenderer.h" -#include "vtkSmartPointer.h" - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionObjects -{ -namespace runTimePostPro -{ - defineTypeName(geometryCloud); - addToRunTimeSelectionTable(pointData, geometryCloud, dictionary); -} -} -} - - -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -bool Foam::functionObjects::runTimePostPro::geometryCloud::addCloudField -( - vtkMultiPieceDataSet* multiPiece, - const objectRegistry& obrTmp, - const word& fieldName -) const -{ - const regIOobject* ioptr = obrTmp.cfindObject(fieldName); - - return (multiPiece) && - ( - addCloudField