PV3FoamReader repaired several misfeatures

- On the first call, select 'internalMesh' and the 'p', 'U' fields.
    This corresponds to a fairly common default case without loading all
    possible fields etc.
  - Include zones should now work without issuing a FatalError when the
    corresponding files are missing. I must have tried too many things
    at once and didn't notice this before.
  - Use ZoneMesh for zone names if the fvMesh is already cached
    (skips re-reading the same files).
  - Change reader description to "OpenFOAM Reader" to distinguish it a bit
    from the vtkOpenFOAMReader built into paraview/vtk
  - Misc. file and method names reorganized

  - Remaining problem:
    mixing internalMesh and cellZones is clunky since there aren't yet
    interpolated point values for cellSets/cellZones. Paraview complains
    about the mismatch, but extracting a block is still okay.

  TODO:
  - multi-port output for Lagrangian
  - hold all the vtk mesh parts (including multiblock) and just pass the
    reference. With this, the pipeline might notice that the geometry is
    actually identical and skip the PVGeometryFilter that takes so long.
This commit is contained in:
Mark Olesen
2008-07-25 10:46:10 +02:00
parent af5674aca5
commit 8a2596a05c
13 changed files with 332 additions and 379 deletions

View File

@ -1,6 +1,6 @@
<ParaViewReaders> <ParaViewReaders>
<Reader name="PV3FoamReader" <Reader name="PV3FoamReader"
extensions="OpenFOAM" extensions="OpenFOAM"
file_description="OpenFOAM"> file_description="OpenFOAM Reader">
</Reader> </Reader>
</ParaViewReaders> </ParaViewReaders>

View File

@ -2,10 +2,8 @@ vtkPV3Foam.C
vtkPV3FoamAddVolumeMesh.C vtkPV3FoamAddVolumeMesh.C
vtkPV3FoamAddLagrangianMesh.C vtkPV3FoamAddLagrangianMesh.C
vtkPV3FoamAddPatchMesh.C vtkPV3FoamAddPatchMesh.C
vtkPV3FoamAddFaceZoneMesh.C vtkPV3FoamAddZoneMesh.C
vtkPV3FoamAddPointZoneMesh.C vtkPV3FoamAddSetMesh.C
vtkPV3FoamAddFaceSetMesh.C
vtkPV3FoamAddPointSetMesh.C
vtkPV3FoamUpdate.C vtkPV3FoamUpdate.C
vtkPV3FoamUpdateInformation.C vtkPV3FoamUpdateInformation.C
vtkPV3FoamConvertMesh.C vtkPV3FoamConvertMesh.C

View File

@ -52,7 +52,7 @@ defineTypeNameAndDebug(Foam::vtkPV3Foam, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
#include "vtkPV3FoamAddFields.H" #include "vtkPV3FoamAddToSelection.H"
#include "vtkPV3FoamUpdateInformationFields.H" #include "vtkPV3FoamUpdateInformationFields.H"
@ -233,13 +233,13 @@ void Foam::vtkPV3Foam::updateSelectedRegions()
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
const label nRegions = arraySelection->GetNumberOfArrays(); const label nSelect = arraySelection->GetNumberOfArrays();
selectedRegions_.setSize(nRegions); selectedRegions_.setSize(nSelect);
selectedRegionDatasetIds_.setSize(nRegions); selectedRegionDatasetIds_.setSize(nSelect);
// Read the selected patches and add to the region list // Read the selected patches and add to the region list
for (int regionId=0; regionId < nRegions; ++regionId) forAll (selectedRegions_, regionId)
{ {
selectedRegions_[regionId] = arraySelection->GetArraySetting(regionId); selectedRegions_[regionId] = arraySelection->GetArraySetting(regionId);
selectedRegionDatasetIds_[regionId] = -1; selectedRegionDatasetIds_[regionId] = -1;
@ -269,7 +269,13 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
if (debug) if (debug)
{ {
Info<< "selections("; Info<< "available(";
forAll (selections, elemI)
{
Info<< " \"" << arraySelection->GetArrayName(elemI) << "\"";
}
Info<< " )\n"
<< "selected(";
} }
forAll (selections, elemI) forAll (selections, elemI)
@ -319,28 +325,40 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
if (debug) if (debug)
{ {
Info<< "selections("; Info<< "available(";
for
(
int elemI = selector.start();
elemI < selector.end();
++elemI
)
{
Info<< " \"" << arraySelection->GetArrayName(elemI) << "\"";
}
Info<< " )\n"
<< "selected(";
} }
for for
( (
int regionId = selector.start(); int elemI = selector.start();
regionId < selector.end(); elemI < selector.end();
++regionId ++elemI
) )
{ {
if (arraySelection->GetArraySetting(regionId)) if (arraySelection->GetArraySetting(elemI))
{ {
if (firstWord) if (firstWord)
{ {
selections[nElem] = getFirstWord selections[nElem] = getFirstWord
( (
arraySelection->GetArrayName(regionId) arraySelection->GetArrayName(elemI)
); );
} }
else else
{ {
selections[nElem] = arraySelection->GetArrayName(regionId); selections[nElem] = arraySelection->GetArrayName(elemI);
} }
if (debug) if (debug)
@ -400,10 +418,7 @@ void Foam::vtkPV3Foam::setSelectedArrayEntries
<< endl; << endl;
} }
arraySelection->EnableArray arraySelection->EnableArray(arrayName.c_str());
(
arrayName.c_str()
);
break; break;
} }
} }
@ -523,25 +538,37 @@ void Foam::vtkPV3Foam::UpdateInformation()
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPV3Foam::UpdateInformation - " Info<< "<beg> Foam::vtkPV3Foam::UpdateInformation"
<< "TimeStep = " << reader_->GetTimeStep() << endl; << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "] TimeStep="
<< reader_->GetTimeStep() << endl;
} }
resetCounters(); resetCounters();
// preserve the currently selected values vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
const stringList selectedEntries = getSelectedArrayEntries
( stringList selectedEntries;
reader_->GetRegionSelection() // enable 'internalMesh' on the first call
); if (arraySelection->GetNumberOfArrays() == 0)
{
selectedEntries.setSize(1);
selectedEntries[0] = "internalMesh";
}
else
{
// preserve the currently selected values
selectedEntries = getSelectedArrayEntries
(
arraySelection
);
}
// Clear current region list/array // Clear current region list/array
reader_->GetRegionSelection()->RemoveAllArrays(); arraySelection->RemoveAllArrays();
// Update region array // Update region array
updateInformationInternalMesh(); updateInformationInternalMesh();
updateInformationLagrangian(); updateInformationLagrangian();
updateInformationPatches(); updateInformationPatches();
if (reader_->GetIncludeSets()) if (reader_->GetIncludeSets())
@ -554,10 +581,10 @@ void Foam::vtkPV3Foam::UpdateInformation()
updateInformationZones(); updateInformationZones();
} }
// Update region selection with the data just read in // restore the currently enabled values
setSelectedArrayEntries setSelectedArrayEntries
( (
reader_->GetRegionSelection(), arraySelection,
selectedEntries selectedEntries
); );
@ -610,9 +637,7 @@ void Foam::vtkPV3Foam::Update
// Convert meshes // Convert meshes
convertMeshVolume(output); convertMeshVolume(output);
convertMeshLagrangian(output); convertMeshLagrangian(output);
convertMeshPatches(output); convertMeshPatches(output);
if (reader_->GetIncludeZones()) if (reader_->GetIncludeZones())
@ -624,16 +649,14 @@ void Foam::vtkPV3Foam::Update
if (reader_->GetIncludeSets()) if (reader_->GetIncludeSets())
{ {
convertMeshCellSet(output); convertMeshCellSets(output);
convertMeshFaceSet(output); convertMeshFaceSets(output);
convertMeshPointSet(output); convertMeshPointSets(output);
} }
// Update fields // Update fields
updateVolFields(output); updateVolFields(output);
updatePointFields(output); updatePointFields(output);
updateLagrangianFields(output); updateLagrangianFields(output);
if (debug) if (debug)
@ -724,8 +747,7 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer)
Info<< "<beg> Foam::vtkPV3Foam::addPatchNames" << endl; Info<< "<beg> Foam::vtkPV3Foam::addPatchNames" << endl;
} }
const fvMesh& mesh = *meshPtr_; const polyBoundaryMesh& pbMesh = meshPtr_->boundaryMesh();
const polyBoundaryMesh& pbMesh = mesh.boundaryMesh();
const selectionInfo& selector = selectInfoPatches_; const selectionInfo& selector = selectInfoPatches_;

View File

@ -29,18 +29,16 @@ Description
Provides a reader interface for OpenFOAM to VTK interaction. Provides a reader interface for OpenFOAM to VTK interaction.
SourceFiles SourceFiles
interpolatePointToCell.C
interpolatePointToCell.H
vtkPV3Foam.C vtkPV3Foam.C
vtkPV3Foam.H vtkPV3Foam.H
vtkPV3FoamAddFaceSetMesh.C vtkPV3FoamI.H
vtkPV3FoamAddFaceZoneMesh.C
vtkPV3FoamAddFields.H
vtkPV3FoamAddLagrangianMesh.C vtkPV3FoamAddLagrangianMesh.C
vtkPV3FoamAddPatchMesh.C vtkPV3FoamAddPatchMesh.C
vtkPV3FoamAddPointSetMesh.C vtkPV3FoamAddSetMesh.C
vtkPV3FoamAddPointZoneMesh.C vtkPV3FoamAddToSelection.H
vtkPV3FoamAddVolumeMesh.C vtkPV3FoamAddVolumeMesh.C
vtkPV3FoamAddZoneMesh.C
vtkPV3FoamConvertFaceField.H
vtkPV3FoamConvertLagrangianFields.H vtkPV3FoamConvertLagrangianFields.H
vtkPV3FoamConvertMesh.C vtkPV3FoamConvertMesh.C
vtkPV3FoamConvertPatchFaceField.H vtkPV3FoamConvertPatchFaceField.H
@ -52,7 +50,7 @@ SourceFiles
vtkPV3FoamUpdateInformation.C vtkPV3FoamUpdateInformation.C
vtkPV3FoamUpdateInformationFields.H vtkPV3FoamUpdateInformationFields.H
// Needed by VTK? // Needed by VTK:
vtkDataArrayTemplateImplicit.txx vtkDataArrayTemplateImplicit.txx
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -64,6 +62,7 @@ SourceFiles
#include "fileName.H" #include "fileName.H"
#include "volPointInterpolation.H" #include "volPointInterpolation.H"
#include "stringList.H" #include "stringList.H"
#include "wordList.H"
#include "primitivePatch.H" #include "primitivePatch.H"
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * // // * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
@ -304,9 +303,21 @@ private:
//- Set info //- Set info
void updateInformationSets(); void updateInformationSets();
//- Read zone names for zoneType from file
wordList readZoneNames(const word& zoneType);
//- Zone info //- Zone info
void updateInformationZones(); void updateInformationZones();
//- Add to paraview array selection
template<class Type>
label addToSelection
(
vtkDataArraySelection *arraySelection,
const IOobjectList&,
const string& suffix = ""
);
//- Field info //- Field info
template<template<class> class patchType, class meshType> template<template<class> class patchType, class meshType>
void updateInformationFields void updateInformationFields
@ -347,20 +358,20 @@ private:
//- Cell zone meshes //- Cell zone meshes
void convertMeshCellZones(vtkMultiBlockDataSet* output); void convertMeshCellZones(vtkMultiBlockDataSet* output);
//- Cell zone meshes //- Face zone meshes
void convertMeshFaceZones(vtkMultiBlockDataSet* output); void convertMeshFaceZones(vtkMultiBlockDataSet* output);
//- Cell zone meshes //- Point zone meshes
void convertMeshPointZones(vtkMultiBlockDataSet* output); void convertMeshPointZones(vtkMultiBlockDataSet* output);
//- Cell set meshes //- Cell set meshes
void convertMeshCellSet(vtkMultiBlockDataSet* output); void convertMeshCellSets(vtkMultiBlockDataSet* output);
//- Face set meshes //- Face set meshes
void convertMeshFaceSet(vtkMultiBlockDataSet* output); void convertMeshFaceSets(vtkMultiBlockDataSet* output);
//- Point set meshes //- Point set meshes
void convertMeshPointSet(vtkMultiBlockDataSet* output); void convertMeshPointSets(vtkMultiBlockDataSet* output);
// Add mesh functions // Add mesh functions
@ -430,7 +441,7 @@ private:
//- Add the fields in the selected time directory to the selection //- Add the fields in the selected time directory to the selection
// lists // lists
template<class GeoField> template<class GeoField>
label addFields label addObjectsToSelection
( (
vtkDataArraySelection* fieldSelection, vtkDataArraySelection* fieldSelection,
const IOobjectList& objects, const IOobjectList& objects,

View File

@ -1,73 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
// Foam includes
#include "pointSet.H"
#include "vtkPV3FoamInsertNextPoint.H"
// VTK includes
#include "vtkPoints.h"
#include "vtkPolyData.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::addPointSetMesh
(
const fvMesh& mesh,
const pointSet& pSet,
vtkPolyData* vtkmesh
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addPointSetMesh" << endl;
}
const pointField& meshPoints = mesh.points();
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(pSet.size());
forAllConstIter(pointSet, pSet, iter)
{
vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[iter.key()]);
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::addPointSetMesh" << endl;
}
}
// ************************************************************************* //

View File

@ -1,72 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H"
// Foam includes
#include "vtkPV3FoamInsertNextPoint.H"
// VTK includes
#include "vtkPoints.h"
#include "vtkPolyData.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::addPointZoneMesh
(
const fvMesh& mesh,
const labelList& pointLabels,
vtkPolyData* vtkmesh
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl;
}
const pointField& meshPoints = mesh.points();
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(pointLabels.size());
forAll(pointLabels, pointI)
{
vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[pointLabels[pointI]]);
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl;
}
}
// ************************************************************************* //

View File

@ -30,6 +30,7 @@ Description
// Foam includes // Foam includes
#include "faceSet.H" #include "faceSet.H"
#include "pointSet.H"
#include "vtkPV3FoamInsertNextPoint.H" #include "vtkPV3FoamInsertNextPoint.H"
// VTK includes // VTK includes
@ -103,4 +104,36 @@ void Foam::vtkPV3Foam::addFaceSetMesh
} }
} }
void Foam::vtkPV3Foam::addPointSetMesh
(
const fvMesh& mesh,
const pointSet& pSet,
vtkPolyData* vtkmesh
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addPointSetMesh" << endl;
}
const pointField& meshPoints = mesh.points();
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(pSet.size());
forAllConstIter(pointSet, pSet, iter)
{
vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[iter.key()]);
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::addPointSetMesh" << endl;
}
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,13 +22,10 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
vtkPV3Foam
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamAddFields_H #ifndef vtkPV3FoamAddToSelection_H
#define vtkPV3FoamAddFields_H #define vtkPV3FoamAddToSelection_H
// FOAM includes // FOAM includes
#include "SortableList.H" #include "SortableList.H"
@ -38,48 +35,48 @@ InClass
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class GeoField> template<class Type>
Foam::label Foam::vtkPV3Foam::addFields Foam::label Foam::vtkPV3Foam::addToSelection
( (
vtkDataArraySelection *fieldSelection, vtkDataArraySelection *arraySelection,
const IOobjectList& objects, const IOobjectList& objectLst,
const string& suffix const string& suffix
) )
{ {
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName)); IOobjectList objects(objectLst.lookupClass(Type::typeName));
SortableList<word> fields(fieldObjects.size()); SortableList<word> objectNames(objects.size());
label count = 0; label count = 0;
forAllConstIter(IOobjectList, fieldObjects, iter) forAllConstIter(IOobjectList, objects, iter)
{ {
fields[count++] = iter()->name(); objectNames[count++] = iter()->name();
} }
if (count) if (count)
{ {
fields.sort(); objectNames.sort();
forAll(fields, fieldI) forAll (objectNames, objI)
{ {
if (debug) if (debug)
{ {
Info<<" addField to GUI " << GeoField::typeName Info<<" addToSelection<" << Type::typeName << "> to GUI "
<< ":" << fields[fieldI] << endl; << ":" << objectNames[objI] << endl;
} }
if (suffix.size()) if (suffix.size())
{ {
fieldSelection->AddArray arraySelection->AddArray
( (
(fields[fieldI] + suffix).c_str() (objectNames[objI] + suffix).c_str()
); );
} }
else else
{ {
fieldSelection->AddArray arraySelection->AddArray
( (
fields[fieldI].c_str() objectNames[objI].c_str()
); );
} }
} }

View File

@ -38,6 +38,7 @@ Description
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::addFaceZoneMesh void Foam::vtkPV3Foam::addFaceZoneMesh
( (
const fvMesh& mesh, const fvMesh& mesh,
@ -102,4 +103,36 @@ void Foam::vtkPV3Foam::addFaceZoneMesh
} }
void Foam::vtkPV3Foam::addPointZoneMesh
(
const fvMesh& mesh,
const labelList& pointLabels,
vtkPolyData* vtkmesh
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl;
}
const pointField& meshPoints = mesh.points();
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(pointLabels.size());
forAll(pointLabels, pointI)
{
vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[pointLabels[pointI]]);
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl;
}
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -76,7 +76,7 @@ void Foam::vtkPV3Foam::convertMeshVolume
if (debug) if (debug)
{ {
Info<< "Creating VTK internal mesh" << endl; Info<< "Creating VTK internalMesh" << endl;
} }
const label datasetId = 0; const label datasetId = 0;
@ -285,14 +285,14 @@ void Foam::vtkPV3Foam::convertMeshCellZones
} }
void Foam::vtkPV3Foam::convertMeshCellSet void Foam::vtkPV3Foam::convertMeshCellSets
( (
vtkMultiBlockDataSet* output vtkMultiBlockDataSet* output
) )
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellSet" << endl; Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellSets" << endl;
} }
const selectionInfo& selector = selectInfoCellSets_; const selectionInfo& selector = selectInfoCellSets_;
@ -359,10 +359,11 @@ void Foam::vtkPV3Foam::convertMeshCellSet
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPV3Foam::convertMeshCellSet" << endl; Info<< "<end> Foam::vtkPV3Foam::convertMeshCellSets" << endl;
} }
} }
void Foam::vtkPV3Foam::convertMeshFaceZones void Foam::vtkPV3Foam::convertMeshFaceZones
( (
vtkMultiBlockDataSet* output vtkMultiBlockDataSet* output
@ -417,7 +418,7 @@ void Foam::vtkPV3Foam::convertMeshFaceZones
vtkmesh->Delete(); vtkmesh->Delete();
} }
} }
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceZones" << endl; Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceZones" << endl;
@ -425,14 +426,14 @@ void Foam::vtkPV3Foam::convertMeshFaceZones
} }
void Foam::vtkPV3Foam::convertMeshFaceSet void Foam::vtkPV3Foam::convertMeshFaceSets
( (
vtkMultiBlockDataSet* output vtkMultiBlockDataSet* output
) )
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPV3Foam::convertMeshFaceSet" << endl; Info<< "<beg> Foam::vtkPV3Foam::convertMeshFaceSets" << endl;
} }
const selectionInfo& selector = selectInfoFaceSets_; const selectionInfo& selector = selectInfoFaceSets_;
@ -487,10 +488,10 @@ void Foam::vtkPV3Foam::convertMeshFaceSet
vtkmesh->Delete(); vtkmesh->Delete();
} }
} }
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceSet" << endl; Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceSets" << endl;
} }
} }
@ -549,7 +550,7 @@ void Foam::vtkPV3Foam::convertMeshPointZones
vtkmesh->Delete(); vtkmesh->Delete();
} }
} }
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPV3Foam::convertMeshPointZones" << endl; Info<< "<end> Foam::vtkPV3Foam::convertMeshPointZones" << endl;
@ -558,14 +559,14 @@ void Foam::vtkPV3Foam::convertMeshPointZones
void Foam::vtkPV3Foam::convertMeshPointSet void Foam::vtkPV3Foam::convertMeshPointSets
( (
vtkMultiBlockDataSet* output vtkMultiBlockDataSet* output
) )
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPV3Foam::convertMeshPointSet" << endl; Info<< "<beg> Foam::vtkPV3Foam::convertMeshPointSets" << endl;
} }
const selectionInfo& selector = selectInfoPointSets_; const selectionInfo& selector = selectInfoPointSets_;
@ -620,10 +621,10 @@ void Foam::vtkPV3Foam::convertMeshPointSet
vtkmesh->Delete(); vtkmesh->Delete();
} }
} }
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPV3Foam::convertMeshPointSet" << endl; Info<< "<end> Foam::vtkPV3Foam::convertMeshPointSets" << endl;
} }
} }

View File

@ -28,7 +28,6 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
//- Extract up to the first non-word characters
inline Foam::word Foam::vtkPV3Foam::getFirstWord(const char* str) inline Foam::word Foam::vtkPV3Foam::getFirstWord(const char* str)
{ {
if (str) if (str)
@ -46,32 +45,4 @@ inline Foam::word Foam::vtkPV3Foam::getFirstWord(const char* str)
} }
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,8 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "vtkPV3Foam.H" #include "vtkPV3Foam.H"
@ -31,9 +29,9 @@ Description
// Foam includes // Foam includes
#include "cellSet.H" #include "cellSet.H"
#include "faceSet.H" #include "faceSet.H"
#include "pointSet.H"
#include "IOobjectList.H" #include "IOobjectList.H"
#include "IOPtrList.H" #include "IOPtrList.H"
#include "pointSet.H"
#include "polyBoundaryMeshEntries.H" #include "polyBoundaryMeshEntries.H"
#include "entry.H" #include "entry.H"
#include "vtkPV3FoamReader.h" #include "vtkPV3FoamReader.h"
@ -79,7 +77,7 @@ public:
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
#include "vtkPV3FoamAddFields.H" #include "vtkPV3FoamAddToSelection.H"
#include "vtkPV3FoamUpdateInformationFields.H" #include "vtkPV3FoamUpdateInformationFields.H"
void Foam::vtkPV3Foam::updateInformationInternalMesh() void Foam::vtkPV3Foam::updateInformationInternalMesh()
@ -103,6 +101,9 @@ void Foam::vtkPV3Foam::updateInformationInternalMesh()
if (debug) if (debug)
{ {
// just for debug info
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPV3Foam::updateInformationInternalMesh" << endl; Info<< "<end> Foam::vtkPV3Foam::updateInformationInternalMesh" << endl;
} }
@ -132,7 +133,7 @@ void Foam::vtkPV3Foam::updateInformationLagrangian()
arraySelection->AddArray("lagrangian"); arraySelection->AddArray("lagrangian");
selectInfoLagrangian_ += 1; selectInfoLagrangian_ += 1;
Info<<"added cloudDirs\n"; Info<< "... added cloudDirs\n";
if (cloudDirs.size() > 1) if (cloudDirs.size() > 1)
{ {
@ -149,13 +150,16 @@ void Foam::vtkPV3Foam::updateInformationLagrangian()
{ {
if (debug) if (debug)
{ {
Info<<"no clouds identified in " <<nl Info<< "... no clouds identified in " <<nl
<< " " <<dbPtr_->timePath()/"lagrangian" << endl; << " " <<dbPtr_->timePath()/"lagrangian" << endl;
} }
} }
if (debug) if (debug)
{ {
// just for debug info
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPV3Foam::updateInformationLagrangian" << endl; Info<< "<end> Foam::vtkPV3Foam::updateInformationLagrangian" << endl;
} }
} }
@ -165,7 +169,8 @@ void Foam::vtkPV3Foam::updateInformationPatches()
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPV3Foam::updateInformationPatches" << endl; Info<< "<beg> Foam::vtkPV3Foam::updateInformationPatches"
<< " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl;
} }
vtkDataArraySelection *arraySelection = reader_->GetRegionSelection(); vtkDataArraySelection *arraySelection = reader_->GetRegionSelection();
@ -209,117 +214,130 @@ void Foam::vtkPV3Foam::updateInformationPatches()
if (debug) if (debug)
{ {
// just for debug info
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPV3Foam::updateInformationPatches" << endl; Info<< "<end> Foam::vtkPV3Foam::updateInformationPatches" << endl;
} }
} }
Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType)
{
wordList zoneNames;
// mesh not loaded - read from file
IOobject ioObj
(
zoneType,
dbPtr_().findInstance
(
polyMesh::meshSubDir,
zoneType,
IOobject::READ_IF_PRESENT
),
polyMesh::meshSubDir,
dbPtr_(),
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
);
if (ioObj.headerOk())
{
zonesEntries zones(ioObj);
zoneNames.setSize(zones.size());
forAll (zones, zoneI)
{
zoneNames[zoneI] = zones[zoneI].keyword();
}
}
return zoneNames;
}
void Foam::vtkPV3Foam::updateInformationZones() void Foam::vtkPV3Foam::updateInformationZones()
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPV3Foam::updateInformationZones" << endl; Info<< "<beg> Foam::vtkPV3Foam::updateInformationZones"
<< " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl;
} }
vtkDataArraySelection *arraySelection = reader_->GetRegionSelection(); vtkDataArraySelection *arraySelection = reader_->GetRegionSelection();
// Read cell zone information wordList zoneNames;
//
// cellZones information
// ~~~~~~~~~~~~~~~~~~~~~
if (meshPtr_)
{ {
zonesEntries zones zoneNames = meshPtr_->cellZones().names();
( }
IOobject else
( {
"cellZones", zoneNames = readZoneNames("cellZones");
dbPtr_().findInstance(polyMesh::meshSubDir, "cellZones"),
polyMesh::meshSubDir,
dbPtr_(),
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
)
);
selectInfoCellZones_ = arraySelection->GetNumberOfArrays();
if (zones.headerOk())
{
forAll(zones, zoneI)
{
arraySelection->AddArray
(
(zones[zoneI].keyword() + " - cellZone").c_str()
);
}
selectInfoCellZones_ += zones.size();
}
superCellZonesCells_.setSize(selectInfoCellZones_.size());
} }
// Read face zone information selectInfoCellZones_ = arraySelection->GetNumberOfArrays();
forAll (zoneNames, zoneI)
{ {
zonesEntries zones arraySelection->AddArray((zoneNames[zoneI] + " - cellZone").c_str());
( }
IOobject selectInfoCellZones_ += zoneNames.size();
( superCellZonesCells_.setSize(selectInfoCellZones_.size());
"faceZones",
dbPtr_().findInstance(polyMesh::meshSubDir, "faceZones"),
polyMesh::meshSubDir,
dbPtr_(),
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
)
);
selectInfoFaceZones_ = arraySelection->GetNumberOfArrays();
if (zones.headerOk()) //
{ // faceZones information
forAll(zones, zoneI) // ~~~~~~~~~~~~~~~~~~~~~
{ if (meshPtr_)
arraySelection->AddArray {
( zoneNames = meshPtr_->faceZones().names();
(zones[zoneI].keyword() + " - faceZone").c_str() }
); else
} {
selectInfoFaceZones_ += zones.size(); zoneNames = readZoneNames("faceZones");
}
} }
// Read point zone information selectInfoFaceZones_ = arraySelection->GetNumberOfArrays();
forAll (zoneNames, zoneI)
{ {
zonesEntries zones arraySelection->AddArray((zoneNames[zoneI] + " - faceZone").c_str());
(
IOobject
(
"pointZones",
dbPtr_().findInstance(polyMesh::meshSubDir, "pointZones"),
polyMesh::meshSubDir,
dbPtr_(),
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
)
);
selectInfoPointZones_ = arraySelection->GetNumberOfArrays();
if (zones.headerOk())
{
forAll(zones, zoneI)
{
arraySelection->AddArray
(
(zones[zoneI].keyword() + " - pointZone").c_str()
);
}
selectInfoPointZones_ += zones.size();
}
} }
selectInfoFaceZones_ += zoneNames.size();
//
// pointZones information
// ~~~~~~~~~~~~~~~~~~~~~~
if (meshPtr_)
{
zoneNames = meshPtr_->pointZones().names();
}
else
{
zoneNames = readZoneNames("pointZones");
}
selectInfoPointZones_ = arraySelection->GetNumberOfArrays();
forAll (zoneNames, zoneI)
{
arraySelection->AddArray((zoneNames[zoneI] + " - pointZone").c_str());
}
selectInfoPointZones_ += zoneNames.size();
if (debug) if (debug)
{ {
// just for debug info
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPV3Foam::updateInformationZones" << endl; Info<< "<end> Foam::vtkPV3Foam::updateInformationZones" << endl;
} }
} }
@ -332,7 +350,7 @@ void Foam::vtkPV3Foam::updateInformationSets()
vtkDataArraySelection *arraySelection = reader_->GetRegionSelection(); vtkDataArraySelection *arraySelection = reader_->GetRegionSelection();
// Add sets // Add names of sets
IOobjectList objects IOobjectList objects
( (
dbPtr_(), dbPtr_(),
@ -342,7 +360,7 @@ void Foam::vtkPV3Foam::updateInformationSets()
selectInfoCellSets_ = arraySelection->GetNumberOfArrays(); selectInfoCellSets_ = arraySelection->GetNumberOfArrays();
selectInfoCellSets_ += addFields<cellSet> selectInfoCellSets_ += addToSelection<cellSet>
( (
arraySelection, arraySelection,
objects, objects,
@ -351,7 +369,7 @@ void Foam::vtkPV3Foam::updateInformationSets()
superCellSetCells_.setSize(selectInfoCellSets_.size()); superCellSetCells_.setSize(selectInfoCellSets_.size());
selectInfoFaceSets_ = arraySelection->GetNumberOfArrays(); selectInfoFaceSets_ = arraySelection->GetNumberOfArrays();
selectInfoFaceSets_ += addFields<faceSet> selectInfoFaceSets_ += addToSelection<faceSet>
( (
arraySelection, arraySelection,
objects, objects,
@ -359,7 +377,7 @@ void Foam::vtkPV3Foam::updateInformationSets()
); );
selectInfoPointSets_ = arraySelection->GetNumberOfArrays(); selectInfoPointSets_ = arraySelection->GetNumberOfArrays();
selectInfoPointSets_ += addFields<pointSet> selectInfoPointSets_ += addToSelection<pointSet>
( (
arraySelection, arraySelection,
objects, objects,
@ -368,6 +386,9 @@ void Foam::vtkPV3Foam::updateInformationSets()
if (debug) if (debug)
{ {
// just for debug info
getSelectedArrayEntries(arraySelection);
Info<< "<end> Foam::vtkPV3Foam::updateInformationSets" << endl; Info<< "<end> Foam::vtkPV3Foam::updateInformationSets" << endl;
} }
} }
@ -399,32 +420,32 @@ void Foam::vtkPV3Foam::updateInformationLagrangianFields()
"lagrangian"/cloudName_ "lagrangian"/cloudName_
); );
addFields<IOField<label> > addToSelection<IOField<label> >
( (
arraySelection, arraySelection,
objects objects
); );
addFields<IOField<scalar> > addToSelection<IOField<scalar> >
( (
arraySelection, arraySelection,
objects objects
); );
addFields<IOField<vector> > addToSelection<IOField<vector> >
( (
arraySelection, arraySelection,
objects objects
); );
addFields<IOField<sphericalTensor> > addToSelection<IOField<sphericalTensor> >
( (
arraySelection, arraySelection,
objects objects
); );
addFields<IOField<symmTensor> > addToSelection<IOField<symmTensor> >
( (
arraySelection, arraySelection,
objects objects
); );
addFields<IOField<tensor> > addToSelection<IOField<tensor> >
( (
arraySelection, arraySelection,
objects objects
@ -444,5 +465,4 @@ void Foam::vtkPV3Foam::updateInformationLagrangianFields()
} }
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -43,11 +43,23 @@ void Foam::vtkPV3Foam::updateInformationFields
Info<< "<beg> Foam::vtkPV3Foam::updateInformationFields" << endl; Info<< "<beg> Foam::vtkPV3Foam::updateInformationFields" << endl;
} }
// preserve the currently selected values stringList selectedEntries;
const stringList selectedEntries = getSelectedArrayEntries // enable 'p' and 'U' on the first call
( if (arraySelection->GetNumberOfArrays() == 0)
arraySelection {
); selectedEntries.setSize(2);
selectedEntries[0] = "p";
selectedEntries[1] = "U";
}
else
{
// preserve the currently selected values
selectedEntries = getSelectedArrayEntries
(
arraySelection
);
}
arraySelection->RemoveAllArrays(); arraySelection->RemoveAllArrays();
// Search for list of objects for this time // Search for list of objects for this time
@ -56,33 +68,33 @@ void Foam::vtkPV3Foam::updateInformationFields
//- Add volume fields to GUI //- Add volume fields to GUI
/* /*
addFields<GeometricField<label, patchType, meshType> > addToSelection<GeometricField<label, patchType, meshType> >
( (
arraySelection, arraySelection,
objects objects
); );
*/ */
addFields<GeometricField<scalar, patchType, meshType> > addToSelection<GeometricField<scalar, patchType, meshType> >
( (
arraySelection, arraySelection,
objects objects
); );
addFields<GeometricField<vector, patchType, meshType> > addToSelection<GeometricField<vector, patchType, meshType> >
( (
arraySelection, arraySelection,
objects objects
); );
addFields<GeometricField<sphericalTensor, patchType, meshType> > addToSelection<GeometricField<sphericalTensor, patchType, meshType> >
( (
arraySelection, arraySelection,
objects objects
); );
addFields<GeometricField<symmTensor, patchType, meshType> > addToSelection<GeometricField<symmTensor, patchType, meshType> >
( (
arraySelection, arraySelection,
objects objects
); );
addFields<GeometricField<tensor, patchType, meshType> > addToSelection<GeometricField<tensor, patchType, meshType> >
( (
arraySelection, arraySelection,
objects objects