diff --git a/applications/utilities/postProcessing/graphics/PVReaders/Allwclean b/applications/utilities/postProcessing/graphics/PVReaders/Allwclean deleted file mode 100755 index 131482f6e7c7d6b1ce367cbe26c931a1dd0f46ca..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/Allwclean +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -cd "${0%/*}" || exit # Run from this directory -. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions -. ${WM_PROJECT_DIR:?}/wmake/scripts/paraviewFunctions # For API info -# ----------------------------------------------------------------------------- - -get_pvplugin_api || echo "No ParaView plugin information found" 1>&2 - -# Cleanup libraries -wclean libso common -wclean libso blockMeshReader/library -wclean libso foamReader/library - -# Cleanup client-server and/or combined plugins -rm -f $FOAM_LIBBIN/libPVblockMeshReader* 2>/dev/null -rm -f $FOAM_LIBBIN/libPVFoamReader* 2>/dev/null - -# Cleanup generated files - remove entire top-level -removeObjectDir $PWD - -#------------------------------------------------------------------------------ diff --git a/applications/utilities/postProcessing/graphics/PVReaders/Allwmake b/applications/utilities/postProcessing/graphics/PVReaders/Allwmake deleted file mode 100755 index 6dbaa022247a9c663c09b83e72f1c662317d7a9b..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/Allwmake +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -cd "${0%/*}" || exit # Run from this directory -export WM_CONTINUE_ON_ERROR=true # Optional unit -. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments -. ${WM_PROJECT_DIR:?}/wmake/scripts/paraviewFunctions # CMake, PV functions -# ----------------------------------------------------------------------------- - -warnIncomplete() -{ - echo - echo " WARNING: incomplete build of ParaView plugin: $@" - echo -} - -if have_pvplugin_support -then -( - wmakeLibPv common - wmakeLibPv blockMeshReader/library - wmakeLibPv foamReader/library - - unset cmakeOpts cmakeType - - if [ "$targetType" != objects ] - then - case "$PARAVIEW_API" in - (5.[0-6]) - cmakeType="cmakePv" - ;; - (*) - # cmakeType="cmakePvInstall" - warnIncomplete "(unknown/unsupported version: $PARAVIEW_API)" - ;; - esac - fi - - if [ -n "$cmakeType" ] - then - "$cmakeType" $PWD/blockMeshReader "$cmakeOpts" || warnIncomplete "blockMesh" - "$cmakeType" $PWD/foamReader "$cmakeOpts" || warnIncomplete "OpenFOAM" - fi -) -fi - -#------------------------------------------------------------------------------ diff --git a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/CMakeLists-OpenFOAM.txt b/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/CMakeLists-OpenFOAM.txt deleted file mode 100644 index 15c675adecbd4663176d8c1d86adc8534959cb51..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/CMakeLists-OpenFOAM.txt +++ /dev/null @@ -1,26 +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 - -std=c++11 -) - -#----------------------------------------------------------------------------- diff --git a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/CMakeLists-Project.txt b/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/CMakeLists-Project.txt deleted file mode 100644 index a86eb41adfc9c6bc14c417fa4484e60616a65750..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/CMakeLists-Project.txt +++ /dev/null @@ -1,61 +0,0 @@ -#----------------------------------------------------------------------------- -# OpenFOAM blockMeshDict reader plugin for ParaView GUI (pre-5.7) - -link_directories( - $ENV{FOAM_LIBBIN} -) - -include_directories( - ${LIB_SRC}/OpenFOAM/include - ${LIB_SRC}/OpenFOAM/lnInclude - ${LIB_SRC}/OSspecific/${WM_OSTYPE}/lnInclude - ${LIB_SRC}/meshing/blockMesh/lnInclude - ${PROJECT_SOURCE_DIR}/../common - ${PROJECT_SOURCE_DIR}/library - ${PROJECT_SOURCE_DIR}/plugin - ${PROJECT_SOURCE_DIR}/plugin/reader -) - -set(OPENFOAM_LIBNAMES - OpenFOAM - blockMesh -) - -# Set output library destination to plugin directory -set( - LIBRARY_OUTPUT_PATH $ENV{FOAM_PV_PLUGIN_LIBBIN} - CACHE INTERNAL - "Single output directory for building all libraries." -) - - -qt5_wrap_cpp(MOC_SRCS plugin/pqFoamBlockMeshControls.h) - -add_paraview_property_group_widget(IFACES0 IFACES0_SRCS - TYPE "openfoam_blockMesh_general_controls" - CLASS_NAME pqFoamBlockMeshControls -) - -add_paraview_plugin( - PVblockMeshReader_SM "${foam_api}" - SERVER_MANAGER_XML - plugin/PVblockMeshReader_SM.xml - SERVER_MANAGER_SOURCES - plugin/reader/vtkPVblockMeshReader.cxx - GUI_INTERFACES - ${IFACES0} - SOURCES - ${IFACES0_SRCS} - ${MOC_SRCS} - plugin/pqFoamBlockMeshControls.cxx -) - -target_link_libraries( - PVblockMeshReader_SM - LINK_PUBLIC - vtkPVFoamCommon${foamPvLibQualifier} - vtkPVblockMesh${foamPvLibQualifier} - ${OPENFOAM_LIBNAMES} -) - -#----------------------------------------------------------------------------- diff --git a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/CMakeLists-Project57.txt b/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/CMakeLists-Project57.txt deleted file mode 100644 index 718a5318de5b489510b773a0795ac2aaf3a82f3f..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/CMakeLists-Project57.txt +++ /dev/null @@ -1,6 +0,0 @@ -#----------------------------------------------------------------------------- -# OpenFOAM blockMeshDict reader plugin for ParaView GUI (5.7+) - -message(FATAL_ERROR "paraview-${pv_api} not yet supported") - -#----------------------------------------------------------------------------- diff --git a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/CMakeLists.txt deleted file mode 100644 index 77d67c73daa4ccbd8d77017218185be50a706351..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/CMakeLists.txt +++ /dev/null @@ -1,62 +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 - -find_package(ParaView REQUIRED) - -# Qualify OpenFOAM/ParaView libraries with -pvMAJ.MIN -# The pv_api can also be used for paraview-MAJ.MIN -if (DEFINED ENV{PARAVIEW_API}) - set(pv_api "$ENV{PARAVIEW_API}") -else() - if (${ParaView_VERSION} GREATER_EQUAL 5.7) - string(REGEX MATCH [0-9]+[.][0-9]+ pv_api ${ParaView_VERSION}) - message("The PARAVIEW_API env was unset, " - "extracted value from version=" - "${ParaView_VERSION} is ${pv_api}") - else() - set(pv_api "${PARAVIEW_VERSION_MAJOR}.${ParaView_VERSION_MINOR}") - message("The PARAVIEW_API env was unset, " - "assembled from maj/min=" - "${ParaView_VERSION_MAJOR}/${ParaView_VERSION_MINOR} is ${pv_api}") - endif() -endif() - -# Pass through the OpenFOAM API value to the reader -set(foam_api "$ENV{FOAM_API}") -if (NOT "${foam_api}") - set(foam_api "2.0") -endif() - -set(foamPvLibQualifier "-pv${pv_api}") - -#----------------------------------------------------------------------------- - -message("================") -message("Using ParaView = $ENV{ParaView_DIR}") -message("OpenFOAM api = ${foam_api}, libs = ${foamPvLibQualifier}") - -#----------------------------------------------------------------------------- - -include(CMakeLists-OpenFOAM.txt) - -if (${ParaView_VERSION} GREATER_EQUAL 5.7) - message("================") - include(CMakeLists-Project57.txt) -else() - message("================") - include(${PARAVIEW_USE_FILE}) - include(CMakeLists-Project.txt) -endif() - -#----------------------------------------------------------------------------- diff --git a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/Make/files b/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/Make/files deleted file mode 100644 index 12405a2ef230b7bca2c043a9aa0553446c82426b..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/Make/files +++ /dev/null @@ -1,4 +0,0 @@ -vtkPVblockMesh.C -vtkPVblockMeshConvert.C - -LIB = $(FOAM_LIBBIN)/libvtkPVblockMesh-pv${PARAVIEW_API} diff --git a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/Make/options b/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/Make/options deleted file mode 100644 index a3bafe7090e5eff76b25051aa524f426e34d4777..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/Make/options +++ /dev/null @@ -1,16 +0,0 @@ -EXE_INC = \ - ${c++LESSWARN} \ - -I$(LIB_SRC)/fileFormats/lnInclude \ - -I$(LIB_SRC)/conversion/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/mesh/blockMesh/lnInclude \ - -I$(PARAVIEW_INC_DIR) \ - -I$(PARAVIEW_INC_DIR)/vtkkwiml \ - -I../../common \ - -I../plugin/reader - -LIB_LIBS = \ - -lmeshTools \ - -lblockMesh \ - -L$(FOAM_LIBBIN) -lvtkPVFoamCommon-pv${PARAVIEW_API} \ - $(GLIBS) diff --git a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/vtkPVblockMesh.C b/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/vtkPVblockMesh.C deleted file mode 100644 index 1f0d6163513f9a43ec17613ab9522e92e506787f..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/vtkPVblockMesh.C +++ /dev/null @@ -1,563 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "vtkPVblockMesh.H" -#include "vtkPVblockMeshReader.h" - -// OpenFOAM includes -#include "blockMesh.H" -#include "blockMeshTools.H" -#include "foamVersion.H" -#include "Time.H" -#include "patchZones.H" -#include "StringStream.H" - -// VTK includes -#include "vtkDataArraySelection.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkRenderer.h" -#include "vtkTextActor.h" -#include "vtkTextProperty.h" -#include "vtkSmartPointer.h" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(vtkPVblockMesh, 0); -} - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -namespace Foam -{ - // file-scope - //- Create a text actor - static vtkSmartPointer<vtkTextActor> createTextActor - ( - const std::string& s, - const Foam::point& pt - ) - { - auto txt = vtkSmartPointer<vtkTextActor>::New(); - - txt->SetInput(s.c_str()); - - // Set text properties - vtkTextProperty* tprop = txt->GetTextProperty(); - tprop->SetFontFamilyToArial(); - tprop->BoldOn(); - tprop->ShadowOff(); - tprop->SetLineSpacing(1.0); - tprop->SetFontSize(14); - tprop->SetColor(1.0, 0.0, 1.0); - tprop->SetJustificationToCentered(); - - txt->GetPositionCoordinate()->SetCoordinateSystemToWorld(); - txt->GetPositionCoordinate()->SetValue(pt.x(), pt.y(), pt.z()); - - return txt; - } -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::vtkPVblockMesh::resetCounters() -{ - // Reset mesh part ids and sizes - rangeBlocks_.reset(); - rangeEdges_.reset(); - rangeCorners_.reset(); -} - - -void Foam::vtkPVblockMesh::updateInfoBlocks -( - vtkDataArraySelection* select -) -{ - DebugInfo - << "<beg> updateInfoBlocks" - << " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl; - - rangeBlocks_.reset(select->GetNumberOfArrays()); - - const blockMesh& blkMesh = *meshPtr_; - - const int nBlocks = blkMesh.size(); - for (int blockI = 0; blockI < nBlocks; ++blockI) - { - const blockDescriptor& blockDef = blkMesh[blockI]; - - // Display either blockI as a number or with its name - // (looked up from blockMeshDict) - OStringStream ostr; - blockDescriptor::write(ostr, blockI, blkMesh.meshDict()); - - // append the (optional) zone name - if (!blockDef.zoneName().empty()) - { - ostr << " - " << blockDef.zoneName(); - } - - // Add "blockId" or "blockId - zoneName" to GUI list - select->AddArray(ostr.str().c_str()); - ++rangeBlocks_; - } - - DebugInfo << "<end> updateInfoBlocks" << endl; -} - - -void Foam::vtkPVblockMesh::updateInfoEdges -( - vtkDataArraySelection* select -) -{ - DebugInfo - << "<beg> updateInfoEdges" - << " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl; - - rangeEdges_.reset(select->GetNumberOfArrays()); - - const blockMesh& blkMesh = *meshPtr_; - const blockEdgeList& edges = blkMesh.edges(); - - forAll(edges, edgeI) - { - OStringStream ostr; - blockVertex::write(ostr, edges[edgeI].start(), blkMesh.meshDict()); - ostr<< ":"; - blockVertex::write(ostr, edges[edgeI].end(), blkMesh.meshDict()); - ostr << " - " << edges[edgeI].type(); - - // Add "beg:end - type" to GUI list - select->AddArray(ostr.str().c_str()); - ++rangeEdges_; - } - - DebugInfo << "<end> updateInfoEdges" << endl; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::vtkPVblockMesh::vtkPVblockMesh -( - const char* const FileName, - vtkPVblockMeshReader* reader -) -: - reader_(reader), - dbPtr_(nullptr), - meshPtr_(nullptr), - meshRegion_(polyMesh::defaultRegion), - meshDir_(polyMesh::meshSubDir), - rangeBlocks_("block"), - rangeEdges_("edges"), - rangeCorners_("corners") -{ - DebugInfo << "vtkPVblockMesh - " << FileName << endl; - - // avoid argList and get rootPath/caseName directly from the file - fileName fullCasePath(fileName(FileName).path()); - - if (!isDir(fullCasePath)) - { - return; - } - if (fullCasePath == ".") - { - fullCasePath = cwd(); - } - - // OPENFOAM API - setEnv("FOAM_API", std::to_string(foamVersion::api), true); - - // The name of the executable, unless already present in the environment - setEnv("FOAM_EXECUTABLE", "paraview", false); - - // Set the case as an environment variable - some BCs might use this - if (fullCasePath.name().find("processor", 0) == 0) - { - const fileName globalCase = fullCasePath.path(); - - setEnv("FOAM_CASE", globalCase, true); - setEnv("FOAM_CASENAME", globalCase.name(), true); - } - else - { - setEnv("FOAM_CASE", fullCasePath, true); - setEnv("FOAM_CASENAME", fullCasePath.name(), true); - } - - // look for 'case{region}.OpenFOAM' - // could be stringent and insist the prefix match the directory name... - // Note: cannot use fileName::name() due to the embedded '{}' - string caseName(fileName(FileName).lessExt()); - string::size_type beg = caseName.find_last_of("/{"); - string::size_type end = caseName.find('}', beg); - - if - ( - beg != string::npos && caseName[beg] == '{' - && end != string::npos && end == caseName.size()-1 - ) - { - meshRegion_ = caseName.substr(beg+1, end-beg-1); - - // some safety - if (meshRegion_.empty()) - { - meshRegion_ = polyMesh::defaultRegion; - } - - if (meshRegion_ != polyMesh::defaultRegion) - { - meshDir_ = meshRegion_/polyMesh::meshSubDir; - } - } - - DebugInfo - << "fullCasePath=" << fullCasePath << nl - << "FOAM_CASE=" << getEnv("FOAM_CASE") << nl - << "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << endl; - - // Create time object - dbPtr_.reset - ( - new Time - ( - Time::controlDictName, - fileName(fullCasePath.path()), - fileName(fullCasePath.name()) - ) - ); - - dbPtr_().functionObjects().off(); - - updateInfo(); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::vtkPVblockMesh::~vtkPVblockMesh() -{ - DebugInfo << "~vtkPVblockMesh" << endl; - - delete meshPtr_; -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::vtkPVblockMesh::updateInfo() -{ - DebugInfo - << "<beg> updateInfo" - << " [meshPtr=" << (meshPtr_ ? "set" : "null") << "] " << endl; - - resetCounters(); - - vtkDataArraySelection* blockSelection = reader_->GetBlockSelection(); - vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection(); - - const bool firstTime = (!blockSelection->GetNumberOfArrays() && !meshPtr_); - - // Preserve the enabled selections if possible - HashSet<string> enabledParts; - HashSet<string> enabledEdges; - if (!firstTime) - { - enabledParts = getSelectedArraySet(blockSelection); - enabledEdges = getSelectedArraySet(edgeSelection); - } - - // Clear current mesh parts list - blockSelection->RemoveAllArrays(); - edgeSelection->RemoveAllArrays(); - - // need a blockMesh - updateFoamMesh(); - - // Update mesh parts list - updateInfoBlocks(blockSelection); - - // Update curved edges list - updateInfoEdges(edgeSelection); - - // Restore the enabled selections - if (!firstTime) - { - setSelectedArrayEntries(blockSelection, enabledParts); - setSelectedArrayEntries(edgeSelection, enabledEdges); - } - - DebugInfo << "<end> updateInfo" << endl; -} - - -void Foam::vtkPVblockMesh::updateFoamMesh() -{ - DebugInfo << "<beg> updateFoamMesh" << endl; - - // Check to see if the OpenFOAM mesh has been created - if (!meshPtr_) - { - if (debug) - { - Info<< "Creating blockMesh at time=" << dbPtr_().timeName() - << endl; - } - - // Set path for the blockMeshDict - const word dictName("blockMeshDict"); - fileName dictPath(dbPtr_().system()/dictName); - - // Check if dictionary is present in the constant directory - if - ( - exists - ( - dbPtr_().path()/dbPtr_().constant() - /polyMesh::meshSubDir/dictName - ) - ) - { - dictPath = dbPtr_().constant()/polyMesh::meshSubDir/dictName; - } - - // Store dictionary since is used as database inside blockMesh class - // for names of vertices and blocks - IOdictionary* meshDictPtr = new IOdictionary - ( - IOobject - ( - dictPath, - dbPtr_(), - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE, - true - ) - ); - meshDictPtr->store(); - - meshPtr_ = new blockMesh(*meshDictPtr, meshRegion_); - } - - - DebugInfo << "<end> updateFoamMesh" << endl; -} - - -void Foam::vtkPVblockMesh::Update -( - vtkMultiBlockDataSet* output -) -{ - reader_->UpdateProgress(0.1); - - // Update the OpenFOAM mesh - updateFoamMesh(); - reader_->UpdateProgress(0.5); - - // Convert mesh elemente - int blockNo = 0; - - convertMeshCorners(output, blockNo); - convertMeshBlocks(output, blockNo); - convertMeshEdges(output, blockNo); - - reader_->UpdateProgress(0.8); -} - - -void Foam::vtkPVblockMesh::UpdateFinalize() -{ - reader_->UpdateProgress(1.0); -} - - -void Foam::vtkPVblockMesh::renderPatchNames -( - vtkRenderer* renderer, - const bool show -) -{ - // always remove old actors first - forAll(patchTextActors_, actori) - { - renderer->RemoveViewProp(patchTextActors_[actori]); - } - patchTextActors_.clear(); - - // the number of text actors - label nActors = 0; - - if (show && meshPtr_) - { - const blockMesh& blkMesh = *meshPtr_; - const dictionary& meshDescription = blkMesh.meshDict(); - const pointField& cornerPts = blkMesh.vertices(); - const scalar scaleFactor = blkMesh.scaleFactor(); - - if (!meshDescription.found("boundary")) - { - return; - } - - // 8 sides per block is plenty - patchTextActors_.setSize(8*blkMesh.size()); - - // Collect all variables - dictionary varDict(meshDescription.subOrEmptyDict("namedVertices")); - varDict.merge(meshDescription.subOrEmptyDict("namedBlocks")); - - // Read like boundary file - const PtrList<entry> patchesInfo(meshDescription.lookup("boundary")); - - forAll(patchesInfo, patchi) - { - const entry& patchInfo = patchesInfo[patchi]; - - if (!patchInfo.isDict()) - { - IOWarningInFunction(meshDescription) - << "Entry " << patchInfo << " in boundary section is not a" - << " valid dictionary." - << endl; - break; - } - - const word& patchName = patchInfo.keyword(); - - // Read block faces - faceList patchFaces = blockMeshTools::read<face> - ( - patchInfo.dict().lookup("faces"), - varDict - ); - - forAll(patchFaces, facei) - { - const face& f = patchFaces[facei]; - - // Into a list for later removal - patchTextActors_[nActors++] = createTextActor - ( - patchName, - f.centre(cornerPts) * scaleFactor - ); - - if (nActors == patchTextActors_.size()) - { - // hit max allocated space - bail out - break; - } - } - - if (nActors == patchTextActors_.size()) - { - // hit max allocated space - bail out - break; - } - } - - patchTextActors_.setSize(nActors); - } - - // Add text to each renderer - forAll(patchTextActors_, actori) - { - renderer->AddViewProp(patchTextActors_[actori]); - } -} - - -void Foam::vtkPVblockMesh::renderPointNumbers -( - vtkRenderer* renderer, - const bool show -) -{ - // always remove old actors first - - forAll(pointTextActors_, actori) - { - renderer->RemoveViewProp(pointTextActors_[actori]); - } - pointTextActors_.clear(); - - if (show && meshPtr_) - { - const blockMesh& blkMesh = *meshPtr_; - const pointField& cornerPts = blkMesh.vertices(); - const scalar scaleFactor = blkMesh.scaleFactor(); - - pointTextActors_.setSize(cornerPts.size()); - forAll(cornerPts, pointi) - { - // Display either pointi as a number or with its name - // (looked up from blockMeshDict) - OStringStream os; - blockVertex::write(os, pointi, blkMesh.meshDict()); - - // Into a list for later removal - pointTextActors_[pointi] = createTextActor - ( - os.str(), - cornerPts[pointi]*scaleFactor - ); - } - } - - // Add text to each renderer - forAll(pointTextActors_, actori) - { - renderer->AddViewProp(pointTextActors_[actori]); - } -} - - -void Foam::vtkPVblockMesh::PrintSelf(ostream& os, vtkIndent indent) const -{ -#if 0 - os << indent << "Number of nodes: " - << (meshPtr_ ? meshPtr_->nPoints() : 0) << "\n"; - - os << indent << "Number of cells: " - << (meshPtr_ ? meshPtr_->nCells() : 0) << "\n"; - - os << indent << "Number of available time steps: " - << (dbPtr_.valid() ? dbPtr_().times().size() : 0) << endl; -#endif -} - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/vtkPVblockMesh.H b/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/vtkPVblockMesh.H deleted file mode 100644 index 58a7a7623cdb81a795aa3b08d5dd457d2d491d13..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/vtkPVblockMesh.H +++ /dev/null @@ -1,208 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. - -Class - Foam::vtkPVblockMesh - -Description - The backend for the vtkPVblockMeshReader reader module - - providing a paraview reader interface for OpenFOAM blockMesh. - - The block reader module can assist when creating a blockMeshDict - for use with the blockMesh utility. As well as blocks, it can be - used to visualize edges,corners and patch names. - - There is no native VTK equivalent for this functionality. - -SourceFiles - vtkPVblockMesh.C - vtkPVblockMeshConvert.C - - // Needed by VTK: - vtkDataArrayTemplateImplicit.txx - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkPVblockMesh_H -#define vtkPVblockMesh_H - -#include "foamPvCore.H" - -// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * // - -class vtkDataArraySelection; -class vtkDataSet; -class vtkPoints; -class vtkPVblockMeshReader; -class vtkRenderer; -class vtkTextActor; -class vtkMultiBlockDataSet; -class vtkPolyData; -class vtkUnstructuredGrid; -class vtkIndent; - -template<class T> class vtkSmartPointer; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// OpenFOAM class forward declarations -class argList; -class Time; -class blockMesh; - -template<class Type> class List; - -/*---------------------------------------------------------------------------*\ - Class vtkPVblockMesh Declaration -\*---------------------------------------------------------------------------*/ - -class vtkPVblockMesh -: - private foamPvCore -{ - // Private Data - - //- Access to the controlling vtkPVblockMeshReader - vtkPVblockMeshReader* reader_; - - //- OpenFOAM time control - autoPtr<Time> dbPtr_; - - //- OpenFOAM mesh - blockMesh* meshPtr_; - - //- The mesh region - word meshRegion_; - - //- The mesh directory for the region - fileName meshDir_; - - //- First instance and size of bleckMesh blocks - // used to index into blockStatus_ - arrayRange rangeBlocks_; - - //- First instance and size of CurvedEdges (only partially used) - arrayRange rangeEdges_; - - //- First instance and size of block corners (only partially used) - arrayRange rangeCorners_; - - //- List of patch names for rendering to window - List<vtkSmartPointer<vtkTextActor>> patchTextActors_; - - //- List of point numbers for rendering to window - List<vtkSmartPointer<vtkTextActor>> pointTextActors_; - - - // Private Member Functions - - //- Reset data counters - void resetCounters(); - - //- OpenFOAM mesh - void updateFoamMesh(); - - //- Internal block info - void updateInfoBlocks(vtkDataArraySelection* select); - - //- Block curved edges info - void updateInfoEdges(vtkDataArraySelection* select); - - //- Mesh blocks - void convertMeshBlocks(vtkMultiBlockDataSet*, int& blockNo); - - //- Mesh curved edges - void convertMeshEdges(vtkMultiBlockDataSet*, int& blockNo); - - //- Mesh corners - void convertMeshCorners(vtkMultiBlockDataSet*, int& blockNo); - - - //- No copy construct - vtkPVblockMesh(const vtkPVblockMesh&) = delete; - - //- No copy assignment - void operator=(const vtkPVblockMesh&) = delete; - - -public: - - //- Static data members - - ClassName("vtkPVblockMesh"); - - - // Constructors - - //- Construct from components - vtkPVblockMesh - ( - const char* const FileName, - vtkPVblockMeshReader* reader - ); - - - //- Destructor - ~vtkPVblockMesh(); - - - // Member Functions - - //- Update - void updateInfo(); - - void Update(vtkMultiBlockDataSet* output); - - //- Final part of Update(), after any last minute rendering. - void UpdateFinalize(); - - //- Add/remove patch names to/from the view - void renderPatchNames(vtkRenderer* renderer, const bool show); - - //- Add/remove point numbers to/from the view - void renderPointNumbers(vtkRenderer* renderer, const bool show); - - - // Access - - //- Debug information - void PrintSelf(ostream&, vtkIndent) const; - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/vtkPVblockMeshConvert.C b/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/vtkPVblockMeshConvert.C deleted file mode 100644 index b8ddd4e316b3a1b8502c85201030e1de4ec3141d..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/library/vtkPVblockMeshConvert.C +++ /dev/null @@ -1,265 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "vtkPVblockMesh.H" -#include "vtkPVblockMeshReader.h" - -// OpenFOAM includes -#include "blockMesh.H" -#include "Time.H" -#include "foamVtkTools.H" - -// VTK includes -#include "vtkCellArray.h" -#include "vtkDataArraySelection.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkPoints.h" -#include "vtkPolyData.h" -#include "vtkUnstructuredGrid.h" -#include "vtkSmartPointer.h" - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::vtkPVblockMesh::convertMeshBlocks -( - vtkMultiBlockDataSet* output, - int& blockNo -) -{ - DebugInfo << "<beg> convertMeshBlocks" << endl; - - const Map<string> blockStatus = getSelectedArrayMap - ( - reader_->GetBlockSelection() - ); - - arrayRange& range = rangeBlocks_; - range.block(blockNo); // set output block - label datasetNo = 0; // restart at dataset 0 - - const blockMesh& blkMesh = *meshPtr_; - const pointField blkPoints(blkMesh.vertices() * blkMesh.scaleFactor()); - - vtkIdType nodeIds[8]; // Space for VTK_HEXAHEDRON vertices - int blockId = -1; - for (auto partId : range) - { - ++blockId; // Increment first - if (!blockStatus.found(partId)) - { - continue; - } - const auto& longName = blockStatus[partId]; - - const blockDescriptor& blockDef = blkMesh[blockId]; - const labelList& blockLabels = blockDef.blockShape(); - - auto vtkpoints = vtkSmartPointer<vtkPoints>::New(); - vtkpoints->SetNumberOfPoints(blockLabels.size()); - - forAll(blockLabels, pointi) - { - vtkpoints->SetPoint - ( - pointi, - blkPoints[blockLabels[pointi]].v_ - ); - nodeIds[pointi] = pointi; - } - - auto vtkmesh = vtkSmartPointer<vtkUnstructuredGrid>::New(); - - vtkmesh->Allocate(1); - vtkmesh->InsertNextCell - ( - VTK_HEXAHEDRON, - 8, - nodeIds - ); - - vtkmesh->SetPoints(vtkpoints); - - addToBlock(output, vtkmesh, range, datasetNo, longName); - ++datasetNo; - } - - - // anything added? - if (datasetNo) - { - ++blockNo; - } - - DebugInfo << "<end> convertMeshBlocks" << endl; -} - - -void Foam::vtkPVblockMesh::convertMeshEdges -( - vtkMultiBlockDataSet* output, - int& blockNo -) -{ - const Map<string> edgeStatus = getSelectedArrayMap - ( - reader_->GetCurvedEdgesSelection() - ); - - arrayRange& range = rangeEdges_; - - range.block(blockNo); // set output block - label datasetNo = 0; // restart at dataset 0 - - const blockMesh& blkMesh = *meshPtr_; - const blockEdgeList& edges = blkMesh.edges(); - const scalar scaleFactor = blkMesh.scaleFactor(); - - int edgeId = -1; - for (auto partId : range) - { - ++edgeId; // Increment first - if (!edgeStatus.found(partId)) - { - continue; - } - const auto& longName = edgeStatus[partId]; - - // Search each block - forAll(blkMesh, blockId) - { - const blockDescriptor& blockDef = blkMesh[blockId]; - - edgeList blkEdges = blockDef.blockShape().edges(); - - // List of edge point and weighting factors - pointField edgesPoints[12]; - scalarList edgesWeights[12]; - blockDef.edgesPointsWeights(edgesPoints, edgesWeights); - - // find the corresponding edge within the block - label foundEdgeI = -1; - forAll(blkEdges, blkEdgeI) - { - if (edges[edgeId].compare(blkEdges[blkEdgeI])) - { - foundEdgeI = blkEdgeI; - break; - } - } - - if (foundEdgeI != -1) - { - const List<point>& edgePoints = edgesPoints[foundEdgeI]; - - auto vtkpoints = vtkSmartPointer<vtkPoints>::New(); - vtkpoints->SetNumberOfPoints(edgePoints.size()); - - vtkIdType pointIds[edgePoints.size()]; - forAll(edgePoints, pointi) - { - const point p = edgePoints[pointi] * scaleFactor; - - vtkpoints->SetPoint(pointi, p.v_); - pointIds[pointi] = pointi; - } - - auto vtkmesh = vtkSmartPointer<vtkPolyData>::New(); - - vtkmesh->Allocate(1); - vtkmesh->InsertNextCell - ( - VTK_POLY_LINE, - edgePoints.size(), - pointIds - ); - - vtkmesh->SetPoints(vtkpoints); - - addToBlock(output, vtkmesh, range, datasetNo, longName); - ++datasetNo; - - break; - } - } - } - - // anything added? - if (datasetNo) - { - ++blockNo; - } - - DebugInfo << "<end> convertMeshEdges" << endl; -} - - -void Foam::vtkPVblockMesh::convertMeshCorners -( - vtkMultiBlockDataSet* output, - int& blockNo -) -{ - arrayRange& range = rangeCorners_; - range.block(blockNo); // set output block - label datasetNo = 0; // restart at dataset 0 - - const pointField blkPoints(meshPtr_->vertices() * meshPtr_->scaleFactor()); - - DebugInfo << "<beg> " << FUNCTION_NAME << endl; - - if (true) // Or some flag or other condition - { - auto vtkpoints = vtkSmartPointer<vtkPoints>::New(); - vtkpoints->SetNumberOfPoints(blkPoints.size()); - - forAll(blkPoints, pointi) - { - vtkpoints->SetPoint(pointi, blkPoints[pointi].v_); - } - - auto vtkmesh = vtkSmartPointer<vtkPolyData>::New(); - - vtkmesh->SetPoints(vtkpoints); - vtkmesh->SetVerts(vtk::Tools::identityVertices(blkPoints.size())); - - addToBlock(output, vtkmesh, range, datasetNo, range.name()); - ++datasetNo; - } - - // anything added? - if (datasetNo) - { - ++blockNo; - } - - DebugInfo << "<end> " << FUNCTION_NAME << endl; -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/PVblockMeshReader_SM.xml b/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/PVblockMeshReader_SM.xml deleted file mode 100644 index e0110552eec69b4fba45e2129e9efd47010f4535..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/PVblockMeshReader_SM.xml +++ /dev/null @@ -1,122 +0,0 @@ -<ServerManagerConfiguration> - <ProxyGroup name="sources"> - <SourceProxy - name="PVblockMeshReader" - class="vtkPVblockMeshReader"> - - <!-- File name - compulsory --> - <StringVectorProperty animateable="0" - name="FileName" - command="SetFileName" - number_of_elements="1" - panel_visibility="never"> - <FileListDomain name="files"/> - <Documentation>The filename for the OpenFOAM blockMesh reader.</Documentation> - </StringVectorProperty> - - <!-- Refresh (push button) --> - <Property - name="Refresh" - command="Refresh" - panel_visibility="default"> - <Documentation>Rescan for updated blockMeshDict.</Documentation> - </Property> - -<!-- General Controls --> - - <!-- Show Patch Names (check-box) --> - <IntVectorProperty animateable="0" - name="ShowPatchNames" - label="Patch Names" - command="SetShowPatchNames" - default_values="0" - number_of_elements="1" - panel_visibility="default"> - <BooleanDomain name="bool"/> - <Documentation>Show patch names in render window.</Documentation> - </IntVectorProperty> - - <!-- Show Point Numbers (check-box) --> - <IntVectorProperty animateable="0" - name="ShowPointNumbers" - label="Point Numbers" - command="SetShowPointNumbers" - default_values="1" - number_of_elements="1" - panel_visibility="default"> - <BooleanDomain name="bool"/> - <Documentation>Show point numbers in render window.</Documentation> - </IntVectorProperty> - - <PropertyGroup - label="General Controls" - panel_widget="openfoam_blockMesh_general_controls"> - <Property name="Refresh"/> - <Property name="ShowPatchNames"/> - <Property name="ShowPointNumbers"/> - </PropertyGroup> - -<!-- Selections --> - - <!-- Available Blocks array --> - <StringVectorProperty - name="BlockArrayStatus" - information_only="1"> - <ArraySelectionInformationHelper attribute_name="Block"/> - </StringVectorProperty> - <StringVectorProperty animateable="0" - name="BlockStatus" - label="Blocks" - command="SetBlockArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="BlockArrayStatus"> - <ArraySelectionDomain name="array_list"> - <RequiredProperties> - <Property name="BlockArrayStatus" function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - <Documentation>The list of blocks</Documentation> - </StringVectorProperty> - - <!-- Available CurvedEdges array --> - <StringVectorProperty - name="CurvedEdgesArrayStatus" - information_only="1"> - <ArraySelectionInformationHelper attribute_name="CurvedEdges"/> - </StringVectorProperty> - <StringVectorProperty animateable="0" - name="CurvedEdgesStatus" - label="Curved Edges" - command="SetCurvedEdgesArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="CurvedEdgesArrayStatus"> - <ArraySelectionDomain name="array_list"> - <RequiredProperties> - <Property name="CurvedEdgesArrayStatus" function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - <Documentation>The list of curved edges</Documentation> - </StringVectorProperty> - - <PropertyGroup label="Selections"> - <Property name="BlockArrayStatus"/> - <Property name="BlockStatus"/> - <Property name="CurvedEdgesArrayStatus"/> - <Property name="CurvedEdgesStatus"/> - </PropertyGroup> - - <Hints> - <ReaderFactory - extensions="blockMesh" - file_description="OpenFOAM blockMesh"/> - </Hints> - - </SourceProxy> - </ProxyGroup> -</ServerManagerConfiguration> diff --git a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/pqFoamBlockMeshControls.cxx b/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/pqFoamBlockMeshControls.cxx deleted file mode 100644 index e5909353e26e61f801afee8b9c2740d1c15b5bf3..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/pqFoamBlockMeshControls.cxx +++ /dev/null @@ -1,255 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "pqFoamBlockMeshControls.h" - -#include <QCheckBox> -#include <QGridLayout> -#include <QPushButton> - -#include "pqPVApplicationCore.h" -#include "pqView.h" -#include "vtkSMDocumentation.h" -#include "vtkSMIntVectorProperty.h" -#include "vtkSMPropertyGroup.h" -#include "vtkSMSourceProxy.h" - - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -// file-scope -// Widget properties -static QWidget* setWidgetProperties -( - QWidget* widget, - vtkSMProperty* prop -) -{ - widget->setFocusPolicy(Qt::NoFocus); // avoid dotted border - - vtkSMDocumentation* doc = prop->GetDocumentation(); - if (doc) - { - const char* txt = doc->GetDescription(); - if (txt) - { - QString tip = QString(txt).simplified(); - if (tip.size()) - { - widget->setToolTip(tip); - } - } - } - - return widget; -} - - -// file-scope -// Button properties -static QAbstractButton* setButtonProperties -( - QAbstractButton* b, - vtkSMProperty* prop -) -{ - setWidgetProperties(b, prop); - b->setText(prop->GetXMLLabel()); - - vtkSMIntVectorProperty* intProp = - vtkSMIntVectorProperty::SafeDownCast(prop); - - // Initial checked state for integer (bool) properties - if (intProp) - { - b->setChecked(intProp->GetElement(0)); - } - - return b; -} - - -static vtkSMIntVectorProperty* lookupIntProp -( - vtkSMPropertyGroup* group, - const char* name -) -{ - vtkSMProperty* prop = group->GetProperty(name); - - if (prop) - { - return vtkSMIntVectorProperty::SafeDownCast(prop); - } - - return nullptr; -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void pqFoamBlockMeshControls::fireCommand(vtkSMProperty* prop) -{ - vtkSMProxy* pxy = this->proxy(); - - // Fire off command - prop->Modified(); - pxy->UpdateProperty(pxy->GetPropertyName(prop)); -} - - -void pqFoamBlockMeshControls::fireCommand -( - vtkSMIntVectorProperty* prop, - int val -) -{ - vtkSMProxy* pxy = this->proxy(); - - prop->SetElement(0, val); // Set int value, toogle bool, etc - - // Fire off command - prop->Modified(); - pxy->UpdateProperty(pxy->GetPropertyName(prop)); -} - - -void pqFoamBlockMeshControls::updateParts() -{ - vtkSMProxy* pxy = this->proxy(); - - pxy->UpdatePropertyInformation(pxy->GetProperty("BlockArrayStatus")); - pxy->UpdatePropertyInformation(pxy->GetProperty("CurvedEdgesArrayStatus")); -} - - -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -void pqFoamBlockMeshControls::refreshPressed() -{ - fireCommand(refresh_); - - vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline(); - - // Trigger a rendering (all views) - pqPVApplicationCore::instance()->render(); - - updateParts(); -} - - -void pqFoamBlockMeshControls::showPatchNames(bool checked) -{ - fireCommand(showPatchNames_, checked); - - // Update the active view - if (this->view()) - { - this->view()->render(); - } - - // OR: update all views - // pqPVApplicationCore::instance()->render(); -} - - -void pqFoamBlockMeshControls::showPointNumbers(bool checked) -{ - fireCommand(showPointNumbers_, checked); - - // Update the active view - if (this->view()) - { - this->view()->render(); - } - - // OR: update all views - // pqPVApplicationCore::instance()->render(); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -pqFoamBlockMeshControls::pqFoamBlockMeshControls -( - vtkSMProxy* proxy, - vtkSMPropertyGroup* group, - QWidget* parent -) -: - Superclass(proxy, parent), - refresh_(group->GetProperty("Refresh")), - showPatchNames_(lookupIntProp(group, "ShowPatchNames")), - showPointNumbers_(lookupIntProp(group, "ShowPointNumbers")) -{ - QGridLayout* form = new QGridLayout(this); - - if (refresh_) - { - QPushButton* b = new QPushButton(this); - setButtonProperties(b, refresh_); - form->addWidget(b, 0, 0, Qt::AlignLeft); - - connect - ( - b, SIGNAL(clicked()), this, SLOT(refreshPressed()) - ); - } - - if (showPatchNames_) - { - QCheckBox* b = new QCheckBox(this); - setButtonProperties(b, showPatchNames_); - form->addWidget(b, 0, 1, Qt::AlignLeft); - - connect - ( - b, SIGNAL(toggled(bool)), this, SLOT(showPatchNames(bool)) - ); - } - - if (showPointNumbers_) - { - QCheckBox* b = new QCheckBox(this); - setButtonProperties(b, showPointNumbers_); - form->addWidget(b, 0, 2, Qt::AlignLeft); - - connect - ( - b, SIGNAL(toggled(bool)), this, SLOT(showPointNumbers(bool)) - ); - } -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -pqFoamBlockMeshControls::~pqFoamBlockMeshControls() -{} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/pqFoamBlockMeshControls.h b/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/pqFoamBlockMeshControls.h deleted file mode 100644 index f7ba171eaf2d362920167d80c45da213405446ac..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/pqFoamBlockMeshControls.h +++ /dev/null @@ -1,125 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. - -Class - pqFoamBlockMeshControls - -Description - Customized property controls for the ParaView blockMesh reader. - - Refresh, ShowPatchNames, ShowPointNumbers. - -SourceFiles - pqFoamBlockMeshControls.cxx - -\*---------------------------------------------------------------------------*/ -#ifndef pqFoamBlockMeshControls_h -#define pqFoamBlockMeshControls_h - -#include "pqPropertyWidget.h" - -// Forward declarations (ParaView) -class vtkSMProperty; -class vtkSMIntVectorProperty; - - -/*---------------------------------------------------------------------------*\ - Class pqFoamBlockMeshControls Declaration -\*---------------------------------------------------------------------------*/ - -class pqFoamBlockMeshControls -: - public pqPropertyWidget -{ - Q_OBJECT; - typedef pqPropertyWidget Superclass; - - // Private data - - //- Refresh (push button) - vtkSMProperty* refresh_; - - //- Show Patch Names (bool property) - vtkSMIntVectorProperty* showPatchNames_; - - //- Show Point Numbers (bool property) - vtkSMIntVectorProperty* showPointNumbers_; - - - // Private Member Functions - - //- Update property - void fireCommand(vtkSMProperty* prop); - - //- Update int property or toggle bool property - void fireCommand(vtkSMIntVectorProperty* prop, int val); - - //- Update "BlockArrayStatus", "CurvedEdgesArrayStatus" information - void updateParts(); - - - //- No copy construct - pqFoamBlockMeshControls(const pqFoamBlockMeshControls&) = delete; - - //- No copy assignment - void operator=(const pqFoamBlockMeshControls&) = delete; - - -protected slots: - - // Protected Member Functions - - //- Trigger refresh - void refreshPressed(); - - //- Sync property with changed checkbox state, update rendered view(s) - void showPatchNames(bool checked); - - //- Sync property with changed checkbox state, update rendered view(s) - void showPointNumbers(bool checked); - - -public: - - //- Construct from components - pqFoamBlockMeshControls - ( - vtkSMProxy* proxy, - vtkSMPropertyGroup* group, - QWidget* parent = nullptr - ); - - - //- Destructor - virtual ~pqFoamBlockMeshControls(); - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/reader/vtkPVblockMeshReader.cxx b/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/reader/vtkPVblockMeshReader.cxx deleted file mode 100644 index 01115a3896ae10ac83ecf5e4d520ff3c800ad055..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/reader/vtkPVblockMeshReader.cxx +++ /dev/null @@ -1,426 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ -#include "vtkPVblockMeshReader.h" - -#include "pqApplicationCore.h" -#include "pqRenderView.h" -#include "pqServerManagerModel.h" - -// VTK includes -#include "vtkCallbackCommand.h" -#include "vtkDataArraySelection.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkObjectFactory.h" -#include "vtkSMRenderViewProxy.h" -#include "vtkStreamingDemandDrivenPipeline.h" -#include "vtkStringArray.h" - -// OpenFOAM includes -#include "vtkPVblockMesh.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -vtkStandardNewMacro(vtkPVblockMeshReader); - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -vtkPVblockMeshReader::vtkPVblockMeshReader() -{ - Debug = 0; - vtkDebugMacro(<<"Constructor"); - - SetNumberOfInputPorts(0); - - FileName = nullptr; - backend_ = nullptr; - - ShowPatchNames = false; - ShowPointNumbers = true; - - BlockSelection = vtkDataArraySelection::New(); - CurvedEdgesSelection = vtkDataArraySelection::New(); - - // Setup the selection callback to modify this object when an array - // selection is changed. - SelectionObserver = vtkCallbackCommand::New(); - SelectionObserver->SetCallback - ( - &vtkPVblockMeshReader::SelectionModifiedCallback - ); - SelectionObserver->SetClientData(this); - - BlockSelection->AddObserver - ( - vtkCommand::ModifiedEvent, - this->SelectionObserver - ); - - CurvedEdgesSelection->AddObserver - ( - vtkCommand::ModifiedEvent, - this->SelectionObserver - ); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -vtkPVblockMeshReader::~vtkPVblockMeshReader() -{ - vtkDebugMacro(<<"Destructor"); - - if (backend_) - { - // Remove text actors - updatePatchNamesView(false); - updatePointNumbersView(false); - - delete backend_; - backend_ = nullptr; - } - - if (FileName) - { - delete[] FileName; - } - - BlockSelection->RemoveAllObservers(); - CurvedEdgesSelection->RemoveAllObservers(); - - SelectionObserver->Delete(); - BlockSelection->Delete(); - CurvedEdgesSelection->Delete(); -} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -int vtkPVblockMeshReader::RequestInformation -( - vtkInformation* vtkNotUsed(request), - vtkInformationVector** vtkNotUsed(inputVector), - vtkInformationVector* outputVector -) -{ - vtkDebugMacro(<<"RequestInformation"); - - if (!FileName) - { - vtkErrorMacro("FileName has to be specified!"); - return 0; - } - - if (Foam::vtkPVblockMesh::debug) - { - cout<<"REQUEST_INFORMATION\n"; - outputVector->GetInformationObject(0)->Print(cout); - } - - if (backend_) - { - backend_->updateInfo(); - } - else - { - backend_ = new Foam::vtkPVblockMesh(FileName, this); - } - - return 1; -} - - -int vtkPVblockMeshReader::RequestData -( - vtkInformation* vtkNotUsed(request), - vtkInformationVector** vtkNotUsed(inputVector), - vtkInformationVector* outputVector -) -{ - vtkDebugMacro(<<"RequestData"); - - if (!FileName) - { - vtkErrorMacro("FileName must be specified!"); - return 0; - } - if (!backend_) - { - // Catch some previous error - vtkErrorMacro("Reader failed - perhaps no blockMesh?"); - return 0; - } - - if (Foam::vtkPVblockMesh::debug) - { - cout<<"RequestData:\n"; - outputVector->GetInformationObject(0)->Print(cout); - } - - vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast - ( - outputVector->GetInformationObject(0)->Get - ( - vtkMultiBlockDataSet::DATA_OBJECT() - ) - ); - - backend_->Update(output); - - updatePatchNamesView(ShowPatchNames); - updatePointNumbersView(ShowPointNumbers); - - backend_->UpdateFinalize(); - - return 1; -} - - -void vtkPVblockMeshReader::Refresh() -{ - // Delete the current blockMesh to force re-read and update - if (backend_) - { - // Remove text actors - updatePatchNamesView(false); - updatePointNumbersView(false); - - delete backend_; - backend_ = nullptr; - } - - this->Modified(); -} - - -void vtkPVblockMeshReader::SetShowPatchNames(bool val) -{ - if (ShowPatchNames != val) - { - ShowPatchNames = val; - updatePatchNamesView(ShowPatchNames); - } -} - - -void vtkPVblockMeshReader::SetShowPointNumbers(bool val) -{ - if (ShowPointNumbers != val) - { - ShowPointNumbers = val; - updatePointNumbersView(ShowPointNumbers); - } -} - - -void vtkPVblockMeshReader::updatePatchNamesView(const bool show) -{ - pqApplicationCore* appCore = pqApplicationCore::instance(); - - // Need to check this, since our destructor calls this - if (!appCore) - { - return; - } - - // Server manager model for querying items in the server manager - pqServerManagerModel* smModel = appCore->getServerManagerModel(); - if (!smModel || !backend_) - { - return; - } - - // Get all the pqRenderView instances - for (auto view : smModel->findItems<pqRenderView*>()) - { - backend_->renderPatchNames - ( - view->getRenderViewProxy()->GetRenderer(), - show - ); - } - - // Use refresh here? -} - - -void vtkPVblockMeshReader::updatePointNumbersView(const bool show) -{ - pqApplicationCore* appCore = pqApplicationCore::instance(); - - // Need to check this, since our destructor calls this - if (!appCore) - { - return; - } - - // Server manager model for querying items in the server manager - pqServerManagerModel* smModel = appCore->getServerManagerModel(); - if (!smModel || !backend_) - { - return; - } - - // Get all the pqRenderView instances - for (auto view : smModel->findItems<pqRenderView*>()) - { - backend_->renderPointNumbers - ( - view->getRenderViewProxy()->GetRenderer(), - show - ); - } - - // Use refresh here? -} - - -void vtkPVblockMeshReader::PrintSelf(ostream& os, vtkIndent indent) -{ - vtkDebugMacro(<<"PrintSelf"); - - this->Superclass::PrintSelf(os,indent); - os << indent << "File name: " - << (this->FileName ? this->FileName : "(none)") << "\n"; - - backend_->PrintSelf(os, indent); -} - - -// ---------------------------------------------------------------------- -// Block selection list control - -vtkDataArraySelection* vtkPVblockMeshReader::GetBlockSelection() -{ - return BlockSelection; -} - -int vtkPVblockMeshReader::GetNumberOfBlockArrays() -{ - return BlockSelection->GetNumberOfArrays(); -} - -const char* vtkPVblockMeshReader::GetBlockArrayName(int index) -{ - return BlockSelection->GetArrayName(index); -} - -int vtkPVblockMeshReader::GetBlockArrayStatus(const char* name) -{ - return BlockSelection->ArrayIsEnabled(name); -} - -void vtkPVblockMeshReader::SetBlockArrayStatus -( - const char* name, - int status -) -{ - if (status) - { - BlockSelection->EnableArray(name); - } - else - { - BlockSelection->DisableArray(name); - } -} - - -// ---------------------------------------------------------------------- -// CurvedEdges selection list control - -vtkDataArraySelection* vtkPVblockMeshReader::GetCurvedEdgesSelection() -{ - return CurvedEdgesSelection; -} - -int vtkPVblockMeshReader::GetNumberOfCurvedEdgesArrays() -{ - return CurvedEdgesSelection->GetNumberOfArrays(); -} - -const char* vtkPVblockMeshReader::GetCurvedEdgesArrayName(int index) -{ - return CurvedEdgesSelection->GetArrayName(index); -} - -int vtkPVblockMeshReader::GetCurvedEdgesArrayStatus(const char* name) -{ - return CurvedEdgesSelection->ArrayIsEnabled(name); -} - -void vtkPVblockMeshReader::SetCurvedEdgesArrayStatus -( - const char* name, - int status -) -{ - if (status) - { - CurvedEdgesSelection->EnableArray(name); - } - else - { - CurvedEdgesSelection->DisableArray(name); - } -} - - -// ---------------------------------------------------------------------- - -void vtkPVblockMeshReader::SelectionModifiedCallback -( - vtkObject*, - unsigned long, - void* clientdata, - void* -) -{ - static_cast<vtkPVblockMeshReader*>(clientdata)->Modified(); -} - - -int vtkPVblockMeshReader::FillOutputPortInformation -( - int port, - vtkInformation* info -) -{ - if (port == 0) - { - return this->Superclass::FillOutputPortInformation(port, info); - } - info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet"); - return 1; -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/reader/vtkPVblockMeshReader.h b/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/reader/vtkPVblockMeshReader.h deleted file mode 100644 index 749fe8d0b9c2d19bca8da3948b093dad5d991a7d..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/blockMeshReader/plugin/reader/vtkPVblockMeshReader.h +++ /dev/null @@ -1,184 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. - -Class - vtkPVblockMeshReader - -Description - reads a dataset in OpenFOAM bockMesh format - - vtkPVblockMeshReader creates an multiblock dataset. - It uses the OpenFOAM infrastructure (blockMesh). - -SourceFiles - vtkPVblockMeshReader.cxx - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkPVblockMeshReader_h -#define vtkPVblockMeshReader_h - -// VTK includes -#include "vtkMultiBlockDataSetAlgorithm.h" - -// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * // - -// VTK forward declarations -class vtkDataArraySelection; -class vtkCallbackCommand; - -namespace Foam -{ - class vtkPVblockMesh; -} - -/*---------------------------------------------------------------------------*\ - Class vtkPVblockMeshReader Declaration -\*---------------------------------------------------------------------------*/ - -class vtkPVblockMeshReader -: - public vtkMultiBlockDataSetAlgorithm -{ -public: - vtkTypeMacro(vtkPVblockMeshReader, vtkMultiBlockDataSetAlgorithm); - void PrintSelf(ostream&, vtkIndent) VTK_OVERRIDE; - - static vtkPVblockMeshReader* New(); - - // Description: - // Set/Get the filename. - vtkSetStringMacro(FileName); - vtkGetStringMacro(FileName); - - // Description: - // Display patch names - virtual void SetShowPatchNames(bool); - vtkGetMacro(ShowPatchNames, bool); - - // Description: - // Display corner point labels - virtual void SetShowPointNumbers(bool); - vtkGetMacro(ShowPointNumbers, bool); - - // Description: - // Refresh blockMesh from changes to blockMeshDict - virtual void Refresh(); - - // Description: - // Blocks selection list control - vtkDataArraySelection* GetBlockSelection(); - int GetNumberOfBlockArrays(); - int GetBlockArrayStatus(const char* name); - void SetBlockArrayStatus(const char* name, int status); - const char* GetBlockArrayName(int index); - - // Description: - // CurvedEdges selection list control - vtkDataArraySelection* GetCurvedEdgesSelection(); - int GetNumberOfCurvedEdgesArrays(); - int GetCurvedEdgesArrayStatus(const char* name); - void SetCurvedEdgesArrayStatus(const char* name, int status); - const char* GetCurvedEdgesArrayName(int index); - - // Description: - // Callback registered with the SelectionObserver - // for all the selection lists - static void SelectionModifiedCallback - ( - vtkObject* caller, - unsigned long eid, - void* clientdata, - void* calldata - ); - - -protected: - - //- Construct null - vtkPVblockMeshReader(); - - //- Destructor - virtual ~vtkPVblockMeshReader(); - - //- Return information about mesh, times, etc without loading anything - virtual int RequestInformation - ( - vtkInformation* unusedRequest, - vtkInformationVector** unusedInputVector, - vtkInformationVector* outputVector - ) VTK_OVERRIDE; - - //- Get the mesh for a particular time - virtual int RequestData - ( - vtkInformation* unusedRequest, - vtkInformationVector** unusedInputVector, - vtkInformationVector* outputVector - ) VTK_OVERRIDE; - - //- Fill in additional port information - virtual int FillOutputPortInformation(int, vtkInformation*) VTK_OVERRIDE; - - // The observer to modify this object when array selections are modified - vtkCallbackCommand* SelectionObserver; - - char* FileName; - - -private: - - //- No copy construct - vtkPVblockMeshReader(const vtkPVblockMeshReader&) = delete; - - //- No copy assignment - void operator=(const vtkPVblockMeshReader&) = delete; - - //- Add/remove patch names to/from the view - void updatePatchNamesView(const bool show); - - //- Add/remove point numbers to/from the view - void updatePointNumbersView(const bool show); - - - //- Show Patch Names - bool ShowPatchNames; - - //- Show Point Numbers - bool ShowPointNumbers; - - vtkDataArraySelection* BlockSelection; - vtkDataArraySelection* CurvedEdgesSelection; - - //- Backend portion of the reader - Foam::vtkPVblockMesh* backend_; -}; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/common/Make/files b/applications/utilities/postProcessing/graphics/PVReaders/common/Make/files deleted file mode 100644 index 8710846366da4900643018460c041bb7682e68b2..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/common/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -foamPvCore.C - -LIB = $(FOAM_LIBBIN)/libvtkPVFoamCommon-pv${PARAVIEW_API} diff --git a/applications/utilities/postProcessing/graphics/PVReaders/common/Make/options b/applications/utilities/postProcessing/graphics/PVReaders/common/Make/options deleted file mode 100644 index b13d6d0a9c6fa04ea3b02277cd3bb1e8f02d04e4..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/common/Make/options +++ /dev/null @@ -1,9 +0,0 @@ -EXE_INC = \ - ${c++LESSWARN} \ - -I$(LIB_SRC)/conversion/lnInclude \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(PARAVIEW_INC_DIR) \ - -I$(PARAVIEW_INC_DIR)/vtkkwiml - -LIB_LIBS = \ - $(GLIBS) diff --git a/applications/utilities/postProcessing/graphics/PVReaders/common/foamPvCore.C b/applications/utilities/postProcessing/graphics/PVReaders/common/foamPvCore.C deleted file mode 100644 index fce9a9a8790d1bc7dff563eaddb6ec0ba1dcc76c..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/common/foamPvCore.C +++ /dev/null @@ -1,271 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "foamPvCore.H" - -#include "memInfo.H" -#include "DynamicList.H" - -#include "vtkDataArraySelection.h" -#include "vtkDataSet.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkInformation.h" -#include "vtkSmartPointer.h" - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -Foam::Ostream& Foam::foamPvCore::printDataArraySelection -( - Ostream& os, - vtkDataArraySelection* select -) -{ - if (!select) - { - return os; - } - - const int n = select->GetNumberOfArrays(); - - os << n << '('; - for (int i=0; i < n; ++i) - { - if (i) os << ' '; - os << select->GetArrayName(i) << '=' - << (select->GetArraySetting(i) ? 1 : 0); - } - os << ')'; - - return os; -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::foamPvCore::addToBlock -( - vtkMultiBlockDataSet* output, - vtkDataSet* dataset, - const arrayRange& selector, - const label datasetNo, - const std::string& datasetName -) -{ - const int blockNo = selector.block(); - - vtkDataObject* dataObj = output->GetBlock(blockNo); - vtkSmartPointer<vtkMultiBlockDataSet> block = - vtkMultiBlockDataSet::SafeDownCast(dataObj); - - if (!block) - { - if (dataObj) - { - FatalErrorInFunction - << "Block already has a vtkDataSet assigned to it" - << endl; - return; - } - - block = vtkSmartPointer<vtkMultiBlockDataSet>::New(); - output->SetBlock(blockNo, block); - } - - #ifdef FULLDEBUG - { - Info<< "block[" << blockNo << "] has " - << block->GetNumberOfBlocks() - << " datasets prior to adding set " << datasetNo - << " with name: " << datasetName << endl; - } - #endif - - block->SetBlock(datasetNo, dataset); - - // Name the output block when assigning dataset 0 - if (datasetNo == 0) - { - output->GetMetaData(blockNo)->Set - ( - vtkCompositeDataSet::NAME(), - selector.name() - ); - } - - if (datasetName.size()) - { - block->GetMetaData(datasetNo)->Set - ( - vtkCompositeDataSet::NAME(), - datasetName.c_str() - ); - } -} - - -Foam::wordHashSet Foam::foamPvCore::getSelected -( - vtkDataArraySelection* select -) -{ - const int n = select->GetNumberOfArrays(); - wordHashSet selected(2*n); - - for (int i=0; i < n; ++i) - { - if (select->GetArraySetting(i)) - { - selected.set(getFoamName(select->GetArrayName(i))); - } - } - - return selected; -} - - -Foam::wordHashSet Foam::foamPvCore::getSelected -( - vtkDataArraySelection* select, - const labelRange& selector -) -{ - const int n = select->GetNumberOfArrays(); - wordHashSet selected(2*n); - - for (auto i : selector) - { - if (select->GetArraySetting(i)) - { - selected.set(getFoamName(select->GetArrayName(i))); - } - } - - return selected; -} - - -Foam::HashSet<Foam::string> -Foam::foamPvCore::getSelectedArraySet -( - vtkDataArraySelection* select -) -{ - const int n = select->GetNumberOfArrays(); - HashSet<string> enabled(2*n); - - for (int i=0; i < n; ++i) - { - if (select->GetArraySetting(i)) - { - enabled.insert(select->GetArrayName(i)); - } - } - - #ifdef FULLDEBUG - { - Info<< "available("; - for (int i=0; i < n; ++i) - { - Info<< " \"" << select->GetArrayName(i) << "\""; - } - Info<< " )\nselected("; - - for (auto k : enabled) - { - Info<< " " << k; - } - Info<< " )\n"; - } - #endif - - return enabled; -} - - -Foam::Map<Foam::string> -Foam::foamPvCore::getSelectedArrayMap -( - vtkDataArraySelection* select -) -{ - const int n = select->GetNumberOfArrays(); - Map<string> enabled(2*n); - - for (int i=0; i < n; ++i) - { - if (select->GetArraySetting(i)) - { - enabled.insert(i, select->GetArrayName(i)); - } - } - - return enabled; -} - - -Foam::word Foam::foamPvCore::getFoamName(const std::string& str) -{ - if (str.size()) - { - auto beg = str.rfind('/'); - if (beg == std::string::npos) - { - beg = 0; - } - else - { - ++beg; - } - - auto end = beg; - - while (str[end] && word::valid(str[end])) - { - ++end; - } - - // Already checked for valid/invalid chars - return word(str.substr(beg, beg+end), false); - } - - return word::null; -} - - -void Foam::foamPvCore::printMemory() -{ - memInfo mem; - - if (mem.valid()) - { - Info<< "mem peak/size/rss: " << mem << endl; - } -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/common/foamPvCore.H b/applications/utilities/postProcessing/graphics/PVReaders/common/foamPvCore.H deleted file mode 100644 index faad9ec279df9e41b6beaa1a8d9964d20586063c..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/common/foamPvCore.H +++ /dev/null @@ -1,315 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. - -Description - Helpers for OpenFOAM reader interfaces in ParaView. - -SourceFiles - foamPvCore.C - foamPvCoreTemplates.C - -\*---------------------------------------------------------------------------*/ - -#ifndef foamPvCore_H -#define foamPvCore_H - -#include "fileName.H" -#include "stringList.H" -#include "boolList.H" -#include "pointList.H" -#include "wordList.H" -#include "Hash.H" -#include "HashSet.H" -#include "Map.H" -#include "labelRange.H" - -// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * // - -class vtkCellArray; -class vtkDataArraySelection; -class vtkDataSet; -class vtkIndent; -class vtkMultiBlockDataSet; -class vtkPoints; -template<class T> class vtkSmartPointer; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -class IOobjectList; - -/*---------------------------------------------------------------------------*\ - Class foamPvCore Declaration -\*---------------------------------------------------------------------------*/ - -class foamPvCore -{ -public: - - //- Bookkeeping for GUI checklists and multi-block organization - // Works like a SubList selection. - class arrayRange - : - public labelRange - { - const char *name_; - int block_; - - public: - - //- Construct with given name for the specified block - arrayRange(const char *name, int blockNo=0) - : - labelRange(), - name_(name), - block_(blockNo) - {} - - //- Return the block holding these datasets - int block() const - { - return block_; - } - - //- Assign block number, return previous value - int block(int blockNo) - { - int prev = block_; - block_ = blockNo; - return prev; - } - - //- Return the name - const char* name() const - { - return name_; - } - - //- Reset the start/size directly - using labelRange::reset; - - //- Reset the size to zero and optionally assign a new start - void reset(label startAt = 0) - { - clear(); - setStart(startAt); - } - - //- Increment the size - void operator+=(label n) - { - setSize(size() + n); - } - - //- True if the labelRange intersects any key in the Map - template<class T> - bool intersects(const Map<T>& map) const - { - for (const label idx : *this) - { - if (map.found(idx)) - { - return true; - } - } - - return false; - } - - //- The intersection ids with keys in the Map - template<class T> - List<label> intersection(const Map<T>& map) const - { - List<label> indices(Foam::min(map.size(), this->size())); - - if (indices.size()) - { - label n = 0; - - for (const label idx : *this) - { - if (map.found(idx)) - { - indices[n++] = idx; - } - } - - indices.setSize(n); - } - - return indices; - } - - }; // End class arrayRange - - -public: - - //- Construct null - constexpr foamPvCore() noexcept {} - - - //- Print information about vtkDataArraySelection - static Ostream& printDataArraySelection - ( - Ostream& os, - vtkDataArraySelection* select - ); - - - //- Convenience method for the VTK multiblock API - static void addToBlock - ( - vtkMultiBlockDataSet* output, - vtkDataSet* dataset, - const arrayRange& selector, - const label datasetNo, - const std::string& datasetName - ); - - //- Add names to array selection - template<class StringType> - static label addToArray - ( - vtkDataArraySelection* select, - const std::string& prefix, - const UList<StringType>& names - ); - - //- Add names to array selection - template<class StringType> - static label addToArray - ( - vtkDataArraySelection* select, - const UList<StringType>& names, - const std::string& suffix = string::null - ); - - //- Add objects of Type to array selection - template<class Type> - static label addToSelection - ( - vtkDataArraySelection* select, - const std::string& prefix, - const IOobjectList& objects - ); - - //- Add objects of Type to array selection - template<class Type> - static label addToSelection - ( - vtkDataArraySelection* select, - const IOobjectList& objects, - const std::string& suffix = string::null - ); - - //- Add objects of Type to array selection - template<class Type> - static label addToSelection - ( - vtkDataArraySelection* select, - const std::string& prefix, - const HashTable<wordHashSet>& objects - ); - - - //- Add objects of Type to array selection - template<class Type> - static label addToSelection - ( - vtkDataArraySelection* select, - const HashTable<wordHashSet>& objects, - const std::string& suffix = string::null - ); - - - //- Retrieve the current selections as a wordHashSet, - //- while stripping off any prefix or suffix - static wordHashSet getSelected - ( - vtkDataArraySelection* select - ); - - - //- Retrieve sub-list of the current selections as a wordHashSet, - //- while stripping off any prefix or suffix - static wordHashSet getSelected - ( - vtkDataArraySelection* select, - const labelRange& selector - ); - - - //- Retrieve the currently enabled selections as hashset - static HashSet<string> getSelectedArraySet - ( - vtkDataArraySelection* select - ); - - //- Retrieve the currently enabled selections as id/name map - static Map<string> getSelectedArrayMap - ( - vtkDataArraySelection* select - ); - - //- Enable the selection(s) - template<class AnyValue, class AnyHasher> - static void setSelectedArrayEntries - ( - vtkDataArraySelection* select, - const HashTable<AnyValue, string, AnyHasher>& enabled - ); - - - //- Extract the first word characters after a slash - static word getFoamName(const std::string& str); - - - //- Simple memory used debugging information - static void printMemory(); - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -}; // End class foamPvCore - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "foamPvCoreTemplates.C" -#endif - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/common/foamPvCoreTemplates.C b/applications/utilities/postProcessing/graphics/PVReaders/common/foamPvCoreTemplates.C deleted file mode 100644 index 91283a54460c0c2a7b0596a93b76c5c0f30d4a99..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/common/foamPvCoreTemplates.C +++ /dev/null @@ -1,173 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "IOobjectList.H" -#include "vtkDataArraySelection.h" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template<class StringType> -Foam::label Foam::foamPvCore::addToArray -( - vtkDataArraySelection *select, - const std::string& prefix, - const UList<StringType>& names -) -{ - if (prefix.empty()) - { - for (const auto& name : names) - { - select->AddArray(name.c_str()); - } - } - else - { - for (const auto& name : names) - { - select->AddArray((prefix + name).c_str()); - } - } - - return names.size(); -} - - -template<class StringType> -Foam::label Foam::foamPvCore::addToArray -( - vtkDataArraySelection *select, - const UList<StringType>& names, - const std::string& suffix -) -{ - if (suffix.empty()) - { - for (const auto& name : names) - { - select->AddArray(name.c_str()); - } - } - else - { - for (const auto& name : names) - { - select->AddArray((name + suffix).c_str()); - } - } - - return names.size(); -} - - -template<class Type> -Foam::label Foam::foamPvCore::addToSelection -( - vtkDataArraySelection *select, - const std::string& prefix, - const IOobjectList& objects -) -{ - return addToArray(select, prefix, objects.sortedNames(Type::typeName)); -} - - -template<class Type> -Foam::label Foam::foamPvCore::addToSelection -( - vtkDataArraySelection *select, - const IOobjectList& objects, - const std::string& suffix -) -{ - return addToArray(select, objects.sortedNames(Type::typeName), suffix); -} - - -template<class Type> -Foam::label Foam::foamPvCore::addToSelection -( - vtkDataArraySelection *select, - const std::string& prefix, - const HashTable<wordHashSet>& objects -) -{ - auto iter = objects.cfind(Type::typeName); - - if (iter.found()) - { - return addToArray(select, prefix, iter.val().sortedToc()); - } - - return 0; -} - - -template<class Type> -Foam::label Foam::foamPvCore::addToSelection -( - vtkDataArraySelection *select, - const HashTable<wordHashSet>& objects, - const std::string& suffix -) -{ - auto iter = objects.cfind(Type::typeName); - - if (iter.found()) - { - return addToArray(select, iter.val().sortedToc(), suffix); - } - - return 0; -} - - -template<class AnyValue, class AnyHasher> -void Foam::foamPvCore::setSelectedArrayEntries -( - vtkDataArraySelection* select, - const HashTable<AnyValue, string, AnyHasher>& enabled -) -{ - const int n = select->GetNumberOfArrays(); - - // Disable everything not explicitly enabled - select->DisableAllArrays(); - - // Loop through entries, enabling as required - for (int i=0; i < n; ++i) - { - const char* arrayName = select->GetArrayName(i); - if (enabled.found(arrayName)) - { - select->EnableArray(arrayName); - } - } -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/CMakeLists-OpenFOAM.txt b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/CMakeLists-OpenFOAM.txt deleted file mode 100644 index 15c675adecbd4663176d8c1d86adc8534959cb51..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/CMakeLists-OpenFOAM.txt +++ /dev/null @@ -1,26 +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 - -std=c++11 -) - -#----------------------------------------------------------------------------- diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/CMakeLists-Project.txt b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/CMakeLists-Project.txt deleted file mode 100644 index a3ad24b3b9a363a458e4b229b79b3a03c2abb5a6..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/CMakeLists-Project.txt +++ /dev/null @@ -1,67 +0,0 @@ -#----------------------------------------------------------------------------- -# OpenFOAM reader plugin for ParaView GUI (pre-5.7) - -link_directories( - $ENV{FOAM_LIBBIN} -) - -include_directories( - ${LIB_SRC}/OpenFOAM/include - ${LIB_SRC}/OpenFOAM/lnInclude - ${LIB_SRC}/OSspecific/${WM_OSTYPE}/lnInclude - ${LIB_SRC}/fileFormats/lnInclude - ${LIB_SRC}/conversion/lnInclude - ${LIB_SRC}/finiteArea/lnInclude - ${LIB_SRC}/finiteVolume/lnInclude - ${PROJECT_SOURCE_DIR}/../common - ${PROJECT_SOURCE_DIR}/library - ${PROJECT_SOURCE_DIR}/plugin - ${PROJECT_SOURCE_DIR}/plugin/reader -) - -set(OPENFOAM_LIBNAMES - OpenFOAM - fileFormats - conversion - finiteArea - finiteVolume -) - -# Set output library destination to plugin directory -set( - LIBRARY_OUTPUT_PATH $ENV{FOAM_PV_PLUGIN_LIBBIN} - CACHE INTERNAL - "Single output directory for building all libraries." -) - - -qt5_wrap_cpp(MOC_SRCS plugin/pqFoamReaderControls.h) - -add_paraview_property_group_widget(IFACES0 IFACES0_SRCS - TYPE "openfoam_reader_general_controls" - CLASS_NAME pqFoamReaderControls -) - -add_paraview_plugin( - PVFoamReader_SM "${foam_api}" - SERVER_MANAGER_XML - plugin/PVFoamReader_SM.xml - SERVER_MANAGER_SOURCES - plugin/reader/vtkPVFoamReader.cxx - GUI_INTERFACES - ${IFACES0} - SOURCES - ${IFACES0_SRCS} - ${MOC_SRCS} - plugin/pqFoamReaderControls.cxx -) - -target_link_libraries( - PVFoamReader_SM - LINK_PUBLIC - vtkPVFoamCommon${foamPvLibQualifier} - vtkPVFoam${foamPvLibQualifier} - ${OPENFOAM_LIBNAMES} -) - -#----------------------------------------------------------------------------- diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/CMakeLists-Project57.txt b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/CMakeLists-Project57.txt deleted file mode 100644 index c5d5236a59a79c43a1c2f1a10b0cfec8e94cc4b9..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/CMakeLists-Project57.txt +++ /dev/null @@ -1,6 +0,0 @@ -#----------------------------------------------------------------------------- -# OpenFOAM reader plugin for ParaView GUI (5.7+) - -message(FATAL_ERROR "paraview-${pv_api} not yet supported") - -#----------------------------------------------------------------------------- diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/CMakeLists.txt deleted file mode 100644 index 8acb2d6128c4be70c56559a8e9f4103b0c63a994..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/CMakeLists.txt +++ /dev/null @@ -1,60 +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 - -find_package(ParaView REQUIRED) - -# Qualify OpenFOAM/ParaView libraries with -pvMAJ.MIN -# The pv_api can also be used for paraview-MAJ.MIN -if (DEFINED ENV{PARAVIEW_API}) - set(pv_api "$ENV{PARAVIEW_API}") -else() - if (${ParaView_VERSION} GREATER_EQUAL 5.7) - string(REGEX MATCH [0-9]+[.][0-9]+ pv_api ${ParaView_VERSION}) - message("The PARAVIEW_API env was unset, " - "extracted value from version=" - "${ParaView_VERSION} is ${pv_api}") - else() - set(pv_api "${PARAVIEW_VERSION_MAJOR}.${ParaView_VERSION_MINOR}") - message("The PARAVIEW_API env was unset, " - "assembled from maj/min=" - "${ParaView_VERSION_MAJOR}/${ParaView_VERSION_MINOR} is ${pv_api}") - endif() -endif() - -# Pass through the OpenFOAM API value to the reader -set(foam_api "$ENV{FOAM_API}") -if (NOT "${foam_api}") - set(foam_api "2.0") -endif() - -set(foamPvLibQualifier "-pv${pv_api}") - -#----------------------------------------------------------------------------- - -message("================") -message("Using ParaView = $ENV{ParaView_DIR}") -message("OpenFOAM api = ${foam_api}, libs = ${foamPvLibQualifier}") - -include(CMakeLists-OpenFOAM.txt) - -if (${ParaView_VERSION} GREATER_EQUAL 5.7) - message("================") - include(CMakeLists-Project57.txt) -else() - message("================") - include(${PARAVIEW_USE_FILE}) - include(CMakeLists-Project.txt) -endif() - -#----------------------------------------------------------------------------- diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/Make/files b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/Make/files deleted file mode 100644 index 079991864adb448516f9e941e052bd81ed472402..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/Make/files +++ /dev/null @@ -1,8 +0,0 @@ -vtkPVFoam.C -vtkPVFoamFields.C -vtkPVFoamMesh.C -vtkPVFoamMeshLagrangian.C -vtkPVFoamMeshVolume.C -vtkPVFoamUpdateInfo.C - -LIB = $(FOAM_LIBBIN)/libvtkPVFoam-pv${PARAVIEW_API} diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/Make/options b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/Make/options deleted file mode 100644 index 0e6f37d86429b49b74de768d690a323e0919e687..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/Make/options +++ /dev/null @@ -1,25 +0,0 @@ -EXE_INC = \ - ${c++LESSWARN} \ - -I$(LIB_SRC)/fileFormats/lnInclude \ - -I$(LIB_SRC)/conversion/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/finiteArea/lnInclude \ - -I$(LIB_SRC)/dynamicMesh/lnInclude \ - -I$(LIB_SRC)/lagrangian/basic/lnInclude \ - -I$(PARAVIEW_INC_DIR) \ - -I$(PARAVIEW_INC_DIR)/vtkkwiml \ - -I../../common \ - -I../plugin/reader - -LIB_LIBS = \ - -lfileFormats \ - -lconversion \ - -lmeshTools \ - -lfiniteVolume \ - -lfiniteArea \ - -ldynamicMesh \ - -lgenericPatchFields \ - -llagrangian \ - -L$(FOAM_LIBBIN) -lvtkPVFoamCommon-pv${PARAVIEW_API} \ - $(GLIBS) diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoam.C b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoam.C deleted file mode 100644 index 8db72b8bf1334abf448085f314565e630c429f0f..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoam.C +++ /dev/null @@ -1,973 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "vtkPVFoam.H" -#include "vtkPVFoamReader.h" - -// OpenFOAM includes -#include "areaFaMesh.H" -#include "faMesh.H" -#include "fvMesh.H" -#include "foamVersion.H" -#include "Time.H" -#include "patchZones.H" -#include "IOobjectList.H" -#include "collatedFileOperation.H" - -// VTK includes -#include "vtkDataArraySelection.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkRenderer.h" -#include "vtkTextActor.h" -#include "vtkTextProperty.h" -#include "vtkSmartPointer.h" -#include "vtkInformation.h" - -// Templates (only needed here) -#include "vtkPVFoamUpdateTemplates.C" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(vtkPVFoam, 0); - - // file-scope - static word updateStateName(polyMesh::readUpdateState state) - { - switch (state) - { - case polyMesh::UNCHANGED: return "UNCHANGED"; - case polyMesh::POINTS_MOVED: return "POINTS_MOVED"; - case polyMesh::TOPO_CHANGE: return "TOPO_CHANGE"; - case polyMesh::TOPO_PATCH_CHANGE: return "TOPO_PATCH_CHANGE"; - }; - - return "UNKNOWN"; - } -} - - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -namespace Foam -{ - // file-scope - - //- Create a text actor - vtkSmartPointer<vtkTextActor> createTextActor - ( - const std::string& s, - const Foam::point& pt - ) - { - vtkSmartPointer<vtkTextActor> txt = - vtkSmartPointer<vtkTextActor>::New(); - - txt->SetInput(s.c_str()); - - // Set text properties - vtkTextProperty* tprop = txt->GetTextProperty(); - tprop->SetFontFamilyToArial(); - tprop->BoldOn(); - tprop->ShadowOff(); - tprop->SetLineSpacing(1.0); - tprop->SetFontSize(14); - tprop->SetColor(1.0, 0.0, 1.0); - tprop->SetJustificationToCentered(); - - txt->GetPositionCoordinate()->SetCoordinateSystemToWorld(); - txt->GetPositionCoordinate()->SetValue(pt.x(), pt.y(), pt.z()); - - return txt; - } -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::vtkPVFoam::resetCounters() -{ - // Reset array range information (ids and sizes) - rangeVolume_.reset(); - rangePatches_.reset(); - rangeClouds_.reset(); - rangeCellZones_.reset(); - rangeFaceZones_.reset(); - rangePointZones_.reset(); - rangeCellSets_.reset(); - rangeFaceSets_.reset(); - rangePointSets_.reset(); -} - - -template<class Container> -bool Foam::vtkPVFoam::addOutputBlock -( - vtkMultiBlockDataSet* output, - const HashTable<Container, string>& cache, - const arrayRange& selector, - const bool singleDataset -) const -{ - const auto blockNo = output->GetNumberOfBlocks(); - vtkSmartPointer<vtkMultiBlockDataSet> block; - int datasetNo = 0; - - const List<label> partIds = selector.intersection(selectedPartIds_); - - for (const auto partId : partIds) - { - const auto& longName = selectedPartIds_[partId]; - const word shortName = getFoamName(longName); - - auto iter = cache.find(longName); - if (iter.found() && iter.val().dataset) - { - auto dataset = iter.val().dataset; - - if (singleDataset) - { - output->SetBlock(blockNo, dataset); - output->GetMetaData(blockNo)->Set - ( - vtkCompositeDataSet::NAME(), - shortName.c_str() - ); - - ++datasetNo; - break; - } - else if (datasetNo == 0) - { - block = vtkSmartPointer<vtkMultiBlockDataSet>::New(); - output->SetBlock(blockNo, block); - output->GetMetaData(blockNo)->Set - ( - vtkCompositeDataSet::NAME(), - selector.name() - ); - } - - block->SetBlock(datasetNo, dataset); - block->GetMetaData(datasetNo)->Set - ( - vtkCompositeDataSet::NAME(), - shortName.c_str() - ); - - ++datasetNo; - } - } - - return datasetNo; -} - - -int Foam::vtkPVFoam::setTime(const std::vector<double>& requestTimes) -{ - if (requestTimes.empty()) - { - return 0; - } - - Time& runTime = dbPtr_(); - - // Get times list. Flush first to force refresh. - fileHandler().flush(); - instantList Times = runTime.times(); - - int nearestIndex = timeIndex_; - for (const double& timeValue : requestTimes) - { - const int index = Time::findClosestTimeIndex(Times, timeValue); - if (index >= 0 && index != timeIndex_) - { - nearestIndex = index; - break; - } - } - - if (nearestIndex < 0) - { - nearestIndex = 0; - } - - if (debug) - { - Info<< "<beg> setTime("; - unsigned reqi = 0; - for (const double& timeValue : requestTimes) - { - if (reqi) Info<< ", "; - Info<< timeValue; - ++reqi; - } - Info<< ") - previousIndex = " << timeIndex_ - << ", nearestIndex = " << nearestIndex << nl; - } - - // See what has changed - if (timeIndex_ != nearestIndex) - { - timeIndex_ = nearestIndex; - runTime.setTime(Times[nearestIndex], nearestIndex); - - // When mesh changes, so do fields - meshState_ = - ( - volMeshPtr_ - ? volMeshPtr_->readUpdate() - : polyMesh::TOPO_CHANGE - ); - - reader_->UpdateProgress(0.05); - - // this seems to be needed for catching Lagrangian fields - updateInfo(); - } - - DebugInfo - << "<end> setTime() - selectedTime=" - << Times[nearestIndex].name() << " index=" << timeIndex_ - << "/" << Times.size() - << " meshUpdateState=" << updateStateName(meshState_) << nl; - - return nearestIndex; -} - - -Foam::word Foam::vtkPVFoam::getReaderPartName(const int partId) const -{ - return getFoamName(reader_->GetPartArrayName(partId)); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::vtkPVFoam::vtkPVFoam -( - const char* const vtkFileName, - vtkPVFoamReader* reader -) -: - reader_(reader), - dbPtr_(nullptr), - volMeshPtr_(nullptr), - areaMeshPtr_(nullptr), - meshRegion_(polyMesh::defaultRegion), - meshDir_(polyMesh::meshSubDir), - timeIndex_(-1), - decomposePoly_(false), - meshState_(polyMesh::TOPO_CHANGE), - rangeVolume_("volMesh"), - rangeArea_("areaMesh"), - rangePatches_("patch"), - rangeClouds_("lagrangian"), - rangeCellZones_("cellZone"), - rangeFaceZones_("faceZone"), - rangePointZones_("pointZone"), - rangeCellSets_("cellSet"), - rangeFaceSets_("faceSet"), - rangePointSets_("pointSet") -{ - if (debug) - { - Info<< "vtkPVFoam - " << vtkFileName << nl; - printMemory(); - } - - fileName FileName(vtkFileName); - - // avoid argList and get rootPath/caseName directly from the file - fileName fullCasePath(FileName.path()); - - if (!isDir(fullCasePath)) - { - return; - } - if (fullCasePath == ".") - { - fullCasePath = cwd(); - } - - // OPENFOAM API - setEnv("FOAM_API", std::to_string(foamVersion::api), true); - - // The name of the executable, unless already present in the environment - setEnv("FOAM_EXECUTABLE", "paraview", false); - - // Set the case as an environment variable - some BCs might use this - if (fullCasePath.name().find("processors", 0) == 0) - { - // FileName e.g. "cavity/processors256/processor1.OpenFOAM - // Remove the processors section so it goes into processorDDD - // checking below. - fullCasePath = fullCasePath.path()/fileName(FileName.name()).lessExt(); - } - - - if (fullCasePath.name().find("processor", 0) == 0) - { - // Give filehandler opportunity to analyse number of processors - (void)fileHandler().filePath(fullCasePath); - - const fileName globalCase = fullCasePath.path(); - - setEnv("FOAM_CASE", globalCase, true); - setEnv("FOAM_CASENAME", globalCase.name(), true); - } - else - { - setEnv("FOAM_CASE", fullCasePath, true); - setEnv("FOAM_CASENAME", fullCasePath.name(), true); - } - - // look for 'case{region}.OpenFOAM' - // could be stringent and insist the prefix match the directory name... - // Note: cannot use fileName::name() due to the embedded '{}' - string caseName(fileName(FileName).lessExt()); - const auto beg = caseName.find_last_of("/{"); - const auto end = caseName.find('}', beg); - - if - ( - beg != std::string::npos && caseName[beg] == '{' - && end != std::string::npos && end == caseName.size()-1 - ) - { - meshRegion_ = caseName.substr(beg+1, end-beg-1); - - // some safety - if (meshRegion_.empty()) - { - meshRegion_ = polyMesh::defaultRegion; - } - - if (meshRegion_ != polyMesh::defaultRegion) - { - meshDir_ = meshRegion_/polyMesh::meshSubDir; - } - } - - DebugInfo - << "fullCasePath=" << fullCasePath << nl - << "FOAM_CASE=" << getEnv("FOAM_CASE") << nl - << "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl - << "region=" << meshRegion_ << nl; - - // Create time object - dbPtr_.reset - ( - new Time - ( - Time::controlDictName, - fileName(fullCasePath.path()), - fileName(fullCasePath.name()) - ) - ); - - dbPtr_().functionObjects().off(); - - updateInfo(); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::vtkPVFoam::~vtkPVFoam() -{ - DebugInfo << "~vtkPVFoam" << nl; - - delete volMeshPtr_; - delete areaMeshPtr_; -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::vtkPVFoam::updateInfo() -{ - DebugInfo - << "<beg> updateInfo" - << " [volMeshPtr=" << (volMeshPtr_ ? "set" : "nullptr") - << "] timeIndex=" - << timeIndex_ << nl; - - resetCounters(); - - // Part selection - { - vtkDataArraySelection* select = reader_->GetPartSelection(); - - // There are two ways to ensure we have the correct list of parts: - // 1. remove everything and then set particular entries 'on' - // 2. build a 'char **' list and call SetArraysWithDefault() - // - // Nr. 2 has the potential advantage of not touching the modification - // time of the vtkDataArraySelection, but the qt/paraview proxy - // layer doesn't care about that anyhow. - - HashSet<string> enabled; - if (!select->GetNumberOfArrays() && !volMeshPtr_) - { - // Fake enable 'internalMesh' on the first call - enabled = { "internalMesh" }; - } - else - { - // Preserve the enabled selections - enabled = getSelectedArraySet(select); - } - - select->RemoveAllArrays(); // Clear existing list - - // Update mesh parts list - add Lagrangian at the bottom - updateInfoInternalMesh(select); - updateInfoPatches(select, enabled); - updateInfoSets(select); - updateInfoZones(select); - updateInfoAreaMesh(select); - updateInfoLagrangian(select); - - setSelectedArrayEntries(select, enabled); // Adjust/restore selected - } - - // Volume and area fields - includes save/restore of selected - updateInfoContinuumFields(reader_->GetVolFieldSelection()); - - // Point fields - includes save/restore of selected - updateInfoPointFields(reader_->GetPointFieldSelection()); - - // Lagrangian fields - includes save/restore of selected - updateInfoLagrangianFields(reader_->GetLagrangianFieldSelection()); - - DebugInfo << "<end> updateInfo" << nl; -} - - -void Foam::vtkPVFoam::Update -( - vtkMultiBlockDataSet* output, - vtkMultiBlockDataSet* outputLagrangian -) -{ - if (debug) - { - cout<< "<beg> Foam::vtkPVFoam::Update\n"; - output->Print(cout); - if (outputLagrangian) outputLagrangian->Print(cout); - printMemory(); - } - reader_->UpdateProgress(0.1); - - const int caching = reader_->GetMeshCaching(); - const bool oldDecomp = decomposePoly_; - decomposePoly_ = !reader_->GetUseVTKPolyhedron(); - - // Set up mesh parts selection(s) - // Update cached, saved, unneed values. - { - vtkDataArraySelection* selection = reader_->GetPartSelection(); - const int n = selection->GetNumberOfArrays(); - - selectedPartIds_.clear(); - HashSet<string> nowActive; - - for (int id=0; id < n; ++id) - { - const string str(selection->GetArrayName(id)); - const bool status = selection->GetArraySetting(id); - - if (status) - { - selectedPartIds_.set(id, str); // id -> name - nowActive.set(str); - } - - if (debug > 1) - { - Info<< " part[" << id << "] = " << status - << " : " << str << nl; - } - } - - // Dispose of unneeded components - cachedVtp_.retain(nowActive); - cachedVtu_.retain(nowActive); - - if - ( - !caching - || meshState_ == polyMesh::TOPO_CHANGE - || meshState_ == polyMesh::TOPO_PATCH_CHANGE - ) - { - // Eliminate cached values that would be unreliable - forAllIters(cachedVtp_, iter) - { - iter.val().clearGeom(); - iter.val().clear(); - } - forAllIters(cachedVtu_, iter) - { - iter.val().clearGeom(); - iter.val().clear(); - } - } - else if (oldDecomp != decomposePoly_) - { - // poly-decompose changed - dispose of cached values - forAllIters(cachedVtu_, iter) - { - iter.val().clearGeom(); - iter.val().clear(); - } - } - } - - reader_->UpdateProgress(0.15); - - // Update the OpenFOAM mesh - { - if (debug) - { - Info<< "<beg> updateFoamMesh" << nl; - printMemory(); - } - - if (!caching) - { - delete volMeshPtr_; - delete areaMeshPtr_; - - volMeshPtr_ = nullptr; - areaMeshPtr_ = nullptr; - } - - // Check to see if the OpenFOAM mesh has been created - if (!volMeshPtr_) - { - DebugInfo - << "Creating OpenFOAM mesh for region " << meshRegion_ - << " at time=" << dbPtr_().timeName() << nl; - - volMeshPtr_ = new fvMesh - ( - IOobject - ( - meshRegion_, - dbPtr_().timeName(), - dbPtr_(), - IOobject::MUST_READ - ) - ); - - meshState_ = polyMesh::TOPO_CHANGE; // New mesh - } - else - { - DebugInfo << "Using existing OpenFOAM mesh" << nl; - } - - if (rangeArea_.intersects(selectedPartIds_)) - { - if (!areaMeshPtr_) - { - areaMeshPtr_ = new faMesh(*volMeshPtr_); - } - } - else - { - delete areaMeshPtr_; - - areaMeshPtr_ = nullptr; - } - - if (debug) - { - Info<< "<end> updateFoamMesh" << nl; - printMemory(); - } - } - - reader_->UpdateProgress(0.4); - - convertMeshVolume(); - convertMeshPatches(); - reader_->UpdateProgress(0.6); - - if (reader_->GetIncludeZones()) - { - convertMeshCellZones(); - convertMeshFaceZones(); - convertMeshPointZones(); - reader_->UpdateProgress(0.65); - } - - if (reader_->GetIncludeSets()) - { - convertMeshCellSets(); - convertMeshFaceSets(); - convertMeshPointSets(); - reader_->UpdateProgress(0.7); - } - - convertMeshArea(); - - convertMeshLagrangian(); - - reader_->UpdateProgress(0.8); - - // Update fields - convertVolFields(); - convertPointFields(); - convertAreaFields(); - - convertLagrangianFields(); - - // Assemble multiblock output - addOutputBlock(output, cachedVtu_, rangeVolume_, true); // One dataset - addOutputBlock(output, cachedVtp_, rangePatches_); - addOutputBlock(output, cachedVtu_, rangeCellZones_); - addOutputBlock(output, cachedVtp_, rangeFaceZones_); - addOutputBlock(output, cachedVtp_, rangePointZones_); - addOutputBlock(output, cachedVtu_, rangeCellSets_); - addOutputBlock(output, cachedVtp_, rangeFaceSets_); - addOutputBlock(output, cachedVtp_, rangePointSets_); - addOutputBlock(output, cachedVtp_, rangeArea_); - addOutputBlock - ( - (outputLagrangian ? outputLagrangian : output), - cachedVtp_, - rangeClouds_ - ); - - DebugInfo << "done reader part" << nl << nl; - reader_->UpdateProgress(0.95); - - meshState_ = polyMesh::UNCHANGED; - - if (caching & 2) - { - // Suppress caching of Lagrangian since it normally always changes. - cachedVtp_.filterKeys - ( - [](const word& k){ return k.starts_with("lagrangian/"); }, - true // prune - ); - } - else - { - cachedVtp_.clear(); - cachedVtu_.clear(); - } -} - - -void Foam::vtkPVFoam::UpdateFinalize() -{ - if (!reader_->GetMeshCaching()) - { - delete volMeshPtr_; - delete areaMeshPtr_; - - volMeshPtr_ = nullptr; - areaMeshPtr_ = nullptr; - } - - reader_->UpdateProgress(1.0); -} - - -std::vector<double> Foam::vtkPVFoam::findTimes(const bool skipZero) const -{ - std::vector<double> times; - - if (dbPtr_.valid()) - { - const Time& runTime = dbPtr_(); - // Get times list. Flush first to force refresh. - fileHandler().flush(); - instantList timeLst = runTime.times(); - - // find the first time for which this mesh appears to exist - label begIndex = timeLst.size(); - forAll(timeLst, timei) - { - if - ( - IOobject - ( - "points", - timeLst[timei].name(), - meshDir_, - runTime - ).typeHeaderOk<pointIOField>(false, false) - ) - { - begIndex = timei; - break; - } - } - - label nTimes = timeLst.size() - begIndex; - - // skip "constant" time whenever possible - if (begIndex == 0 && nTimes > 1) - { - if (timeLst[begIndex].name() == runTime.constant()) - { - ++begIndex; - --nTimes; - } - } - - // skip "0/" time if requested and possible - if (skipZero && nTimes > 1 && timeLst[begIndex].name() == "0") - { - ++begIndex; - --nTimes; - } - - times.reserve(nTimes); - while (nTimes-- > 0) - { - times.push_back(timeLst[begIndex++].value()); - } - } - else - { - if (debug) - { - cout<< "no valid dbPtr:\n"; - } - } - - return times; -} - - -void Foam::vtkPVFoam::renderPatchNames -( - vtkRenderer* renderer, - const bool show -) -{ - // Always remove old actors first - - for (auto& actor : patchTextActors_) - { - renderer->RemoveViewProp(actor); - } - patchTextActors_.clear(); - - if (show && volMeshPtr_) - { - // Get the display patches, strip off any prefix/suffix - wordHashSet selectedPatches - ( - getSelected(reader_->GetPartSelection(), rangePatches_) - ); - - if (selectedPatches.empty()) - { - return; - } - - const polyBoundaryMesh& pbMesh = volMeshPtr_->boundaryMesh(); - - // Find the total number of zones - // Each zone will take the patch name - // Number of zones per patch ... zero zones should be skipped - labelList nZones(pbMesh.size(), Zero); - - // Per global zone number the average face centre position - List<DynamicList<point>> zoneCentre(pbMesh.size()); - - - // Loop through all patches to determine zones, and centre of each zone - forAll(pbMesh, patchi) - { - const polyPatch& pp = pbMesh[patchi]; - - // Only include the patch if it is selected - if (!selectedPatches.found(pp.name())) - { - continue; - } - - const labelListList& edgeFaces = pp.edgeFaces(); - const vectorField& n = pp.faceNormals(); - - boolList featEdge(pp.nEdges(), false); - - forAll(edgeFaces, edgei) - { - const labelList& eFaces = edgeFaces[edgei]; - - if (eFaces.size() == 1) - { - // Note: could also do ones with > 2 faces but this gives - // too many zones for baffles - featEdge[edgei] = true; - } - else if (mag(n[eFaces[0]] & n[eFaces[1]]) < 0.5) - { - featEdge[edgei] = true; - } - } - - // Do topological analysis of patch, find disconnected regions - patchZones pZones(pp, featEdge); - - nZones[patchi] = pZones.nZones(); - - labelList zoneNFaces(pZones.nZones(), Zero); - - // Create storage for additional zone centres - forAll(zoneNFaces, zonei) - { - zoneCentre[patchi].append(Zero); - } - - // Do averaging per individual zone - forAll(pp, facei) - { - const label zonei = pZones[facei]; - zoneCentre[patchi][zonei] += pp[facei].centre(pp.points()); - zoneNFaces[zonei]++; - } - - forAll(zoneCentre[patchi], zonei) - { - zoneCentre[patchi][zonei] /= zoneNFaces[zonei]; - } - } - - // Count number of zones we're actually going to display. - // This is truncated to a max per patch - - const label MAXPATCHZONES = 20; - - label displayZoneI = 0; - - forAll(pbMesh, patchi) - { - displayZoneI += min(MAXPATCHZONES, nZones[patchi]); - } - - DebugInfo - << "displayed zone centres = " << displayZoneI << nl - << "zones per patch = " << nZones << nl; - - // Set the size of the patch labels to max number of zones - patchTextActors_.setSize(displayZoneI); - - DebugInfo << "constructing patch labels" << nl; - - // Actor index - displayZoneI = 0; - - forAll(pbMesh, patchi) - { - const polyPatch& pp = pbMesh[patchi]; - - // Only selected patches will have a non-zero number of zones - const label nDisplayZones = min(MAXPATCHZONES, nZones[patchi]); - label increment = 1; - if (nZones[patchi] >= MAXPATCHZONES) - { - increment = nZones[patchi]/MAXPATCHZONES; - } - - label globalZoneI = 0; - for (label i = 0; i < nDisplayZones; ++i, globalZoneI += increment) - { - DebugInfo - << "patch name = " << pp.name() << nl - << "anchor = " << zoneCentre[patchi][globalZoneI] << nl - << "globalZoneI = " << globalZoneI << nl; - - // Into a list for later removal - patchTextActors_[displayZoneI++] = createTextActor - ( - pp.name(), - zoneCentre[patchi][globalZoneI] - ); - } - } - - // Resize the patch names list to the actual number of patch names added - patchTextActors_.setSize(displayZoneI); - } - - // Add text to each renderer - for (auto& actor : patchTextActors_) - { - renderer->AddViewProp(actor); - } -} - - -void Foam::vtkPVFoam::PrintSelf(ostream& os, vtkIndent indent) const -{ - os << indent << "Number of nodes: " - << (volMeshPtr_ ? volMeshPtr_->nPoints() : 0) << "\n"; - - os << indent << "Number of cells: " - << (volMeshPtr_ ? volMeshPtr_->nCells() : 0) << "\n"; - - os << indent << "Number of available time steps: " - << (dbPtr_.valid() ? dbPtr_().times().size() : 0) << "\n"; - - os << indent << "mesh region: " << meshRegion_ << "\n"; -} - - -void Foam::vtkPVFoam::printInfo() const -{ - std::cout - << "Region: " << meshRegion_ << "\n" - << "nPoints: " << (volMeshPtr_ ? volMeshPtr_->nPoints() : 0) << "\n" - << "nCells: " << (volMeshPtr_ ? volMeshPtr_->nCells() : 0) << "\n" - << "nTimes: " - << (dbPtr_.valid() ? dbPtr_().times().size() : 0) << "\n"; - - std::vector<double> times = this->findTimes(reader_->GetSkipZeroTime()); - - std::cout<<" " << times.size() << "("; - for (const double& val : times) - { - std::cout<< ' ' << val; - } - std::cout << " )" << std::endl; -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoam.H b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoam.H deleted file mode 100644 index b4960c223065d8710e4b803194900e4e3d8e23b2..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoam.H +++ /dev/null @@ -1,503 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-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 <http://www.gnu.org/licenses/>. - -Class - Foam::vtkPVFoam - -Description - The backend for the vtkPVFoamReader reader module - - providing a paraview reader interface for OpenFOAM meshes and fields. - - Similar, and sometimes better, functionality may be provided by the - native VTK OpenFOAM reader. OpenCFD has recently (2017) been working - on improving the native VTK OpenFOAM reader for the benefit of everyone. - - In some areas the reader module lacks compared to the native reader - (notably the ability to work on decomosed datasets), but provides - additional handling of sets,zones,groups. Some features have also since - been adapted to the native reader. Additionally, the reader module - provides a useful platform for testing new ideas. - -Note - The reader module allows two levels of caching. The OpenFOAM fvMesh - can be cached in memory, for faster loading of fields. Additionally, - the translated VTK geometries are held in a local cache. The cached - VTK geometries should incur no additional overhead since they use - the VTK reference counting for their storage management. - -SourceFiles - vtkPVFoam.C - vtkPVFoamFields.C - vtkPVFoamMesh.C - vtkPVFoamMeshLagrangian.C - vtkPVFoamMeshVolume.C - vtkPVFoamTemplates.C - vtkPVFoamUpdateInfo.C - vtkPVFoamFieldTemplates.C - vtkPVFoamUpdateTemplates.C - - // Needed by VTK: - vtkDataArrayTemplateImplicit.txx - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkPVFoam_H -#define vtkPVFoam_H - -#include "className.H" -#include "fileName.H" -#include "stringList.H" -#include "wordList.H" -#include "primitivePatch.H" -#include "PrimitivePatchInterpolation.H" -#include "volPointInterpolation.H" -#include "foamPvCore.H" -#include "foamVtkVtuAdaptor.H" - -// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * // - -class vtkCellArray; -class vtkDataArraySelection; -class vtkDataSet; -class vtkFloatArray; -class vtkIndent; -class vtkPVFoamReader; -class vtkRenderer; -class vtkTextActor; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// Forward declarations (OpenFOAM) -class argList; -class Time; -class faMesh; -class fvMesh; -class IOobjectList; -class polyPatch; -class fvMeshSubset; - -template<class Type> class IOField; -template<class Type> class Field; -template<class Type> class List; - -/*---------------------------------------------------------------------------*\ - Class vtkPVFoam Declaration -\*---------------------------------------------------------------------------*/ - -class vtkPVFoam -: - private foamPvCore -{ - // Convenience typedefs - typedef PrimitivePatchInterpolation<primitivePatch> patchInterpolator; - - //- Bookkeeping for vtkPolyData - struct foamVtpData - : - public vtk::Caching<vtkPolyData>, - public foamVtkMeshMaps - {}; - - //- Bookkeeping for vtkUnstructuredGrid - struct foamVtuData - : - public vtk::vtuAdaptor - { - //- Subsetted mesh as vtkUnstructuredGrid - vtkSmartPointer<vtkUnstructuredGrid> subset - ( - const fvMeshSubset& subsetter, - bool decompPoly = false - ); - }; - - - // Private Data - - //- Access to the controlling vtkPVFoamReader - vtkPVFoamReader* reader_; - - //- OpenFOAM time control - autoPtr<Time> dbPtr_; - - //- OpenFOAM finite volume mesh - fvMesh* volMeshPtr_; - - //- OpenFOAM finite area mesh - faMesh* areaMeshPtr_; - - //- The mesh region - word meshRegion_; - - //- The mesh directory for the region - fileName meshDir_; - - //- The time index - int timeIndex_; - - //- Previous/current decomposition request - bool decomposePoly_; - - //- Track changes in mesh geometry - enum polyMesh::readUpdateState meshState_; - - //- The index of selected parts mapped to their names - Map<string> selectedPartIds_; - - //- Any information for 2D (VTP) geometries - HashTable<foamVtpData, string> cachedVtp_; - - //- Cell maps and other information for 3D (VTU) geometries - HashTable<foamVtuData, string> cachedVtu_; - - //- First instance and size of various mesh parts - // used to index into selectedPartIds and thus indirectly into - // cachedVtp, cachedVtu - arrayRange rangeVolume_; - arrayRange rangeArea_; - arrayRange rangePatches_; - arrayRange rangeClouds_; - arrayRange rangeCellZones_; - arrayRange rangeFaceZones_; - arrayRange rangePointZones_; - arrayRange rangeCellSets_; - arrayRange rangeFaceSets_; - arrayRange rangePointSets_; - - //- List of patch names for rendering to window - List<vtkSmartPointer<vtkTextActor>> patchTextActors_; - - - // Private Member Functions - - template<class Container> - bool addOutputBlock - ( - vtkMultiBlockDataSet* output, - const HashTable<Container, string>& cache, - const arrayRange& selector, - const bool singleDataset = false - ) const; - - - //- Reset data counters - void resetCounters(); - - // Update information helper functions - - //- Internal mesh info - void updateInfoInternalMesh(vtkDataArraySelection* select); - - //- Finite area mesh info - void updateInfoAreaMesh(vtkDataArraySelection* select); - - //- Lagrangian info - void updateInfoLagrangian(vtkDataArraySelection* select); - - //- Patch info, modifies enabledEntries - void updateInfoPatches - ( - vtkDataArraySelection* select, - HashSet<string>& enabledEntries - ); - - //- Set info - void updateInfoSets(vtkDataArraySelection* select); - - //- Zone info - void updateInfoZones(vtkDataArraySelection* select); - - - //- Get non-empty zone names for zoneType from file - wordList getZoneNames(const word& zoneType) const; - - //- Get names of on non-empty zones from the mesh info - template<class ZoneType> - static wordList getZoneNames - ( - const ZoneMesh<ZoneType, polyMesh>& zmesh - ); - - //- Field info - template<template<class> class patchType, class meshType> - void updateInfoFields - ( - vtkDataArraySelection* select, - const IOobjectList& objects - ); - - //- Volume/Area field info - void updateInfoContinuumFields(vtkDataArraySelection* select); - - //- Point field info - void updateInfoPointFields(vtkDataArraySelection* select); - - //- Lagrangian field info - void updateInfoLagrangianFields(vtkDataArraySelection* select); - - - // Mesh conversion functions - - //- Convert internalMesh - void convertMeshVolume(); - - //- Convert areaMesh - void convertMeshArea(); - - //- Convert Lagrangian points - void convertMeshLagrangian(); - - //- Convert mesh patches. - // The additionalIds (cached data) contain the patch Ids. - // There will be several for groups, but only one for regular patches. - void convertMeshPatches(); - - //- Convert cell zones - void convertMeshCellZones(); - - //- Convert cell sets - void convertMeshCellSets(); - - //- Convert face zones - void convertMeshFaceZones(); - - //- Convert face sets - // The cellMap (cached data) contains the face-labels. - void convertMeshFaceSets(); - - //- Convert point zones - // The pointMap (cached data) contains the point-labels. - void convertMeshPointZones(); - - //- Convert point sets - // The pointMap (cached data) contains the point-labels. - void convertMeshPointSets(); - - - // Add mesh functions - - //- Lagrangian positions as vtkPolyData - vtkSmartPointer<vtkPolyData> lagrangianVTKMesh - ( - const polyMesh& mesh, - const word& cloudName - ) const; - - - // Field conversion functions - - //- Face set/zone field - template<class Type> - vtkSmartPointer<vtkFloatArray> convertFaceFieldToVTK - ( - const GeometricField<Type, fvPatchField, volMesh>& fld, - const labelUList& faceLabels - ) const; - - - //- Convert finite volume fields - void convertVolFields(); - - //- Convert finite area fields - void convertAreaFields(); - - //- Convert point fields - void convertPointFields(); - - //- Convert Lagrangian fields - void convertLagrangianFields(); - - - // Convert OpenFOAM fields - - //- Volume field - all types - template<class Type> - void convertVolField - ( - const PtrList<patchInterpolator>& patchInterpList, - const GeometricField<Type, fvPatchField, volMesh>& fld - ); - - //- Volume fields - all types - template<class Type> - void convertVolFields - ( - const fvMesh& mesh, - const PtrList<patchInterpolator>& patchInterpList, - const IOobjectList& objects - ); - - //- Volume internal fields (DimensionedField)- all types - template<class Type> - void convertDimFields - ( - const fvMesh& mesh, - const PtrList<patchInterpolator>& patchInterpList, - const IOobjectList& objects - ); - - //- Area fields - all types - template<class Type> - void convertAreaFields - ( - const faMesh& mesh, - const IOobjectList& objects - ); - - //- Volume field - all selected parts - template<class Type> - void convertVolFieldBlock - ( - const GeometricField<Type, fvPatchField, volMesh>& fld, - autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr, - const arrayRange& range - ); - - //- Lagrangian fields - all types - template<class Type> - void convertLagrangianFields - ( - const IOobjectList& objects, - vtkPolyData* vtkmesh - ); - - //- Point fields - all types - template<class Type> - void convertPointFields - ( - const pointMesh& pMesh, - const IOobjectList& objectst - ); - - //- Point field - all selected parts - template<class Type> - void convertPointFieldBlock - ( - const GeometricField<Type, pointPatchField, pointMesh>& pfld, - const arrayRange& range - ); - - //- Point field - template<class Type> - vtkSmartPointer<vtkFloatArray> convertPointField - ( - const GeometricField<Type, pointPatchField, pointMesh>& pfld, - const GeometricField<Type, fvPatchField, volMesh>& vfld, - const foamVtuData& vtuData - ); - - - // GUI selection helper functions - - //- Get the first word from the reader 'parts' selection - word getReaderPartName(const int partId) const; - - - // Constructors - - //- No copy construct - vtkPVFoam(const vtkPVFoam&) = delete; - - //- No copy assignment - void operator=(const vtkPVFoam&) = delete; - - -public: - - //- Static data members - - ClassName("vtkPVFoam"); - - - // Constructors - - //- Construct from components - vtkPVFoam - ( - const char* const FileName, - vtkPVFoamReader* reader - ); - - - //- Destructor - ~vtkPVFoam(); - - - // Member Functions - - //- Update - void updateInfo(); - - void Update - ( - vtkMultiBlockDataSet* output, - vtkMultiBlockDataSet* outputLagrangian - ); - - //- Final part of Update(), after any last minute rendering. - void UpdateFinalize(); - - //- Add/remove patch names to/from the view - void renderPatchNames(vtkRenderer* renderer, const bool show); - - //- Return a list of selected times. - // Use STL container since these values are used by the plugin - std::vector<double> findTimes(const bool skipZero = false) const; - - //- Set the runTime to the first plausible request time, - // returns the timeIndex - // sets to "constant" on error - int setTime(const std::vector<double>& requestTimes); - - - //- The current time index - int timeIndex() const - { - return timeIndex_; - } - - - // Access - - //- Debug information - void PrintSelf(ostream&, vtkIndent) const; - - void printInfo() const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamFieldTemplates.C b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamFieldTemplates.C deleted file mode 100644 index 6e9a709d8741b338bebc93680a616ded0cbe314a..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamFieldTemplates.C +++ /dev/null @@ -1,901 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2017-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 <http://www.gnu.org/licenses/>. - -InClass - vtkPVFoam - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkPVFoamFieldTemplates_C -#define vtkPVFoamFieldTemplates_C - -// OpenFOAM includes -#include "error.H" -#include "emptyFvPatchField.H" -#include "wallPolyPatch.H" -#include "faceSet.H" -#include "volPointInterpolation.H" -#include "zeroGradientFvPatchField.H" -#include "interpolatePointToCell.H" -#include "areaFaMesh.H" -#include "areaFields.H" - -// VTK includes -#include <vtkFloatArray.h> -#include <vtkCellData.h> -#include <vtkPointData.h> -#include <vtkSmartPointer.h> - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// -// volume-fields -// - -template<class Type> -void Foam::vtkPVFoam::convertVolField -( - const PtrList<patchInterpolator>& patchInterpList, - const GeometricField<Type, fvPatchField, volMesh>& fld -) -{ - const fvMesh& mesh = fld.mesh(); - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - const bool interpField = !patchInterpList.empty(); - const bool extrapPatch = reader_->GetExtrapolatePatches(); - - // Interpolated field (demand driven) - autoPtr<GeometricField<Type, pointPatchField, pointMesh>> ptfPtr; - if (interpField) - { - DebugInfo << "convertVolField interpolating:" << fld.name() << nl; - - ptfPtr.reset - ( - volPointInterpolation::New(mesh).interpolate(fld).ptr() - ); - } - - convertVolFieldBlock(fld, ptfPtr, rangeVolume_); // internalMesh - convertVolFieldBlock(fld, ptfPtr, rangeCellZones_); // cellZones - convertVolFieldBlock(fld, ptfPtr, rangeCellSets_); // cellSets - - // Patches - currently skip field conversion for groups - for - ( - const auto partId - : rangePatches_.intersection(selectedPartIds_) - ) - { - const auto& longName = selectedPartIds_[partId]; - - auto iter = cachedVtp_.find(longName); - if (!iter.found() || !iter.val().dataset) - { - // Should not happen, but for safety require a vtk geometry - continue; - } - - foamVtpData& vtpData = iter.val(); - auto dataset = vtpData.dataset; - - const labelUList& patchIds = vtpData.additionalIds(); - - if (patchIds.empty()) - { - continue; - } - - // This is slightly roundabout, but we deal with groups and with - // single patches. - // For groups (spanning several patches) it is fairly messy to - // get interpolated point fields. We would need to create a indirect - // patch each time to obtain the mesh points. We thus skip that. - // - // To improve code reuse, we allocate the CellData as a zeroed-field - // ahead of time. - - vtkSmartPointer<vtkFloatArray> cdata = vtk::Tools::zeroField<Type> - ( - fld.name(), - dataset->GetNumberOfPolys() - ); - - vtkSmartPointer<vtkFloatArray> pdata; - const bool allowPdata = (interpField && patchIds.size() == 1); - - label coffset = 0; // the write offset into cell-data - for (label patchId : patchIds) - { - const fvPatchField<Type>& ptf = fld.boundaryField()[patchId]; - - if - ( - isType<emptyFvPatchField<Type>>(ptf) - || - ( - extrapPatch - && !polyPatch::constraintType(patches[patchId].type()) - ) - ) - { - fvPatch p(ptf.patch().patch(), mesh.boundary()); - - tmp<Field<Type>> tpptf - ( - fvPatchField<Type>(p, fld).patchInternalField() - ); - - coffset += - vtk::Tools::transcribeFloatData(cdata, tpptf(), coffset); - - if (allowPdata && patchId < patchInterpList.size()) - { - pdata = vtk::Tools::convertFieldToVTK - ( - fld.name(), - patchInterpList[patchId].faceToPointInterpolate(tpptf)() - ); - } - } - else - { - coffset += - vtk::Tools::transcribeFloatData(cdata, ptf, coffset); - - if (allowPdata && patchId < patchInterpList.size()) - { - pdata = vtk::Tools::convertFieldToVTK - ( - fld.name(), - patchInterpList[patchId].faceToPointInterpolate(ptf)() - ); - } - } - } - - if (cdata) - { - dataset->GetCellData()->AddArray(cdata); - } - if (pdata) - { - dataset->GetPointData()->AddArray(pdata); - } - } - - - // Face Zones - for - ( - const auto partId - : rangeFaceZones_.intersection(selectedPartIds_) - ) - { - const auto& longName = selectedPartIds_[partId]; - const word zoneName = getFoamName(longName); - - auto iter = cachedVtp_.find(longName); - if (!iter.found() || !iter.val().dataset) - { - // Should not happen, but for safety require a vtk geometry - continue; - } - - foamVtpData& vtpData = iter.val(); - auto dataset = vtpData.dataset; - - const faceZoneMesh& zMesh = mesh.faceZones(); - const label zoneId = zMesh.findZoneID(zoneName); - - if (zoneId < 0) - { - continue; - } - - vtkSmartPointer<vtkFloatArray> cdata = - convertFaceFieldToVTK - ( - fld, - zMesh[zoneId] - ); - - dataset->GetCellData()->AddArray(cdata); - - // TODO: point data - } - - - // Face Sets - for - ( - const auto partId - : rangeFaceSets_.intersection(selectedPartIds_) - ) - { - const auto& longName = selectedPartIds_[partId]; - const word selectName = getFoamName(longName); - - auto iter = cachedVtp_.find(longName); - if (!iter.found() || !iter.val().dataset) - { - // Should not happen, but for safety require a vtk geometry - continue; - } - foamVtpData& vtpData = iter.val(); - auto dataset = vtpData.dataset; - - vtkSmartPointer<vtkFloatArray> cdata = convertFaceFieldToVTK - ( - fld, - vtpData.cellMap() - ); - - dataset->GetCellData()->AddArray(cdata); - - // TODO: point data - } -} - - -template<class Type> -void Foam::vtkPVFoam::convertVolFields -( - const fvMesh& mesh, - const PtrList<patchInterpolator>& patchInterpList, - const IOobjectList& objects -) -{ - typedef GeometricField<Type, fvPatchField, volMesh> FieldType; - - forAllConstIters(objects, iter) - { - // Restrict to GeometricField<Type, ...> - const auto& ioobj = *(iter.val()); - - if (ioobj.headerClassName() == FieldType::typeName) - { - // Throw FatalError, FatalIOError as exceptions - const bool throwingError = FatalError.throwExceptions(); - const bool throwingIOerr = FatalIOError.throwExceptions(); - - try - { - // Load field - FieldType fld(ioobj, mesh); - - // Convert - convertVolField(patchInterpList, fld); - } - catch (const Foam::IOerror& ioErr) - { - ioErr.write(Warning, false); - Info<< nl << endl; - } - catch (const Foam::error& err) - { - // Bit of trickery to get the original message - err.write(Warning, false); - Info<< nl << endl; - } - - // Restore previous exception throwing state - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOerr); - } - } -} - - -template<class Type> -void Foam::vtkPVFoam::convertDimFields -( - const fvMesh& mesh, - const PtrList<patchInterpolator>& patchInterpList, - const IOobjectList& objects -) -{ - typedef DimensionedField<Type, volMesh> FieldType; - typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; - - forAllConstIters(objects, iter) - { - // Restrict to DimensionedField<Type, ...> - const auto& ioobj = *(iter.val()); - - if (ioobj.headerClassName() != FieldType::typeName) - { - continue; - } - - // Throw FatalError, FatalIOError as exceptions - const bool throwingError = FatalError.throwExceptions(); - const bool throwingIOerr = FatalIOError.throwExceptions(); - - try - { - // Load field - FieldType dimFld(ioobj, mesh); - - // Construct volField with zero-gradient patch fields - - IOobject io(dimFld); - io.readOpt() = IOobject::NO_READ; - - PtrList<fvPatchField<Type>> patchFields(mesh.boundary().size()); - forAll(patchFields, patchI) - { - patchFields.set - ( - patchI, - fvPatchField<Type>::New - ( - zeroGradientFvPatchField<Type>::typeName, - mesh.boundary()[patchI], - dimFld - ) - ); - } - - VolFieldType volFld - ( - io, - dimFld.mesh(), - dimFld.dimensions(), - dimFld, - patchFields - ); - volFld.correctBoundaryConditions(); - - convertVolField(patchInterpList, volFld); - } - catch (const Foam::IOerror& ioErr) - { - ioErr.write(Warning, false); - Info<< nl << endl; - } - catch (const Foam::error& err) - { - // Bit of trickery to get the original message - err.write(Warning, false); - Info<< nl << endl; - } - - // Restore previous exception throwing state - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOerr); - } -} - - -template<class Type> -void Foam::vtkPVFoam::convertVolFieldBlock -( - const GeometricField<Type, fvPatchField, volMesh>& fld, - autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr, - const arrayRange& range -) -{ - for - ( - const auto partId - : range.intersection(selectedPartIds_) - ) - { - const auto& longName = selectedPartIds_[partId]; - - auto iter = cachedVtu_.find(longName); - if (!iter.found() || !iter.val().dataset) - { - // Should not happen, but for safety require a vtk geometry - continue; - } - - foamVtuData& vtuData = iter.val(); - auto dataset = vtuData.dataset; - - dataset->GetCellData()->AddArray - ( - vtuData.convertField(fld) - ); - - if (ptfPtr.valid()) - { - dataset->GetPointData()->AddArray - ( - convertPointField(*ptfPtr, fld, vtuData) - ); - } - } -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// -// area-fields -// - -template<class Type> -void Foam::vtkPVFoam::convertAreaFields -( - const faMesh& mesh, - const IOobjectList& objects -) -{ - typedef GeometricField<Type, faPatchField, areaMesh> FieldType; - - const List<label> partIds = - rangeArea_.intersection(selectedPartIds_); - - if (partIds.empty()) - { - return; - } - - forAllConstIters(objects, iter) - { - // Restrict to GeometricField<Type, ...> - const auto& ioobj = *(iter.val()); - - if (ioobj.headerClassName() == FieldType::typeName) - { - // Throw FatalError, FatalIOError as exceptions - const bool throwingError = FatalError.throwExceptions(); - const bool throwingIOerr = FatalIOError.throwExceptions(); - - try - { - // Load field - FieldType fld(ioobj, mesh); - - // Convert - for (const auto partId : partIds) - { - const auto& longName = selectedPartIds_[partId]; - - auto iter = cachedVtp_.find(longName); - if (!iter.found() || !iter.val().dataset) - { - // Should not happen, but for safety require a vtk - // geometry - continue; - } - - foamVtpData& vtpData = iter.val(); - auto dataset = vtpData.dataset; - - vtkSmartPointer<vtkFloatArray> cdata = - vtk::Tools::convertFieldToVTK - ( - fld.name(), - fld - ); - - dataset->GetCellData()->AddArray(cdata); - } - } - catch (const Foam::IOerror& ioErr) - { - ioErr.write(Warning, false); - Info<< nl << endl; - } - catch (const Foam::error& err) - { - // Bit of trickery to get the original message - err.write(Warning, false); - Info<< nl << endl; - } - - // Restore previous exception throwing state - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOerr); - } - } -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// -// point-fields -// -template<class Type> -void Foam::vtkPVFoam::convertPointFields -( - const pointMesh& pMesh, - const IOobjectList& objects -) -{ - const polyMesh& mesh = pMesh.mesh(); - - typedef GeometricField<Type, pointPatchField, pointMesh> FieldType; - - forAllConstIters(objects, iter) - { - // Restrict to this GeometricField<Type, ...> - const auto& ioobj = *(iter.val()); - - const word& fieldName = ioobj.name(); - if (ioobj.headerClassName() != FieldType::typeName) - { - continue; - } - - DebugInfo << "convertPointFields : " << fieldName << nl; - - // Throw FatalError, FatalIOError as exceptions - const bool throwingError = FatalError.throwExceptions(); - const bool throwingIOerr = FatalIOError.throwExceptions(); - - try - { - FieldType pfld(ioobj, pMesh); - - convertPointFieldBlock(pfld, rangeVolume_); // internalMesh - convertPointFieldBlock(pfld, rangeCellZones_); // cellZones - convertPointFieldBlock(pfld, rangeCellSets_); // cellSets - - // Patches - currently skip field conversion for groups - for - ( - const auto partId - : rangePatches_.intersection(selectedPartIds_) - ) - { - const auto& longName = selectedPartIds_[partId]; - - auto iter = cachedVtp_.find(longName); - if (!iter.found() || !iter.val().dataset) - { - // Should not happen, but for safety require a vtk geometry - continue; - } - - foamVtpData& vtpData = iter.val(); - auto dataset = vtpData.dataset; - - const labelUList& patchIds = vtpData.additionalIds(); - if (patchIds.size() != 1) - { - continue; - } - - const label patchId = patchIds[0]; - - vtkSmartPointer<vtkFloatArray> pdata = - vtk::Tools::convertFieldToVTK - ( - fieldName, - pfld.boundaryField()[patchId].patchInternalField()() - ); - - dataset->GetPointData()->AddArray(pdata); - } - - // Face Zones - for - ( - const auto partId - : rangeFaceZones_.intersection(selectedPartIds_) - ) - { - const auto& longName = selectedPartIds_[partId]; - const word zoneName = getFoamName(longName); - - auto iter = cachedVtp_.find(longName); - if (!iter.found() || !iter.val().dataset) - { - // Should not happen, but for safety require a vtk geometry - continue; - } - - foamVtpData& vtpData = iter.val(); - auto dataset = vtpData.dataset; - - const label zoneId = mesh.faceZones().findZoneID(zoneName); - - if (zoneId < 0) - { - continue; - } - - // Extract the field on the zone - Field<Type> znfld - ( - pfld.primitiveField(), - mesh.faceZones()[zoneId]().meshPoints() - ); - - vtkSmartPointer<vtkFloatArray> pdata = - vtk::Tools::convertFieldToVTK - ( - fieldName, - znfld - ); - - dataset->GetPointData()->AddArray(pdata); - } - } - catch (const Foam::IOerror& ioErr) - { - ioErr.write(Warning, false); - Info<< nl << endl; - } - catch (const Foam::error& err) - { - // Bit of trickery to get the original message - err.write(Warning, false); - Info<< nl << endl; - } - - // Restore previous exception throwing state - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOerr); - } -} - - -template<class Type> -void Foam::vtkPVFoam::convertPointFieldBlock -( - const GeometricField<Type, pointPatchField, pointMesh>& pfld, - const arrayRange& range -) -{ - for - ( - const auto partId - : range.intersection(selectedPartIds_) - ) - { - const auto& longName = selectedPartIds_[partId]; - - auto iter = cachedVtu_.find(longName); - if (!iter.found() || !iter.val().dataset) - { - // Should not happen, but for safety require a vtk geometry - continue; - } - - foamVtuData& vtuData = iter.val(); - auto dataset = vtuData.dataset; - - vtkSmartPointer<vtkFloatArray> pdata = convertPointField - ( - pfld, - GeometricField<Type, fvPatchField, volMesh>::null(), - vtuData - ); - - dataset->GetPointData()->AddArray(pdata); - } -} - - -template<class Type> -vtkSmartPointer<vtkFloatArray> Foam::vtkPVFoam::convertPointField -( - const GeometricField<Type, pointPatchField, pointMesh>& pfld, - const GeometricField<Type, fvPatchField, volMesh>& vfld, - const foamVtuData& vtuData -) -{ - const labelUList& addPointCellLabels = vtuData.additionalIds(); - const labelUList& pointMap = vtuData.pointMap(); - - // Use a pointMap or address directly into mesh - const label nPoints = (pointMap.size() ? pointMap.size() : pfld.size()); - - auto data = vtkSmartPointer<vtkFloatArray>::New(); - data->SetNumberOfComponents(static_cast<int>(pTraits<Type>::nComponents)); - data->SetNumberOfTuples(nPoints + addPointCellLabels.size()); - - // Note: using the name of the original volField - // not the name generated by the interpolation "volPointInterpolate(<name>)" - - if (notNull(vfld)) - { - data->SetName(vfld.name().c_str()); - } - else - { - data->SetName(pfld.name().c_str()); - } - - DebugInfo - << "Convert point field: " << pfld.name() - << " size=" << (nPoints + addPointCellLabels.size()) - << " (" << nPoints << " + " << addPointCellLabels.size() - << ") nComp=" << static_cast<int>(pTraits<Type>::nComponents) << nl; - - - float scratch[pTraits<Type>::nComponents]; - - vtkIdType pointi = 0; - if (pointMap.size()) - { - for (const label meshPointi : pointMap) - { - vtk::Tools::foamToVtkTuple(scratch, pfld[meshPointi]); - data->SetTuple(pointi++, scratch); - } - } - else - { - for (const Type& val : pfld) - { - vtk::Tools::foamToVtkTuple(scratch, val); - data->SetTuple(pointi++, scratch); - } - } - - // Continue with additional points - // - correspond to cell centres - - if (notNull(vfld)) - { - for (const label meshCelli : addPointCellLabels) - { - vtk::Tools::foamToVtkTuple(scratch, vfld[meshCelli]); - data->SetTuple(pointi++, scratch); - } - } - else - { - for (const label meshCelli : addPointCellLabels) - { - vtk::Tools::foamToVtkTuple - ( - scratch, - interpolatePointToCell(pfld, meshCelli) - ); - data->SetTuple(pointi++, scratch); - } - } - - return data; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// -// lagrangian-fields -// - -template<class Type> -void Foam::vtkPVFoam::convertLagrangianFields -( - const IOobjectList& objects, - vtkPolyData* vtkmesh -) -{ - forAllConstIters(objects, iter) - { - // Restrict to IOField<Type> - const auto& ioobj = *(iter.val()); - - if (ioobj.headerClassName() == IOField<Type>::typeName) - { - // Throw FatalError, FatalIOError as exceptions - const bool throwingError = FatalError.throwExceptions(); - const bool throwingIOerr = FatalIOError.throwExceptions(); - - try - { - IOField<Type> fld(ioobj); - - vtkSmartPointer<vtkFloatArray> data = - vtk::Tools::convertFieldToVTK - ( - ioobj.name(), - fld - ); - - // Provide identical data as cell and as point data - vtkmesh->GetCellData()->AddArray(data); - vtkmesh->GetPointData()->AddArray(data); - } - catch (const Foam::IOerror& ioErr) - { - ioErr.write(Warning, false); - Info<< nl << endl; - } - catch (const Foam::error& err) - { - // Bit of trickery to get the original message - err.write(Warning, false); - Info<< nl << endl; - } - - // Restore previous exception throwing state - FatalError.throwExceptions(throwingError); - FatalIOError.throwExceptions(throwingIOerr); - } - } -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// -// low-level conversions -// - -template<class Type> -vtkSmartPointer<vtkFloatArray> -Foam::vtkPVFoam::convertFaceFieldToVTK -( - const GeometricField<Type, fvPatchField, volMesh>& fld, - const labelUList& faceLabels -) const -{ - DebugInfo - << "Convert face field: " << fld.name() - << " size=" << faceLabels.size() - << " nComp=" << static_cast<int>(pTraits<Type>::nComponents) << nl; - - const fvMesh& mesh = fld.mesh(); - - const label nInternalFaces = mesh.nInternalFaces(); - const labelUList& faceOwner = mesh.faceOwner(); - const labelUList& faceNeigh = mesh.faceNeighbour(); - - auto data = vtkSmartPointer<vtkFloatArray>::New(); - data->SetName(fld.name().c_str()); - data->SetNumberOfComponents(static_cast<int>(pTraits<Type>::nComponents)); - data->SetNumberOfTuples(faceLabels.size()); - - // Interior faces: average owner/neighbour - // Boundary faces: the owner value - - float scratch[pTraits<Type>::nComponents]; - - vtkIdType faceId = 0; - for (const label meshFacei : faceLabels) - { - if (meshFacei < nInternalFaces) - { - Type val = - 0.5*(fld[faceOwner[meshFacei]] + fld[faceNeigh[meshFacei]]); - - vtk::Tools::foamToVtkTuple(scratch, val); - } - else - { - const Type& val = fld[faceOwner[meshFacei]]; - vtk::Tools::foamToVtkTuple(scratch, val); - } - - data->SetTuple(faceId++, scratch); - } - - return data; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamFields.C b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamFields.C deleted file mode 100644 index 348e0625d9cd15a9df59c6b45180b40245e165ff..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamFields.C +++ /dev/null @@ -1,319 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "vtkPVFoam.H" - -// OpenFOAM includes -#include "areaFaMesh.H" -#include "Cloud.H" -#include "IOobjectList.H" -#include "vtkPVFoamReader.h" - -// VTK includes -#include "vtkDataArraySelection.h" -#include "vtkPolyData.h" -#include "vtkUnstructuredGrid.h" - -// Templates (only needed here) -#include "vtkPVFoamFieldTemplates.C" - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::vtkPVFoam::convertVolFields() -{ - const fvMesh& mesh = *volMeshPtr_; - - const bool interpFields = reader_->GetInterpolateVolFields(); - wordHashSet selectedFields - ( - getSelected - ( - reader_->GetVolFieldSelection() - ) - ); - - if (selectedFields.empty()) - { - return; - } - - // Get objects (fields) for this time - only keep selected fields - // the region name is already in the mesh db - IOobjectList objects(mesh, dbPtr_().timeName()); - objects.filterKeys(selectedFields); - - if (objects.empty()) - { - return; - } - - if (debug) - { - Info<< "<beg> " << FUNCTION_NAME << nl; - forAllConstIters(objects, iter) - { - Info<< " " << (*iter)->name() - << " == " << (*iter)->objectPath() << nl; - } - printMemory(); - } - - - PtrList<patchInterpolator> interpLst; - - if (interpFields) - { - interpLst.setSize(mesh.boundaryMesh().size()); - - forAll(interpLst, i) - { - interpLst.set - ( - i, - new PrimitivePatchInterpolation<primitivePatch> - ( - mesh.boundaryMesh()[i] - ) - ); - } - } - - convertVolFields<scalar>(mesh, interpLst, objects); - convertVolFields<vector>(mesh, interpLst, objects); - convertVolFields<sphericalTensor>(mesh, interpLst, objects); - convertVolFields<symmTensor>(mesh, interpLst, objects); - convertVolFields<tensor>(mesh, interpLst, objects); - - convertDimFields<scalar>(mesh, interpLst, objects); - convertDimFields<vector>(mesh, interpLst, objects); - convertDimFields<sphericalTensor>(mesh, interpLst, objects); - convertDimFields<symmTensor>(mesh, interpLst, objects); - convertDimFields<tensor>(mesh, interpLst, objects); - - if (debug) - { - Info<< "<end> " << FUNCTION_NAME << nl; - printMemory(); - } -} - - -void Foam::vtkPVFoam::convertPointFields() -{ - const fvMesh& mesh = *volMeshPtr_; - - wordHashSet selectedFields - ( - getSelected - ( - reader_->GetPointFieldSelection() - ) - ); - - if (selectedFields.empty()) - { - DebugInfo << "no point fields selected" << nl; - return; - } - - // Get objects (fields) for this time - only keep selected fields - // the region name is already in the mesh db - IOobjectList objects(mesh, dbPtr_().timeName()); - objects.filterKeys(selectedFields); - - if (objects.empty()) - { - return; - } - - if (debug) - { - Info<< "<beg> convert volume -> point fields" << nl; - forAllConstIters(objects, iter) - { - Info<< " " << (*iter)->name() - << " == " << (*iter)->objectPath() << nl; - } - printMemory(); - } - - // Construct interpolation on the raw mesh - const pointMesh& pMesh = pointMesh::New(mesh); - - convertPointFields<scalar>(pMesh, objects); - convertPointFields<vector>(pMesh, objects); - convertPointFields<sphericalTensor>(pMesh, objects); - convertPointFields<symmTensor>(pMesh, objects); - convertPointFields<tensor>(pMesh, objects); - - if (debug) - { - Info<< "<end> convert volume -> point fields" << nl; - printMemory(); - } -} - - -void Foam::vtkPVFoam::convertAreaFields() -{ - if (!areaMeshPtr_) - { - return; - } - - const faMesh& mesh = *areaMeshPtr_; - - vtkDataArraySelection* select = reader_->GetVolFieldSelection(); - - wordHashSet selectedFields - ( - getSelected(select) - ); - - if (selectedFields.empty()) - { - return; - } - - // Get objects (fields) for this time - only keep selected fields - // the region name is already in the mesh db - IOobjectList objects(mesh.mesh(), dbPtr_().timeName()); - objects.filterKeys(selectedFields); - - if (objects.empty()) - { - return; - } - - if (debug) - { - Info<< "<beg> " << FUNCTION_NAME << nl; - forAllConstIters(objects, iter) - { - Info<< " " << (*iter)->name() - << " == " << (*iter)->objectPath() << nl; - } - printMemory(); - } - - convertAreaFields<scalar>(mesh, objects); - convertAreaFields<vector>(mesh, objects); - convertAreaFields<sphericalTensor>(mesh, objects); - convertAreaFields<symmTensor>(mesh, objects); - convertAreaFields<tensor>(mesh, objects); - - if (debug) - { - Info<< "<end> " << FUNCTION_NAME << nl; - printMemory(); - } -} - - -void Foam::vtkPVFoam::convertLagrangianFields() -{ - const List<label> partIds = - rangeClouds_.intersection(selectedPartIds_); - - const fvMesh& mesh = *volMeshPtr_; - - wordHashSet selectedFields - ( - getSelected - ( - reader_->GetLagrangianFieldSelection() - ) - ); - - if (selectedFields.empty()) - { - return; - } - - if (debug) - { - Info<< "<beg> " << FUNCTION_NAME << nl; - printMemory(); - } - - for (const auto partId : partIds) - { - const auto& longName = selectedPartIds_[partId]; - const word cloudName = getFoamName(longName); - - auto iter = cachedVtp_.find(longName); - if (!iter.found() || !iter.val().dataset) - { - // Should not happen, but for safety require a vtk geometry - continue; - } - auto dataset = iter.val().dataset; - - // Get the Lagrangian fields for this time and this cloud - // but only keep selected fields - // the region name is already in the mesh db - IOobjectList objects - ( - mesh, - dbPtr_().timeName(), - cloud::prefix/cloudName - ); - objects.filterKeys(selectedFields); - - if (objects.empty()) - { - continue; - } - - if (debug) - { - Info<< "converting OpenFOAM lagrangian fields" << nl; - forAllConstIters(objects, iter) - { - Info<< " " << (*iter)->name() - << " == " << (*iter)->objectPath() << nl; - } - } - - convertLagrangianFields<label>(objects, dataset); - convertLagrangianFields<scalar>(objects, dataset); - convertLagrangianFields<vector>(objects, dataset); - convertLagrangianFields<sphericalTensor>(objects, dataset); - convertLagrangianFields<symmTensor>(objects, dataset); - convertLagrangianFields<tensor>(objects, dataset); - } - - if (debug) - { - Info<< "<end> " << FUNCTION_NAME << nl; - printMemory(); - } -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamMesh.C b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamMesh.C deleted file mode 100644 index b94cd67203848d8b0063d1fa5be57d9dc052f1a4..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamMesh.C +++ /dev/null @@ -1,764 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "vtkPVFoam.H" - -// OpenFOAM includes -#include "cellSet.H" -#include "faceSet.H" -#include "pointSet.H" -#include "faMesh.H" -#include "fvMeshSubset.H" -#include "vtkPVFoamReader.h" -#include "uindirectPrimitivePatch.H" - -// VTK includes -#include "vtkDataArraySelection.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkPolyData.h" -#include "vtkUnstructuredGrid.h" -#include "vtkSmartPointer.h" - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::vtkPVFoam::convertMeshVolume() -{ - // Convert internalMesh - actually only one part - const List<label> partIds = - rangeVolume_.intersection(selectedPartIds_); - - const fvMesh& mesh = *volMeshPtr_; - - if (debug) - { - Info<< "<beg> " << FUNCTION_NAME << nl; - printMemory(); - } - - for (const auto partId : partIds) - { - const auto& longName = selectedPartIds_[partId]; - foamVtuData& vtuData = cachedVtu_(longName); - - vtkSmartPointer<vtkUnstructuredGrid> vtkgeom; - if (vtuData.nPoints()) - { - if (meshState_ == polyMesh::UNCHANGED) - { - DebugInfo << "reuse " << longName << nl; - vtuData.reuse(); // reuse - continue; - } - else if (meshState_ == polyMesh::POINTS_MOVED) - { - DebugInfo << "move points " << longName << nl; - vtkgeom = vtuData.getCopy(); - vtkgeom->SetPoints(vtuData.points(mesh)); - } - } - - if (!vtkgeom) - { - // Nothing usable from cache - create new geometry - vtkgeom = vtuData.internal(mesh, this->decomposePoly_); - } - - vtuData.set(vtkgeom); - } - - if (debug) - { - Info<< "<end> " << FUNCTION_NAME << nl; - printMemory(); - } -} - - -void Foam::vtkPVFoam::convertMeshLagrangian() -{ - const List<label> partIds = - rangeClouds_.intersection(selectedPartIds_); - - const fvMesh& mesh = *volMeshPtr_; - - if (debug) - { - Info<< "<beg> " << FUNCTION_NAME << nl; - printMemory(); - } - - for (const auto partId : partIds) - { - const auto& longName = selectedPartIds_[partId]; - const word cloudName = getFoamName(longName); - - // Direct conversion, no caching for Lagrangian - cachedVtp_(longName).set - ( - lagrangianVTKMesh(mesh, cloudName) - ); - } - - if (debug) - { - Info<< "<end> " << FUNCTION_NAME << nl; - printMemory(); - } -} - - -void Foam::vtkPVFoam::convertMeshPatches() -{ - const List<label> partIds = - rangePatches_.intersection(selectedPartIds_); - - const fvMesh& mesh = *volMeshPtr_; - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - if (debug) - { - Info<< "<beg> " << FUNCTION_NAME << nl; - printMemory(); - } - - for (const auto partId : partIds) - { - const auto& longName = selectedPartIds_[partId]; - const word partName = getFoamName(longName); - foamVtpData& vtpData = cachedVtp_(longName); - - vtkSmartPointer<vtkPolyData> vtkgeom; - if (vtpData.nPoints()) - { - if (meshState_ == polyMesh::UNCHANGED) - { - // Without movement is easy. - DebugInfo << "reuse " << longName << nl; - vtpData.reuse(); - continue; - } - else if (meshState_ == polyMesh::POINTS_MOVED) - { - // Point movement on single patch is OK - - const labelUList& patchIds = vtpData.additionalIds(); - if (patchIds.size() == 1) - { - vtkgeom = vtpData.getCopy(); - vtkgeom->SetPoints - ( - vtk::Tools::Patch::points(patches[patchIds[0]]) - ); - continue; - } - } - } - - if (longName.starts_with("group/")) - { - // Patch group. Collect patch faces. - - vtpData.clear(); // Remove any old mappings - - const labelList& patchIds = - patches.groupPatchIDs().lookup(partName, labelList()); - - DebugInfo - << "Creating VTK mesh for patches [" << patchIds <<"] " - << longName << nl; - - // Store good patch ids as additionalIds - vtpData.additionalIds().reserve(patchIds.size()); - - label sz = 0; - for (const auto id : patchIds) - { - const label n = patches[id].size(); - - if (n) - { - vtpData.additionalIds().append(id); - sz += n; - } - } - Foam::sort(vtpData.additionalIds()); - - // Temporarily (mis)use cellMap for face labels - DynamicList<label>& faceLabels = vtpData.cellMap(); - faceLabels.reserve(sz); - - for (const auto id : vtpData.additionalIds()) - { - const auto& pp = patches[id]; - forAll(pp, i) - { - faceLabels.append(pp.start()+i); - } - } - - if (faceLabels.size()) - { - uindirectPrimitivePatch pp - ( - UIndirectList<face>(mesh.faces(), faceLabels), - mesh.points() - ); - - vtkgeom = vtk::Tools::Patch::mesh(pp); - } - - faceLabels.clear(); // Unneeded - } - else - { - vtpData.clear(); // Remove any old mappings - - const label patchId = patches.findPatchID(partName); - - DebugInfo - << "Creating VTK mesh for patch [" << patchId <<"] " - << partName << nl; - - if (patchId >= 0) - { - // Store good patch id as additionalIds - vtpData.additionalIds() = {patchId}; - - vtkgeom = vtk::Tools::Patch::mesh(patches[patchId]); - } - } - - if (vtkgeom) - { - vtpData.set(vtkgeom); - } - else - { - cachedVtp_.erase(longName); - } - } - - if (debug) - { - Info<< "<end> " << FUNCTION_NAME << nl; - printMemory(); - } -} - - -void Foam::vtkPVFoam::convertMeshArea() -{ - // Convert areaMesh - actually only one part - const List<label> partIds = - rangeArea_.intersection(selectedPartIds_); - - if (partIds.empty()) - { - return; - } - else if (!areaMeshPtr_ && volMeshPtr_) - { - areaMeshPtr_ = new faMesh(*volMeshPtr_); - } - - if (!areaMeshPtr_) - { - return; - } - - const faMesh& mesh = *areaMeshPtr_; - - if (debug) - { - Info<< "<beg> " << FUNCTION_NAME << nl; - printMemory(); - } - - for (const auto partId : partIds) - { - const auto& longName = selectedPartIds_[partId]; - foamVtpData& vtpData = cachedVtp_(longName); - - vtkSmartPointer<vtkPolyData> vtkgeom; - -// This needs checking -// #if 0 -// if (vtpData.nPoints()) -// { -// if (meshState_ == polyMesh::UNCHANGED) -// { -// DebugInfo << "reuse " << longName << nl; -// vtpData.reuse(); // reuse -// continue; -// } -// else if (meshState_ == polyMesh::POINTS_MOVED) -// { -// DebugInfo << "move points " << longName << nl; -// vtkgeom = vtpData.getCopy(); -// vtkgeom->SetPoints(movePoints(mesh, vtpData)); -// } -// } -// #endif - - if (!vtkgeom) - { - vtpData.clear(); // Remove any old mappings - - // Nothing usable from cache - create new geometry - vtkgeom = vtk::Tools::Patch::mesh(mesh.patch()); - } - - vtpData.set(vtkgeom); - } - - if (debug) - { - Info<< "<end> " << FUNCTION_NAME << nl; - printMemory(); - } -} - - -void Foam::vtkPVFoam::convertMeshCellZones() -{ - const List<label> partIds = - rangeCellZones_.intersection(selectedPartIds_); - - const fvMesh& mesh = *volMeshPtr_; - - if (partIds.empty()) - { - return; - } - - if (debug) - { - Info<< "<beg> " << FUNCTION_NAME << nl; - printMemory(); - } - - const cellZoneMesh& zMesh = mesh.cellZones(); - for (const auto partId : partIds) - { - const auto& longName = selectedPartIds_[partId]; - const word zoneName = getFoamName(longName); - const label zoneId = zMesh.findZoneID(zoneName); - - if (zoneId < 0) - { - continue; - } - - DebugInfo - << "Creating VTK mesh for cellZone[" << zoneId << "] " - << zoneName << nl; - - foamVtuData& vtuData = cachedVtu_(longName); - - vtkSmartPointer<vtkUnstructuredGrid> vtkgeom; - if (vtuData.nPoints() && vtuData.pointMap().size()) - { - if (meshState_ == polyMesh::UNCHANGED) - { - DebugInfo << "reuse " << longName << nl; - vtuData.reuse(); - continue; - } - else if (meshState_ == polyMesh::POINTS_MOVED) - { - DebugInfo << "move points " << longName << nl; - vtkgeom = vtuData.getCopy(); - vtkgeom->SetPoints(vtuData.points(mesh, vtuData.pointMap())); - } - } - - if (!vtkgeom) - { - fvMeshSubset subsetter(mesh, zMesh[zoneId]); - - vtkgeom = vtuData.subset(subsetter, this->decomposePoly_); - } - - vtuData.set(vtkgeom); - } - - if (debug) - { - Info<< "<end> " << FUNCTION_NAME << nl; - printMemory(); - } -} - - -void Foam::vtkPVFoam::convertMeshCellSets() -{ - const List<label> partIds = - rangeCellSets_.intersection(selectedPartIds_); - - const fvMesh& mesh = *volMeshPtr_; - - if (debug) - { - Info<< "<beg> " << FUNCTION_NAME << nl; - printMemory(); - } - - for (const auto partId : partIds) - { - const auto& longName = selectedPartIds_[partId]; - const word partName = getFoamName(longName); - - DebugInfo << "Creating VTK mesh for cellSet=" << partName << nl; - - foamVtuData& vtuData = cachedVtu_(longName); - - vtkSmartPointer<vtkUnstructuredGrid> vtkgeom; - if (vtuData.nPoints() && vtuData.pointMap().size()) - { - if (meshState_ == polyMesh::UNCHANGED) - { - DebugInfo << "reuse " << longName << nl; - vtuData.reuse(); - continue; - } - else if (meshState_ == polyMesh::POINTS_MOVED) - { - DebugInfo << "move points " << longName << nl; - vtkgeom = vtuData.getCopy(); - vtkgeom->SetPoints(vtuData.points(mesh, vtuData.pointMap())); - } - } - - if (!vtkgeom) - { - fvMeshSubset subsetter(mesh, cellSet(mesh, partName)); - - vtkgeom = vtuData.subset(subsetter, this->decomposePoly_); - } - - vtuData.set(vtkgeom); - } - - if (debug) - { - Info<< "<end> " << FUNCTION_NAME << nl; - printMemory(); - } -} - - -void Foam::vtkPVFoam::convertMeshFaceZones() -{ - const List<label> partIds = - rangeFaceZones_.intersection(selectedPartIds_); - - const fvMesh& mesh = *volMeshPtr_; - - if (partIds.empty()) - { - return; - } - - if (debug) - { - Info<< "<beg> " << FUNCTION_NAME << nl; - printMemory(); - } - - const faceZoneMesh& zMesh = mesh.faceZones(); - for (const auto partId : partIds) - { - const auto& longName = selectedPartIds_[partId]; - const word zoneName = getFoamName(longName); - const label zoneId = zMesh.findZoneID(zoneName); - - if (zoneId < 0) - { - continue; - } - DebugInfo - << "Creating VTKmesh for faceZone[" << zoneId << "] " - << zoneName << nl; - - foamVtpData& vtpData = cachedVtp_(longName); - - vtkSmartPointer<vtkPolyData> vtkgeom; - if (vtpData.nPoints()) - { - if (meshState_ == polyMesh::UNCHANGED) - { - // Without movement is easy. - DebugInfo <<"reuse " << longName << nl; - vtpData.reuse(); - continue; - } - else if (meshState_ == polyMesh::POINTS_MOVED) - { - // Need point maps etc - not worth it at the moment - } - } - - if (!vtkgeom) - { - vtpData.clear(); // No additional ids, maps - - const primitiveFacePatch& pp = zMesh[zoneId](); - vtkgeom = vtk::Tools::Patch::mesh(pp); - } - - vtpData.set(vtkgeom); - } - - if (debug) - { - Info<< "<end> " << FUNCTION_NAME << nl; - printMemory(); - } -} - - -void Foam::vtkPVFoam::convertMeshFaceSets() -{ - const List<label> partIds = - rangeFaceSets_.intersection(selectedPartIds_); - - const fvMesh& mesh = *volMeshPtr_; - - if (debug) - { - Info<< "<beg> " << FUNCTION_NAME << nl; - printMemory(); - } - - for (const auto partId : partIds) - { - const auto& longName = selectedPartIds_[partId]; - const word partName = getFoamName(longName); - - DebugInfo << "Creating VTK mesh for faceSet=" << partName << nl; - - foamVtpData& vtpData = cachedVtp_(longName); - - vtkSmartPointer<vtkPolyData> vtkgeom; - if (vtpData.nPoints()) - { - if (meshState_ == polyMesh::UNCHANGED) - { - // Without movement is easy. - DebugInfo <<"reuse " << longName << nl; - vtpData.reuse(); - continue; - } - else if (meshState_ == polyMesh::POINTS_MOVED) - { - // Need point maps etc - not worth it at the moment - } - } - - if (!vtkgeom) - { - vtpData.clear(); // No other additional ids, maps - - // Misuse cellMap for face labels - sorted order for reliability - vtpData.cellMap() = faceSet(mesh, partName).sortedToc(); - - if (vtpData.cellMap().size()) - { - uindirectPrimitivePatch pp - ( - UIndirectList<face>(mesh.faces(), vtpData.cellMap()), - mesh.points() - ); - - vtkgeom = vtk::Tools::Patch::mesh(pp); - } - } - - if (vtkgeom) - { - vtpData.set(vtkgeom); - } - else - { - cachedVtp_.erase(longName); - } - } - - if (debug) - { - Info<< "<end> " << FUNCTION_NAME << nl; - printMemory(); - } -} - - -void Foam::vtkPVFoam::convertMeshPointZones() -{ - const List<label> partIds = - rangePointZones_.intersection(selectedPartIds_); - - const fvMesh& mesh = *volMeshPtr_; - - if (partIds.empty()) - { - return; - } - - if (debug) - { - Info<< "<beg> " << FUNCTION_NAME << nl; - printMemory(); - } - - const pointZoneMesh& zMesh = mesh.pointZones(); - for (const auto partId : partIds) - { - const auto& longName = selectedPartIds_[partId]; - const word zoneName = getFoamName(longName); - const label zoneId = zMesh.findZoneID(zoneName); - - if (zoneId < 0) - { - continue; - } - - foamVtpData& vtpData = cachedVtp_(longName); - - vtkSmartPointer<vtkPolyData> vtkgeom; - if (vtpData.nPoints() && vtpData.pointMap().size()) - { - if (meshState_ == polyMesh::UNCHANGED) - { - DebugInfo << "reusing " << longName << nl; - vtpData.reuse(); - continue; - } - else if (meshState_ == polyMesh::POINTS_MOVED) - { - DebugInfo << "move points " << longName << nl; - vtkgeom = vtpData.getCopy(); - } - } - - if (!vtkgeom) - { - // First time, or topo change - vtkgeom = vtkSmartPointer<vtkPolyData>::New(); - vtpData.pointMap() = zMesh[zoneId]; - } - - const pointField& points = mesh.points(); - const labelUList& pointMap = vtpData.pointMap(); - - auto vtkpoints = vtkSmartPointer<vtkPoints>::New(); - - vtkpoints->SetNumberOfPoints(pointMap.size()); - forAll(pointMap, pointi) - { - vtkpoints->SetPoint(pointi, points[pointMap[pointi]].v_); - } - - vtkgeom->SetPoints(vtkpoints); - vtpData.set(vtkgeom); - } - - if (debug) - { - Info<< "<end> " << FUNCTION_NAME << nl; - printMemory(); - } -} - - -void Foam::vtkPVFoam::convertMeshPointSets() -{ - const List<label> partIds = - rangePointSets_.intersection(selectedPartIds_); - - const fvMesh& mesh = *volMeshPtr_; - - if (debug) - { - Info<< "<beg> " << FUNCTION_NAME << nl; - printMemory(); - } - - for (const auto partId : partIds) - { - const auto& longName = selectedPartIds_[partId]; - const word partName = getFoamName(longName); - - foamVtpData& vtpData = cachedVtp_(longName); - - vtkSmartPointer<vtkPolyData> vtkgeom; - if (vtpData.nPoints() && vtpData.pointMap().size()) - { - if (meshState_ == polyMesh::UNCHANGED) - { - DebugInfo << "reusing " << longName << nl; - vtpData.reuse(); - continue; - } - else if (meshState_ == polyMesh::POINTS_MOVED) - { - DebugInfo << "move points " << longName << nl; - vtkgeom = vtpData.getCopy(); - } - } - - if (!vtkgeom) - { - // First time, or topo change - vtkgeom = vtkSmartPointer<vtkPolyData>::New(); - vtpData.pointMap() = pointSet(mesh, partName).sortedToc(); - } - - const pointField& points = mesh.points(); - const labelUList& pointMap = vtpData.pointMap(); - - auto vtkpoints = vtkSmartPointer<vtkPoints>::New(); - - vtkpoints->SetNumberOfPoints(pointMap.size()); - forAll(pointMap, pointi) - { - vtkpoints->SetPoint(pointi, points[pointMap[pointi]].v_); - } - - vtkgeom->SetPoints(vtkpoints); - vtpData.set(vtkgeom); - } - - if (debug) - { - Info<< "<end> " << FUNCTION_NAME << nl; - printMemory(); - } -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamMeshLagrangian.C b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamMeshLagrangian.C deleted file mode 100644 index c114429f5866d252648e78838ada03e878c91e09..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamMeshLagrangian.C +++ /dev/null @@ -1,104 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "vtkPVFoam.H" - -// OpenFOAM includes -#include "Cloud.H" -#include "fvMesh.H" -#include "IOobjectList.H" -#include "passiveParticle.H" - -// VTK includes -#include "vtkCellArray.h" -#include "vtkPoints.h" -#include "vtkPolyData.h" -#include "vtkSmartPointer.h" - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -vtkSmartPointer<vtkPolyData> Foam::vtkPVFoam::lagrangianVTKMesh -( - const polyMesh& mesh, - const word& cloudName -) const -{ - vtkSmartPointer<vtkPolyData> vtkmesh; - - if (debug) - { - Info<< "<beg> lagrangianVTKMesh - timePath " - << mesh.time().timePath()/cloud::prefix/cloudName << nl; - printMemory(); - } - - - // The region name is already in the mesh db - IOobjectList cloudObjects - ( - mesh, - mesh.time().timeName(), - cloud::prefix/cloudName - ); - - if - ( - cloudObjects.found("positions") - || cloudObjects.found("coordinates") - ) - { - Cloud<passiveParticle> parcels(mesh, cloudName, false); - - DebugInfo << "cloud with " << parcels.size() << " parcels" << nl; - - auto vtkpoints = vtkSmartPointer<vtkPoints>::New(); - vtkpoints->SetNumberOfPoints(parcels.size()); - - vtkIdType particleId = 0; - for (const passiveParticle& p : parcels) - { - vtkpoints->SetPoint(particleId, p.position().v_); - ++particleId; - } - - vtkmesh = vtkSmartPointer<vtkPolyData>::New(); - vtkmesh->SetPoints(vtkpoints); - vtkmesh->SetVerts(vtk::Tools::identityVertices(parcels.size())); - } - - if (debug) - { - Info<< "<end> lagrangianVTKMesh" << nl; - printMemory(); - } - - return vtkmesh; -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamMeshVolume.C b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamMeshVolume.C deleted file mode 100644 index 34ba07e080f3abb40f3ec417d23c7a87a601df4e..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamMeshVolume.C +++ /dev/null @@ -1,51 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2016-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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "vtkPVFoam.H" -#include "fvMeshSubset.H" - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -vtkSmartPointer<vtkUnstructuredGrid> Foam::vtkPVFoam::foamVtuData::subset -( - const fvMeshSubset& subsetter, - bool decompPoly -) -{ - auto vtkmesh = internal(subsetter.subMesh(), decompPoly); - - // Convert cellMap, addPointCellLabels to global cell ids - renumberCells(subsetter.cellMap()); - - // Copy pointMap as well, otherwise pointFields fail - pointMap() = subsetter.pointMap(); - - return vtkmesh; -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamUpdateInfo.C b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamUpdateInfo.C deleted file mode 100644 index ef11057afb85f871b39b1f49e73252828b200717..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamUpdateInfo.C +++ /dev/null @@ -1,691 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2018 OpenFOAM Foundation - Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "vtkPVFoam.H" - -// OpenFOAM includes -#include "cellSet.H" -#include "faceSet.H" -#include "pointSet.H" -#include "IOobjectList.H" -#include "IOPtrList.H" -#include "polyBoundaryMeshEntries.H" -#include "entry.H" -#include "Cloud.H" -#include "areaFaMesh.H" - -// VTK includes -#include "vtkDataArraySelection.h" - -// OpenFOAM/VTK interface -#include "vtkPVFoamReader.h" - -// Templates (only needed here) -#include "vtkPVFoamUpdateTemplates.C" - -// * * * * * * * * * * * * * * * Private Classes * * * * * * * * * * * * * * // - -namespace Foam -{ - -//- A class for reading zone information without requiring a mesh -class zonesEntries -: - public regIOobject, - public PtrList<entry> -{ - -public: - - // Constructors - - explicit zonesEntries(const IOobject& io) - : - regIOobject(io), - PtrList<entry>(readStream(word("regIOobject"))) - { - close(); - } - - // Member functions - - bool writeData(Ostream&) const - { - NotImplemented; - return false; - } -}; - -} - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -template<class ZoneType> -Foam::wordList Foam::vtkPVFoam::getZoneNames -( - const ZoneMesh<ZoneType, polyMesh>& zmesh -) -{ - wordList names(zmesh.size()); - label nZone = 0; - - for (const auto& zn : zmesh) - { - if (!zn.empty()) - { - names[nZone++] = zn.name(); - } - } - names.setSize(nZone); - - return names; -} - - -Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const -{ - // mesh not loaded - read from file - IOobject ioObj - ( - zoneType, - dbPtr_().findInstance - ( - meshDir_, - zoneType, - IOobject::READ_IF_PRESENT - ), - meshDir_, - dbPtr_(), - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE, - false - ); - - wordList names; - if (ioObj.typeHeaderOk<cellZoneMesh>(false, false)) - { - zonesEntries zones(ioObj); - - names.setSize(zones.size()); - label nZone = 0; - - for (const auto& zn : zones) - { - names[nZone++] = zn.keyword(); - } - } - - return names; -} - - -void Foam::vtkPVFoam::updateInfoInternalMesh -( - vtkDataArraySelection* select -) -{ - DebugInfo << "<beg> " << FUNCTION_NAME << nl; - - // Determine mesh parts (internalMesh, patches...) - // Add internal mesh as first entry - rangeVolume_.reset(select->GetNumberOfArrays(), 1); - select->AddArray("internalMesh"); - - DebugInfo << "<end> " << FUNCTION_NAME << nl; -} - - -void Foam::vtkPVFoam::updateInfoAreaMesh -( - vtkDataArraySelection* select -) -{ - DebugInfo << "<beg> " << FUNCTION_NAME << nl; - - rangeArea_.reset(select->GetNumberOfArrays(), 0); - - // Use the db directly since this might be called without a mesh, - // but the region must get added back in - fileName faMeshPrefix(faMesh::meshSubDir); - if (meshRegion_ != polyMesh::defaultRegion) - { - faMeshPrefix = meshRegion_/faMeshPrefix; - } - - // Check for finiteArea mesh - if - ( - isFile - ( - dbPtr_->constantPath()/faMeshPrefix/"faceLabels" - ) - ) - { - rangeArea_ += 1; - select->AddArray("areaMesh"); - } - - DebugInfo << "<end> " << FUNCTION_NAME << nl; -} - - -void Foam::vtkPVFoam::updateInfoLagrangian -( - vtkDataArraySelection* select -) -{ - DebugInfo - << "<beg> " << FUNCTION_NAME << nl - << " " << dbPtr_->timePath()/cloud::prefix << nl; - - // Use the db directly since this might be called without a mesh, - // but the region must get added back in - fileName lagrangianPrefix(cloud::prefix); - if (meshRegion_ != polyMesh::defaultRegion) - { - lagrangianPrefix = meshRegion_/cloud::prefix; - } - - // List of lagrangian objects across all times - HashSet<fileName> names; - - // Get times list. Flush first to force refresh. - fileHandler().flush(); - - for (const instant& t : dbPtr_().times()) - { - names.insert - ( - fileHandler().readDir - ( - dbPtr_->path()/t.name()/lagrangianPrefix, - fileName::DIRECTORY - ) - ); - } - - rangeClouds_.reset(select->GetNumberOfArrays()); - rangeClouds_ += addToArray(select, "lagrangian/", names.sortedToc()); - - DebugInfo << "<end> " << FUNCTION_NAME << nl; -} - - -void Foam::vtkPVFoam::updateInfoPatches -( - vtkDataArraySelection* select, - HashSet<string>& enabledEntries -) -{ - DebugInfo - << "<beg> " << FUNCTION_NAME - << " [volMeshPtr=" << (volMeshPtr_ ? "set" : "null") << "]" << nl; - - rangePatches_.reset(select->GetNumberOfArrays()); - - if (volMeshPtr_) - { - const polyBoundaryMesh& patches = volMeshPtr_->boundaryMesh(); - const HashTable<labelList>& groups = patches.groupPatchIDs(); - DynamicList<string> displayNames(groups.size()); - - // Add (non-zero) patch groups to the list of mesh parts - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - forAllConstIters(groups, iter) - { - const auto& groupName = iter.key(); - const auto& patchIDs = iter.val(); - - label nFaces = 0; - for (auto patchId : patchIDs) - { - nFaces += patches[patchId].size(); - } - - if (!nFaces) - { - // Skip if group has no faces - continue; - } - - // Valid patch if nFace > 0 - add patch to GUI list - const string dpyName = "group/" + groupName; - displayNames.append(dpyName); - - // Optionally replace group with patch name selections - // - must remove the group from the select itself, otherwise - // it can toggle on, but not toggle off very well - if - ( - !reader_->GetShowGroupsOnly() - && enabledEntries.erase(dpyName) - ) - { - for (auto patchId : patchIDs) - { - const polyPatch& pp = patches[patchId]; - if (pp.size()) - { - enabledEntries.insert("patch/" + pp.name()); - } - } - } - } - - Foam::sort(displayNames); // Sorted group names - rangePatches_ += addToArray(select, displayNames); - - // Add (non-zero) patches to the list of mesh parts - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - if (!reader_->GetShowGroupsOnly()) - { - for (const polyPatch& pp : patches) - { - if (pp.size()) - { - // Add patch to GUI list - select->AddArray(("patch/" + pp.name()).c_str()); - ++rangePatches_; - } - } - } - } - else - { - // mesh not loaded - read from file - // but this could fail if we've supplied a bad region name - IOobject ioObj - ( - "boundary", - dbPtr_().findInstance - ( - meshDir_, - "boundary", - IOobject::READ_IF_PRESENT - ), - meshDir_, - dbPtr_(), - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE, - false - ); - - // This should only ever fail if the mesh region doesn't exist - if (ioObj.typeHeaderOk<polyBoundaryMesh>(true, false)) - { - polyBoundaryMeshEntries patchEntries(ioObj); - - // Read patches, determine sizes and patch groups - wordList names(patchEntries.size()); - labelList sizes(patchEntries.size()); - HashTable<labelHashSet> groups(2*patchEntries.size()); - - forAll(patchEntries, patchi) - { - const dictionary& patchDict = patchEntries[patchi].dict(); - wordList groupNames; - - sizes[patchi] = patchDict.get<label>("nFaces"); - names[patchi] = patchEntries[patchi].keyword(); - - if - ( - sizes[patchi] // Valid patch if nFace > 0 - && patchDict.readIfPresent("inGroups", groupNames) - ) - { - for (const auto& groupName : groupNames) - { - groups(groupName).insert(patchi); - } - } - } - - - // Add (non-zero) patch groups to the list of mesh parts - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - DynamicList<string> displayNames(groups.size()); - - forAllConstIters(groups, iter) - { - const auto& groupName = iter.key(); - const auto& patchIDs = iter.val(); - - const string dpyName = "group/" + groupName; - displayNames.append(dpyName); - - // Optionally replace group with patch name selections - // - must remove the group from the select itself, otherwise - // it can toggle on, but not toggle off very well - if - ( - !reader_->GetShowGroupsOnly() - && enabledEntries.erase(dpyName) - ) - { - for (auto patchId : patchIDs) - { - enabledEntries.insert("patch/" + names[patchId]); - } - } - } - - Foam::sort(displayNames); // Sorted group names - rangePatches_ += addToArray(select, displayNames); - - // Add (non-zero) patches to the list of mesh parts - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - if (!reader_->GetShowGroupsOnly()) - { - forAll(names, patchi) - { - // Valid patch if nFace > 0 - add patch to GUI list - if (sizes[patchi]) - { - select->AddArray(("patch/" + names[patchi]).c_str()); - ++rangePatches_; - } - } - } - } - } - - DebugInfo << "<end> " << FUNCTION_NAME << nl; -} - - -void Foam::vtkPVFoam::updateInfoZones -( - vtkDataArraySelection* select -) -{ - if (!reader_->GetIncludeZones()) - { - return; - } - - DebugInfo - << "<beg> " << FUNCTION_NAME - << " [volMeshPtr=" << (volMeshPtr_ ? "set" : "null") << "]" << nl; - - // cellZones - { - const wordList names = - ( - volMeshPtr_ - ? getZoneNames(volMeshPtr_->cellZones()) - : getZoneNames("cellZones") - ); - - rangeCellZones_.reset(select->GetNumberOfArrays()); - rangeCellZones_ += addToArray(select, "cellZone/", names); - } - - // faceZones - { - const wordList names = - ( - volMeshPtr_ - ? getZoneNames(volMeshPtr_->faceZones()) - : getZoneNames("faceZones") - ); - - rangeFaceZones_.reset(select->GetNumberOfArrays()); - rangeFaceZones_ += addToArray(select, "faceZone/", names); - } - - // pointZones - { - const wordList names = - ( - volMeshPtr_ - ? getZoneNames(volMeshPtr_->pointZones()) - : getZoneNames("pointZones") - ); - - rangePointZones_.reset(select->GetNumberOfArrays()); - rangePointZones_ += addToArray(select, "pointZone/", names); - } - - DebugInfo << "<end> " << FUNCTION_NAME << nl; -} - - -void Foam::vtkPVFoam::updateInfoSets -( - vtkDataArraySelection* select -) -{ - if (!reader_->GetIncludeSets()) - { - return; - } - - DebugInfo << "<beg> " << FUNCTION_NAME << nl; - - // Add names of sets. Search for last time directory with a sets - // subdirectory. Take care not to search beyond the last mesh. - - const word facesInstance = dbPtr_().findInstance - ( - meshDir_, - "faces", - IOobject::READ_IF_PRESENT - ); - - const word setsInstance = dbPtr_().findInstance - ( - meshDir_/"sets", - word::null, - IOobject::READ_IF_PRESENT, - facesInstance - ); - - const IOobjectList objects(dbPtr_(), setsInstance, meshDir_/"sets"); - - DebugInfo - << " updateInfoSets read " - << objects.names() << " from " << setsInstance << nl; - - - rangeCellSets_.reset(select->GetNumberOfArrays()); - rangeCellSets_ += addToSelection<cellSet> - ( - select, - "cellSet/", - objects - ); - - rangeFaceSets_.reset(select->GetNumberOfArrays()); - rangeFaceSets_ += addToSelection<faceSet> - ( - select, - "faceSet/", - objects - ); - - rangePointSets_.reset(select->GetNumberOfArrays()); - rangePointSets_ += addToSelection<pointSet> - ( - select, - "pointSet/", - objects - ); - - DebugInfo << "<end> " << FUNCTION_NAME << nl; -} - - -void Foam::vtkPVFoam::updateInfoContinuumFields -( - vtkDataArraySelection* select -) -{ - DebugInfo << "<beg> " << FUNCTION_NAME << nl; - - // Preserve the enabled selections - HashSet<string> enabled; - if (!select->GetNumberOfArrays() && !volMeshPtr_) - { - // First call: automatically enable pressure, temperature, velocity - enabled = { "p", "T", "U" }; - } - else - { - enabled = getSelectedArraySet(select); - } - - select->RemoveAllArrays(); // Clear existing list - - // Use the db directly since this might be called without a mesh, - // but the region name is still required - word regionPrefix; - if (meshRegion_ != polyMesh::defaultRegion) - { - regionPrefix = meshRegion_; - } - - // Objects for this time and mesh region - IOobjectList objects(dbPtr_(), dbPtr_().timeName(), regionPrefix); - - updateInfoFields<fvPatchField, volMesh>(select, objects); - updateInfoFields<faPatchField, areaMesh>(select, objects); - - setSelectedArrayEntries(select, enabled); // Adjust/restore selected - - DebugInfo << "<end> " << FUNCTION_NAME << nl; -} - - -void Foam::vtkPVFoam::updateInfoPointFields -( - vtkDataArraySelection* select -) -{ - DebugInfo << "<beg> " << FUNCTION_NAME << nl; - - // Preserve the enabled selections - HashSet<string> enabled = getSelectedArraySet(select); - - select->RemoveAllArrays(); // Clear existing list - - // Use the db directly since this might be called without a mesh, - // but the region name is still required - word regionPrefix; - if (meshRegion_ != polyMesh::defaultRegion) - { - regionPrefix = meshRegion_; - } - - // Objects for this time and mesh region - IOobjectList objects(dbPtr_(), dbPtr_().timeName(), regionPrefix); - - updateInfoFields<pointPatchField, pointMesh>(select, objects); - - setSelectedArrayEntries(select, enabled); // Adjust/restore selected - - DebugInfo << "<end> " << FUNCTION_NAME << nl; -} - - -void Foam::vtkPVFoam::updateInfoLagrangianFields -( - vtkDataArraySelection* select -) -{ - DebugInfo << "<beg> " << FUNCTION_NAME << nl; - - // Preserve the enabled selections - HashSet<string> enabled = getSelectedArraySet(select); - select->RemoveAllArrays(); - - const arrayRange& range = rangeClouds_; - if (range.empty()) - { - return; - } - - // Reuse the previously determined cloud information. - DynamicList<word> cloudNames(range.size()); - for (auto partId : range) - { - cloudNames.append(getReaderPartName(partId)); - } - - // Use the db directly since this might be called without a mesh, - // but the region must get added back in - fileName lagrangianPrefix(cloud::prefix); - if (meshRegion_ != polyMesh::defaultRegion) - { - lagrangianPrefix = meshRegion_/cloud::prefix; - } - - // List of lagrangian fields across all clouds and all times. - // ParaView displays "(partial)" after field names that only apply - // to some of the clouds. - HashTable<wordHashSet> fields; - - fileHandler().flush(); - for (const instant& t : dbPtr_().times()) - { - for (const auto& cloudName : cloudNames) - { - const HashTable<wordHashSet> localFields = - IOobjectList - ( - dbPtr_(), - t.name(), - lagrangianPrefix/cloudName - ).classes(); - - forAllConstIters(localFields, iter) - { - fields(iter.key()) |= iter.val(); - } - } - } - - // Known/supported field-types - addToSelection<IOField<label>>(select, fields); - addToSelection<IOField<scalar>>(select, fields); - addToSelection<IOField<vector>>(select, fields); - addToSelection<IOField<sphericalTensor>>(select, fields); - addToSelection<IOField<symmTensor>>(select, fields); - addToSelection<IOField<tensor>>(select, fields); - - // Restore the enabled selections - setSelectedArrayEntries(select, enabled); - - DebugInfo << "<end> " << FUNCTION_NAME << nl; -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamUpdateTemplates.C b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamUpdateTemplates.C deleted file mode 100644 index 2e420e473d6410b05123b580d1a889b992456d04..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/library/vtkPVFoamUpdateTemplates.C +++ /dev/null @@ -1,112 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-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 <http://www.gnu.org/licenses/>. - -InClass - vtkPVFoam - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkPVFoamUpdateTemplates_C -#define vtkPVFoamUpdateTemplates_C - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template<template<class> class patchType, class meshType> -void Foam::vtkPVFoam::updateInfoFields -( - vtkDataArraySelection* select, - const IOobjectList& objects -) -{ - DebugInfo - << "<beg> updateInfoFields <" - << meshType::Mesh::typeName - << "> [volMeshPtr=" << (volMeshPtr_ ? "set" : "null") << "]" - << nl; - - // Add geometric fields (volume/area) to GUI - addToSelection<GeometricField<scalar, patchType, meshType>> - ( - select, - objects - ); - addToSelection<GeometricField<vector, patchType, meshType>> - ( - select, - objects - ); - addToSelection<GeometricField<sphericalTensor, patchType, meshType>> - ( - select, - objects - ); - addToSelection<GeometricField<symmTensor, patchType, meshType>> - ( - select, - objects - ); - addToSelection<GeometricField<tensor, patchType, meshType>> - ( - select, - objects - ); - - // Add dimensioned fields (volume/area) to GUI - addToSelection<DimensionedField<scalar, meshType>> - ( - select, - objects - ); - addToSelection<DimensionedField<vector, meshType>> - ( - select, - objects - ); - addToSelection<DimensionedField<sphericalTensor, meshType>> - ( - select, - objects - ); - addToSelection<DimensionedField<symmTensor, meshType>> - ( - select, - objects - ); - addToSelection<DimensionedField<tensor, meshType>> - ( - select, - objects - ); - - DebugInfo << "<end> updateInfoFields" << nl; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/PVFoamReader_SM.xml b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/PVFoamReader_SM.xml deleted file mode 100644 index 7daa151df4183f9d93a55e01cdb078341b7dbaf0..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/PVFoamReader_SM.xml +++ /dev/null @@ -1,334 +0,0 @@ -<ServerManagerConfiguration> - <ProxyGroup name="sources"> - <SourceProxy - name="PVFoamReader" - class="vtkPVFoamReader"> - - <!-- File name - compulsory --> - <StringVectorProperty animateable="0" - name="FileName" - command="SetFileName" - number_of_elements="1" - panel_visibility="never"> - <FileListDomain name="files"/> - <Documentation> - The filename for the OpenFOAM reader module. - </Documentation> - </StringVectorProperty> - - <!-- Send discrete time info to the animation panel --> - <DoubleVectorProperty - name="TimestepValues" - repeatable="1" - information_only="1"> - <TimeStepsInformationHelper/> - <Documentation> - Available timestep values. - </Documentation> - </DoubleVectorProperty> - -<!-- General Controls --> - - <!-- Refresh (push button) --> - <Property - name="Refresh" - command="Refresh" - panel_visibility="default"> - <Documentation>Rescan for updated times/fields.</Documentation> - </Property> - - <!-- Skip Zero Time (check-box) --> - <IntVectorProperty animateable="0" - name="ZeroTime" - label="Skip 0/ time" - command="SetSkipZeroTime" - default_values="1" - number_of_elements="1" - panel_visibility="default"> - <BooleanDomain name="bool"/> - <Documentation> - Ignore the 0/ time directory. - </Documentation> - </IntVectorProperty> - - <!-- Include Sets (check-box) --> - <IntVectorProperty animateable="0" - name="IncludeSets" - label="With Sets" - command="SetIncludeSets" - default_values="0" - number_of_elements="1" - panel_visibility="default"> - <BooleanDomain name="bool"/> - <Documentation> - Search the polyMesh/sets/ directory for {cell,face,point} sets - </Documentation> - </IntVectorProperty> - - <!-- Include Zones (check-box) --> - <IntVectorProperty animateable="0" - name="IncludeZones" - label="With Zones" - command="SetIncludeZones" - default_values="0" - number_of_elements="1" - panel_visibility="default"> - <BooleanDomain name="bool"/> - <Documentation> - ZoneMesh information is used to find {cell,face,point} zones. - The polyMesh/ directory is only checked on startup. - </Documentation> - </IntVectorProperty> - - <!-- Show Groups Only (check-box) --> - <IntVectorProperty animateable="0" - name="ShowGroupsOnly" - label="Groups Only" - command="SetShowGroupsOnly" - default_values="0" - number_of_elements="1" - panel_visibility="default"> - <BooleanDomain name="bool"/> - <Documentation> - Display patchGroups only instead of individual patches. - </Documentation> - </IntVectorProperty> - - <!-- Show Patch Names (check-box) --> - <IntVectorProperty animateable="0" - name="ShowPatchNames" - label="Patch Names" - command="SetShowPatchNames" - default_values="0" - number_of_elements="1" - panel_visibility="default"> - <BooleanDomain name="bool"/> - <Documentation> - Show patch names in render window. - </Documentation> - </IntVectorProperty> - - <!-- Interpolate Fields (check-box) --> - <IntVectorProperty animateable="0" - name="InterpolateFields" - label="cell-to-point" - command="SetInterpolateVolFields" - default_values="1" - number_of_elements="1" - panel_visibility="default"> - <BooleanDomain name="bool"/> - <Documentation> - Interpolate volFields into pointFields. - </Documentation> - </IntVectorProperty> - - <!-- Extrapolate Patches (check-box) --> - <IntVectorProperty animateable="0" - name="ExtrapolatePatches" - label="field-to-patch" - command="SetExtrapolatePatches" - default_values="0" - number_of_elements="1" - panel_visibility="default"> - <BooleanDomain name="bool"/> - <Documentation> - Extrapolate internalField to non-constraint patches. - </Documentation> - </IntVectorProperty> - - <!-- Force GUI update (push button) --> - <IntVectorProperty animateable="0" - name="UpdateGUI" - command="SetUpdateGUI" - default_values="0" - number_of_elements="1" - panel_visibility="default"> - <BooleanDomain name="bool"/> - <Documentation> - Force reader GUI update. - </Documentation> - </IntVectorProperty> - - <!-- Use VTK Polyhedron (check-box) --> - <IntVectorProperty animateable="0" - name="UseVTKPolyhedron" - label="VTK Polyhedra" - command="SetUseVTKPolyhedron" - default_values="0" - number_of_elements="1" - panel_visibility="default"> - <BooleanDomain name="bool"/> - <Documentation> - Use vtkPolyhedron instead of decomposing polyhedra. - </Documentation> - </IntVectorProperty> - - <!-- Mesh Caching (combo-box) --> - <IntVectorProperty animateable="0" - name="MeshCaching" - command="SetMeshCaching" - default_values="3" - number_of_elements="1" - panel_visibility="default"> - <EnumerationDomain name="enum"> - <Entry text="No caching" value="0" /> - <Entry text="Cache fvMesh" value="1" /> - <Entry text="Cache vtk,fvMesh" value="3" /> - </EnumerationDomain> - <Documentation> - Mesh caching styles. - Caching the OpenFOAM fvMesh reduces disk access. - Caching the VTK mesh reduces transcription overhead. - </Documentation> - </IntVectorProperty> - - <PropertyGroup - label="General Controls" - panel_widget="openfoam_reader_general_controls"> - <Property name="Refresh"/> - <Property name="ZeroTime"/> - <Property name="IncludeSets"/> - <Property name="IncludeZones"/> - <Property name="InterpolateFields"/> - <Property name="ExtrapolatePatches"/> - <Property name="ShowGroupsOnly"/> - <Property name="ShowPatchNames"/> - <Property name="UpdateGUI"/> - <Property name="UseVTKPolyhedron"/> - <Property name="MeshCaching"/> - </PropertyGroup> - -<!-- Parts Selections --> - - <!-- Available Parts (volume, patches, lagrangian) array --> - <StringVectorProperty - name="PartArrayStatus" - information_only="1"> - <ArraySelectionInformationHelper attribute_name="Part"/> - </StringVectorProperty> - <StringVectorProperty animateable="0" - name="PartStatus" - label="Mesh Parts" - command="SetPartArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="PartArrayStatus"> - <ArraySelectionDomain name="array_list"> - <RequiredProperties> - <Property name="PartArrayStatus" function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - <Documentation> - The list of mesh parts (patches, groups, sets, zones). - </Documentation> - </StringVectorProperty> - - <PropertyGroup label="Parts"> - <Property name="PartArrayStatus"/> - <Property name="PartStatus"/> - </PropertyGroup> - -<!-- Fields Selections --> - - <!-- Available volFields array --> - <StringVectorProperty - name="VolFieldArrayStatus" - information_only="1"> - <ArraySelectionInformationHelper attribute_name="VolField"/> - </StringVectorProperty> - <StringVectorProperty animateable="0" - name="VolFieldStatus" - label="Volume Fields" - command="SetVolFieldArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="VolFieldArrayStatus"> - <ArraySelectionDomain name="array_list"> - <RequiredProperties> - <Property name="VolFieldArrayStatus" function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - <Documentation>The list of volume fields.</Documentation> - </StringVectorProperty> - - <!-- Available Lagrangian fields array --> - <StringVectorProperty - name="LagrangianFieldArrayStatus" - information_only="1"> - <ArraySelectionInformationHelper attribute_name="LagrangianField"/> - </StringVectorProperty> - <StringVectorProperty animateable="0" - name="LagrangianFieldStatus" - label="Lagrangian Fields" - command="SetLagrangianFieldArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="LagrangianFieldArrayStatus"> - <ArraySelectionDomain name="array_list"> - <RequiredProperties> - <Property name="LagrangianFieldArrayStatus" function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - <Documentation>The list of Lagrangian fields.</Documentation> - </StringVectorProperty> - - <!-- Available pointFields array --> - <StringVectorProperty - name="PointFieldArrayStatus" - information_only="1"> - <ArraySelectionInformationHelper attribute_name="PointField"/> - </StringVectorProperty> - <StringVectorProperty animateable="0" - name="PointFieldStatus" - label="Point Fields" - command="SetPointFieldArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="PointFieldArrayStatus"> - <ArraySelectionDomain name="array_list"> - <RequiredProperties> - <Property name="PointFieldArrayStatus" function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - <Documentation>The list of point fields.</Documentation> - </StringVectorProperty> - - <PropertyGroup label="Fields"> - <Property name="VolFieldArrayStatus"/> - <Property name="VolFieldStatus"/> - <Property name="LagrangianFieldArrayStatus"/> - <Property name="LagrangianFieldStatus"/> - <Property name="PointFieldArrayStatus"/> - <Property name="PointFieldStatus"/> - </PropertyGroup> - -<!-- Miscellaneous --> - - <!-- Print button --> - <Property animateable="0" - name="PrintInfo" - command="PrintInfo" - panel_widget="command_button" - panel_visibility="advanced"> - <Documentation> - Print basic information to stdout - </Documentation> - </Property> - - <Hints> - <ReaderFactory - extensions="OpenFOAM" - file_description="OpenFOAM reader module" /> - </Hints> - - </SourceProxy> - </ProxyGroup> -</ServerManagerConfiguration> diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/pqFoamReaderControls.cxx b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/pqFoamReaderControls.cxx deleted file mode 100644 index ff00e5edf59048c554507b16876395e2e35eaf78..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/pqFoamReaderControls.cxx +++ /dev/null @@ -1,486 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "pqFoamReaderControls.h" - -#include <QCheckBox> -#include <QComboBox> -#include <QFrame> -#include <QGridLayout> -#include <QPushButton> - -#include "pqPVApplicationCore.h" -#include "pqPipelineRepresentation.h" -#include "pqView.h" -#include "vtkSMDocumentation.h" -#include "vtkSMIntVectorProperty.h" -#include "vtkSMPropertyGroup.h" -#include "vtkSMSourceProxy.h" -#include "vtkSMEnumerationDomain.h" - - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -// file-scope -// Add horizontal divider to layout -static void addHline(QGridLayout* layout, int row, int nCols) -{ - QFrame* hline = new QFrame(layout->parentWidget()); - hline->setFrameStyle(QFrame::HLine | QFrame::Sunken); - - layout->addWidget(hline, row, 0, 1, nCols); -} - - -// file-scope -// Widget properties -static QWidget* setWidgetProperties -( - QWidget* widget, - vtkSMProperty* prop -) -{ - widget->setFocusPolicy(Qt::NoFocus); // avoid dotted border - - vtkSMDocumentation* doc = prop->GetDocumentation(); - if (doc) - { - const char* txt = doc->GetDescription(); - if (txt) - { - QString tip = QString(txt).simplified(); - if (tip.size()) - { - widget->setToolTip(tip); - } - } - } - - return widget; -} - - -// file-scope -// Button properties -static QAbstractButton* setButtonProperties -( - QAbstractButton* b, - vtkSMProperty* prop -) -{ - setWidgetProperties(b, prop); - b->setText(prop->GetXMLLabel()); - - vtkSMIntVectorProperty* intProp = - vtkSMIntVectorProperty::SafeDownCast(prop); - - // Initial checked state for integer (bool) properties - if (intProp) - { - b->setChecked(intProp->GetElement(0)); - } - - return b; -} - - -// file-scope -// Fill combo-box from XML enumeration -static QComboBox* setComboBoxContent -( - QComboBox* b, - vtkSMIntVectorProperty* prop -) -{ - vtkSMEnumerationDomain* propEnum = - vtkSMEnumerationDomain::SafeDownCast - ( - prop->FindDomain("vtkSMEnumerationDomain") - ); - - if (propEnum) - { - unsigned int n = propEnum->GetNumberOfEntries(); - for (unsigned int idx=0; idx < n; ++idx) - { - const int val = propEnum->GetEntryValue(idx); - const char* txt = propEnum->GetEntryText(idx); - - b->insertItem(val, txt); - } - - // Set default - const int val = prop->GetElement(0); - unsigned int idx = 0; - if (!propEnum->IsInDomain(val, idx)) - { - idx = 0; - } - b->setCurrentIndex(idx); - } - - return b; -} - - -// file-scope -// Translate a combo-box index to a lookup value -static int comboBoxValue(vtkSMIntVectorProperty* prop, int idx) -{ - vtkSMEnumerationDomain* propEnum = - vtkSMEnumerationDomain::SafeDownCast - ( - prop->FindDomain("vtkSMEnumerationDomain") - ); - - if (propEnum) - { - return propEnum->GetEntryValue(idx); - } - else - { - return idx; - } -} - - -static vtkSMIntVectorProperty* lookupIntProp -( - vtkSMPropertyGroup* group, - const char* name -) -{ - vtkSMProperty* prop = group->GetProperty(name); - - if (prop) - { - return vtkSMIntVectorProperty::SafeDownCast(prop); - } - - return nullptr; -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void pqFoamReaderControls::fireCommand -( - vtkSMIntVectorProperty* prop, - int val -) -{ - vtkSMProxy* pxy = this->proxy(); - - prop->SetElement(0, val); // Set int value, toggle bool, etc - - // Fire off command - prop->Modified(); - pxy->UpdateProperty(pxy->GetPropertyName(prop)); -} - - -void pqFoamReaderControls::updateParts() -{ - vtkSMProxy* pxy = this->proxy(); - - pxy->UpdatePropertyInformation(pxy->GetProperty("PartArrayStatus")); -} - - -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -void pqFoamReaderControls::refreshPressed() -{ - vtkSMProxy* pxy = this->proxy(); - - // Fire off command - refresh_->Modified(); - pxy->UpdateProperty(pxy->GetPropertyName(refresh_)); - - vtkSMSourceProxy::SafeDownCast(pxy)->UpdatePipeline(); - - // Trigger a rendering (all views) - pqPVApplicationCore::instance()->render(); -} - - -void pqFoamReaderControls::cacheMesh(int idx) -{ - fireCommand(meshCaching_, comboBoxValue(meshCaching_, idx)); -} - - -void pqFoamReaderControls::showPatchNames(bool checked) -{ - fireCommand(showPatchNames_, checked); - - // update the active view - if (this->view()) - { - this->view()->render(); - } - // OR: update all views - // pqPVApplicationCore::instance()->render(); -} - - -void pqFoamReaderControls::showGroupsOnly(bool checked) -{ - fireCommand(showGroupsOnly_, checked); - updateParts(); -} - - -void pqFoamReaderControls::includeSets(bool checked) -{ - fireCommand(includeSets_, checked); - updateParts(); -} - - -void pqFoamReaderControls::includeZones(bool checked) -{ - fireCommand(includeZones_, checked); - updateParts(); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -pqFoamReaderControls::pqFoamReaderControls -( - vtkSMProxy* proxy, - vtkSMPropertyGroup* group, - QWidget* parent -) -: - Superclass(proxy, parent), - refresh_(group->GetProperty("Refresh")), - showPatchNames_(lookupIntProp(group, "ShowPatchNames")), - showGroupsOnly_(lookupIntProp(group, "ShowGroupsOnly")), - includeSets_(lookupIntProp(group, "IncludeSets")), - includeZones_(lookupIntProp(group, "IncludeZones")), - meshCaching_(lookupIntProp(group, "MeshCaching")) -{ - typedef vtkSMIntVectorProperty intProp; - - QGridLayout* form = new QGridLayout(this); - - const int nCols = 3; - - // ROW - // ~~~ - int row = 0; - - if (refresh_) - { - QPushButton* b = new QPushButton(this); - setButtonProperties(b, refresh_); - form->addWidget(b, row, 0, Qt::AlignLeft); - - connect(b, SIGNAL(clicked()), this, SLOT(refreshPressed())); - } - - intProp* zeroTime = lookupIntProp(group, "ZeroTime"); - if (zeroTime) - { - QCheckBox* b = new QCheckBox(this); - setButtonProperties(b, zeroTime); - form->addWidget(b, row, 1, Qt::AlignLeft); - - addPropertyLink - ( - b, "checked", SIGNAL(toggled(bool)), zeroTime - ); - } - - // LINE - addHline(form, ++row, nCols); - - // ROW - // ~~~ - ++row; - - if (includeSets_) - { - QCheckBox* b = new QCheckBox(this); - setButtonProperties(b, includeSets_); - form->addWidget(b, row, 0, Qt::AlignLeft); - - addPropertyLink - ( - b, "checked", SIGNAL(toggled(bool)), includeSets_ - ); - connect - ( - b, SIGNAL(toggled(bool)), this, SLOT(includeSets(bool)) - ); - } - - if (showGroupsOnly_) - { - QCheckBox* b = new QCheckBox(this); - setButtonProperties(b, showGroupsOnly_); - form->addWidget(b, row, 1, Qt::AlignLeft); - - addPropertyLink - ( - b, "checked", SIGNAL(toggled(bool)), showGroupsOnly_ - ); - connect - ( - b, SIGNAL(toggled(bool)), this, SLOT(showGroupsOnly(bool)) - ); - } - - - // ROW - // ~~~ - ++row; - - if (includeZones_) - { - QCheckBox* b = new QCheckBox(this); - setButtonProperties(b, includeZones_); - form->addWidget(b, row, 0, Qt::AlignLeft); - - addPropertyLink - ( - b, "checked", SIGNAL(toggled(bool)), includeZones_ - ); - connect - ( - b, SIGNAL(toggled(bool)), this, SLOT(includeZones(bool)) - ); - } - - if (showPatchNames_) - { - QCheckBox* b = new QCheckBox(this); - setButtonProperties(b, showPatchNames_); - form->addWidget(b, row, 1, Qt::AlignLeft); - - connect - ( - b, SIGNAL(toggled(bool)), this, SLOT(showPatchNames(bool)) - ); - } - - // LINE - addHline(form, ++row, nCols); - - // ROW - // ~~~ - ++row; - - intProp* interpolate = lookupIntProp(group, "InterpolateFields"); - if (interpolate) - { - QCheckBox* b = new QCheckBox(this); - setButtonProperties(b, interpolate); - form->addWidget(b, row, 0, Qt::AlignLeft); - - addPropertyLink - ( - b, "checked", SIGNAL(toggled(bool)), interpolate - ); - } - - intProp* extrapolate = lookupIntProp(group, "ExtrapolatePatches"); - if (extrapolate) - { - QCheckBox* b = new QCheckBox(this); - setButtonProperties(b, extrapolate); - form->addWidget(b, row, 1, Qt::AlignLeft); - - addPropertyLink - ( - b, "checked", SIGNAL(toggled(bool)), extrapolate - ); - } - - // LINE - addHline(form, ++row, nCols); - - // ROW - // ~~~ - ++row; - - intProp* updateGui = lookupIntProp(group, "UpdateGUI"); - if (updateGui) - { - QPushButton* b = new QPushButton(this); - setButtonProperties(b, updateGui); - form->addWidget(b, row, 0, Qt::AlignLeft); - - addPropertyLink - ( - b, "checked", SIGNAL(clicked()), updateGui - ); - } - - intProp* usePolyhedron = lookupIntProp(group, "UseVTKPolyhedron"); - if (usePolyhedron) - { - QCheckBox* b = new QCheckBox(this); - setButtonProperties(b, usePolyhedron); - form->addWidget(b, row, 1, Qt::AlignLeft); - - addPropertyLink - ( - b, "checked", SIGNAL(toggled(bool)), usePolyhedron - ); - } - - if (meshCaching_) - { - QComboBox* b = new QComboBox(this); - form->addWidget(b, row, 2, Qt::AlignLeft); - - setWidgetProperties(b, meshCaching_); - setComboBoxContent(b, meshCaching_); - - addPropertyLink - ( - b, "indexChanged", SIGNAL(currentIndexChanged(int)), meshCaching_ - ); - - connect - ( - b, SIGNAL(currentIndexChanged(int)), this, SLOT(cacheMesh(int)) - ); - } -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -pqFoamReaderControls::~pqFoamReaderControls() -{} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/pqFoamReaderControls.h b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/pqFoamReaderControls.h deleted file mode 100644 index 8c731c9bca8168fde919754016c7cf6b5c4f21b0..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/pqFoamReaderControls.h +++ /dev/null @@ -1,134 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. - -Class - pqFoamReaderControls - -Description - A custom property group widget for the PVFoamReader. - -SourceFiles - pqFoamReaderControls.cxx - -\*---------------------------------------------------------------------------*/ -#ifndef pqFoamReaderControls_h -#define pqFoamReaderControls_h - -#include "pqPropertyWidget.h" - -// Forward declarations -class vtkSMProperty; -class vtkSMIntVectorProperty; - - -/*---------------------------------------------------------------------------*\ - Class pqFoamReaderControls Declaration -\*---------------------------------------------------------------------------*/ - -class pqFoamReaderControls -: - public pqPropertyWidget -{ - Q_OBJECT; - typedef pqPropertyWidget Superclass; - - // Private data - - //- Refresh (push button) - vtkSMProperty* refresh_; - - //- Show Patch Names (bool property) - vtkSMIntVectorProperty* showPatchNames_; - - //- Show Groups Only (bool property) - vtkSMIntVectorProperty* showGroupsOnly_; - - //- IncludeSets (bool property) - vtkSMIntVectorProperty* includeSets_; - - //- IncludeZones (bool property) - vtkSMIntVectorProperty* includeZones_; - - //- MeshCaching (enum property) - vtkSMIntVectorProperty* meshCaching_; - - - // Private Member Functions - - //- Update property - void fireCommand(vtkSMProperty* prop); - - //- Update int property or toggle bool property - void fireCommand(vtkSMIntVectorProperty* prop, int val); - - - //- No copy construct - pqFoamReaderControls(const pqFoamReaderControls&) = delete; - - //- No copy assignment - void operator=(const pqFoamReaderControls&) = delete; - - -private slots: - - // Private Member Functions - - //- Update "PartArrayStatus" property information - void updateParts(); - - -protected slots: - - // Protected Member Functions - - void refreshPressed(); - void cacheMesh(int idx); - void showPatchNames(bool checked); - void showGroupsOnly(bool checked); - void includeSets(bool checked); - void includeZones(bool checked); - - -public: - - //- Construct from components - pqFoamReaderControls - ( - vtkSMProxy* proxy, - vtkSMPropertyGroup* group, - QWidget* parent = nullptr - ); - - //- Destructor - virtual ~pqFoamReaderControls(); - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/reader/vtkPVFoamReader.cxx b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/reader/vtkPVFoamReader.cxx deleted file mode 100644 index d08b2409db87b8e148c198cfcd75f4f616aa8009..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/reader/vtkPVFoamReader.cxx +++ /dev/null @@ -1,691 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ -#include "vtkPVFoamReader.h" - -#include "pqApplicationCore.h" -#include "pqRenderView.h" -#include "pqServerManagerModel.h" - -// VTK includes -#include "vtkCallbackCommand.h" -#include "vtkDataArraySelection.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkInformationDoubleVectorKey.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkObjectFactory.h" -#include "vtkSMRenderViewProxy.h" -#include "vtkStreamingDemandDrivenPipeline.h" -#include "vtkStringArray.h" -#include "vtkSmartPointer.h" - -// OpenFOAM includes -#include "vtkPVFoam.H" - -// STL includes -#include <vector> - -#undef VTKPVFOAM_DUALPORT - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -vtkStandardNewMacro(vtkPVFoamReader); - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -vtkPVFoamReader::vtkPVFoamReader() -{ - Debug = 0; - vtkDebugMacro(<<"Constructor"); - - SetNumberOfInputPorts(0); - FileName = nullptr; - backend_ = nullptr; - -#ifdef VTKPVFOAM_DUALPORT - // Add second output for the Lagrangian - this->SetNumberOfOutputPorts(2); - - auto lagrangian = vtkSmartPointer<vtkMultiBlockDataSet>::New(); - - lagrangian->ReleaseData(); - - this->GetExecutive()->SetOutputData(1, lagrangian); -#endif - - TimeStepRange[0] = 0; - TimeStepRange[1] = 0; - - MeshCaching = 3; // fvMesh+vtk - - SkipZeroTime = true; - ExtrapolatePatches = false; - UseVTKPolyhedron = false; - IncludeSets = false; - IncludeZones = false; - ShowPatchNames = false; - ShowGroupsOnly = false; - InterpolateVolFields = true; - - UpdateGUI = false; - - PartSelection = vtkDataArraySelection::New(); - VolFieldSelection = vtkDataArraySelection::New(); - PointFieldSelection = vtkDataArraySelection::New(); - LagrangianFieldSelection = vtkDataArraySelection::New(); - - // Setup the selection callback to modify this object when an array - // selection is changed. - SelectionObserver = vtkCallbackCommand::New(); - SelectionObserver->SetCallback - ( - &vtkPVFoamReader::SelectionModifiedCallback - ); - SelectionObserver->SetClientData(this); - - PartSelection->AddObserver - ( - vtkCommand::ModifiedEvent, - this->SelectionObserver - ); - VolFieldSelection->AddObserver - ( - vtkCommand::ModifiedEvent, - this->SelectionObserver - ); - PointFieldSelection->AddObserver - ( - vtkCommand::ModifiedEvent, - this->SelectionObserver - ); - LagrangianFieldSelection->AddObserver - ( - vtkCommand::ModifiedEvent, - this->SelectionObserver - ); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -vtkPVFoamReader::~vtkPVFoamReader() -{ - vtkDebugMacro(<<"Deconstructor"); - - if (backend_) - { - // Remove text actors - updatePatchNamesView(false); - - delete backend_; - backend_ = nullptr; - } - - if (FileName) - { - delete[] FileName; - } - - PartSelection->RemoveAllObservers(); - VolFieldSelection->RemoveAllObservers(); - PointFieldSelection->RemoveAllObservers(); - LagrangianFieldSelection->RemoveAllObservers(); - - SelectionObserver->Delete(); - - PartSelection->Delete(); - VolFieldSelection->Delete(); - PointFieldSelection->Delete(); - LagrangianFieldSelection->Delete(); -} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -// Do everything except set the output info -int vtkPVFoamReader::RequestInformation -( - vtkInformation* vtkNotUsed(request), - vtkInformationVector** vtkNotUsed(inputVector), - vtkInformationVector* outputVector -) -{ - vtkDebugMacro(<<"RequestInformation"); - - if (Foam::vtkPVFoam::debug) - { - cout<<"REQUEST_INFORMATION\n"; - } - - if (!FileName) - { - vtkErrorMacro("FileName has to be specified!"); - return 0; - } - - const int nInfo = outputVector->GetNumberOfInformationObjects(); - - if (Foam::vtkPVFoam::debug) - { - cout<<"RequestInformation with " << nInfo << " item(s)\n"; - for (int infoI = 0; infoI < nInfo; ++infoI) - { - outputVector->GetInformationObject(infoI)->Print(cout); - } - } - - if (backend_) - { - backend_->updateInfo(); - } - else - { - backend_ = new Foam::vtkPVFoam(FileName, this); - } - - std::vector<double> times = backend_->findTimes(this->SkipZeroTime); - - if (times.empty()) - { - vtkErrorMacro("could not find valid OpenFOAM mesh"); - - // delete backend handler and flag it as fatal error - delete backend_; - backend_ = nullptr; - return 0; - } - - // set identical time steps for all ports - for (int infoI = 0; infoI < nInfo; ++infoI) - { - vtkInformation *outInfo = outputVector->GetInformationObject(infoI); - - outInfo->Set - ( - vtkStreamingDemandDrivenPipeline::TIME_STEPS(), - times.data(), - static_cast<int>(times.size()) - ); - - // Something like this may be useful: - // outInfo->Set - // ( - // vtkStreamingDemandDrivenPipeline::TIME_DEPENDENT_INFORMATION(), - // 1 - // ); - } - - if (times.size()) - { - double timeRange[2]{ times.front(), times.back() }; - - if (Foam::vtkPVFoam::debug > 1) - { - cout - <<"nInfo " << nInfo << "\n" - <<"time-range " << times.front() << ':' << times.back() << "\n" - <<"times " << times.size() << "("; - - for (auto val : times) - { - cout<< ' ' << val; - } - cout << " )" << std::endl; - } - - for (int infoI = 0; infoI < nInfo; ++infoI) - { - vtkInformation *outInfo = outputVector->GetInformationObject(infoI); - - outInfo->Set - ( - vtkStreamingDemandDrivenPipeline::TIME_RANGE(), - timeRange, - 2 - ); - } - } - - return 1; -} - - -// Set the output info -int vtkPVFoamReader::RequestData -( - vtkInformation* vtkNotUsed(request), - vtkInformationVector** vtkNotUsed(inputVector), - vtkInformationVector* outputVector -) -{ - vtkDebugMacro(<<"RequestData"); - - if (!FileName) - { - vtkErrorMacro("FileName must be specified!"); - return 0; - } - if (!backend_) - { - // Catch some previous error - vtkErrorMacro("Reader failed - perhaps no mesh?"); - return 0; - } - - const int nInfo = outputVector->GetNumberOfInformationObjects(); - - if (Foam::vtkPVFoam::debug) - { - cout<<"RequestData with " << nInfo << " item(s)\n"; - for (int infoI = 0; infoI < nInfo; ++infoI) - { - outputVector->GetInformationObject(infoI)->Print(cout); - } - } - - // Get the requested time step. - // We only support requests for a single time step - - std::vector<double> requestTime; - requestTime.reserve(nInfo); - - // taking port0 as the lead for other outputs would be nice, but fails when - // a filter is added - we need to check everything - // but since PREVIOUS_UPDATE_TIME_STEPS() is protected, relay the logic - // to the vtkPVFoam::setTime() method - for (int infoi = 0; infoi < nInfo; ++infoi) - { - vtkInformation *outInfo = outputVector->GetInformationObject(infoi); - - const int nsteps = - outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS()); - - if - ( - outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) - && nsteps > 0 - ) - { - const double timeValue = - ( - 1 == nsteps - // Only one time-step available, UPDATE_TIME_STEP is unreliable - ? outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), 0) - : outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) - ); - - // outInfo->Set(vtkDataObject::DATA_TIME_STEP(), timeValue); - // this->SetTimeValue(timeValue); - requestTime.push_back(timeValue); - } - } - - backend_->setTime(requestTime); - - vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast - ( - outputVector->GetInformationObject(0)->Get - ( - vtkMultiBlockDataSet::DATA_OBJECT() - ) - ); - -#ifdef VTKPVFOAM_DUALPORT - vtkMultiBlockDataSet* output1 = vtkMultiBlockDataSet::SafeDownCast - ( - outputVector->GetInformationObject(1)->Get - ( - vtkMultiBlockDataSet::DATA_OBJECT() - ) - ); - - backend_->Update(output, output1); -#else - backend_->Update(output, nullptr); -#endif - - updatePatchNamesView(ShowPatchNames); - - backend_->UpdateFinalize(); - - return 1; -} - - -void vtkPVFoamReader::PrintInfo() -{ - if (backend_) - { - backend_->printInfo(); - } - else - { - cout - <<"OpenFOAM reader not initialized\n" - << std::flush; - } -} - - -void vtkPVFoamReader::Refresh() -{ - Modified(); -} - - -void vtkPVFoamReader::SetIncludeSets(bool val) -{ - if (IncludeSets != val) - { - IncludeSets = val; - if (backend_) - { - backend_->updateInfo(); - } - } -} - - -void vtkPVFoamReader::SetIncludeZones(bool val) -{ - if (IncludeZones != val) - { - IncludeZones = val; - if (backend_) - { - backend_->updateInfo(); - } - } -} - - -void vtkPVFoamReader::SetShowPatchNames(bool val) -{ - if (ShowPatchNames != val) - { - ShowPatchNames = val; - updatePatchNamesView(ShowPatchNames); - } -} - - -void vtkPVFoamReader::SetShowGroupsOnly(bool val) -{ - if (ShowGroupsOnly != val) - { - ShowGroupsOnly = val; - if (backend_) - { - backend_->updateInfo(); - } - } -} - - -void vtkPVFoamReader::updatePatchNamesView(const bool show) -{ - pqApplicationCore* appCore = pqApplicationCore::instance(); - - // need to check this, since our destructor calls this - if (!appCore) - { - return; - } - - // Server manager model for querying items in the server manager - pqServerManagerModel* smModel = appCore->getServerManagerModel(); - - if (!smModel || !backend_) - { - return; - } - - // Get all the pqRenderView instances - for (auto view : smModel->findItems<pqRenderView*>()) - { - backend_->renderPatchNames - ( - view->getRenderViewProxy()->GetRenderer(), - show - ); - } - - // Use refresh here? -} - - -void vtkPVFoamReader::PrintSelf(ostream& os, vtkIndent indent) -{ - vtkDebugMacro(<<"PrintSelf"); - - this->Superclass::PrintSelf(os,indent); - os << indent << "File name: " - << (this->FileName ? this->FileName : "(none)") << "\n"; - - backend_->PrintSelf(os, indent); - - os << indent << "Time step range: " - << this->TimeStepRange[0] << " - " << this->TimeStepRange[1] << "\n" - << indent << "Time step: " << this->GetTimeStep() << endl; -} - - -int vtkPVFoamReader::GetTimeStep() -{ - return backend_ ? backend_->timeIndex() : -1; -} - - -// ---------------------------------------------------------------------- -// Parts selection list control - -vtkDataArraySelection* vtkPVFoamReader::GetPartSelection() -{ - return PartSelection; -} - -int vtkPVFoamReader::GetNumberOfPartArrays() -{ - return PartSelection->GetNumberOfArrays(); -} - -const char* vtkPVFoamReader::GetPartArrayName(int index) -{ - return PartSelection->GetArrayName(index); -} - -int vtkPVFoamReader::GetPartArrayStatus(const char* name) -{ - return PartSelection->ArrayIsEnabled(name); -} - -void vtkPVFoamReader::SetPartArrayStatus(const char* name, int status) -{ - vtkDebugMacro("Set mesh part \"" << name << "\" status to: " << status); - - if (status) - { - PartSelection->EnableArray(name); - } - else - { - PartSelection->DisableArray(name); - } -} - - -// ---------------------------------------------------------------------- -// volField selection list control - -vtkDataArraySelection* vtkPVFoamReader::GetVolFieldSelection() -{ - return VolFieldSelection; -} - -int vtkPVFoamReader::GetNumberOfVolFieldArrays() -{ - return VolFieldSelection->GetNumberOfArrays(); -} - -const char* vtkPVFoamReader::GetVolFieldArrayName(int index) -{ - return VolFieldSelection->GetArrayName(index); -} - -int vtkPVFoamReader::GetVolFieldArrayStatus(const char* name) -{ - return VolFieldSelection->ArrayIsEnabled(name); -} - -void vtkPVFoamReader::SetVolFieldArrayStatus(const char* name, int status) -{ - if (status) - { - VolFieldSelection->EnableArray(name); - } - else - { - VolFieldSelection->DisableArray(name); - } -} - - -// ---------------------------------------------------------------------- -// pointField selection list control - -vtkDataArraySelection* vtkPVFoamReader::GetPointFieldSelection() -{ - return PointFieldSelection; -} - -int vtkPVFoamReader::GetNumberOfPointFieldArrays() -{ - return PointFieldSelection->GetNumberOfArrays(); -} - -const char* vtkPVFoamReader::GetPointFieldArrayName(int index) -{ - return PointFieldSelection->GetArrayName(index); -} - -int vtkPVFoamReader::GetPointFieldArrayStatus(const char* name) -{ - return PointFieldSelection->ArrayIsEnabled(name); -} - -void vtkPVFoamReader::SetPointFieldArrayStatus(const char* name, int status) -{ - if (status) - { - PointFieldSelection->EnableArray(name); - } - else - { - PointFieldSelection->DisableArray(name); - } -} - - -// ---------------------------------------------------------------------- -// lagrangianField selection list control - -vtkDataArraySelection* vtkPVFoamReader::GetLagrangianFieldSelection() -{ - return LagrangianFieldSelection; -} - -int vtkPVFoamReader::GetNumberOfLagrangianFieldArrays() -{ - return LagrangianFieldSelection->GetNumberOfArrays(); -} - -const char* vtkPVFoamReader::GetLagrangianFieldArrayName(int index) -{ - return LagrangianFieldSelection->GetArrayName(index); -} - -int vtkPVFoamReader::GetLagrangianFieldArrayStatus(const char* name) -{ - return LagrangianFieldSelection->ArrayIsEnabled(name); -} - -void vtkPVFoamReader::SetLagrangianFieldArrayStatus -( - const char* name, - int status -) -{ - if (status) - { - LagrangianFieldSelection->EnableArray(name); - } - else - { - LagrangianFieldSelection->DisableArray(name); - } -} - - -// ---------------------------------------------------------------------- - -void vtkPVFoamReader::SelectionModifiedCallback -( - vtkObject*, - unsigned long, - void* clientdata, - void* -) -{ - static_cast<vtkPVFoamReader*>(clientdata)->SelectionModified(); -} - - -void vtkPVFoamReader::SelectionModified() -{ - vtkDebugMacro(<<"SelectionModified"); - Modified(); -} - - -int vtkPVFoamReader::FillOutputPortInformation -( - int port, - vtkInformation* info -) -{ - if (port == 0) - { - return this->Superclass::FillOutputPortInformation(port, info); - } - info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet"); - return 1; -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/reader/vtkPVFoamReader.h b/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/reader/vtkPVFoamReader.h deleted file mode 100644 index a7af312f176dacb1ef2af7bbaa3e1bb23c7e9ce5..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamReader/plugin/reader/vtkPVFoamReader.h +++ /dev/null @@ -1,265 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. - -Class - vtkPVFoamReader - -Description - Reads a dataset in OpenFOAM format - - vtkPVFoamReader creates an multiblock dataset. - It uses the OpenFOAM infrastructure (fvMesh, etc) to handle mesh and - field data. - -SourceFiles - vtkPVblockMeshReader.cxx - -\*---------------------------------------------------------------------------*/ -#ifndef vtkPVFoamReader_h -#define vtkPVFoamReader_h - -// VTK includes -#include "vtkMultiBlockDataSetAlgorithm.h" - -// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * // - -// VTK forward declarations -class vtkDataArraySelection; -class vtkCallbackCommand; -template<class T> class vtkSmartPointer; - -// OpenFOAM forward declarations -namespace Foam -{ - class vtkPVFoam; -} - - -/*---------------------------------------------------------------------------*\ - Class vtkPVFoamReader Declaration -\*---------------------------------------------------------------------------*/ - -class vtkPVFoamReader -: - public vtkMultiBlockDataSetAlgorithm -{ -public: - vtkTypeMacro(vtkPVFoamReader, vtkMultiBlockDataSetAlgorithm); - void PrintSelf(ostream&, vtkIndent) VTK_OVERRIDE; - - static vtkPVFoamReader* New(); - - // Description: - // Get the current timestep and the timestep range. - vtkGetVector2Macro(TimeStepRange, int); - - // Description: - // Set/Get the filename. - vtkSetStringMacro(FileName); - vtkGetStringMacro(FileName); - - // Description: - // Print some case information - virtual void PrintInfo(); - - // Description: - // Mesh caching control (0:none,1:fvMesh,3:fvMesh+vtk) - vtkSetMacro(MeshCaching, int); - vtkGetMacro(MeshCaching, int); - - // Description: - // OpenFOAM refresh times/fields - virtual void Refresh(); - - // Description: - // OpenFOAM skip/include the 0/ time directory - vtkSetMacro(SkipZeroTime, bool); - vtkGetMacro(SkipZeroTime, bool); - - // Description: - // GUI update control - vtkSetMacro(UpdateGUI, bool); - vtkGetMacro(UpdateGUI, bool); - - // Description: - // OpenFOAM extrapolate internal values onto the patches - vtkSetMacro(ExtrapolatePatches, bool); - vtkGetMacro(ExtrapolatePatches, bool); - - // Description: - // OpenFOAM use vtkPolyhedron instead of decomposing polyhedra - vtkSetMacro(UseVTKPolyhedron, bool); - vtkGetMacro(UseVTKPolyhedron, bool); - - // Description: - // OpenFOAM read sets control - virtual void SetIncludeSets(bool); - vtkGetMacro(IncludeSets, bool); - - // Description: - // OpenFOAM read zones control - virtual void SetIncludeZones(bool); - vtkGetMacro(IncludeZones, bool); - - // Description: - // OpenFOAM display patch names control - virtual void SetShowPatchNames(bool); - vtkGetMacro(ShowPatchNames, bool); - - // Description: - // OpenFOAM display patchGroups - virtual void SetShowGroupsOnly(bool); - vtkGetMacro(ShowGroupsOnly, bool); - - // Description: - // OpenFOAM volField interpolation - vtkSetMacro(InterpolateVolFields, bool); - vtkGetMacro(InterpolateVolFields, bool); - - // Description: - // Get the current timestep - int GetTimeStep(); - - // Description: - // Parts selection list control - virtual vtkDataArraySelection* GetPartSelection(); - int GetNumberOfPartArrays(); - int GetPartArrayStatus(const char* name); - void SetPartArrayStatus(const char* name, int status); - const char* GetPartArrayName(int index); - - // Description: - // volField selection list control - virtual vtkDataArraySelection* GetVolFieldSelection(); - int GetNumberOfVolFieldArrays(); - int GetVolFieldArrayStatus(const char* name); - void SetVolFieldArrayStatus(const char* name, int status); - const char* GetVolFieldArrayName(int index); - - // Description: - // pointField selection list control - virtual vtkDataArraySelection* GetPointFieldSelection(); - int GetNumberOfPointFieldArrays(); - int GetPointFieldArrayStatus(const char* name); - void SetPointFieldArrayStatus(const char* name, int status); - const char* GetPointFieldArrayName(int index); - - // Description: - // lagrangianField selection list control - virtual vtkDataArraySelection* GetLagrangianFieldSelection(); - int GetNumberOfLagrangianFieldArrays(); - int GetLagrangianFieldArrayStatus(const char* name); - void SetLagrangianFieldArrayStatus(const char* name, int status); - const char* GetLagrangianFieldArrayName(int index); - - // Description: - // Callback registered with the SelectionObserver - // for all the selection lists - static void SelectionModifiedCallback - ( - vtkObject* caller, - unsigned long eid, - void* clientdata, - void* calldata - ); - - void SelectionModified(); - - -protected: - - //- Construct null - vtkPVFoamReader(); - - //- Destructor - ~vtkPVFoamReader(); - - //- Return information about mesh, times, etc without loading anything - virtual int RequestInformation - ( - vtkInformation*, - vtkInformationVector**, - vtkInformationVector* - ) VTK_OVERRIDE; - - //- Get the mesh/fields for a particular time - virtual int RequestData - ( - vtkInformation*, - vtkInformationVector**, - vtkInformationVector* - ) VTK_OVERRIDE; - - //- Fill in additional port information - virtual int FillOutputPortInformation(int, vtkInformation*) VTK_OVERRIDE; - - //- The observer to modify this object when array selections are modified - vtkCallbackCommand* SelectionObserver; - - //- The file name for this case - char* FileName; - - -private: - - //- No copy construct - vtkPVFoamReader(const vtkPVFoamReader&) = delete; - - //- No copy assignment - void operator=(const vtkPVFoamReader&) = delete; - - //- Add/remove patch names to/from the view - void updatePatchNamesView(const bool show); - - int TimeStepRange[2]; - int MeshCaching; - bool SkipZeroTime; - - bool ExtrapolatePatches; - bool UseVTKPolyhedron; - bool IncludeSets; - bool IncludeZones; - bool ShowPatchNames; - bool ShowGroupsOnly; - bool InterpolateVolFields; - - //- Dummy variable/switch to invoke a reader update - bool UpdateGUI; - - vtkDataArraySelection* PartSelection; - vtkDataArraySelection* VolFieldSelection; - vtkDataArraySelection* PointFieldSelection; - vtkDataArraySelection* LagrangianFieldSelection; - - //- Backend portion of the reader - Foam::vtkPVFoam* backend_; -}; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* //