Merge branch 'master' into dsmc

This commit is contained in:
graham
2009-10-21 14:12:36 +01:00
346 changed files with 9946 additions and 2903 deletions

View File

@ -113,13 +113,8 @@ int main(int argc, char *argv[])
}
// control for renumbering iterations
bool optIndex = false;
label indexingNumber = 0;
if (args.optionFound("index"))
{
optIndex = true;
indexingNumber = args.optionRead<label>("index");
}
bool optIndex = args.optionReadIfPresent("index", indexingNumber);
// always write the geometry, unless the -noMesh option is specified
bool optNoMesh = args.optionFound("noMesh");
@ -134,7 +129,7 @@ int main(int argc, char *argv[])
// or a particular time interval
if (isDir(ensightDir))
{
Info<<"Warning: reusing existing directory" << nl
Info<<"Warning: re-using existing directory" << nl
<< " " << ensightDir << endl;
}
mkDir(ensightDir);

View File

@ -106,7 +106,7 @@
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
A simple way cause a reader GUI modification.
A simple way to cause a reader GUI modification.
</Documentation>
</IntVectorProperty>

View File

@ -385,14 +385,7 @@ int vtkPV3FoamReader::RequestData
foamData_->Update(output, output);
#endif
if (ShowPatchNames)
{
addPatchNamesToView();
}
else
{
removePatchNamesFromView();
}
updatePatchNamesView(ShowPatchNames);
#endif
@ -403,7 +396,7 @@ int vtkPV3FoamReader::RequestData
}
void vtkPV3FoamReader::addPatchNamesToView()
void vtkPV3FoamReader::updatePatchNamesView(const bool show)
{
pqApplicationCore* appCore = pqApplicationCore::instance();
@ -415,29 +408,10 @@ void vtkPV3FoamReader::addPatchNamesToView()
for (int viewI=0; viewI<renderViews.size(); viewI++)
{
foamData_->addPatchNames
foamData_->renderPatchNames
(
renderViews[viewI]->getRenderViewProxy()->GetRenderer()
);
}
}
void vtkPV3FoamReader::removePatchNamesFromView()
{
pqApplicationCore* appCore = pqApplicationCore::instance();
// Server manager model for querying items in the server manager
pqServerManagerModel* smModel = appCore->getServerManagerModel();
// Get all the pqRenderView instances
QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>();
for (int viewI=0; viewI<renderViews.size(); viewI++)
{
foamData_->removePatchNames
(
renderViews[viewI]->getRenderViewProxy()->GetRenderer()
renderViews[viewI]->getRenderViewProxy()->GetRenderer(),
show
);
}
}

View File

@ -174,11 +174,8 @@ private:
//- Disallow default bitwise assignment
void operator=(const vtkPV3FoamReader&);
//- Add patch names to the view
void addPatchNamesToView();
//- Remove patch names from the view
void removePatchNamesFromView();
//- Add/remove patch names to/from the view
void updatePatchNamesView(const bool show);
int TimeStepRange[2];
int CacheMesh;

View File

@ -7,6 +7,6 @@ vtkPV3FoamMeshSet.C
vtkPV3FoamMeshVolume.C
vtkPV3FoamMeshZone.C
vtkPV3FoamUpdateInfo.C
vtkPV3FoamUtilities.C
vtkPV3FoamUtils.C
LIB = $(FOAM_LIBBIN)/libvtkPV3Foam

View File

@ -27,15 +27,15 @@ InClass
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamPoints_H
#define vtkPV3FoamPoints_H
#ifndef vtkOpenFOAMPoints_H
#define vtkOpenFOAMPoints_H
// VTK includes
#include "vtkPoints.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline void vtkPV3FoamInsertNextPoint
inline void vtkInsertNextOpenFOAMPoint
(
vtkPoints *points,
const Foam::point& p
@ -46,7 +46,7 @@ inline void vtkPV3FoamInsertNextPoint
#if 0
// this should be faster, but didn't get it working ...
inline void vtkPV3FoamSetPoint
inline void vtkSetOpenFOAMPoint
(
vtkPoints *points,
const Foam::label id,
@ -58,7 +58,7 @@ inline void vtkPV3FoamSetPoint
// Convert Foam mesh vertices to VTK
inline vtkPoints* vtkPV3FoamVTKPoints(const Foam::pointField& points)
inline vtkPoints* vtkSetOpenFOAMPoints(const Foam::pointField& points)
{
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->SetNumberOfPoints(points.size());

View File

@ -590,220 +590,204 @@ double* Foam::vtkPV3Foam::findTimes(int& nTimeSteps)
}
void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer)
void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show)
{
// Remove any patch names previously added to the renderer
removePatchNames(renderer);
// always remove old actors first
// get the display patches, strip off any suffix
wordHashSet selectedPatches = getSelected
(
reader_->GetPartSelection(),
partInfoPatches_
);
if (!selectedPatches.size())
{
return;
}
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::addPatchNames" << nl
<<"... add patches: " << selectedPatches << endl;
}
const polyBoundaryMesh& pbMesh = meshPtr_->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(), 0);
// Per global zone number the average face centre position
DynamicList<point> zoneCentre(pbMesh.size());
if (debug)
{
Info<< "... determining patch zones" << endl;
}
// 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(), 0);
// Save start of information for current patch
label patchStart = zoneCentre.size();
// Create storage for additional zone centres
forAll(zoneNFaces, zoneI)
{
zoneCentre.append(vector::zero);
}
// Do averaging per individual zone
forAll(pp, faceI)
{
label zoneI = pZones[faceI];
zoneCentre[patchStart+zoneI] += pp[faceI].centre(pp.points());
zoneNFaces[zoneI]++;
}
for (label i=0; i<nZones[patchI]; i++)
{
zoneCentre[patchStart + i] /= zoneNFaces[i];
}
}
// 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]);
}
zoneCentre.shrink();
if (debug)
{
Info<< "patch zone centres = " << zoneCentre << nl
<< "displayed zone centres = " << displayZoneI << nl
<< "zones per patch = " << nZones << endl;
}
// Set the size of the patch labels to max number of zones
patchTextActorsPtrs_.setSize(displayZoneI);
if (debug)
{
Info<< "constructing patch labels" << endl;
}
// Actor index
displayZoneI = 0;
// Index in zone centres
label globalZoneI = 0;
forAll(pbMesh, patchI)
{
const polyPatch& pp = pbMesh[patchI];
// Only selected patches will have a non-zero number of zones
label nDisplayZones = min(MAXPATCHZONES, nZones[patchI]);
label increment = 1;
if (nZones[patchI] >= MAXPATCHZONES)
{
increment = nZones[patchI]/MAXPATCHZONES;
}
for (label i = 0; i < nDisplayZones; i++)
{
if (debug)
{
Info<< "patch name = " << pp.name() << nl
<< "anchor = " << zoneCentre[globalZoneI] << nl
<< "globalZoneI = " << globalZoneI << endl;
}
vtkTextActor* txt = vtkTextActor::New();
txt->SetInput(pp.name().c_str());
// Set text properties
vtkTextProperty* tprop = txt->GetTextProperty();
tprop->SetFontFamilyToArial();
tprop->BoldOff();
tprop->ShadowOff();
tprop->SetLineSpacing(1.0);
tprop->SetFontSize(12);
tprop->SetColor(1.0, 0.0, 0.0);
tprop->SetJustificationToCentered();
// Set text to use 3-D world co-ordinates
txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
txt->GetPositionCoordinate()->SetValue
(
zoneCentre[globalZoneI].x(),
zoneCentre[globalZoneI].y(),
zoneCentre[globalZoneI].z()
);
// Add text to each renderer
renderer->AddViewProp(txt);
// Maintain a list of text labels added so that they can be
// removed later
patchTextActorsPtrs_[displayZoneI] = txt;
globalZoneI += increment;
displayZoneI++;
}
}
// Resize the patch names list to the actual number of patch names added
patchTextActorsPtrs_.setSize(displayZoneI);
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::addPatchNames" << endl;
}
}
void Foam::vtkPV3Foam::removePatchNames(vtkRenderer* renderer)
{
forAll(patchTextActorsPtrs_, patchI)
{
renderer->RemoveViewProp(patchTextActorsPtrs_[patchI]);
patchTextActorsPtrs_[patchI]->Delete();
}
patchTextActorsPtrs_.clear();
if (show)
{
// get the display patches, strip off any suffix
wordHashSet selectedPatches = getSelected
(
reader_->GetPartSelection(),
partInfoPatches_
);
if (!selectedPatches.size())
{
return;
}
const polyBoundaryMesh& pbMesh = meshPtr_->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(), 0);
// Per global zone number the average face centre position
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(), 0);
// Save start of information for current patch
label patchStart = zoneCentre.size();
// Create storage for additional zone centres
forAll(zoneNFaces, zoneI)
{
zoneCentre.append(vector::zero);
}
// Do averaging per individual zone
forAll(pp, faceI)
{
label zoneI = pZones[faceI];
zoneCentre[patchStart+zoneI] += pp[faceI].centre(pp.points());
zoneNFaces[zoneI]++;
}
for (label i=0; i<nZones[patchI]; i++)
{
zoneCentre[patchStart + i] /= zoneNFaces[i];
}
}
// 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]);
}
zoneCentre.shrink();
if (debug)
{
Info<< "patch zone centres = " << zoneCentre << nl
<< "displayed zone centres = " << displayZoneI << nl
<< "zones per patch = " << nZones << endl;
}
// Set the size of the patch labels to max number of zones
patchTextActorsPtrs_.setSize(displayZoneI);
if (debug)
{
Info<< "constructing patch labels" << endl;
}
// Actor index
displayZoneI = 0;
// Index in zone centres
label globalZoneI = 0;
forAll(pbMesh, patchI)
{
const polyPatch& pp = pbMesh[patchI];
// Only selected patches will have a non-zero number of zones
label nDisplayZones = min(MAXPATCHZONES, nZones[patchI]);
label increment = 1;
if (nZones[patchI] >= MAXPATCHZONES)
{
increment = nZones[patchI]/MAXPATCHZONES;
}
for (label i = 0; i < nDisplayZones; i++)
{
if (debug)
{
Info<< "patch name = " << pp.name() << nl
<< "anchor = " << zoneCentre[globalZoneI] << nl
<< "globalZoneI = " << globalZoneI << endl;
}
vtkTextActor* txt = vtkTextActor::New();
txt->SetInput(pp.name().c_str());
// Set text properties
vtkTextProperty* tprop = txt->GetTextProperty();
tprop->SetFontFamilyToArial();
tprop->BoldOff();
tprop->ShadowOff();
tprop->SetLineSpacing(1.0);
tprop->SetFontSize(12);
tprop->SetColor(1.0, 0.0, 0.0);
tprop->SetJustificationToCentered();
// Set text to use 3-D world co-ordinates
txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
txt->GetPositionCoordinate()->SetValue
(
zoneCentre[globalZoneI].x(),
zoneCentre[globalZoneI].y(),
zoneCentre[globalZoneI].z()
);
// Add text to each renderer
renderer->AddViewProp(txt);
// Maintain a list of text labels added so that they can be
// removed later
patchTextActorsPtrs_[displayZoneI] = txt;
globalZoneI += increment;
displayZoneI++;
}
}
// Resize the patch names list to the actual number of patch names added
patchTextActorsPtrs_.setSize(displayZoneI);
}
}
void Foam::vtkPV3Foam::PrintSelf(ostream& os, vtkIndent indent) const
{
os << indent << "Number of nodes: "

View File

@ -31,7 +31,6 @@ Description
SourceFiles
vtkPV3Foam.C
vtkPV3Foam.H
vtkPV3FoamI.H
vtkPV3FoamFields.C
vtkPV3FoamMesh.C
vtkPV3FoamMeshLagrangian.C
@ -46,7 +45,7 @@ SourceFiles
vtkPV3FoamPoints.H
vtkPV3FoamUpdateInfo.C
vtkPV3FoamUpdateInfoFields.H
vtkPV3FoamUtilities.C
vtkPV3FoamUtils.C
vtkPV3FoamVolFields.H
vtkPV3FoamAddToSelection.H
@ -316,7 +315,7 @@ class vtkPV3Foam
vtkDataSet* dataset,
const partInfo&,
const label datasetNo,
const string& datasetName
const std::string& datasetName
);
// Convenience method use to convert the readers from VTK 5
@ -627,9 +626,6 @@ class vtkPV3Foam
// GUI selection helper functions
//- Extract up to the first non-word characters
inline static word getFirstWord(const char*);
//- Only keep what is listed in hashSet
static void pruneObjectList
(
@ -715,11 +711,8 @@ public:
// returns the count via the parameter
double* findTimes(int& nTimeSteps);
//- Add patch names to the display
void addPatchNames(vtkRenderer* renderer);
//- Remove patch names from the display
void removePatchNames(vtkRenderer* renderer);
//- Add/remove patch names to/from the view
void renderPatchNames(vtkRenderer*, const bool show);
//- set the runTime to the first plausible request time,
// returns the timeIndex
@ -751,8 +744,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
# include "vtkPV3FoamI.H"
#endif
// ************************************************************************* //

View File

@ -33,7 +33,7 @@ Description
#include "fvMesh.H"
#include "IOobjectList.H"
#include "passiveParticle.H"
#include "vtkPV3FoamPoints.H"
#include "vtkOpenFOAMPoints.H"
// VTK includes
#include "vtkCellArray.h"
@ -86,7 +86,7 @@ vtkPolyData* Foam::vtkPV3Foam::lagrangianVTKMesh
vtkIdType particleId = 0;
forAllConstIter(Cloud<passiveParticle>, parcels, iter)
{
vtkPV3FoamInsertNextPoint(vtkpoints, iter().position());
vtkInsertNextOpenFOAMPoint(vtkpoints, iter().position());
vtkcells->InsertNextCell(1, &particleId);
particleId++;

View File

@ -31,7 +31,7 @@ Description
// Foam includes
#include "polyPatch.H"
#include "primitivePatch.H"
#include "vtkPV3FoamPoints.H"
#include "vtkOpenFOAMPoints.H"
// VTK includes
#include "vtkCellArray.h"
@ -60,7 +60,7 @@ vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh
vtkpoints->Allocate( points.size() );
forAll(points, i)
{
vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
}
vtkmesh->SetPoints(vtkpoints);

View File

@ -31,7 +31,7 @@ Description
// Foam includes
#include "faceSet.H"
#include "pointSet.H"
#include "vtkPV3FoamPoints.H"
#include "vtkOpenFOAMPoints.H"
// VTK includes
#include "vtkPoints.h"
@ -75,7 +75,7 @@ vtkPolyData* Foam::vtkPV3Foam::faceSetVTKMesh
vtkpoints->Allocate( points.size() );
forAll(points, i)
{
vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
@ -132,7 +132,7 @@ vtkPolyData* Foam::vtkPV3Foam::pointSetVTKMesh
forAllConstIter(pointSet, pSet, iter)
{
vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[iter.key()]);
vtkInsertNextOpenFOAMPoint(vtkpoints, meshPoints[iter.key()]);
}
vtkmesh->SetPoints(vtkpoints);

View File

@ -31,7 +31,7 @@ Description
// Foam includes
#include "fvMesh.H"
#include "cellModeller.H"
#include "vtkPV3FoamPoints.H"
#include "vtkOpenFOAMPoints.H"
// VTK includes
#include "vtkCellArray.h"
@ -143,7 +143,7 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh
forAll(points, i)
{
vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
}
@ -267,7 +267,7 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh
// Insert the new vertex from the cell-centre
label newVertexLabel = mesh.nPoints() + addPointI;
vtkPV3FoamInsertNextPoint(vtkpoints, mesh.C()[cellI]);
vtkInsertNextOpenFOAMPoint(vtkpoints, mesh.C()[cellI]);
// Whether to insert cell in place of original or not.
bool substituteCell = true;

View File

@ -29,7 +29,7 @@ Description
#include "vtkPV3Foam.H"
// Foam includes
#include "vtkPV3FoamPoints.H"
#include "vtkOpenFOAMPoints.H"
// VTK includes
#include "vtkPoints.h"
@ -72,7 +72,7 @@ vtkPolyData* Foam::vtkPV3Foam::faceZoneVTKMesh
vtkpoints->Allocate( points.size() );
forAll(points, i)
{
vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
}
vtkmesh->SetPoints(vtkpoints);
@ -131,7 +131,7 @@ vtkPolyData* Foam::vtkPV3Foam::pointZoneVTKMesh
forAll(pointLabels, pointI)
{
vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[pointLabels[pointI]]);
vtkInsertNextOpenFOAMPoint(vtkpoints, meshPoints[pointLabels[pointI]]);
}
vtkmesh->SetPoints(vtkpoints);

View File

@ -41,6 +41,34 @@ Description
#include "vtkMultiBlockDataSet.h"
#include "vtkInformation.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//! @cond fileScope
// Extract up to the first non-word characters
inline word getFirstWord(const char* str)
{
if (str)
{
label n = 0;
while (str[n] && word::valid(str[n]))
{
++n;
}
return word(str, n, true);
}
else
{
return word::null;
}
}
//! @endcond fileScope
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::vtkPV3Foam::AddToBlock
@ -49,7 +77,7 @@ void Foam::vtkPV3Foam::AddToBlock
vtkDataSet* dataset,
const partInfo& selector,
const label datasetNo,
const string& datasetName
const std::string& datasetName
)
{
const int blockNo = selector.block();

View File

@ -0,0 +1,8 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
set -x
rm -rf PV3blockMeshReader/Make
wclean libso vtkPV3blockMesh
# ----------------------------------------------------------------- end-of-file

View File

@ -0,0 +1,21 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
set -x
if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ]
then
case "$ParaView_VERSION" in
3*)
wmake libso vtkPV3blockMesh
(
cd PV3blockMeshReader
mkdir -p Make/$WM_OPTIONS > /dev/null 2>&1
cd Make/$WM_OPTIONS
cmake ../..
make
)
;;
esac
fi
# ----------------------------------------------------------------- end-of-file

View File

@ -0,0 +1,56 @@
# create a plugin that adds a reader to the ParaView GUI
# it is added in the file dialog when doing opens/saves.
# The qrc file is processed by Qt's resource compiler (rcc)
# the qrc file must have a resource prefix of "/ParaViewResources"
# and ParaView will read anything contained under that prefix
# the pqReader.xml file contains xml defining readers with their
# file extensions and descriptions.
cmake_minimum_required(VERSION 2.4)
FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})
LINK_DIRECTORIES(
$ENV{FOAM_LIBBIN}
)
INCLUDE_DIRECTORIES(
$ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
$ENV{WM_PROJECT_DIR}/src/meshing/blockMesh/lnInclude
${PROJECT_SOURCE_DIR}/../vtkPV3blockMesh
)
ADD_DEFINITIONS(
-DWM_$ENV{WM_PRECISION_OPTION}
)
# Set output library destination to plugin folder
SET(
LIBRARY_OUTPUT_PATH $ENV{PV_PLUGIN_PATH}
CACHE INTERNAL
"Single output directory for building all libraries."
)
# Build the server-side plugin
ADD_PARAVIEW_PLUGIN(
PV3blockMeshReader_SM "1.0"
SERVER_MANAGER_XML PV3blockMeshReader_SM.xml
SERVER_MANAGER_SOURCES vtkPV3blockMeshReader.cxx
)
# Build the client-side plugin
ADD_PARAVIEW_PLUGIN(
PV3blockMeshReader
"1.0"
GUI_RESOURCES PV3blockMeshReader.qrc
)
TARGET_LINK_LIBRARIES(
PV3blockMeshReader_SM
OpenFOAM
blockMesh
vtkPV3blockMesh
)
#-----------------------------------------------------------------------------

View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/ParaViewResources" >
<file>PV3blockMeshReader.xml</file>
</qresource>
</RCC>

View File

@ -0,0 +1,6 @@
<ParaViewReaders>
<Reader name="PV3blockMeshReader"
extensions="blockMesh"
file_description="OpenFOAM blockMesh reader">
</Reader>
</ParaViewReaders>

View File

@ -0,0 +1,98 @@
<ServerManagerConfiguration>
<ProxyGroup name="sources">
<SourceProxy
name="PV3blockMeshReader"
class="vtkPV3blockMeshReader">
<!-- File name - compulsory -->
<StringVectorProperty
name="FileName"
command="SetFileName"
number_of_elements="1"
animateable="0">
<FileListDomain name="files"/>
<Documentation>
Specifies the filename for the OpenFOAM blockMesh Reader.
</Documentation>
</StringVectorProperty>
<!-- Global settings -->
<!-- Show Point Numbers check-box -->
<IntVectorProperty
name="ShowPointNumbers"
command="SetShowPointNumbers"
number_of_elements="1"
default_values="1"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
Show point numbers in render window.
</Documentation>
</IntVectorProperty>
<!-- Update GUI check box -->
<IntVectorProperty
name="UpdateGUI"
command="SetUpdateGUI"
number_of_elements="1"
default_values="0"
animateable="0">
<BooleanDomain name="bool"/>
<Documentation>
A simple way to cause a reader GUI modification.
</Documentation>
</IntVectorProperty>
<!-- Selections -->
<!-- Available Parts (blocks) array -->
<StringVectorProperty
name="PartArrayInfo"
information_only="1">
<ArraySelectionInformationHelper attribute_name="Part"/>
</StringVectorProperty>
<StringVectorProperty
name="PartStatus"
label="Blocks"
command="SetPartArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="PartArrayInfo"
animateable="0">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="PartArrayInfo" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
</StringVectorProperty>
<!-- Available Parts (blocks) array -->
<StringVectorProperty
name="CurvedEdgesArrayInfo"
information_only="1">
<ArraySelectionInformationHelper attribute_name="CurvedEdges"/>
</StringVectorProperty>
<StringVectorProperty
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="CurvedEdgesArrayInfo"
animateable="0">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="CurvedEdgesArrayInfo" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
</StringVectorProperty>
</SourceProxy>
</ProxyGroup>
</ServerManagerConfiguration>

View File

@ -0,0 +1,381 @@
/*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: vtkPV3blockMeshReader.cxx,v $
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkPV3blockMeshReader.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"
// Foam includes
#include "vtkPV3blockMesh.H"
vtkCxxRevisionMacro(vtkPV3blockMeshReader, "$Revision: 1.5$");
vtkStandardNewMacro(vtkPV3blockMeshReader);
vtkPV3blockMeshReader::vtkPV3blockMeshReader()
{
Debug = 0;
vtkDebugMacro(<<"Constructor");
SetNumberOfInputPorts(0);
FileName = NULL;
foamData_ = NULL;
ShowPointNumbers = 1;
UpdateGUI = 0;
PartSelection = vtkDataArraySelection::New();
CurvedEdgesSelection = vtkDataArraySelection::New();
// Setup the selection callback to modify this object when an array
// selection is changed.
SelectionObserver = vtkCallbackCommand::New();
SelectionObserver->SetCallback
(
&vtkPV3blockMeshReader::SelectionModifiedCallback
);
SelectionObserver->SetClientData(this);
PartSelection->AddObserver
(
vtkCommand::ModifiedEvent,
this->SelectionObserver
);
CurvedEdgesSelection->AddObserver
(
vtkCommand::ModifiedEvent,
this->SelectionObserver
);
}
vtkPV3blockMeshReader::~vtkPV3blockMeshReader()
{
vtkDebugMacro(<<"Deconstructor");
delete foamData_;
if (FileName)
{
delete [] FileName;
}
PartSelection->RemoveObserver(this->SelectionObserver);
CurvedEdgesSelection->RemoveObserver(this->SelectionObserver);
SelectionObserver->Delete();
PartSelection->Delete();
}
// Do everything except set the output info
int vtkPV3blockMeshReader::RequestInformation
(
vtkInformation* vtkNotUsed(request),
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* outputVector
)
{
vtkDebugMacro(<<"RequestInformation");
if (Foam::vtkPV3blockMesh::debug)
{
cout<<"REQUEST_INFORMATION\n";
}
if (!FileName)
{
vtkErrorMacro("FileName has to be specified!");
return 0;
}
int nInfo = outputVector->GetNumberOfInformationObjects();
if (Foam::vtkPV3blockMesh::debug)
{
cout<<"RequestInformation with " << nInfo << " item(s)\n";
for (int infoI = 0; infoI < nInfo; ++infoI)
{
outputVector->GetInformationObject(infoI)->Print(cout);
}
}
if (!foamData_)
{
foamData_ = new Foam::vtkPV3blockMesh(FileName, this);
}
else
{
foamData_->updateInfo();
}
// might need some other type of error handling
// {
// vtkErrorMacro("could not find valid OpenFOAM blockMesh");
//
// // delete foamData and flag it as fatal error
// delete foamData_;
// foamData_ = NULL;
// return 0;
// }
return 1;
}
// Set the output info
int vtkPV3blockMeshReader::RequestData
(
vtkInformation* vtkNotUsed(request),
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* outputVector
)
{
vtkDebugMacro(<<"RequestData");
if (!FileName)
{
vtkErrorMacro("FileName has to be specified!");
return 0;
}
// catch previous error
if (!foamData_)
{
vtkErrorMacro("Reader failed - perhaps no mesh?");
return 0;
}
int nInfo = outputVector->GetNumberOfInformationObjects();
if (Foam::vtkPV3blockMesh::debug)
{
cout<<"RequestData with " << nInfo << " item(s)\n";
for (int infoI = 0; infoI < nInfo; ++infoI)
{
outputVector->GetInformationObject(infoI)->Print(cout);
}
}
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
(
outputVector->GetInformationObject(0)->Get
(
vtkMultiBlockDataSet::DATA_OBJECT()
)
);
if (Foam::vtkPV3blockMesh::debug)
{
cout<< "update output with "
<< output->GetNumberOfBlocks() << " blocks\n";
}
foamData_->Update(output);
updatePointNumbersView(ShowPointNumbers);
// Do any cleanup on the Foam side
foamData_->CleanUp();
return 1;
}
void vtkPV3blockMeshReader::updatePointNumbersView(const bool show)
{
pqApplicationCore* appCore = pqApplicationCore::instance();
// Server manager model for querying items in the server manager
pqServerManagerModel* smModel = appCore->getServerManagerModel();
// Get all the pqRenderView instances
QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>();
for (int viewI=0; viewI<renderViews.size(); ++viewI)
{
foamData_->renderPointNumbers
(
renderViews[viewI]->getRenderViewProxy()->GetRenderer(),
show
);
}
}
void vtkPV3blockMeshReader::PrintSelf(ostream& os, vtkIndent indent)
{
vtkDebugMacro(<<"PrintSelf");
this->Superclass::PrintSelf(os,indent);
os<< indent << "File name: "
<< (this->FileName ? this->FileName : "(none)") << "\n";
foamData_->PrintSelf(os, indent);
}
// ----------------------------------------------------------------------
// Parts selection list control
vtkDataArraySelection* vtkPV3blockMeshReader::GetPartSelection()
{
vtkDebugMacro(<<"GetPartSelection");
return PartSelection;
}
int vtkPV3blockMeshReader::GetNumberOfPartArrays()
{
vtkDebugMacro(<<"GetNumberOfPartArrays");
return PartSelection->GetNumberOfArrays();
}
const char* vtkPV3blockMeshReader::GetPartArrayName(int index)
{
vtkDebugMacro(<<"GetPartArrayName");
return PartSelection->GetArrayName(index);
}
int vtkPV3blockMeshReader::GetPartArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetPartArrayStatus");
return PartSelection->ArrayIsEnabled(name);
}
void vtkPV3blockMeshReader::SetPartArrayStatus
(
const char* name,
int status
)
{
vtkDebugMacro(<<"SetPartArrayStatus");
if (status)
{
PartSelection->EnableArray(name);
}
else
{
PartSelection->DisableArray(name);
}
}
// ----------------------------------------------------------------------
// CurvedEdges selection list control
vtkDataArraySelection* vtkPV3blockMeshReader::GetCurvedEdgesSelection()
{
vtkDebugMacro(<<"GetCurvedEdgesSelection");
return CurvedEdgesSelection;
}
int vtkPV3blockMeshReader::GetNumberOfCurvedEdgesArrays()
{
vtkDebugMacro(<<"GetNumberOfCurvedEdgesArrays");
return CurvedEdgesSelection->GetNumberOfArrays();
}
const char* vtkPV3blockMeshReader::GetCurvedEdgesArrayName(int index)
{
vtkDebugMacro(<<"GetCurvedEdgesArrayName");
return CurvedEdgesSelection->GetArrayName(index);
}
int vtkPV3blockMeshReader::GetCurvedEdgesArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetCurvedEdgesArrayStatus");
return CurvedEdgesSelection->ArrayIsEnabled(name);
}
void vtkPV3blockMeshReader::SetCurvedEdgesArrayStatus
(
const char* name,
int status
)
{
vtkDebugMacro(<<"SetCurvedEdgesArrayStatus");
if (status)
{
CurvedEdgesSelection->EnableArray(name);
}
else
{
CurvedEdgesSelection->DisableArray(name);
}
}
// ----------------------------------------------------------------------
void vtkPV3blockMeshReader::SelectionModifiedCallback
(
vtkObject*,
unsigned long,
void* clientdata,
void*
)
{
static_cast<vtkPV3blockMeshReader*>(clientdata)->SelectionModified();
}
void vtkPV3blockMeshReader::SelectionModified()
{
vtkDebugMacro(<<"SelectionModified");
Modified();
}
int vtkPV3blockMeshReader::FillOutputPortInformation
(
int port,
vtkInformation* info
)
{
if (port == 0)
{
return this->Superclass::FillOutputPortInformation(port, info);
}
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet");
return 1;
}
// ************************************************************************* //

View File

@ -0,0 +1,153 @@
/*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: vtkPV3blockMeshReader.h,v $
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPV3blockMeshReader - reads a dataset in OpenFOAM bockMesh format
// .SECTION Description
// vtkPV3blockMeshReader creates an multiblock dataset.
// It uses the OpenFOAM infrastructure (blockMesh).
#ifndef __vtkPV3blockMeshReader_h
#define __vtkPV3blockMeshReader_h
// Foam forward declarations
namespace Foam
{
class vtkPV3blockMesh;
}
// VTK includes
#include "vtkMultiBlockDataSetAlgorithm.h"
// VTK forward declarations
class vtkDataArraySelection;
class vtkCallbackCommand;
class VTK_IO_EXPORT vtkPV3blockMeshReader
:
public vtkMultiBlockDataSetAlgorithm
{
public:
vtkTypeRevisionMacro(vtkPV3blockMeshReader,vtkMultiBlockDataSetAlgorithm);
void PrintSelf(ostream&, vtkIndent);
static vtkPV3blockMeshReader* New();
// Description:
// Set/Get the filename.
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
// Description:
// GUI update control
vtkSetMacro(UpdateGUI, int);
vtkGetMacro(UpdateGUI, int);
// Description:
// FOAM display patch names control
vtkSetMacro(ShowPointNumbers, int);
vtkGetMacro(ShowPointNumbers, int);
// Description:
// Parts (blocks) selection list control
vtkDataArraySelection* GetPartSelection();
int GetNumberOfPartArrays();
int GetPartArrayStatus(const char*);
void SetPartArrayStatus(const char*, int status);
const char* GetPartArrayName(int index);
// Description:
// Parts (blocks) selection list control
vtkDataArraySelection* GetCurvedEdgesSelection();
int GetNumberOfCurvedEdgesArrays();
int GetCurvedEdgesArrayStatus(const char*);
void SetCurvedEdgesArrayStatus(const char*, 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
);
void SelectionModified();
protected:
//- Construct null
vtkPV3blockMeshReader();
//- Destructor
~vtkPV3blockMeshReader();
//- Return information about mesh, times, etc without loading anything
virtual int RequestInformation
(
vtkInformation*,
vtkInformationVector**,
vtkInformationVector*
);
//- Get the mesh/fields for a particular time
virtual int RequestData
(
vtkInformation*,
vtkInformationVector**,
vtkInformationVector*
);
//- Fill in additional port information
virtual int FillOutputPortInformation(int, vtkInformation*);
// The observer to modify this object when array selections are modified
vtkCallbackCommand* SelectionObserver;
char* FileName;
private:
//- Disallow default bitwise copy construct
vtkPV3blockMeshReader(const vtkPV3blockMeshReader&);
//- Disallow default bitwise assignment
void operator=(const vtkPV3blockMeshReader&);
//- Add/remove point numbers to/from the view
void updatePointNumbersView(const bool show);
int ShowPointNumbers;
//- Dummy variable/switch to invoke a reader update
int UpdateGUI;
vtkDataArraySelection* PartSelection;
vtkDataArraySelection* CurvedEdgesSelection;
//BTX
Foam::vtkPV3blockMesh* foamData_;
//ETX
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,5 @@
vtkPV3blockMesh.C
vtkPV3blockMeshConvert.C
vtkPV3blockMeshUtils.C
LIB = $(FOAM_LIBBIN)/libvtkPV3blockMesh

View File

@ -0,0 +1,15 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/mesh/blockMesh/lnInclude \
-I$(ParaView_DIR)/VTK \
-I$(ParaView_INST_DIR) \
-I$(ParaView_INST_DIR)/VTK \
-I$(ParaView_INST_DIR)/VTK/Common \
-I$(ParaView_INST_DIR)/VTK/Filtering \
-I$(ParaView_INST_DIR)/VTK/Rendering \
-I../PV3blockMeshReader
LIB_LIBS = \
-lmeshTools \
-lblockMesh \
$(GLIBS)

View File

@ -22,27 +22,30 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
vtkPV3blockMesh
\*---------------------------------------------------------------------------*/
#ifndef vtkOpenFOAMPoints_H
#define vtkOpenFOAMPoints_H
// VTK includes
#include "vtkPoints.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline Foam::word Foam::vtkPV3Foam::getFirstWord(const char* str)
inline void vtkInsertNextOpenFOAMPoint
(
vtkPoints *points,
const Foam::point& p
)
{
if (str)
{
label n = 0;
while (str[n] && word::valid(str[n]))
{
++n;
}
return word(str, n, true);
}
else
{
return word::null;
}
points->InsertNextPoint(p.x(), p.y(), p.z());
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,433 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
\*---------------------------------------------------------------------------*/
#include "vtkPV3blockMesh.H"
#include "vtkPV3blockMeshReader.h"
// Foam includes
#include "blockMesh.H"
#include "Time.H"
#include "patchZones.H"
#include "OStringStream.H"
// VTK includes
#include "vtkDataArraySelection.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkRenderer.h"
#include "vtkTextActor.h"
#include "vtkTextProperty.h"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::vtkPV3blockMesh, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::vtkPV3blockMesh::resetCounters()
{
// Reset mesh part ids and sizes
partInfoBlocks_.reset();
partInfoEdges_.reset();
partInfoCorners_.reset();
}
void Foam::vtkPV3blockMesh::updateInfoBlocks()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3blockMesh::updateInfoBlocks"
<< " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl;
}
vtkDataArraySelection* selection = reader_->GetPartSelection();
partInfoBlocks_ = selection->GetNumberOfArrays();
const blockMesh& blkMesh = *meshPtr_;
const int nBlocks = blkMesh.size();
for (int blockI = 0; blockI < nBlocks; ++blockI)
{
const blockDescriptor& blockDef = blkMesh[blockI].blockDef();
word partName = Foam::name(blockI);
// append the (optional) zone name
if (!blockDef.zoneName().empty())
{
partName += " - " + blockDef.zoneName();
}
// Add blockId and zoneName to GUI list
selection->AddArray(partName.c_str());
}
partInfoBlocks_ += nBlocks;
if (debug)
{
// just for debug info
getSelectedArrayEntries(selection);
Info<< "<end> Foam::vtkPV3blockMesh::updateInfoBlocks" << endl;
}
}
void Foam::vtkPV3blockMesh::updateInfoEdges()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3blockMesh::updateInfoEdges"
<< " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl;
}
vtkDataArraySelection* selection = reader_->GetCurvedEdgesSelection();
partInfoEdges_ = selection->GetNumberOfArrays();
const blockMesh& blkMesh = *meshPtr_;
const curvedEdgeList& edges = blkMesh.edges();
const int nEdges = edges.size();
forAll(edges, edgeI)
{
OStringStream ostr;
ostr<< edges[edgeI].start() << ":" << edges[edgeI].end() << " - "
<< edges[edgeI].type();
// Add "beg:end - type" to GUI list
selection->AddArray(ostr.str().c_str());
}
partInfoEdges_ += nEdges;
if (debug)
{
// just for debug info
getSelectedArrayEntries(selection);
Info<< "<end> Foam::vtkPV3blockMesh::updateInfoEdges" << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::vtkPV3blockMesh::vtkPV3blockMesh
(
const char* const FileName,
vtkPV3blockMeshReader* reader
)
:
reader_(reader),
dbPtr_(NULL),
meshPtr_(NULL),
partInfoBlocks_("block"),
partInfoEdges_("edges"),
partInfoCorners_("corners")
{
if (debug)
{
Info<< "Foam::vtkPV3blockMesh::vtkPV3blockMesh - "
<< 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();
}
// 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());
if (debug)
{
Info<< "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::vtkPV3blockMesh::~vtkPV3blockMesh()
{
if (debug)
{
Info<< "<end> Foam::vtkPV3blockMesh::~vtkPV3blockMesh" << endl;
}
delete meshPtr_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3blockMesh::updateInfo()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3blockMesh::updateInfo"
<< " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "] " << endl;
}
resetCounters();
vtkDataArraySelection* partSelection = reader_->GetPartSelection();
vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
// enable 'internalMesh' on the first call
// or preserve the enabled selections
stringList enabledParts;
stringList enabledEdges;
bool firstTime = false;
if (!partSelection->GetNumberOfArrays() && !meshPtr_)
{
firstTime = true;
}
else
{
enabledParts = getSelectedArrayEntries(partSelection);
enabledEdges = getSelectedArrayEntries(edgeSelection);
}
// Clear current mesh parts list
partSelection->RemoveAllArrays();
edgeSelection->RemoveAllArrays();
// need a blockMesh
updateFoamMesh();
// Update mesh parts list
updateInfoBlocks();
// Update curved edges list
updateInfoEdges();
// restore the enabled selections
if (!firstTime)
{
setSelectedArrayEntries(partSelection, enabledParts);
setSelectedArrayEntries(edgeSelection, enabledEdges);
}
if (debug)
{
Info<< "<end> Foam::vtkPV3blockMesh::updateInfo" << endl;
}
}
void Foam::vtkPV3blockMesh::updateFoamMesh()
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3blockMesh::updateFoamMesh" << endl;
}
// Check to see if the FOAM mesh has been created
if (!meshPtr_)
{
if (debug)
{
Info<< "Creating blockMesh at time=" << dbPtr_().timeName()
<< endl;
}
IOdictionary meshDict
(
IOobject
(
"blockMeshDict",
dbPtr_().constant(),
polyMesh::meshSubDir,
dbPtr_(),
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
meshPtr_ = new blockMesh(meshDict);
}
if (debug)
{
Info<< "<end> Foam::vtkPV3blockMesh::updateFoamMesh" << endl;
}
}
void Foam::vtkPV3blockMesh::Update
(
vtkMultiBlockDataSet* output
)
{
reader_->UpdateProgress(0.1);
// Set up mesh parts selection(s)
updateBoolListStatus(partStatus_, reader_->GetPartSelection());
// Set up curved edges selection(s)
updateBoolListStatus(edgeStatus_, reader_->GetCurvedEdgesSelection());
reader_->UpdateProgress(0.2);
// Update the Foam 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::vtkPV3blockMesh::CleanUp()
{
reader_->UpdateProgress(1.0);
}
void Foam::vtkPV3blockMesh::renderPointNumbers
(
vtkRenderer* renderer,
const bool show
)
{
// always remove old actors first
forAll(pointNumberTextActorsPtrs_, pointI)
{
renderer->RemoveViewProp(pointNumberTextActorsPtrs_[pointI]);
pointNumberTextActorsPtrs_[pointI]->Delete();
}
pointNumberTextActorsPtrs_.clear();
if (show && meshPtr_)
{
const pointField& cornerPts = meshPtr_->blockPointField();
pointNumberTextActorsPtrs_.setSize(cornerPts.size());
forAll(cornerPts, pointI)
{
vtkTextActor* txt = vtkTextActor::New();
txt->SetInput(Foam::name(pointI).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();
// Set text to use 3-D world co-ordinates
txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
txt->GetPositionCoordinate()->SetValue
(
cornerPts[pointI].x(),
cornerPts[pointI].y(),
cornerPts[pointI].z()
);
// Add text to each renderer
renderer->AddViewProp(txt);
// Maintain a list of text labels added so that they can be
// removed later
pointNumberTextActorsPtrs_[pointI] = txt;
}
}
}
void Foam::vtkPV3blockMesh::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
}
// ************************************************************************* //

View File

@ -0,0 +1,353 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Class
Foam::vtkPV3blockMesh
Description
Provides a reader interface for OpenFOAM blockMesh to VTK interaction
SourceFiles
vtkPV3blockMesh.C
vtkPV3blockMeshConvert.C
vtkPV3blockMeshUpdate.C
vtkPV3blockMeshUtils.C
// Needed by VTK:
vtkDataArrayTemplateImplicit.txx
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3blockMesh_H
#define vtkPV3blockMesh_H
// do not include legacy strstream headers
#ifndef VTK_EXCLUDE_STRSTREAM_HEADERS
# define VTK_EXCLUDE_STRSTREAM_HEADERS
#endif
#include "className.H"
#include "fileName.H"
#include "stringList.H"
#include "wordList.H"
#include "primitivePatch.H"
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
class vtkDataArraySelection;
class vtkDataSet;
class vtkPoints;
class vtkPV3blockMeshReader;
class vtkRenderer;
class vtkTextActor;
class vtkMultiBlockDataSet;
class vtkPolyData;
class vtkUnstructuredGrid;
class vtkIndent;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Foam class forward declarations
class argList;
class Time;
class blockMesh;
template<class Type> class List;
/*---------------------------------------------------------------------------*\
Class vtkPV3blockMesh Declaration
\*---------------------------------------------------------------------------*/
class vtkPV3blockMesh
{
// Private classes
//- Bookkeeping for GUI checklists and the multi-block organization
class partInfo
{
const char *name_;
int block_;
int start_;
int size_;
public:
partInfo(const char *name, const int blockNo=0)
:
name_(name),
block_(blockNo),
start_(-1),
size_(0)
{}
//- 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;
}
const char* name() const
{
return name_;
}
int start() const
{
return start_;
}
int end() const
{
return start_ + size_;
}
int size() const
{
return size_;
}
bool empty() const
{
return !size_;
}
void reset()
{
start_ = -1;
size_ = 0;
}
//- Assign new start and reset the size
void operator=(const int i)
{
start_ = i;
size_ = 0;
}
//- Increment the size
void operator+=(const int n)
{
size_ += n;
}
};
// Private Data
//- Access to the controlling vtkPV3blockMeshReader
vtkPV3blockMeshReader* reader_;
//- Foam time control
autoPtr<Time> dbPtr_;
//- Foam mesh
blockMesh* meshPtr_;
//- Selected geometrical parts
boolList partStatus_;
//- Selected curved edges
boolList edgeStatus_;
//- First instance and size of bleckMesh blocks
// used to index into partStatus_
partInfo partInfoBlocks_;
//- First instance and size of CurvedEdges
// only partially used
partInfo partInfoEdges_;
//- First instance and size of block corners
// only partially used
partInfo partInfoCorners_;
//- List of point numbers for rendering to window
List<vtkTextActor*> pointNumberTextActorsPtrs_;
// Private Member Functions
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
static void AddToBlock
(
vtkMultiBlockDataSet* output,
vtkDataSet* dataset,
const partInfo&,
const label datasetNo,
const std::string& datasetName
);
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
static vtkDataSet* GetDataSetFromBlock
(
vtkMultiBlockDataSet* output,
const partInfo&,
const label datasetNo
);
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
static label GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
const partInfo&
);
//- Update boolList from GUI selection
static void updateBoolListStatus
(
boolList&,
vtkDataArraySelection*
);
//- Reset data counters
void resetCounters();
// Update information helper functions
//- Internal block info
void updateInfoBlocks();
//- block curved edges info
void updateInfoEdges();
// Update helper functions
//- Foam mesh
void updateFoamMesh();
// Mesh conversion functions
//- mesh blocks
void convertMeshBlocks(vtkMultiBlockDataSet*, int& blockNo);
//- mesh curved edges
void convertMeshEdges(vtkMultiBlockDataSet*, int& blockNo);
//- mesh corners
void convertMeshCorners(vtkMultiBlockDataSet*, int& blockNo);
// GUI selection helper functions
//- Retrieve the current selections
static wordHashSet getSelected(vtkDataArraySelection*);
//- Retrieve a sub-list of the current selections
static wordHashSet getSelected
(
vtkDataArraySelection*,
const partInfo&
);
//- Retrieve the current selections
static stringList getSelectedArrayEntries(vtkDataArraySelection*);
//- Retrieve a sub-list of the current selections
static stringList getSelectedArrayEntries
(
vtkDataArraySelection*,
const partInfo&
);
//- Set selection(s)
static void setSelectedArrayEntries
(
vtkDataArraySelection*,
const stringList&
);
//- Disallow default bitwise copy construct
vtkPV3blockMesh(const vtkPV3blockMesh&);
//- Disallow default bitwise assignment
void operator=(const vtkPV3blockMesh&);
public:
//- Static data members
ClassName("vtkPV3blockMesh");
// Constructors
//- Construct from components
vtkPV3blockMesh
(
const char* const FileName,
vtkPV3blockMeshReader* reader
);
//- Destructor
~vtkPV3blockMesh();
// Member Functions
//- Update
void updateInfo();
void Update(vtkMultiBlockDataSet* output);
//- Clean any storage
void CleanUp();
//- Add/remove point numbers to/from the view
void renderPointNumbers(vtkRenderer*, const bool show);
// Access
//- Debug information
void PrintSelf(ostream&, vtkIndent) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,318 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 "vtkPV3blockMesh.H"
#include "vtkPV3blockMeshReader.h"
// Foam includes
#include "blockMesh.H"
#include "Time.H"
#include "vtkOpenFOAMPoints.H"
// VTK includes
#include "vtkCellArray.h"
#include "vtkDataArraySelection.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkPoints.h"
#include "vtkPolyData.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3blockMesh::convertMeshBlocks
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
vtkDataArraySelection* selection = reader_->GetPartSelection();
partInfo& selector = partInfoBlocks_;
selector.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const blockMesh& blkMesh = *meshPtr_;
const Foam::pointField& blockPoints = blkMesh.blockPointField();
if (debug)
{
Info<< "<beg> Foam::vtkPV3blockMesh::convertMeshBlocks" << endl;
}
int blockI = 0;
for
(
int partId = selector.start();
partId < selector.end();
++partId, ++blockI
)
{
if (!partStatus_[partId])
{
continue;
}
const blockDescriptor& blockDef = blkMesh[blockI].blockDef();
word partName("block");
// // append the (optional) zone name
// if (!blockDef.zoneName().empty())
// {
// partName += " - " + blockDef.zoneName();
// }
//
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
// Convert Foam mesh vertices to VTK
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate( blockDef.nPoints() );
const labelList& blockLabels = blockDef.blockShape();
vtkmesh->Allocate(1);
vtkIdType nodeIds[8];
forAll(blockLabels, ptI)
{
vtkInsertNextOpenFOAMPoint
(
vtkpoints,
blockPoints[blockLabels[ptI]]
);
nodeIds[ptI] = ptI;
}
vtkmesh->InsertNextCell
(
VTK_HEXAHEDRON,
8,
nodeIds
);
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
AddToBlock
(
output, vtkmesh, selector, datasetNo,
selection->GetArrayName(partId)
);
vtkmesh->Delete();
datasetNo++;
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3blockMesh::convertMeshBlocks" << endl;
}
}
void Foam::vtkPV3blockMesh::convertMeshEdges
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
vtkDataArraySelection* selection = reader_->GetCurvedEdgesSelection();
partInfo& selector = partInfoEdges_;
selector.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const blockMesh& blkMesh = *meshPtr_;
const curvedEdgeList& edges = blkMesh.edges();
int edgeI = 0;
for
(
int partId = selector.start();
partId < selector.end();
++partId, ++edgeI
)
{
if (!edgeStatus_[partId])
{
continue;
}
OStringStream ostr;
ostr<< edges[edgeI].start() << ":" << edges[edgeI].end() << " - "
<< edges[edgeI].type();
// search each block
forAll(blkMesh, blockI)
{
const blockDescriptor& blockDef = blkMesh[blockI].blockDef();
edgeList blkEdges = blockDef.blockShape().edges();
// find the corresponding edge within the block
label foundEdgeI = -1;
forAll(blkEdges, blkEdgeI)
{
if (edges[edgeI].compare(blkEdges[blkEdgeI]))
{
foundEdgeI = blkEdgeI;
break;
}
}
if (foundEdgeI != -1)
{
const List<point>& edgePoints =
blockDef.blockEdgePoints()[foundEdgeI];
vtkPolyData* vtkmesh = vtkPolyData::New();
vtkPoints* vtkpoints = vtkPoints::New();
vtkpoints->Allocate( edgePoints.size() );
vtkmesh->Allocate(1);
vtkIdType pointIds[edgePoints.size()];
forAll(edgePoints, ptI)
{
vtkInsertNextOpenFOAMPoint(vtkpoints, edgePoints[ptI]);
pointIds[ptI] = ptI;
}
vtkmesh->InsertNextCell
(
VTK_POLY_LINE,
edgePoints.size(),
pointIds
);
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
AddToBlock
(
output, vtkmesh, selector, datasetNo,
selection->GetArrayName(partId)
);
vtkmesh->Delete();
datasetNo++;
break;
}
}
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3blockMesh::convertMeshEdges" << endl;
}
}
void Foam::vtkPV3blockMesh::convertMeshCorners
(
vtkMultiBlockDataSet* output,
int& blockNo
)
{
partInfo& selector = partInfoCorners_;
selector.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const pointField& blockPoints = meshPtr_->blockPointField();
if (debug)
{
Info<< "<beg> Foam::vtkPV3blockMesh::convertMeshCorners" << endl;
}
if (true) // or some flag or other condition
{
vtkPolyData* vtkmesh = vtkPolyData::New();
vtkPoints* vtkpoints = vtkPoints::New();
vtkCellArray* vtkcells = vtkCellArray::New();
vtkpoints->Allocate( blockPoints.size() );
vtkcells->Allocate( blockPoints.size() );
vtkIdType pointId = 0;
forAll(blockPoints, ptI)
{
vtkInsertNextOpenFOAMPoint(vtkpoints, blockPoints[ptI]);
vtkcells->InsertNextCell(1, &pointId);
pointId++;
}
vtkmesh->SetPoints(vtkpoints);
vtkpoints->Delete();
vtkmesh->SetVerts(vtkcells);
vtkcells->Delete();
AddToBlock(output, vtkmesh, selector, datasetNo, partInfoCorners_.name());
vtkmesh->Delete();
datasetNo++;
}
// anything added?
if (datasetNo)
{
++blockNo;
}
if (debug)
{
Info<< "<end> Foam::vtkPV3blockMesh::convertMeshCorners" << endl;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,358 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Misc helper methods and utilities
\*---------------------------------------------------------------------------*/
#include "vtkPV3blockMesh.H"
#include "vtkPV3blockMeshReader.h"
// VTK includes
#include "vtkDataArraySelection.h"
#include "vtkDataSet.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkInformation.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//! @cond fileScope
// Extract up to the first non-word characters
inline word getFirstWord(const char* str)
{
if (str)
{
label n = 0;
while (str[n] && word::valid(str[n]))
{
++n;
}
return word(str, n, true);
}
else
{
return word::null;
}
}
//! @endcond fileScope
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::vtkPV3blockMesh::AddToBlock
(
vtkMultiBlockDataSet* output,
vtkDataSet* dataset,
const partInfo& selector,
const label datasetNo,
const std::string& datasetName
)
{
const int blockNo = selector.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (!block)
{
if (blockDO)
{
FatalErrorIn("Foam::vtkPV3blockMesh::AddToBlock")
<< "Block already has a vtkDataSet assigned to it"
<< endl;
return;
}
block = vtkMultiBlockDataSet::New();
output->SetBlock(blockNo, block);
block->Delete();
}
if (debug)
{
Info<< "block[" << blockNo << "] has "
<< block->GetNumberOfBlocks()
<< " datasets prior to adding set " << datasetNo
<< " with name: " << datasetName << endl;
}
block->SetBlock(datasetNo, dataset);
// name the 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()
);
}
}
vtkDataSet* Foam::vtkPV3blockMesh::GetDataSetFromBlock
(
vtkMultiBlockDataSet* output,
const partInfo& selector,
const label datasetNo
)
{
const int blockNo = selector.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block)
{
return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo));
}
return 0;
}
// ununsed at the moment
Foam::label Foam::vtkPV3blockMesh::GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
const partInfo& selector
)
{
const int blockNo = selector.block();
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block)
{
return block->GetNumberOfBlocks();
}
return 0;
}
Foam::wordHashSet Foam::vtkPV3blockMesh::getSelected
(
vtkDataArraySelection* select
)
{
int nElem = select->GetNumberOfArrays();
wordHashSet selections(2*nElem);
for (int elemI=0; elemI < nElem; ++elemI)
{
if (select->GetArraySetting(elemI))
{
selections.insert(getFirstWord(select->GetArrayName(elemI)));
}
}
return selections;
}
Foam::wordHashSet Foam::vtkPV3blockMesh::getSelected
(
vtkDataArraySelection* select,
const partInfo& selector
)
{
int nElem = select->GetNumberOfArrays();
wordHashSet selections(2*nElem);
for (int elemI = selector.start(); elemI < selector.end(); ++elemI)
{
if (select->GetArraySetting(elemI))
{
selections.insert(getFirstWord(select->GetArrayName(elemI)));
}
}
return selections;
}
Foam::stringList Foam::vtkPV3blockMesh::getSelectedArrayEntries
(
vtkDataArraySelection* select
)
{
stringList selections(select->GetNumberOfArrays());
label nElem = 0;
forAll(selections, elemI)
{
if (select->GetArraySetting(elemI))
{
selections[nElem++] = select->GetArrayName(elemI);
}
}
selections.setSize(nElem);
if (debug)
{
label nElem = select->GetNumberOfArrays();
Info<< "available(";
for (int elemI = 0; elemI < nElem; ++elemI)
{
Info<< " \"" << select->GetArrayName(elemI) << "\"";
}
Info<< " )\nselected(";
forAll(selections, elemI)
{
Info<< " " << selections[elemI];
}
Info<< " )\n";
}
return selections;
}
Foam::stringList Foam::vtkPV3blockMesh::getSelectedArrayEntries
(
vtkDataArraySelection* select,
const partInfo& selector
)
{
stringList selections(selector.size());
label nElem = 0;
for (int elemI = selector.start(); elemI < selector.end(); ++elemI)
{
if (select->GetArraySetting(elemI))
{
selections[nElem++] = select->GetArrayName(elemI);
}
}
selections.setSize(nElem);
if (debug)
{
Info<< "available(";
for (int elemI = selector.start(); elemI < selector.end(); ++elemI)
{
Info<< " \"" << select->GetArrayName(elemI) << "\"";
}
Info<< " )\nselected(";
forAll(selections, elemI)
{
Info<< " " << selections[elemI];
}
Info<< " )\n";
}
return selections;
}
void Foam::vtkPV3blockMesh::setSelectedArrayEntries
(
vtkDataArraySelection* select,
const stringList& selections
)
{
const int nElem = select->GetNumberOfArrays();
select->DisableAllArrays();
// Loop through entries, setting values from selectedEntries
for (int elemI=0; elemI < nElem; ++elemI)
{
string arrayName(select->GetArrayName(elemI));
forAll(selections, elemI)
{
if (selections[elemI] == arrayName)
{
select->EnableArray(arrayName.c_str());
break;
}
}
}
}
void Foam::vtkPV3blockMesh::updateBoolListStatus
(
boolList& status,
vtkDataArraySelection* selection
)
{
if (debug)
{
Info<< "<beg> Foam::vtkPV3blockMesh::updateBoolListStatus" << endl;
}
const label nElem = selection->GetNumberOfArrays();
if (status.size() != nElem)
{
status.setSize(nElem);
status = false;
}
forAll(status, elemI)
{
const int setting = selection->GetArraySetting(elemI);
status[elemI] = setting;
if (debug)
{
Info<< " part[" << elemI << "] = "
<< status[elemI]
<< " : " << selection->GetArrayName(elemI) << endl;
}
}
if (debug)
{
Info<< "<end> Foam::vtkPV3blockMesh::updateBoolListStatus" << endl;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
foamListTimes.C
EXE = $(FOAM_APPBIN)/foamListTimes

View File

@ -0,0 +1,2 @@
/* EXE_INC = */
/* EXE_LIBS = */

View File

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Application
foamListTimes
Description
List times using timeSelector
Usage
- foamListTimes [OPTION]
@param -processor \n
List times from processor0 directory
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
timeSelector::addOptions(); // -constant enabled
argList::noBanner();
argList::noParallel();
argList::validOptions.insert("processor", "");
# include "setRootCase.H"
label nProcs = 0;
// Create the processor databases
PtrList<Time> databases(1);
if (args.optionFound("processor"))
{
// determine the processor count directly
while (isDir(args.path()/(word("processor") + name(nProcs))))
{
++nProcs;
}
if (!nProcs)
{
FatalErrorIn(args.executable())
<< "No processor* directories found"
<< exit(FatalError);
}
// Create the processor databases
databases.setSize(nProcs);
forAll(databases, procI)
{
databases.set
(
procI,
new Time
(
Time::controlDictName,
args.rootPath(),
args.caseName()/fileName(word("processor") + name(procI))
)
);
}
}
else
{
databases.set
(
0,
new Time
(
Time::controlDictName,
args.rootPath(),
args.caseName()
)
);
}
// use the times list from the master processor
// and select a subset based on the command-line options
instantList timeDirs = timeSelector::select
(
databases[0].times(),
args
);
forAll(timeDirs, timeI)
{
Info<< timeDirs[timeI].name() << endl;
}
return 0;
}
// ************************************************************************* //