updating PV3FoamReader with Mark's version

This commit is contained in:
andy
2008-05-27 14:23:21 +01:00
parent bada64a0f0
commit 46f84af1ea
60 changed files with 0 additions and 5192 deletions

View File

@ -1,18 +0,0 @@
#!/bin/sh
set -x
if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ]
then
case "$ParaView_VERSION" in
3*)
wmake libso vtkPV3Foam
(
cd PV3FoamReader
mkdir -p Make/$WM_OPTIONS > /dev/null 2>&1
cd Make/$WM_OPTIONS
cmake ../..
make
)
;;
esac
fi

View File

@ -1,54 +0,0 @@
# 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.
FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})
LINK_DIRECTORIES(
$ENV{FOAM_LIBBIN}
)
INCLUDE_DIRECTORIES(
$ENV{FOAM_SRC}/OpenFOAM/lnInclude
$ENV{FOAM_SRC}/finiteVolume/lnInclude
${PROJECT_SOURCE_DIR}/../vtkPV3Foam
)
ADD_DEFINITIONS(
-D$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(
PV3FoamReader_SM "1.0"
SERVER_MANAGER_XML PV3FoamReader_SM.xml
SERVER_MANAGER_SOURCES vtkPV3FoamReader.cxx
)
# Build the client-side plugin
ADD_PARAVIEW_PLUGIN(
PV3FoamReader
"1.0"
GUI_RESOURCES PV3FoamReader.qrc
)
TARGET_LINK_LIBRARIES(
PV3FoamReader_SM
OpenFOAM
finiteVolume
vtkPV3Foam
)

View File

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

View File

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

View File

@ -1,238 +0,0 @@
<ServerManagerConfiguration>
<ProxyGroup name="sources">
<SourceProxy
name="PV3FoamReader"
class="vtkPV3FoamReader">
<!-- File name - compulsory -->
<StringVectorProperty
name="FileName"
command="SetFileName"
number_of_elements="1">
<FileListDomain
name="files"/>
</StringVectorProperty>
<!-- Time info sent to animation controls (top of window) -->
<DoubleVectorProperty
name="TimestepValues"
information_only="1">
<TimeStepsInformationHelper/>
<Documentation>
Available timestep values.
</Documentation>
</DoubleVectorProperty>
<DoubleVectorProperty
name="TimeRange"
information_only="1">
<TimeRangeInformationHelper/>
</DoubleVectorProperty>
<!-- Update GUI check box -->
<IntVectorProperty
name="UpdateGUI"
command="SetUpdateGUI"
number_of_elements="1"
default_values="0">
<BooleanDomain
name="bool"/>
</IntVectorProperty>
<!-- Cache mesh check box -->
<IntVectorProperty
name="CacheMesh"
command="SetCacheMesh"
number_of_elements="1"
default_values="1">
<BooleanDomain
name="bool"/>
</IntVectorProperty>
<!-- Include sets check box -->
<IntVectorProperty
name="IncludeSets"
command="SetIncludeSets"
number_of_elements="1"
default_values="0">
<BooleanDomain
name="bool"/>
</IntVectorProperty>
<!-- Show patch names check box -->
<IntVectorProperty
name="ShowPatchNames"
command="SetShowPatchNames"
number_of_elements="1"
default_values="0">
<BooleanDomain name="bool"/>
</IntVectorProperty>
<!-- Time step edit box -->
<IntVectorProperty
name="TimeStepRangeInfo"
command="GetTimeStepRange"
information_only="1">
<SimpleIntInformationHelper/>
</IntVectorProperty>
<IntVectorProperty
name="TimeStep"
command="SetTimeStep"
number_of_elements="1"
animateable="1"
default_values="0"
information_property="TimestepValues">
<IntRangeDomain
name="range">
<RequiredProperties>
<Property name="TimeStepRangeInfo"
function="Range"/>
</RequiredProperties>
</IntRangeDomain>
</IntVectorProperty>
<!-- Time step limits boxes -->
<!-- <IntVectorProperty
name="TimeStepLimitsInfo"
command="GetTimeStepLimits"
information_only="1">
<SimpleIntInformationHelper/>
</IntVectorProperty>
<IntVectorProperty
name="TimeStepLimits"
command="SetTimeStepLimits"
number_of_elements="2"
default_values="2 5" >
<IntRangeDomain
name="range">
<RequiredProperties>
<Property name="TimeStepLimitsInfo"
function="Range"/>
</RequiredProperties>
</IntRangeDomain>
</IntVectorProperty>-->
<!-- Available times array -->
<StringVectorProperty
name="TimeArrayInfo"
information_only="1">
<ArraySelectionInformationHelper
attribute_name="Time"/>
</StringVectorProperty>
<StringVectorProperty
name="TimeStatus"
command="SetTimeArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="TimeArrayInfo">
<ArraySelectionDomain
name="array_list">
<RequiredProperties>
<Property name="TimeArrayInfo"
function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
</StringVectorProperty>
<!-- Available regions array -->
<StringVectorProperty
name="RegionArrayInfo"
information_only="1">
<ArraySelectionInformationHelper
attribute_name="Region"/>
</StringVectorProperty>
<StringVectorProperty
name="RegionStatus"
command="SetRegionArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="RegionArrayInfo">
<ArraySelectionDomain
name="array_list">
<RequiredProperties>
<Property name="RegionArrayInfo"
function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
</StringVectorProperty>
<!-- Available volFields array -->
<StringVectorProperty
name="VolFieldArrayInfo"
information_only="1">
<ArraySelectionInformationHelper
attribute_name="VolField"/>
</StringVectorProperty>
<StringVectorProperty
name="VolFieldStatus"
command="SetVolFieldArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="VolFieldArrayInfo">
<ArraySelectionDomain
name="array_list">
<RequiredProperties>
<Property name="VolFieldArrayInfo"
function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
</StringVectorProperty>
<!-- Available pointFields array -->
<StringVectorProperty
name="PointFieldArrayInfo"
information_only="1">
<ArraySelectionInformationHelper
attribute_name="PointField"/>
</StringVectorProperty>
<StringVectorProperty
name="PointFieldStatus"
command="SetPointFieldArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="PointFieldArrayInfo">
<ArraySelectionDomain
name="array_list">
<RequiredProperties>
<Property name="PointFieldArrayInfo"
function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
</StringVectorProperty>
<!-- Available Lagrangian fields array -->
<StringVectorProperty
name="LagrangianFieldArrayInfo"
information_only="1">
<ArraySelectionInformationHelper
attribute_name="LagrangianField"/>
</StringVectorProperty>
<StringVectorProperty
name="LagrangianFieldStatus"
command="SetLagrangianFieldArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="LagrangianFieldArrayInfo">
<ArraySelectionDomain
name="array_list">
<RequiredProperties>
<Property name="LagrangianFieldArrayInfo"
function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
</StringVectorProperty>
</SourceProxy>
</ProxyGroup>
</ServerManagerConfiguration>

View File

@ -1,600 +0,0 @@
/*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: vtkPV3FoamReader.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 "vtkPV3FoamReader.h"
#include "pqApplicationCore.h"
#include "pqRenderView.h"
#include "pqServerManagerModel.h"
// VTK includes
#include "vtkCallbackCommand.h"
#include "vtkCellArray.h"
#include "vtkCellData.h"
#include "vtkDataArraySelection.h"
#include "vtkDirectory.h"
#include "vtkDoubleArray.h"
#include "vtkErrorCode.h"
#include "vtkFloatArray.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkIntArray.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkObjectFactory.h"
#include "vtkPoints.h"
#include "vtkRenderer.h"
#include "vtkSMRenderViewProxy.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkStringArray.h"
#include "vtkUnstructuredGrid.h"
#include "vtkUnstructuredGridAlgorithm.h"
// Foam includes
#include "vtkPV3Foam.H"
vtkCxxRevisionMacro(vtkPV3FoamReader, "$Revision: 1.2$");
vtkStandardNewMacro(vtkPV3FoamReader);
vtkPV3FoamReader::vtkPV3FoamReader()
{
vtkDebugMacro(<<"Constructor");
SetNumberOfInputPorts(0);
FileName = NULL;
foamData_ = NULL;
CacheMesh = 0;
UpdateGUI = 1;
UpdateGUIOld = 1;
TimeStep = 0;
TimeStepRange[0] = 0;
TimeStepRange[1] = 0;
ShowPatchNames = 0;
TimeSelection = vtkDataArraySelection::New();
PointFieldSelection = vtkDataArraySelection::New();
RegionSelection = vtkDataArraySelection::New();
VolFieldSelection = vtkDataArraySelection::New();
LagrangianFieldSelection = vtkDataArraySelection::New();
// Setup the selection callback to modify this object when an array
// selection is changed.
SelectionObserver = vtkCallbackCommand::New();
SelectionObserver->SetCallback
(
&vtkPV3FoamReader::SelectionModifiedCallback
);
SelectionObserver->SetClientData(this);
TimeSelection->AddObserver
(
vtkCommand::ModifiedEvent,
this->SelectionObserver
);
RegionSelection->AddObserver
(
vtkCommand::ModifiedEvent,
this->SelectionObserver
);
VolFieldSelection->AddObserver
(
vtkCommand::ModifiedEvent,
this->SelectionObserver
);
PointFieldSelection->AddObserver
(
vtkCommand::ModifiedEvent,
this->SelectionObserver
);
LagrangianFieldSelection->AddObserver
(
vtkCommand::ModifiedEvent,
this->SelectionObserver
);
}
vtkPV3FoamReader::~vtkPV3FoamReader()
{
vtkDebugMacro(<<"Deconstructor");
if (foamData_)
{
delete foamData_;
}
if (FileName)
{
delete [] FileName;
}
TimeSelection->RemoveObserver(this->SelectionObserver);
RegionSelection->RemoveObserver(this->SelectionObserver);
VolFieldSelection->RemoveObserver(this->SelectionObserver);
PointFieldSelection->RemoveObserver(this->SelectionObserver);
SelectionObserver->Delete();
TimeSelection->Delete();
RegionSelection->Delete();
VolFieldSelection->Delete();
PointFieldSelection->Delete();
}
// Do everything except set the output info
int vtkPV3FoamReader::RequestInformation
(
vtkInformation* vtkNotUsed(request),
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* outputVector
)
{
vtkDebugMacro(<<"Request Information");
if (!FileName)
{
vtkErrorMacro("FileName has to be specified!");
return 0;
}
if (!foamData_)
{
vtkDebugMacro("RequestInformation: creating foamData_");
vtkInformation* outInfo = outputVector->GetInformationObject(0);
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
(
outInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT())
);
foamData_ = new Foam::vtkPV3Foam(FileName, this, output);
foamData_->UpdateInformation();
}
else
{
vtkDebugMacro("RequestInformation: updating information");
foamData_->UpdateInformation();
}
double* timeSteps = foamData_->timeSteps();
outputVector->GetInformationObject(0)->Set
(
vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
timeSteps,
foamData_->numberOfTimeSteps()
);
delete timeSteps;
return 1;
}
// Set the output info
int vtkPV3FoamReader::RequestData
(
vtkInformation* vtkNotUsed(request),
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* outputVector
)
{
vtkDebugMacro(<<"RequestData");
if (!FileName)
{
vtkErrorMacro("FileName has to be specified!");
return 0;
}
vtkInformation* outInfo = outputVector->GetInformationObject(0);
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
(
outInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT())
);
if
(
(UpdateGUIOld == GetUpdateGUI())
|| (output->GetNumberOfBlocks() == 0)
)
{
foamData_->Update(output);
if (ShowPatchNames == 1)
{
addPatchNamesToView();
}
else
{
removePatchNamesFromView();
}
}
UpdateGUIOld = GetUpdateGUI();
return 1;
}
void vtkPV3FoamReader::addPatchNamesToView()
{
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_->addPatchNames
(
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()
);
}
}
void vtkPV3FoamReader::PrintSelf
(
ostream& os,
vtkIndent indent
)
{
vtkDebugMacro(<<"PrintSelf");
this->Superclass::PrintSelf(os,indent);
os<< indent << "File name: "
<< (this->FileName ? this->FileName : "(none)") << "\n";
os<< indent << "Number of meshes: " << foamData_->numberOfMeshes() << "\n";
os<< indent << "Number of nodes: " << foamData_->numberOfPoints() << "\n";
os<< indent << "Number of cells: " << foamData_->numberOfCells() << "\n";
os<< indent << "Number of time steps: " << foamData_->numberOfTimeSteps()
<< endl;
os<< indent << "Time step range: "
<< this->TimeStepRange[0] << " - " << this->TimeStepRange[1]
<< endl;
os<< indent << "Time step: " << this->TimeStep << endl;
return;
}
vtkDataArraySelection* vtkPV3FoamReader::GetTimeSelection()
{
vtkDebugMacro(<<"GetTimeSelection");
return TimeSelection;
}
int vtkPV3FoamReader::GetNumberOfTimeArrays()
{
vtkDebugMacro(<<"GetNumberOf TimeArrays");
return TimeSelection->GetNumberOfArrays();
}
const char* vtkPV3FoamReader::GetTimeArrayName
(
int index
)
{
vtkDebugMacro(<<"GetTimeArrayName");
return TimeSelection->GetArrayName(index);
}
int vtkPV3FoamReader::GetTimeArrayStatus
(
const char* name
)
{
vtkDebugMacro(<<"GetTimeArrayStatus");
return TimeSelection->ArrayIsEnabled(name);
}
void vtkPV3FoamReader::SetTimeArrayStatus
(
const char* name,
int status
)
{
vtkDebugMacro(<<"SetTimeArrayStatus");
if (status)
{
TimeSelection->EnableArray(name);
}
else
{
TimeSelection->DisableArray(name);
}
}
vtkDataArraySelection* vtkPV3FoamReader::GetRegionSelection()
{
vtkDebugMacro(<<"GetRegionSelection");
return RegionSelection;
}
int vtkPV3FoamReader::GetNumberOfRegionArrays()
{
vtkDebugMacro(<<"GetNumberOfRegionArrays");
return RegionSelection->GetNumberOfArrays();
}
const char* vtkPV3FoamReader::GetRegionArrayName
(
int index
)
{
vtkDebugMacro(<<"GetRegionArrayName");
return RegionSelection->GetArrayName(index);
}
int vtkPV3FoamReader::GetRegionArrayStatus
(
const char* name
)
{
vtkDebugMacro(<<"GetRegionArrayStatus");
return RegionSelection->ArrayIsEnabled(name);
}
void vtkPV3FoamReader::SetRegionArrayStatus
(
const char* name,
int status
)
{
vtkDebugMacro(<<"SetRegionArrayStatus");
if(status)
{
RegionSelection->EnableArray(name);
}
else
{
RegionSelection->DisableArray(name);
}
}
vtkDataArraySelection* vtkPV3FoamReader::GetVolFieldSelection()
{
vtkDebugMacro(<<"GetVolFieldSelection");
return VolFieldSelection;
}
int vtkPV3FoamReader::GetNumberOfVolFieldArrays()
{
vtkDebugMacro(<<"GetNumberOfVolFieldArrays");
return VolFieldSelection->GetNumberOfArrays();
}
const char* vtkPV3FoamReader::GetVolFieldArrayName
(
int index
)
{
vtkDebugMacro(<<"GetVolFieldArrayName");
return VolFieldSelection->GetArrayName(index);
}
int vtkPV3FoamReader::GetVolFieldArrayStatus
(
const char* name
)
{
vtkDebugMacro(<<"GetVolFieldArrayStatus");
return VolFieldSelection->ArrayIsEnabled(name);
}
void vtkPV3FoamReader::SetVolFieldArrayStatus
(
const char* name,
int status
)
{
vtkDebugMacro(<<"SetVolFieldArrayStatus");
if (status)
{
VolFieldSelection->EnableArray(name);
}
else
{
VolFieldSelection->DisableArray(name);
}
}
vtkDataArraySelection* vtkPV3FoamReader::GetPointFieldSelection()
{
vtkDebugMacro(<<"GetPointFieldSelection");
return PointFieldSelection;
}
int vtkPV3FoamReader::GetNumberOfPointFieldArrays()
{
vtkDebugMacro(<<"GetNumberOfPointFieldArrays");
return PointFieldSelection->GetNumberOfArrays();
}
const char* vtkPV3FoamReader::GetPointFieldArrayName
(
int index
)
{
vtkDebugMacro(<<"GetPointFieldArrayName");
return PointFieldSelection->GetArrayName(index);
}
int vtkPV3FoamReader::GetPointFieldArrayStatus
(
const char* name
)
{
vtkDebugMacro(<<"GetPointFieldArrayStatus");
return PointFieldSelection->ArrayIsEnabled(name);
}
void vtkPV3FoamReader::SetPointFieldArrayStatus
(
const char* name,
int status
)
{
vtkDebugMacro(<<"SetPointFieldArrayStatus");
if (status)
{
PointFieldSelection->EnableArray(name);
}
else
{
PointFieldSelection->DisableArray(name);
}
}
vtkDataArraySelection* vtkPV3FoamReader::GetLagrangianFieldSelection()
{
vtkDebugMacro(<<"GetLagrangianFieldSelection");
return LagrangianFieldSelection;
}
int vtkPV3FoamReader::GetNumberOfLagrangianFieldArrays()
{
vtkDebugMacro(<<"GetNumberOfLagrangianFieldArrays");
return LagrangianFieldSelection->GetNumberOfArrays();
}
const char* vtkPV3FoamReader::GetLagrangianFieldArrayName
(
int index
)
{
vtkDebugMacro(<<"GetLagrangianFieldArrayName");
return LagrangianFieldSelection->GetArrayName(index);
}
int vtkPV3FoamReader::GetLagrangianFieldArrayStatus
(
const char* name
)
{
vtkDebugMacro(<<"GetLagrangianFieldArrayStatus");
return LagrangianFieldSelection->ArrayIsEnabled(name);
}
void vtkPV3FoamReader::SetLagrangianFieldArrayStatus
(
const char* name,
int status
)
{
vtkDebugMacro(<<"SetLagrangianFieldArrayStatus");
if (status)
{
LagrangianFieldSelection->EnableArray(name);
}
else
{
LagrangianFieldSelection->DisableArray(name);
}
}
void vtkPV3FoamReader::SelectionModifiedCallback
(
vtkObject*,
unsigned long,
void* clientdata,
void*
)
{
static_cast<vtkPV3FoamReader*>(clientdata)->SelectionModified();
}
void vtkPV3FoamReader::SelectionModified()
{
vtkDebugMacro(<<"SelectionModified");
Modified();
}

View File

@ -1,197 +0,0 @@
/*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: vtkPV3FoamReader.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 vtkPV3FoamReader - reads a dataset in OpenFOAM format
// .SECTION Description
// vtkPV3FoamReader creates an multiblock dataset. It reads a controlDict
// file, mesh information, and time dependent data. The controlDict file
// contains timestep information. The polyMesh folders contain mesh information
// The time folders contain transient data for the cells Each folder can
// contain any number of data files.
#ifndef __vtkPV3FoamReader_h
#define __vtkPV3FoamReader_h
#include "vtkMultiBlockDataSetAlgorithm.h"
// Foam forward declarations
namespace Foam
{
class vtkPV3Foam;
}
// VTK forward declarations
class vtkUnstructuredGrid;
class vtkPoints;
class vtkIntArray;
class vtkFloatArray;
class vtkDoubleArray;
class vtkDataArraySelection;
class vtkCallbackCommand;
class VTK_IO_EXPORT vtkPV3FoamReader
:
public vtkMultiBlockDataSetAlgorithm
{
public:
static vtkPV3FoamReader* New();
vtkTypeRevisionMacro
(
vtkPV3FoamReader,
vtkMultiBlockDataSetAlgorithm
);
void PrintSelf
(
ostream& os,
vtkIndent indent
);
// Description:
// Set/Get the filename.
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
// GUI update control
vtkSetMacro(UpdateGUI, int);
vtkGetMacro(UpdateGUI, int);
// FOAM mesh caching control
vtkSetMacro(CacheMesh, int);
vtkGetMacro(CacheMesh, int);
// FOAM read sets control
vtkSetMacro(IncludeSets, int);
vtkGetMacro(IncludeSets, int);
// FOAM patch names control
vtkSetMacro(ShowPatchNames, int);
vtkGetMacro(ShowPatchNames, int);
// Time-step slider control
vtkSetMacro(TimeStep, int);
vtkGetMacro(TimeStep, int);
vtkSetVector2Macro(TimeStepRange, int);
vtkGetVector2Macro(TimeStepRange, int);
// Time selection list control
vtkDataArraySelection* GetTimeSelection();
int GetNumberOfTimeArrays();
const char* GetTimeArrayName(int index);
int GetTimeArrayStatus(const char* name);
void SetTimeArrayStatus(const char* name, int status);
// Region selection list control
vtkDataArraySelection* GetRegionSelection();
int GetNumberOfRegionArrays();
const char* GetRegionArrayName(int index);
int GetRegionArrayStatus(const char* name);
void SetRegionArrayStatus(const char* name, int status);
// volField selection list control
vtkDataArraySelection* GetVolFieldSelection();
int GetNumberOfVolFieldArrays();
const char* GetVolFieldArrayName(int index);
int GetVolFieldArrayStatus(const char* name);
void SetVolFieldArrayStatus(const char* name, int status);
// pointField selection list control
vtkDataArraySelection* GetPointFieldSelection();
int GetNumberOfPointFieldArrays();
const char* GetPointFieldArrayName(int index);
int GetPointFieldArrayStatus(const char* name);
void SetPointFieldArrayStatus(const char* name, int status);
// lagrangianField selection list control
vtkDataArraySelection* GetLagrangianFieldSelection();
int GetNumberOfLagrangianFieldArrays();
const char* GetLagrangianFieldArrayName(int index);
int GetLagrangianFieldArrayStatus(const char* name);
void SetLagrangianFieldArrayStatus(const char* name, int status);
// 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:
vtkPV3FoamReader();
~vtkPV3FoamReader();
char* FileName;
virtual int RequestData
(
vtkInformation*,
vtkInformationVector**,
vtkInformationVector*
);
virtual int RequestInformation
(
vtkInformation*,
vtkInformationVector**,
vtkInformationVector*
);
// The observer to modify this object when the array selections
// are modified
vtkCallbackCommand* SelectionObserver;
private:
vtkPV3FoamReader(const vtkPV3FoamReader&); // Not implemented.
void operator=(const vtkPV3FoamReader&); // Not implemented.
//- Add patch names to the view
void addPatchNamesToView();
//- Remove patch names from the view
void removePatchNamesFromView();
int CacheMesh;
int IncludeSets;
int ShowPatchNames;
int UpdateGUI;
int UpdateGUIOld;
int TimeStep;
int TimeStepRange[2];
vtkDataArraySelection* TimeSelection;
vtkDataArraySelection* RegionSelection;
vtkDataArraySelection* VolFieldSelection;
vtkDataArraySelection* PointFieldSelection;
vtkDataArraySelection* LagrangianFieldSelection;
//BTX
Foam::vtkPV3Foam* foamData_;
//ETX
};
#endif

View File

@ -1,11 +0,0 @@
vtkPV3Foam.C
vtkPV3FoamAddVolumeMesh.C
vtkPV3FoamAddLagrangianMesh.C
vtkPV3FoamAddPatchMesh.C
vtkPV3FoamAddFaceSetMesh.C
vtkPV3FoamAddPointSetMesh.C
vtkPV3FoamUpdate.C
vtkPV3FoamUpdateInformation.C
vtkPV3FoamConvertMesh.C
LIB = $(FOAM_LIBBIN)/libvtkPV3Foam

View File

@ -1,17 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/meshTools/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../PV3FoamReader
LIB_LIBS = \
-lfiniteVolume \
-llagrangian \
-lmeshTools \
$(GLIBS)

View File

@ -1,803 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "vtkPV3Foam.H"
// Foam includes
#include "argList.H"
#include "Time.H"
#include "IOobjectList.H"
#include "fvMesh.H"
#include "vtkPV3FoamReader.h"
#include "patchZones.H"
// VTK includes
#include "vtkCharArray.h"
#include "vtkDataArraySelection.h"
#include "vtkDataSet.h"
#include "vtkFieldData.h"
#include "vtkInformation.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkRenderer.h"
#include "vtkTextActor.h"
#include "vtkTextProperty.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::vtkPV3Foam, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
#include "vtkPV3FoamAddFields.H"
#include "vtkPV3FoamUpdateInformationFields.H"
void Foam::vtkPV3Foam::AddToBlock
(
vtkMultiBlockDataSet* output,
unsigned int blockNo,
unsigned int datasetNo,
vtkDataSet* dataset,
const char* datasetName
)
{
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (blockDO && !block)
{
FatalErrorIn("Foam::vtkPV3Foam::AddToBlock")
<< "Block already has a vtkDataSet assigned to it" << nl << endl;
return;
}
if (!block)
{
block = vtkMultiBlockDataSet::New();
output->SetBlock(blockNo, block);
block->Delete();
}
block->SetBlock(datasetNo, dataset);
block->GetMetaData(datasetNo)->Set
(
vtkCompositeDataSet::NAME(), datasetName
);
}
vtkDataSet* Foam::vtkPV3Foam::GetDataSetFromBlock
(
vtkMultiBlockDataSet* output,
unsigned int blockNo,
unsigned int datasetNo
)
{
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block)
{
return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo));
}
return 0;
}
Foam::label Foam::vtkPV3Foam::GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
unsigned int blockNo
)
{
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block)
{
return block->GetNumberOfBlocks();
}
return 0;
}
void Foam::vtkPV3Foam::resetCounters()
{
// Reset data size counts
lagrangianDataSize_ = 0;
patchDataSize_ = 0;
cellSetDataSize_ = 0;
faceSetDataSize_ = 0;
pointSetDataSize_ = 0;
// Reset region ids
idRegionVolume_ = -1;
idRegionLagrangian_ = -1;
idRegionPatches_ = -1;
idRegionCellSets_ = -1;
idRegionFaceSets_ = -1;
idRegionPointSets_ = -1;
}
void Foam::vtkPV3Foam::SetBlockName
(
vtkMultiBlockDataSet* blocks,
const int id,
const char* name
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::setBlockName" << endl;
}
if (blocks->GetMetaData(id) != NULL)
{
blocks->GetMetaData(id)->Set(vtkCompositeDataSet::NAME(), name);
}
}
void Foam::vtkPV3Foam::setSelectedTime
(
Time& runTime,
vtkPV3FoamReader* reader
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::setSelectedTime" << endl;
}
// Get times list
instantList times = runTime.times();
int timeIndex = min(max(reader->GetTimeStep() + 1, 0), times.size() - 1);
// If this is the first call timeIndex will be 0 ("constant")
// so reset to the first time step if one exists and deselect every
// element of the selection array
if (timeIndex == 0)
{
timeIndex = min(1, times.size() - 1);
reader->GetTimeSelection()->DisableAllArrays();
}
label selectedTimeIndex = -1;
const label nSelectedTimes =
reader->GetTimeSelection()->GetNumberOfArrays();
// Choose latest time
for (label i=nSelectedTimes - 1; i>=0; i--)
{
if (reader->GetTimeSelection()->GetArraySetting(i))
{
word timeName = string::validate<word>
(
reader->GetTimeSelection()->GetArrayName(i)
);
forAll(times, j)
{
if (times[j].name() == timeName)
{
selectedTimeIndex = j;
break;
}
}
break;
}
}
if (selectedTimeIndex != -1)
{
timeIndex = min(selectedTimeIndex, times.size() - 1);
}
if (debug)
{
Info<< "Selecting time " << times[timeIndex].name() << endl;
}
runTime.setTime(times[timeIndex], timeIndex);
times = runTime.times();
// set time step slider range
reader->SetTimeStepRange(0, max(times.size() - 2, 0));
reader->SetTimeStep(timeIndex); // TODO - does nothing???
// reset the time steps ...
reader->GetTimeSelection()->RemoveAllArrays();
forAll (times, timeI)
{
reader->GetTimeSelection()->AddArray(times[timeI].name().c_str());
}
// Disable all the time selections (which are all selected by default) ...
reader->GetTimeSelection()->DisableAllArrays();
// But maintain the selection made previously
if (selectedTimeIndex != -1 && selectedTimeIndex < times.size())
{
reader->GetTimeSelection()->EnableArray
(times[selectedTimeIndex].name().c_str());
}
}
void Foam::vtkPV3Foam::updateSelectedRegions()
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::updateSelectedRegions" << endl;
}
const label nRegions = reader_->GetRegionSelection()->GetNumberOfArrays();
selectedRegions_.setSize(nRegions);
selectedRegionDatasetIds_.setSize(nRegions);
// Read the selected patches and add to the region list
for (int i=0; i<nRegions; i++)
{
selectedRegions_[i] = reader_->GetRegionSelection()
->GetArraySetting(i);
selectedRegionDatasetIds_[i] = -1;
if (debug)
{
Info<< "region" << i << " selected = " << selectedRegions_[i]
<< endl;
}
}
}
Foam::wordList Foam::vtkPV3Foam::getSelectedArrayEntries
(
vtkDataArraySelection* arraySelection
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::getSelectedArrayEntries" << endl;
}
const label nArrays = arraySelection->GetNumberOfArrays();
wordList selections(nArrays);
label j = 0;
for (label i=0; i<nArrays; i++)
{
if (arraySelection->GetArraySetting(i))
{
selections[j] = arraySelection->GetArrayName(i);
if (debug)
{
Info<< "Active array: " << selections[j] << " index: " << j
<< endl;
}
j++;
}
}
// Fill non-selected arrays with 'default' value
for (label k=j; k<nArrays; k++)
{
selections[k] = "undefinedArrayEntry";
}
return selections;
}
void Foam::vtkPV3Foam::setSelectedArrayEntries
(
vtkDataArraySelection* arraySelection,
const wordList& selectedEntries
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::setSelectedArrayEntries" << endl;
}
const label nEntries = arraySelection->GetNumberOfArrays();
// Reset all current entries to 'not selected'
arraySelection->DisableAllArrays();
// Loop through entries, setting values from selectedEntries
forAll (selectedEntries, entryI)
{
if (debug)
{
Info<< "selectedEntries[entryI] = " << selectedEntries[entryI]
<< endl;
}
for (label i=0; i<nEntries; i++)
{
const word arrayName = string::validate<word>
(
arraySelection->GetArrayName(i)
);
if (arrayName == selectedEntries[entryI])
{
if (debug)
{
Info<< "enabling array: " << arrayName << " Index = " << i
<< endl;
}
arraySelection->EnableArray
(
arrayName.c_str()
);
break;
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::vtkPV3Foam::vtkPV3Foam
(
const char* const FileName,
vtkPV3FoamReader* reader,
vtkMultiBlockDataSet* output
)
:
reader_(reader),
argsPtr_(NULL),
dbPtr_(NULL),
meshPtr_(NULL),
patchTextActorsPtrs_(0),
nMesh_(0)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::vtkPV3Foam" << endl;
}
// Set paths
fileName fullCasePath(fileName(FileName).path());
if (!dir(fullCasePath))
{
return;
}
char* argvStrings[3];
argvStrings[0] = new char[12];
strcpy(argvStrings[0], "/vtkPV3Foam");
argvStrings[1] = new char[6];
strcpy(argvStrings[1], "-case");
argvStrings[2] = new char[fullCasePath.size() + 1];
strcpy(argvStrings[2], fullCasePath.c_str());
int argc = 3;
char** argv = &argvStrings[0];
argsPtr_.reset(new argList(argc, argv));
for (int i=0; i<argc; i++)
{
delete[] argvStrings[i];
}
// Create time object
dbPtr_.reset
(
new Time
(
Time::controlDictName,
argsPtr_().rootPath(),
argsPtr_().caseName()
)
);
dbPtr_().functionObjects().off();
resetCounters();
// Set initial cloud name
// TODO - TEMPORARY MEASURE UNTIL CAN PROCESS MULTIPLE CLOUDS
cloudName_ = "cloud1";
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::vtkPV3Foam::~vtkPV3Foam()
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::~vtkPV3Foam" << endl;
}
if (meshPtr_)
{
delete meshPtr_;
meshPtr_ = NULL;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::UpdateInformation()
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::UpdateInformation" << nl
<< "TimeStep = " << reader_->GetTimeStep() << endl;
}
resetCounters();
const wordList selectedArrayEntries = getSelectedArrayEntries
(
reader_->GetRegionSelection()
);
// Clear current region list/array
reader_->GetRegionSelection()->RemoveAllArrays();
// Set current time
setSelectedTime(dbPtr_(), reader_);
// Update region array
updateInformationInternalMesh();
updateInformationLagrangian();
updateInformationPatches();
if (reader_->GetIncludeSets())
{
updateInformationSets();
}
// Update region selection with the data just read in
setSelectedArrayEntries
(
reader_->GetRegionSelection(),
selectedArrayEntries
);
// Update volField array
updateInformationFields<fvPatchField, volMesh>
(
reader_->GetVolFieldSelection()
);
// Update pointField array
updateInformationFields<pointPatchField, pointMesh>
(
reader_->GetPointFieldSelection()
);
// Update lagrangian field array
updateInformationLagrangianFields();
}
void Foam::vtkPV3Foam::Update
(
vtkMultiBlockDataSet* output
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::Update" << endl;
}
// Set up region selection(s)
updateSelectedRegions();
// Update the Foam mesh
updateFoamMesh();
// Convert meshes
convertMeshVolume(output);
convertMeshLagrangian(output);
convertMeshPatches(output);
if (reader_->GetIncludeSets())
{
convertMeshCellSet(output);
convertMeshFaceSet(output);
convertMeshPointSet(output);
}
// Update fields
updateVolFields(output);
updatePointFields(output);
updateLagrangianFields(output);
if (debug)
{
Info<< "Number of data sets after update" << nl
<< " VOLUME = " << GetNumberOfDataSets(output, VOLUME) << nl
<< " LAGRANGIAN = " << GetNumberOfDataSets(output, LAGRANGIAN)
<< nl << " CELLSET = " << GetNumberOfDataSets(output, CELLSET)
<< nl << " FACESET = " << GetNumberOfDataSets(output, FACESET)
<< nl << " POINTSET = " << GetNumberOfDataSets(output, POINTSET)
<< endl;
}
}
double* Foam::vtkPV3Foam::timeSteps()
{
if (dbPtr_.valid())
{
const instantList foamTimes =
dbPtr_().findTimes(dbPtr_().path().path());
double* ts = new double[foamTimes.size()];
for (int i = 0; i < foamTimes.size(); i++)
{
ts[i] = foamTimes[i].value();
if (debug)
{
Info<< "found time = " << ts[i] << endl;
}
}
return ts;
}
else
{
return NULL;
}
}
void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer)
{
if (debug)
{
Info<< "addPatchNames()" << endl;
}
// Remove any patch names previously added to the renderer
removePatchNames(renderer);
const fvMesh& mesh = *meshPtr_;
const polyBoundaryMesh& pbMesh = mesh.boundaryMesh();
// Find the total number of zones
// Each zone will take the patch name
// Number of zones per patch
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 (reader_->GetRegionArrayStatus(pp.name().c_str()) == 1)
{
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() != 2)
{
featEdge[edgeI] = true;
}
else if (mag(n[eFaces[0]] & n[eFaces[1]]) < 0.5)
{
featEdge[edgeI] = true;
}
}
// Do topological analysis of patch. Determine 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];
}
}
}
zoneCentre.shrink();
if (debug)
{
Info<< "patch zone centres = " << zoneCentre << endl;
Info<< "zones per patch = " << nZones << endl;
}
// Set the size of the patch labels to max number of zones
patchTextActorsPtrs_.setSize(zoneCentre.size());
if (debug)
{
Info<< "constructing patch labels" << endl;
}
label globalZoneI = 0;
forAll(pbMesh, patchI)
{
const polyPatch& pp = pbMesh[patchI];
if (reader_->GetRegionArrayStatus(pp.name().c_str()) == 1)
{
for (label i=0; i<nZones[patchI]; i++)
{
if (debug)
{
Info<< "patch name = " << pp.name() << endl;
Info<< "anchor = " << zoneCentre[globalZoneI] << endl;
Info<< "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(20);
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_[globalZoneI] = txt;
globalZoneI++;
}
}
}
// Resize the patch names list to the actual number of patch names added
patchTextActorsPtrs_.setSize(globalZoneI);
}
void Foam::vtkPV3Foam::removePatchNames(vtkRenderer* renderer)
{
if (debug)
{
Info<< "removePatchNames()" << endl;
}
forAll(patchTextActorsPtrs_, patchI)
{
renderer->RemoveViewProp(patchTextActorsPtrs_[patchI]);
}
patchTextActorsPtrs_.setSize(0);
}
int Foam::vtkPV3Foam::numberOfTimeSteps()
{
if (dbPtr_.valid())
{
return dbPtr_().times().size();
}
else
{
return 0;
}
}
int Foam::vtkPV3Foam::numberOfPoints()
{
if (meshPtr_)
{
return meshPtr_->nPoints();
}
else
{
return 0;
}
}
int Foam::vtkPV3Foam::numberOfCells()
{
if (meshPtr_)
{
return meshPtr_->nCells();
}
{
return 0;
}
}
int Foam::vtkPV3Foam::numberOfMeshes() const
{
return nMesh_;
}
// ************************************************************************* //

View File

@ -1,568 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
vtkPV3Foam
Description
SourceFiles
interpolatePointToCell.C
interpolatePointToCell.H
vtkPV3Foam.C
vtkPV3Foam.H
vtkPV3FoamAddFaceSetMesh.C
vtkPV3FoamAddFields.H
vtkPV3FoamAddLagrangianMesh.C
vtkPV3FoamAddPatchMesh.C
vtkPV3FoamAddPointSetMesh.C
vtkPV3FoamAddVolumeMesh.C
vtkPV3FoamConvertLagrangianFields.H
vtkPV3FoamConvertMesh.C
vtkPV3FoamConvertPatchFaceField.H
vtkPV3FoamConvertPatchPointField.H
vtkPV3FoamConvertPointFields.H
vtkPV3FoamConvertVolFields.H
vtkPV3FoamInsertNextPoint.H
vtkPV3FoamUpdate.C
vtkPV3FoamUpdateInformation.C
vtkPV3FoamUpdateInformationFields.H
// Needed by VTK?
vtkDataArrayTemplateImplicit.txx
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3Foam_H
#define vtkPV3Foam_H
#include "className.H"
#include "fileName.H"
#include "volPointInterpolation.H"
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
class vtkDataArraySelection;
class vtkDataSet;
class vtkMultiBlockDataSet;
class vtkPoints;
class vtkPV3FoamReader;
class vtkRenderer;
class vtkTextActor;
class vtkUnstructuredGrid;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Foam class forward declarations
class argList;
class Time;
class fvMesh;
class IOobjectList;
class polyPatch;
class faceSet;
class pointSet;
class WordList;
template<class Type>
class IOField;
template<class Type>
class List;
/*---------------------------------------------------------------------------*\
Class vtkPV3Foam Declaration
\*---------------------------------------------------------------------------*/
class vtkPV3Foam
{
// Private data
//BTX
//- Indices for datasets in vtkMultiBlockDataSet
enum
{
VOLUME = 0, // internal mesh AND patches
LAGRANGIAN = 1,
CELLSET = 2,
FACESET = 3,
POINTSET = 4
};
//ETX
//- Indices of (first instance of) various regions
int idRegionVolume_;
int idRegionLagrangian_;
int idRegionPatches_;
int idRegionCellSets_;
int idRegionFaceSets_;
int idRegionPointSets_;
//- Access to the controlling vtkPV3FoamReader
vtkPV3FoamReader* reader_;
//- Selected regions
// [0] = internal mesh, then lagrangian, patches, and sets
boolList selectedRegions_;
//- Selected regions indices in each respective block
labelList selectedRegionDatasetIds_;
//- Foam argument handler
autoPtr<argList> argsPtr_;
//- Path to root and case
fileName rootPath_;
fileName casePath_;
//- Foam time control
autoPtr<Time> dbPtr_;
//- Foam mesh
fvMesh* meshPtr_;
//- Labels of cell-centres used as additional points when decomposing
// polyhedra
labelList addPointCellLabels_;
//- Label of original cell the decomposed cells are split from
// - internal mesh
labelList superCells_;
//- Label of original cell the decomposed cells are split from
// - cell set meshes
List<labelList> superCellSetCells_;
//- List of patch names
List<vtkTextActor*> patchTextActorsPtrs_;
// Dataset sizes
//- Number of meshes
// TODO - for info only - only set up to process ONE mesh
int nMesh_;
//- Lagrangian data size (i.e. 0 or 1)
int lagrangianDataSize_;
//- Cloud name to be processed
// TODO - currently only set up to process ONE cloud
word cloudName_;
//- Patch data size, 0 to n
int patchDataSize_;
//- Cell set data size, 0 to n
int cellSetDataSize_;
//- Face set data size, 0 to n
int faceSetDataSize_;
//- Point set data size, 0 to n
int pointSetDataSize_;
// Private Member Functions
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
void AddToBlock
(
vtkMultiBlockDataSet* output,
unsigned int blockNo,
unsigned int datasetNo,
vtkDataSet* dataset,
const char* datasetName
);
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
vtkDataSet* GetDataSetFromBlock
(
vtkMultiBlockDataSet* output,
unsigned int blockNo,
unsigned int datasetNo
);
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
label GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
unsigned int blockNo
);
//- Reset data counters
void resetCounters();
//- Find and set the selected time from all the methods of selection
static void setSelectedTime
(
Time& runTime,
vtkPV3FoamReader* reader
);
// Update information helper functions
//- Update the regions selected in the GUI
void updateSelectedRegions();
//- Internal mesh info
void updateInformationInternalMesh();
//- Lagrangian info
void updateInformationLagrangian();
//- Patch info
void updateInformationPatches();
//- Set info
void updateInformationSets();
//- Field info
template<template<class> class patchType, class meshType>
void updateInformationFields
(
vtkDataArraySelection *fieldSelection
);
//- Lagrangian field info
void updateInformationLagrangianFields();
// Update helper functions
//- Foam mesh
void updateFoamMesh();
//- Volume fields
void updateVolFields(vtkMultiBlockDataSet* output);
//- Point fields
void updatePointFields(vtkMultiBlockDataSet* output);
//- Lagrangian fields
void updateLagrangianFields(vtkMultiBlockDataSet* output);
// Mesh conversion functions
//- Volume mesh
void convertMeshVolume(vtkMultiBlockDataSet* output);
//- Lagrangian mesh
void convertMeshLagrangian(vtkMultiBlockDataSet* output);
//- Patch meshes
void convertMeshPatches(vtkMultiBlockDataSet* output);
//- Cell set meshes
void convertMeshCellSet(vtkMultiBlockDataSet* output);
//- Face set meshes
void convertMeshFaceSet(vtkMultiBlockDataSet* output);
//- Point set meshes
void convertMeshPointSet(vtkMultiBlockDataSet* output);
// Add mesh functions
//- Add internal mesh/cell set meshes
void addVolumeMesh
(
const fvMesh& mesh,
vtkUnstructuredGrid* vtkMesh,
labelList& superCells
);
//- Add Lagrangian mesh
void addLagrangianMesh
(
const fvMesh& mesh,
vtkUnstructuredGrid* vtkMesh
);
//- Add patch mesh
void addPatchMesh
(
const polyPatch& p,
vtkUnstructuredGrid* vtkMesh
);
//- Add cell set mesh
void addCellSetMesh
(
const fvMesh& mesh,
vtkUnstructuredGrid* vtkMesh
);
//- Add face set mesh
void addFaceSetMesh
(
const fvMesh& mesh,
const faceSet& fSet,
vtkUnstructuredGrid* vtkMesh
);
//- Add point mesh
void addPointSetMesh
(
const fvMesh& mesh,
const pointSet& pSet,
vtkUnstructuredGrid* vtkMesh
);
//- Add the fields in the selected time directory to the selection
// lists
template<class GeoField>
void addFields
(
vtkDataArraySelection* fieldSelection,
const IOobjectList& objects
);
// Convert Foam fields
//- Volume fields - all types
template<class Type>
void convertVolFields
(
const fvMesh& mesh,
const volPointInterpolation& pInterp,
const IOobjectList& objects,
vtkDataArraySelection* fieldSelection,
vtkMultiBlockDataSet* output
);
//- Volume field - all types except scalar
template<class Type>
void convertVolField
(
const GeometricField<Type, fvPatchField, volMesh>& tf,
vtkMultiBlockDataSet* output
);
//- Patch field
template<class Type>
void convertPatchFaceField
(
const word& name,
const Field<Type>& tf,
const label regioni,
vtkMultiBlockDataSet* output
);
//- Lagrangian fields - all types
template<class Type>
void convertLagrangianFields
(
const fvMesh& mesh,
const IOobjectList& objects,
vtkDataArraySelection *fieldSelection,
vtkMultiBlockDataSet* output
);
//- Lagrangian field - all types except scalar
template<class Type>
void convertLagrangianField
(
const IOField<Type>& tf,
vtkMultiBlockDataSet* output
);
//- Point fields - all types
template<class Type>
void convertPointFields
(
const fvMesh& mesh,
const IOobjectList& objects,
vtkDataArraySelection *fieldSelection,
vtkMultiBlockDataSet* output
);
//- Point fields - all types except scalar
template<class Type>
void convertPointField
(
const GeometricField<Type, pointPatchField, pointMesh>& ptf,
const GeometricField<Type, fvPatchField, volMesh>& tf,
vtkMultiBlockDataSet* output
);
//- Patch point field - all types except scalar
template<class Type>
void convertPatchPointField
(
const word& name,
const Field<Type>& tf,
const label regioni,
vtkMultiBlockDataSet* output
);
// GUI selection helper functions
//- Store selection(s)
wordList getSelectedArrayEntries
(
vtkDataArraySelection* arraySelection
);
//- Set selection(s)
void setSelectedArrayEntries
(
vtkDataArraySelection* arraySelection,
const wordList& selectedEntries
);
//- Set the name of the block
void SetBlockName
(
vtkMultiBlockDataSet* blocks,
const int id,
const char* name
);
//- Disallow default bitwise copy construct
vtkPV3Foam(const vtkPV3Foam&);
//- Disallow default bitwise assignment
void operator=(const vtkPV3Foam&);
public:
//- Static data members
ClassName("vtkPV3Foam");
// Constructors
//- Construct from components
vtkPV3Foam
(
const char* const FileName,
vtkPV3FoamReader* reader,
vtkMultiBlockDataSet* output
);
//- Destructor
~vtkPV3Foam();
// Member Functions
void UpdateInformation();
void Update(vtkMultiBlockDataSet* output);
double* timeSteps();
//- Add patch names to the display
void addPatchNames(vtkRenderer* renderer);
//- Remove patch names from the display
void removePatchNames(vtkRenderer* renderer);
// Access
int numberOfTimeSteps();
int numberOfCells();
int numberOfPoints();
int numberOfMeshes() const;
};
// * * * * * * * * * * * * * Template Specialisations * * * * * * * * * * * //
template<>
void vtkPV3Foam::convertVolField
(
const GeometricField<scalar, fvPatchField, volMesh>& sf,
vtkMultiBlockDataSet* output
);
template<>
void vtkPV3Foam::convertPatchFaceField
(
const word& name,
const Field<scalar>& sf,
const label regioni,
vtkMultiBlockDataSet* output
);
template<>
void vtkPV3Foam::convertPointField
(
const GeometricField<scalar, pointPatchField, pointMesh>& psf,
const GeometricField<scalar, fvPatchField, volMesh>& sf,
vtkMultiBlockDataSet* output
);
template<>
void vtkPV3Foam::convertPatchPointField
(
const word& name,
const Field<scalar>& sf,
const label regioni,
vtkMultiBlockDataSet* output
);
template<>
void vtkPV3Foam::convertLagrangianField
(
const IOField<scalar>& sf,
vtkMultiBlockDataSet* output
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,102 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "faceSet.H"
#include "vtkPV3FoamInsertNextPoint.H"
// VTK includes
#include "vtkPoints.h"
#include "vtkPolygon.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::addFaceSetMesh
(
const fvMesh& mesh,
const faceSet& fSet,
vtkUnstructuredGrid* vtkMesh
)
{
if (debug)
{
Info<< "entered add face set internal mesh" << endl;
}
// Construct primitivePatch of faces in fSet.
const faceList& faces = mesh.faces();
faceList setFaces(fSet.size());
label setFaceI = 0;
forAllConstIter(faceSet, fSet, iter)
{
setFaces[setFaceI++] = faces[iter.key()];
}
primitiveFacePatch fp(setFaces, mesh.points());
// Add face points
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(fp.size());
forAll(fp.localPoints(), i)
{
vtkPV3FoamInsertNextPoint(vtkpoints, fp.localPoints()[i]);
}
// Add faces as polygons
vtkMesh->Allocate(fp.size());
forAll(fp.localFaces(), faceI)
{
const face& f = fp.localFaces()[faceI];
vtkIdType nodeIds[f.size()];
for (int j=0; j<f.size(); j++)
{
nodeIds[j] = f[j];
}
vtkMesh->InsertNextCell
(
VTK_POLYGON,
f.size(),
nodeIds
);
}
vtkMesh->SetPoints(vtkpoints);
vtkpoints->Delete();
}
// ************************************************************************* //

View File

@ -1,58 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamAddFields_H
#define vtkPV3FoamAddFields_H
// VTK includes
#include "vtkDataArraySelection.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class GeoField>
void Foam::vtkPV3Foam::addFields
(
vtkDataArraySelection *fieldSelection,
const IOobjectList& objects
)
{
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
forAllConstIter(IOobjectList, fieldObjects, iter)
{
fieldSelection->AddArray(iter()->name().c_str());
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,92 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "Cloud.H"
#include "fvMesh.H"
#include "passiveParticle.H"
#include "vtkPV3FoamInsertNextPoint.H"
#include "IOobjectList.H"
// Foam includes
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::addLagrangianMesh
(
const fvMesh& mesh,
vtkUnstructuredGrid* vtkMesh
)
{
if (debug)
{
Info<< "entered add Lagrangian mesh" << endl;
}
fileNameList cloudDirs
(
readDir(mesh.time().timePath()/"lagrangian", fileName::DIRECTORY)
);
bool foundCloud = false;
forAll(cloudDirs, i)
{
IOobjectList sprayObjs
(
mesh,
mesh.time().timeName(),
"lagrangian"/cloudDirs[i]
);
IOobject* positionsPtr = sprayObjs.lookup("positions");
if (positionsPtr && !foundCloud)
{
foundCloud = true;
Cloud<passiveParticle> parcels(mesh, cloudDirs[i], false);
vtkPoints* vtkpoints = vtkPoints::New();
vtkpoints->Allocate(parcels.size());
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
{
vtkPV3FoamInsertNextPoint(vtkpoints, elmnt().position());
}
vtkMesh->SetPoints(vtkpoints);
vtkpoints->Delete();
}
}
}
// ************************************************************************* //

View File

@ -1,129 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "polyPatch.H"
#include "vtkPV3FoamInsertNextPoint.H"
// VTK includes
#include "vtkCellArray.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::addPatchMesh
(
const polyPatch& p,
vtkUnstructuredGrid *vtkPatch
)
{
if (debug)
{
Info<< "Adding patch: " << p.name() << endl;
}
if (debug)
{
Info<< "converting points" << endl;
}
const Foam::pointField& points = p.localPoints();
// Convert Foam mesh vertices to VTK
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(points.size());
forAll(points, i)
{
vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
}
if (debug)
{
Info<< "converting faces" << endl;
}
const faceList& faces = p.localFaces();
vtkPatch->Allocate(faces.size());
forAll(faces, facei)
{
const face& f = faces[facei];
vtkIdType nodeIds[f.size()];
if (f.size() == 3)
{
for (int j=0; j<3; j++)
{
nodeIds[j] = f[j];
}
vtkPatch->InsertNextCell
(
VTK_TRIANGLE,
3,
nodeIds
);
}
else if (f.size() == 4)
{
for (int j=0; j<4; j++)
{
nodeIds[j] = f[j];
}
vtkPatch->InsertNextCell
(
VTK_QUAD,
4,
nodeIds
);
}
else
{
for (int j=0; j<f.size(); j++)
{
nodeIds[j] = f[j];
}
vtkPatch->InsertNextCell
(
VTK_POLYGON,
f.size(),
nodeIds
);
}
}
vtkPatch->SetPoints(vtkpoints);
vtkpoints->Delete();
}
// ************************************************************************* //

View File

@ -1,66 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::addPointSetMesh
(
const fvMesh& mesh,
const pointSet& pSet,
vtkUnstructuredGrid* vtkMesh
)
{
if (debug)
{
Info<< "entered add point set mesh" << endl;
}
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(mesh.nPoints());
forAllConstIter(pointSet, pSet, iter)
{
vtkPV3FoamInsertNextPoint(vtkpoints, mesh.points()[iter.key()]);
}
vtkMesh->SetPoints(vtkpoints);
vtkpoints->Delete();
}
// ************************************************************************* //

View File

@ -1,360 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamAddVolumeMesh_H
#define vtkPV3FoamAddVolumeMesh_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "vtkPV3Foam.H"
// Foam includes
#include "fvMesh.H"
#include "cellModeller.H"
#include "vtkPV3FoamInsertNextPoint.H"
// VTK includes
#include "vtkCellArray.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::addVolumeMesh
(
const fvMesh& mesh,
vtkUnstructuredGrid* vtkMesh,
labelList& superCells
)
{
if (debug)
{
Info<< "entered add volume mesh" << endl;
}
// Number of additional points needed by the decomposition of polyhedra
label nAddPoints = 0;
// Number of additional cells generated by the decomposition of polyhedra
label nAddCells = 0;
const cellModel& tet = *(cellModeller::lookup("tet"));
const cellModel& pyr = *(cellModeller::lookup("pyr"));
const cellModel& prism = *(cellModeller::lookup("prism"));
const cellModel& wedge = *(cellModeller::lookup("wedge"));
const cellModel& tetWedge = *(cellModeller::lookup("tetWedge"));
const cellModel& hex = *(cellModeller::lookup("hex"));
// Scan for cells which need to be decomposed and count additional points
// and cells
if (debug)
{
Info<< "building cell-shapes" << endl;
}
const cellShapeList& cellShapes = mesh.cellShapes();
if (debug)
{
Info<< "scanning" << endl;
}
forAll(cellShapes, cellI)
{
const cellModel& model = cellShapes[cellI].model();
if
(
model != hex
&& model != wedge
&& model != prism
&& model != pyr
&& model != tet
&& model != tetWedge
)
{
const cell& cFaces = mesh.cells()[cellI];
forAll(cFaces, cFaceI)
{
const face& f = mesh.faces()[cFaces[cFaceI]];
label nFacePoints = f.size();
label nQuads = (nFacePoints - 2)/2;
label nTris = (nFacePoints - 2)%2;
nAddCells += nQuads + nTris;
}
nAddCells--;
nAddPoints++;
}
}
// Set size of additional point addressing array
// (from added point to original cell)
addPointCellLabels_.setSize(nAddPoints);
// Set size of additional cells mapping array
// (from added cell to original cell)
if (debug)
{
Info<<"mesh.nCells() = " << mesh.nCells() << nl
<<"mesh.nPoints() = " << mesh.nPoints() << nl
<<"nAddCells = " << nAddCells << nl
<<"nAddPoints = " << nAddPoints << endl;
}
superCells.setSize(mesh.nCells() + nAddCells);
if (debug)
{
Info<< "converting points" << endl;
}
// Convert Foam mesh vertices to VTK
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(mesh.nPoints() + nAddPoints);
const Foam::pointField& points = mesh.points();
forAll(points, i)
{
vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
}
if (debug)
{
Info<< "converting cells" << endl;
}
vtkMesh->Allocate(mesh.nCells() + nAddCells);
// Set counters for additional points and additional cells
label api = 0, aci = 0;
// Create storage for points - needed for mapping from Foam to VTK
// data types - max 'order' = hex = 8 points
vtkIdType nodeIds[8];
forAll(cellShapes, celli)
{
const cellShape& cellShape = cellShapes[celli];
const cellModel& cellModel = cellShape.model();
superCells[aci++] = celli;
if (cellModel == tet)
{
for (int j = 0; j < 4; j++)
{
nodeIds[j] = cellShape[j];
}
vtkMesh->InsertNextCell
(
VTK_TETRA,
4,
nodeIds
);
}
else if (cellModel == pyr)
{
for (int j = 0; j < 5; j++)
{
nodeIds[j] = cellShape[j];
}
vtkMesh->InsertNextCell
(
VTK_PYRAMID,
5,
nodeIds
);
}
else if (cellModel == prism)
{
for (int j = 0; j < 6; j++)
{
nodeIds[j] = cellShape[j];
}
vtkMesh->InsertNextCell
(
VTK_WEDGE,
6,
nodeIds
);
}
else if (cellModel == tetWedge)
{
// Treat as squeezed prism
nodeIds[0] = cellShape[0];
nodeIds[1] = cellShape[2];
nodeIds[2] = cellShape[1];
nodeIds[3] = cellShape[3];
nodeIds[4] = cellShape[4];
nodeIds[5] = cellShape[4];
vtkMesh->InsertNextCell
(
VTK_WEDGE,
6,
nodeIds
);
}
else if (cellModel == wedge)
{
// Treat as squeezed hex
nodeIds[0] = cellShape[0];
nodeIds[1] = cellShape[1];
nodeIds[2] = cellShape[2];
nodeIds[3] = cellShape[2];
nodeIds[4] = cellShape[3];
nodeIds[5] = cellShape[4];
nodeIds[6] = cellShape[5];
nodeIds[7] = cellShape[6];
vtkMesh->InsertNextCell
(
VTK_HEXAHEDRON,
8,
nodeIds
);
}
else if (cellModel == hex)
{
for (int j = 0; j < 8; j++)
{
nodeIds[j] = cellShape[j];
}
vtkMesh->InsertNextCell
(
VTK_HEXAHEDRON,
8,
nodeIds
);
}
else
{
// Polyhedral cell. Decompose into tets + prisms.
// Mapping from additional point to cell
addPointCellLabels_[api] = celli;
// Insert the new vertex from the cell-centre
label newVertexLabel = mesh.nPoints() + api;
vtkPV3FoamInsertNextPoint(vtkpoints, mesh.C()[celli]);
// Whether to insert cell in place of original or not.
bool substituteCell = true;
const labelList& cFaces = mesh.cells()[celli];
forAll(cFaces, cFaceI)
{
const face& f = mesh.faces()[cFaces[cFaceI]];
label nFacePoints = f.size();
label nQuads = (nFacePoints - 2)/2;
label nTris = (nFacePoints - 2)%2;
label qpi = 0;
for (label quadi=0; quadi<nQuads; quadi++)
{
label thisCellI = -1;
if (substituteCell)
{
thisCellI = celli;
substituteCell = false;
}
else
{
thisCellI = mesh.nCells() + aci;
superCells[aci++] = celli;
}
nodeIds[0] = f[0];
nodeIds[1] = f[qpi + 1];
nodeIds[2] = f[qpi + 2];
nodeIds[3] = f[qpi + 3];
nodeIds[4] = newVertexLabel;
vtkMesh->InsertNextCell
(
VTK_PYRAMID,
5,
nodeIds
);
qpi += 2;
}
if (nTris)
{
label thisCellI = -1;
if (substituteCell)
{
thisCellI = celli;
substituteCell = false;
}
else
{
thisCellI = mesh.nCells() + aci;
superCells[aci++] = celli;
}
nodeIds[0] = f[0];
nodeIds[1] = f[qpi + 1];
nodeIds[2] = f[qpi + 2];
nodeIds[3] = newVertexLabel;
vtkMesh->InsertNextCell
(
VTK_TETRA,
4,
nodeIds
);
}
}
api++;
}
}
vtkMesh->SetPoints(vtkpoints);
vtkpoints->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,182 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamConvertLagrangianFields_H
#define vtkPV3FoamConvertLagrangianFields_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkPV3Foam::convertLagrangianFields
(
const fvMesh& mesh,
const IOobjectList& objects,
vtkDataArraySelection* fieldSelection,
vtkMultiBlockDataSet* output
)
{
if (!lagrangianDataSize_)
{
return;
}
if (!selectedRegions_[LAGRANGIAN])
{
return;
}
IOobjectList fieldObjects
(
objects.lookupClass
(
IOField<Type>::typeName
)
);
label nSelectedFields = fieldSelection->GetNumberOfArrays();
for (label i=0; i<nSelectedFields; i++)
{
if (fieldSelection->GetArraySetting(i))
{
const word fieldName = fieldSelection->GetArrayName(i);
if (fieldObjects.found(fieldName))
{
if (debug)
{
Info<< "converting Foam Lagrangian field: " << fieldName
<< endl;
}
IOField<Type> iotf
(
IOobject
(
fieldName,
mesh.time().timeName(),
"lagrangian"/cloudName_,
mesh,
IOobject::MUST_READ
)
);
convertLagrangianField(iotf, output);
}
}
}
}
template<class Type>
void Foam::vtkPV3Foam::convertLagrangianField
(
const IOField<Type>& tf,
vtkMultiBlockDataSet* output
)
{
vtkUnstructuredGrid* lagrangianMesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, LAGRANGIAN, 0)
);
vtkFloatArray *pointTypes = vtkFloatArray::New();
pointTypes->SetNumberOfTuples(tf.size());
pointTypes->SetNumberOfComponents(Type::nComponents);
pointTypes->Allocate(Type::nComponents*tf.size());
pointTypes->SetName(tf.name().c_str());
if (debug)
{
Info<< "converting Lagrangian <Type>Field: " << tf.name() << nl
<< "tf.size() = " << tf.size() << nl
<< "nComps = " << Type::nComponents << endl;
}
float vec[Type::nComponents];
forAll(tf, i)
{
for (direction d=0; d<Type::nComponents; d++)
{
vec[d] = tf[i][d];
}
pointTypes->InsertTuple(i, vec);
}
lagrangianMesh->GetPointData()->AddArray(pointTypes);
pointTypes->Delete();
}
template<>
void Foam::vtkPV3Foam::convertLagrangianField
(
const IOField<scalar>& sf,
vtkMultiBlockDataSet* output
)
{
vtkUnstructuredGrid* lagrangianMesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, LAGRANGIAN, 0)
);
vtkFloatArray *pointScalars = vtkFloatArray::New();
pointScalars->SetNumberOfTuples(sf.size());
pointScalars->SetNumberOfComponents(1);
pointScalars->Allocate(sf.size());
pointScalars->SetName(sf.name().c_str());
if (debug)
{
Info<< "converting Lagrangian scalarField: " << sf.name() << nl
<< "sf.size() = " << sf.size() << nl
<< "nComps = 1" << endl;
}
for (int i=0; i<sf.size(); i++)
{
pointScalars->InsertComponent(i, 0, sf[i]);
}
lagrangianMesh->GetPointData()->AddArray(pointScalars);
if (!lagrangianMesh->GetPointData()->GetScalars())
{
lagrangianMesh->GetPointData()->SetScalars(pointScalars);
}
pointScalars->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,313 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "cellSet.H"
#include "faceSet.H"
#include "fvMeshSubset.H"
#include "pointSet.H"
#include "vtkPV3FoamReader.h"
// VTK includes
#include "vtkDataArraySelection.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::vtkPV3Foam::convertMeshVolume
(
vtkMultiBlockDataSet* output
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::convertMeshVolume" << endl;
}
// Create the internal mesh and add as DataSet(VOLUME, 0)
if (selectedRegions_[VOLUME])
{
if (debug)
{
Info<< "Creating VTK internal mesh" << endl;
}
const fvMesh& mesh = *meshPtr_;
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
addVolumeMesh(mesh, ugrid, superCells_);
AddToBlock(output, VOLUME, 0, ugrid, "internalMesh");
SetBlockName(output, VOLUME, "Volume");
selectedRegionDatasetIds_[VOLUME] = 0;
ugrid->Delete();
}
}
void Foam::vtkPV3Foam::convertMeshLagrangian
(
vtkMultiBlockDataSet* output
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::convertMeshLagrangian" << endl;
}
// Create the Lagrangian mesh and add as DataSet(LAGRANGIAN, 0)
if (lagrangianDataSize_)
{
if (selectedRegions_[LAGRANGIAN])
{
if (debug)
{
Info<< "Creating VTK Lagrangian mesh" << endl;
}
const fvMesh& mesh = *meshPtr_;
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
addLagrangianMesh(mesh, ugrid);
AddToBlock(output, LAGRANGIAN, 0, ugrid, cloudName_.c_str());
SetBlockName(output, LAGRANGIAN, "Lagrangian");
selectedRegionDatasetIds_[LAGRANGIAN] = 0;
ugrid->Delete();
}
}
}
void Foam::vtkPV3Foam::convertMeshPatches
(
vtkMultiBlockDataSet* output
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::convertMeshPatches" << endl;
}
// Convert patches
if (patchDataSize_)
{
const fvMesh& mesh = *meshPtr_;
const polyBoundaryMesh& patches = mesh.boundaryMesh();
const label regionStartId = idRegionPatches_;
const label regionEndId = idRegionPatches_ + patchDataSize_ - 1;
// Create the patches and add as DataSet(VOLUME, ...)
for (int i=regionStartId; i<=regionEndId; i++)
{
if (selectedRegions_[i])
{
const word regionName = reader_->GetRegionSelection()
->GetArrayName(i);
if (debug)
{
Info<< "Creating VTK mesh for patch: " << regionName
<< " region index: " << i << endl;
}
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
const label patchId = mesh.boundaryMesh()
.findPatchID(regionName);
addPatchMesh(patches[patchId], ugrid);
const label nextId = GetNumberOfDataSets(output, VOLUME);
AddToBlock(output, VOLUME, nextId, ugrid, regionName.c_str());
selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete();
}
}
}
}
void Foam::vtkPV3Foam::convertMeshCellSet
(
vtkMultiBlockDataSet* output
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::convertMeshCellSet" << endl;
}
// Create the cell sets and add as DataSet(CELLSET, 0..n)
if (cellSetDataSize_)
{
const fvMesh& mesh = *meshPtr_;
const label regionStartId = idRegionCellSets_;
const label regionEndId = regionStartId + cellSetDataSize_ - 1;
for (int i=regionStartId; i<=regionEndId; i++)
{
if (selectedRegions_[i])
{
const word cSetName = reader_->GetRegionSelection()
->GetArrayName(i);
if (debug)
{
Info<< "Creating VTK mesh for cellSet: " << cSetName
<< " region index: " << i << endl;
}
const cellSet cSet(mesh, cSetName);
fvMeshSubset subsetter(mesh);
subsetter.setLargeCellSubset(cSet);
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
const label nextId = GetNumberOfDataSets(output, CELLSET);
addVolumeMesh
(
subsetter.subMesh(),
ugrid,
superCellSetCells_[nextId]
);
AddToBlock(output, CELLSET, nextId, ugrid, cSetName.c_str());
selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete();
}
}
SetBlockName(output, CELLSET, "CellSets");
}
}
void Foam::vtkPV3Foam::convertMeshFaceSet
(
vtkMultiBlockDataSet* output
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::convertMeshFaceSet" << endl;
}
// Create the face sets and add as DataSet(FACESET, 0..n)
if (faceSetDataSize_)
{
const fvMesh& mesh = *meshPtr_;
const label regionStartId = idRegionFaceSets_;
const label regionEndId = regionStartId + faceSetDataSize_ - 1;
for (int i=regionStartId; i<=regionEndId ; i++)
{
if (selectedRegions_[i])
{
const word fSetName = reader_->GetRegionSelection()
->GetArrayName(i);
if (debug)
{
Info<< "Creating VTK mesh for faceSet: " << fSetName
<< " region index: " << i << endl;
}
const faceSet fSet(mesh, fSetName);
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
addFaceSetMesh
(
mesh,
fSet,
ugrid
);
const label nextId = GetNumberOfDataSets(output, FACESET);
AddToBlock(output, FACESET, nextId, ugrid, fSetName.c_str());
selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete();
}
}
SetBlockName(output, FACESET, "FaceSets");
}
}
void Foam::vtkPV3Foam::convertMeshPointSet
(
vtkMultiBlockDataSet* output
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::convertMeshPointSet" << endl;
}
// Create the point sets and add as DataSet(POINTSET, 0..n)
if (pointSetDataSize_)
{
const fvMesh& mesh = *meshPtr_;
const label regionStartId = idRegionPointSets_;
const label regionEndId = regionStartId + pointSetDataSize_ - 1;
for (int i=regionStartId; i<=regionEndId ; i++)
{
if (selectedRegions_[i])
{
const word pSetName = reader_->GetRegionSelection()
->GetArrayName(i);
if (debug)
{
Info<< "Creating VTK mesh for pointSet: " << pSetName
<< " region index: " << i << endl;
}
const pointSet pSet(mesh, pSetName);
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
addPointSetMesh
(
mesh,
pSet,
ugrid
);
label nextId = GetNumberOfDataSets(output, POINTSET);
AddToBlock(output, POINTSET, nextId, ugrid, pSetName.c_str());
selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete();
}
}
SetBlockName(output, POINTSET, "PointSets");
}
}
// ************************************************************************* //

View File

@ -1,118 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamConvertPatchFaceField_H
#define vtkPV3FoamConvertPatchFaceField_H
// VTK includes
#include "vtkCellData.h"
#include "vtkFloatArray.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkUnstructuredGrid.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkPV3Foam::convertPatchFaceField
(
const word& name,
const Field<Type>& ptf,
const label regioni,
vtkMultiBlockDataSet* output
)
{
vtkUnstructuredGrid* vtkMesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, VOLUME, regioni)
);
vtkFloatArray *cellTypes = vtkFloatArray::New();
cellTypes->SetNumberOfTuples(ptf.size());
cellTypes->SetNumberOfComponents(Type::nComponents);
cellTypes->Allocate(Type::nComponents*ptf.size());
cellTypes->SetName(name.c_str());
float vec[Type::nComponents];
forAll(ptf, i)
{
const Type& t = ptf[i];
for (direction d=0; d<Type::nComponents; d++)
{
vec[d] = t[d];
}
cellTypes->InsertTuple(i, vec);
}
vtkMesh->GetCellData()->AddArray(cellTypes);
cellTypes->Delete();
}
template<>
void Foam::vtkPV3Foam::convertPatchFaceField
(
const word& name,
const Field<scalar>& psf,
const label regioni,
vtkMultiBlockDataSet* output
)
{
vtkUnstructuredGrid* vtkMesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, VOLUME, regioni)
);
vtkFloatArray *cellScalars = vtkFloatArray::New();
cellScalars->SetNumberOfTuples(psf.size());
cellScalars->SetNumberOfComponents(1);
cellScalars->Allocate(psf.size());
cellScalars->SetName(name.c_str());
forAll(psf, i)
{
cellScalars->InsertComponent(i, 0, psf[i]);
}
vtkMesh->GetCellData()->AddArray(cellScalars);
if (!vtkMesh->GetCellData()->GetScalars())
{
vtkMesh->GetCellData()->SetScalars(cellScalars);
}
cellScalars->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,114 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamConvertPatchPointField_H
#define vtkPV3FoamConvertPatchPointField_H
// VTK includes
#include "vtkPointData.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkPV3Foam::convertPatchPointField
(
const word& name,
const Field<Type>& pptf,
const label regioni,
vtkMultiBlockDataSet* output
)
{
vtkUnstructuredGrid* vtkMesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, VOLUME, regioni)
);
vtkFloatArray *pointTypes = vtkFloatArray::New();
pointTypes->SetNumberOfTuples(pptf.size());
pointTypes->SetNumberOfComponents(Type::nComponents);
pointTypes->Allocate(Type::nComponents*pptf.size());
pointTypes->SetName(name.c_str());
float vec[Type::nComponents];
forAll(pptf, i)
{
for (direction d=0; d<Type::nComponents; d++)
{
vec[d] = pptf[i][d];
}
pointTypes->InsertTuple(i, vec);
}
vtkMesh->GetPointData()->AddArray(pointTypes);
pointTypes->Delete();
}
template<>
void Foam::vtkPV3Foam::convertPatchPointField
(
const word& name,
const Field<scalar>& ppsf,
const label regioni,
vtkMultiBlockDataSet* output
)
{
vtkUnstructuredGrid* vtkMesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, VOLUME, regioni)
);
vtkFloatArray *pointScalars = vtkFloatArray::New();
pointScalars->SetNumberOfTuples(ppsf.size());
pointScalars->SetNumberOfComponents(1);
pointScalars->Allocate(ppsf.size());
pointScalars->SetName(name.c_str());
for (int i=0; i<ppsf.size(); i++)
{
pointScalars->InsertComponent(i, 0, ppsf[i]);
}
vtkMesh->GetPointData()->AddArray(pointScalars);
if (!vtkMesh->GetPointData()->GetScalars())
{
vtkMesh->GetPointData()->SetScalars(pointScalars);
}
pointScalars->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,255 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamConvertPointFields_H
#define vtkPV3FoamConvertPointFields_H
// Foam includes
#include "interpolatePointToCell.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkPV3Foam::convertPointFields
(
const fvMesh& mesh,
const IOobjectList& objects,
vtkDataArraySelection* fieldSelection,
vtkMultiBlockDataSet* output
)
{
IOobjectList fieldObjects
(
objects.lookupClass
(
GeometricField<Type, pointPatchField, pointMesh>::typeName
)
);
label nSelectedFields = fieldSelection->GetNumberOfArrays();
for (label i=0; i<nSelectedFields; i++)
{
if (fieldSelection->GetArraySetting(i))
{
word fieldName = fieldSelection->GetArrayName(i);
if (fieldObjects.found(fieldName))
{
if (debug)
{
Info<< "converting Foam point field: " << fieldName
<< endl;
}
pointMesh pMesh(mesh);
GeometricField<Type, pointPatchField, pointMesh> ptf
(
IOobject
(
fieldName,
mesh.time().timeName(),
mesh,
IOobject::MUST_READ
),
pMesh
);
// Convert internal mesh
if (selectedRegions_[0])
{
convertPointField
(
ptf,
GeometricField<Type, fvPatchField, volMesh>::null(),
output
);
}
// Convert patches
label regioni = idRegionPatches_;
forAll (mesh.boundaryMesh(), patchi)
{
if (mesh.boundaryMesh()[patchi].size())
{
if (selectedRegions_[regioni])
{
convertPatchPointField
(
ptf.name(),
ptf.boundaryField()[patchi]
.patchInternalField()(),
selectedRegionDatasetIds_[regioni],
output
);
}
regioni++;
}
}
}
}
}
}
template<class Type>
void Foam::vtkPV3Foam::convertPointField
(
const GeometricField<Type, pointPatchField, pointMesh>& ptf,
const GeometricField<Type, fvPatchField, volMesh>& tf,
vtkMultiBlockDataSet* output
)
{
vtkUnstructuredGrid* internalMesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, VOLUME, 0)
);
vtkFloatArray *pointTypes = vtkFloatArray::New();
pointTypes->SetNumberOfTuples(ptf.size() + addPointCellLabels_.size());
pointTypes->SetNumberOfComponents(Type::nComponents);
pointTypes->Allocate(Type::nComponents*ptf.size());
pointTypes->SetName(ptf.name().c_str());
float vec[Type::nComponents];
forAll(ptf, i)
{
for (direction d=0; d<Type::nComponents; d++)
{
vec[d] = ptf[i][d];
}
pointTypes->InsertTuple(i, vec);
}
label i = ptf.size();
if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null())
{
forAll(addPointCellLabels_, api)
{
Type t = tf[addPointCellLabels_[api]];
for (direction d=0; d<Type::nComponents; d++)
{
vec[d] = t[d];
}
pointTypes->InsertTuple(i++, vec);
}
}
else
{
forAll(addPointCellLabels_, api)
{
Type t = interpolatePointToCell(ptf, addPointCellLabels_[api]);
for (direction d=0; d<Type::nComponents; d++)
{
vec[d] = t[d];
}
pointTypes->InsertTuple(i++, vec);
}
}
internalMesh->GetPointData()->AddArray(pointTypes);
pointTypes->Delete();
}
template<>
void Foam::vtkPV3Foam::convertPointField
(
const GeometricField<scalar, pointPatchField, pointMesh>& psf,
const GeometricField<scalar, fvPatchField, volMesh>& sf,
vtkMultiBlockDataSet* output
)
{
vtkUnstructuredGrid* internalMesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, VOLUME, 0)
);
vtkFloatArray *pointScalars = vtkFloatArray::New();
pointScalars->SetNumberOfTuples(psf.size() + addPointCellLabels_.size());
pointScalars->SetNumberOfComponents(1);
pointScalars->Allocate(psf.size());
pointScalars->SetName(psf.name().c_str());
for (int i=0; i<psf.size(); i++)
{
pointScalars->InsertComponent(i, 0, psf[i]);
}
label i = psf.size();
if (&sf != &GeometricField<scalar, fvPatchField, volMesh>::null())
{
forAll(addPointCellLabels_, api)
{
pointScalars->InsertComponent
(
i++,
0,
sf[addPointCellLabels_[api]]
);
}
}
else
{
forAll(addPointCellLabels_, api)
{
pointScalars->InsertComponent
(
i++,
0,
interpolatePointToCell(psf, addPointCellLabels_[api])
);
}
}
internalMesh->GetPointData()->AddArray(pointScalars);
if (!internalMesh->GetPointData()->GetScalars())
{
internalMesh->GetPointData()->SetScalars(pointScalars);
}
pointScalars->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,259 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamConvertVolFields_H
#define vtkPV3FoamConvertVolFields_H
// Foam includes
#include "emptyFvPatchField.H"
#include "vtkPV3FoamConvertPatchFaceField.H"
#include "vtkPV3FoamConvertPatchPointField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkPV3Foam::convertVolFields
(
const fvMesh& mesh,
const volPointInterpolation& pInterp,
const IOobjectList& objects,
vtkDataArraySelection *fieldSelection,
vtkMultiBlockDataSet* output
)
{
IOobjectList fieldObjects
(
objects.lookupClass
(
GeometricField<Type, fvPatchField, volMesh>::typeName
)
);
label nFields = fieldSelection->GetNumberOfArrays();
for (label i=0; i<nFields; i++)
{
if (fieldSelection->GetArraySetting(i))
{
const word fieldName = fieldSelection->GetArrayName(i);
if (fieldObjects.found(fieldName))
{
if (debug)
{
Info<< "converting Foam volume field: " << fieldName
<< endl;
}
GeometricField<Type, fvPatchField, volMesh> tf
(
IOobject
(
fieldName,
mesh.time().timeName(),
mesh,
IOobject::MUST_READ
),
mesh
);
tmp<GeometricField<Type, pointPatchField, pointMesh> > tptf
(
pInterp.interpolate(tf)
);
// Convert internal mesh
if (selectedRegions_[0])
{
convertVolField(tf, output);
convertPointField(tptf(), tf, output);
}
// Convert patches
const label regionStartId = idRegionPatches_;
const label regionEndId = idRegionPatches_
+ patchDataSize_ - 1;
for (label i=regionStartId; i<=regionEndId; i++)
{
if (selectedRegions_[i])
{
const word regionName = reader_->GetRegionSelection()
->GetArrayName(i);
const label patchId = mesh.boundaryMesh()
.findPatchID(regionName);
const fvPatchField<Type>& ptf
(
tf.boundaryField()[patchId]
);
if (!isType<emptyFvPatchField<Type> >(ptf))
{
convertPatchFaceField
(
tf.name(),
ptf,
selectedRegionDatasetIds_[i],
output
);
convertPatchPointField
(
tptf().name(),
tptf().boundaryField()[patchId]
.patchInternalField()(),
selectedRegionDatasetIds_[i],
output
);
}
else
{
fvPatch p
(
ptf.patch().patch(),
tf.mesh().boundary()
);
convertPatchFaceField
(
tf.name(),
fvPatchField<Type>(p, tf)
.patchInternalField()(),
selectedRegionDatasetIds_[i],
output
);
convertPatchPointField
(
tptf().name(),
tptf().boundaryField()[patchId]
.patchInternalField()(),
selectedRegionDatasetIds_[i],
output
);
}
}
}
}
}
}
}
template<class Type>
void Foam::vtkPV3Foam::convertVolField
(
const GeometricField<Type, fvPatchField, volMesh>& tf,
vtkMultiBlockDataSet* output
)
{
vtkUnstructuredGrid* internalMesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, VOLUME, 0)
);
vtkFloatArray* cellTypes = vtkFloatArray::New();
cellTypes->SetNumberOfTuples(superCells_.size());
cellTypes->SetNumberOfComponents(Type::nComponents);
cellTypes->Allocate(Type::nComponents*superCells_.size());
cellTypes->SetName(tf.name().c_str());
if (debug)
{
Info<< "converting vol<Type>Field: " << tf.name() << nl
<< "nTuples = " << superCells_.size() << nl
<< "nComps = " << Type::nComponents << endl;
}
float vec[Type::nComponents];
forAll(superCells_, sci)
{
const Type& t = tf[superCells_[sci]];
for (direction d=0; d<Type::nComponents; d++)
{
vec[d] = t[d];
}
cellTypes->InsertTuple(sci, vec);
}
internalMesh->GetCellData()->AddArray(cellTypes);
cellTypes->Delete();
}
template<>
void Foam::vtkPV3Foam::convertVolField
(
const GeometricField<scalar, fvPatchField, volMesh>& sf,
vtkMultiBlockDataSet* output
)
{
vtkUnstructuredGrid* internalMesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, VOLUME, 0)
);
vtkFloatArray *cellScalars = vtkFloatArray::New();
cellScalars->SetNumberOfTuples(superCells_.size());
cellScalars->SetNumberOfComponents(1);
cellScalars->Allocate(superCells_.size());
cellScalars->SetName(sf.name().c_str());
if (debug)
{
Info<< "converting volScalarField: " << sf.name() << nl
<< "sf.size() = " << sf.size() << nl
<< "nTuples = " << superCells_.size() << nl
<< "nComps = 1" << endl;
}
forAll(superCells_, sci)
{
cellScalars->InsertComponent(sci, 0, sf[superCells_[sci]]);
}
internalMesh->GetCellData()->AddArray(cellScalars);
if (!internalMesh->GetCellData()->GetScalars())
{
internalMesh->GetCellData()->SetScalars(cellScalars);
}
cellScalars->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,52 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamInsertNextPoint_H
#define vtkPV3FoamInsertNextPoint_H
// VTK includes
#include "vtkPoints.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline void vtkPV3FoamInsertNextPoint
(
vtkPoints *points,
const Foam::point& p
)
{
points->InsertNextPoint(p.x(), p.y(), p.z());
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,229 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "IOobjectList.H"
#include "vtkPV3FoamReader.h"
// VTK includes
#include "vtkDataArraySelection.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
#include "vtkPV3FoamConvertVolFields.H"
#include "vtkPV3FoamConvertPointFields.H"
#include "vtkPV3FoamConvertLagrangianFields.H"
void Foam::vtkPV3Foam::updateFoamMesh()
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::updateFoamMesh" << endl;
}
if
(
!reader_->GetCacheMesh()
|| reader_->GetTimeSelection()->GetArraySetting(0)
)
{
delete meshPtr_;
meshPtr_ = NULL;
}
// Check to see if the FOAM mesh has been created
if (!meshPtr_)
{
if (debug)
{
Info<< "Creating Foam mesh" << endl;
}
meshPtr_ = new fvMesh
(
IOobject
(
fvMesh::defaultRegion,
dbPtr_().timeName(),
dbPtr_()
)
);
}
else
{
if (debug)
{
Info<< "Using existing Foam mesh" << endl;
}
}
}
void Foam::vtkPV3Foam::updateVolFields
(
vtkMultiBlockDataSet* output
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::updateVolFields" << endl;
}
const fvMesh& mesh = *meshPtr_;
// Construct interpolation on the raw mesh
Foam::pointMesh pMesh(mesh);
// Search for list of objects for this time
Foam::IOobjectList objects(mesh, dbPtr_().timeName());
// Convert volume fields
if (debug)
{
Info<< "converting Foam volume fields" << endl;
}
Foam::volPointInterpolation pInterp(mesh, pMesh);
convertVolFields<Foam::scalar>
(
mesh, pInterp, objects, reader_->GetVolFieldSelection(), output
);
convertVolFields<Foam::vector>
(
mesh, pInterp, objects, reader_->GetVolFieldSelection(), output
);
convertVolFields<Foam::sphericalTensor>
(
mesh, pInterp, objects, reader_->GetVolFieldSelection(), output
);
convertVolFields<Foam::symmTensor>
(
mesh, pInterp, objects, reader_->GetVolFieldSelection(), output
);
convertVolFields<Foam::tensor>
(
mesh, pInterp, objects, reader_->GetVolFieldSelection(), output
);
}
void Foam::vtkPV3Foam::updatePointFields
(
vtkMultiBlockDataSet* output
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::updatePointFields" << endl;
}
const fvMesh& mesh = *meshPtr_;
// Search for list of objects for this time
Foam::IOobjectList objects(mesh, dbPtr_().timeName());
// Convert point fields
if (debug)
{
Info<< "converting Foam point fields" << endl;
}
convertPointFields<Foam::scalar>
(
mesh, objects, reader_->GetPointFieldSelection(), output
);
convertPointFields<Foam::vector>
(
mesh, objects, reader_->GetPointFieldSelection(), output
);
convertPointFields<Foam::sphericalTensor>
(
mesh, objects, reader_->GetPointFieldSelection(), output
);
convertPointFields<Foam::symmTensor>
(
mesh, objects, reader_->GetPointFieldSelection(), output
);
convertPointFields<Foam::tensor>
(
mesh, objects, reader_->GetPointFieldSelection(), output
);
}
void Foam::vtkPV3Foam::updateLagrangianFields
(
vtkMultiBlockDataSet* output
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::updateLagrangianFields" << endl;
}
const fvMesh& mesh = *meshPtr_;
// Search for list of objects for this time
//- TODO - currently hard-coded to ONE cloud
Foam::IOobjectList lagrangianObjects
(
mesh,
dbPtr_().timeName(),
"lagrangian"/cloudName_
);
// Convert Lagrangian fields
if (debug)
{
Info<< "converting Foam Lagrangian fields" << endl;
}
convertLagrangianFields<Foam::scalar>
(
mesh, lagrangianObjects, reader_->GetLagrangianFieldSelection(), output
);
convertLagrangianFields<Foam::vector>
(
mesh, lagrangianObjects, reader_->GetLagrangianFieldSelection(), output
);
convertLagrangianFields<Foam::sphericalTensor>
(
mesh, lagrangianObjects, reader_->GetLagrangianFieldSelection(), output
);
convertLagrangianFields<Foam::symmTensor>
(
mesh, lagrangianObjects, reader_->GetLagrangianFieldSelection(), output
);
convertLagrangianFields<Foam::tensor>
(
mesh, lagrangianObjects, reader_->GetLagrangianFieldSelection(), output
);
}
// ************************************************************************* //

View File

@ -1,250 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "cellSet.H"
#include "faceSet.H"
#include "IOobjectList.H"
#include "pointSet.H"
#include "polyBoundaryMeshEntries.H"
#include "vtkPV3FoamReader.h"
// VTK includes
#include "vtkDataArraySelection.h"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
#include "vtkPV3FoamAddFields.H"
#include "vtkPV3FoamUpdateInformationFields.H"
void Foam::vtkPV3Foam::updateInformationInternalMesh()
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::updateInformationInternalMesh" << endl;
}
// Determine number of meshes available
HashTable<const fvMesh*> meshObjects = dbPtr_().lookupClass<const fvMesh>();
nMesh_ = meshObjects.size();
// Determine regions (internal mesh and patches...)
//- Add internal mesh as first entry
idRegionVolume_ = reader_->GetRegionSelection()->GetNumberOfArrays();
reader_->GetRegionSelection()->AddArray("internalMesh");
}
void Foam::vtkPV3Foam::updateInformationLagrangian()
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::updateInformationLagrangian" << endl;
}
// Search for list of lagrangian objects for this time
// IOobjectList lagrangianObjects(dbPtr(), dbPtr_().timeName(), "lagrangian");
// lagrangianDataSize_ = lagrangianObjects.size();
fileNameList cloudDirs
(
readDir(dbPtr_->timePath()/"lagrangian", fileName::DIRECTORY)
);
lagrangianDataSize_ = cloudDirs.size();
if (lagrangianDataSize_)
{
idRegionLagrangian_ = reader_->GetRegionSelection()
->GetNumberOfArrays();
reader_->GetRegionSelection()->AddArray("lagrangian");
if (lagrangianDataSize_ > 1)
{
WarningIn("void Foam::vtkPV3Foam::updateInformationLagrangian()")
<< "Multiple lagrangian clouds identified. Currently only able "
<< "to process ONE cloud: " << cloudDirs[0]
<< endl;
}
// Set cloud name to first cloud found
// TODO - multiple clouds
cloudName_ = cloudDirs[0];
}
}
void Foam::vtkPV3Foam::updateInformationPatches()
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::updateInformationPatches" << endl;
}
//- Read patches
polyBoundaryMeshEntries patchEntries
(
IOobject
(
"boundary",
dbPtr_().findInstance(polyMesh::meshSubDir, "boundary"),
polyMesh::meshSubDir,
dbPtr_(),
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
// Start regions at patches
forAll (patchEntries, entryi)
{
label nFaces(readLabel(patchEntries[entryi].dict().lookup("nFaces")));
//- Valid patch if nFace > 0
if (nFaces)
{
// Add patch to GUI region list
if (idRegionPatches_ < 0)
{
idRegionPatches_ = reader_->GetRegionSelection()
->GetNumberOfArrays();
}
reader_->GetRegionSelection()->AddArray
(
patchEntries[entryi].keyword().c_str()
);
patchDataSize_++;
}
}
}
void Foam::vtkPV3Foam::updateInformationSets()
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::updateInformationSets" << endl;
}
// Add sets
IOobjectList setObjects
(
dbPtr_(),
dbPtr_().findInstance(polyMesh::meshSubDir, "faces"),
polyMesh::meshSubDir/"sets"
);
IOobjectList cellSetObjects(setObjects.lookupClass(cellSet::typeName));
cellSetDataSize_ = cellSetObjects.size();
superCellSetCells_.setSize(cellSetDataSize_);
idRegionCellSets_ = reader_->GetRegionSelection()->GetNumberOfArrays();
addFields<cellSet>
(
reader_->GetRegionSelection(),
cellSetObjects
);
IOobjectList faceSetObjects(setObjects.lookupClass(faceSet::typeName));
faceSetDataSize_ = faceSetObjects.size();
idRegionFaceSets_ = reader_->GetRegionSelection()->GetNumberOfArrays();
addFields<faceSet>
(
reader_->GetRegionSelection(),
faceSetObjects
);
IOobjectList pointSetObjects(setObjects.lookupClass(pointSet::typeName));
pointSetDataSize_ = pointSetObjects.size();
idRegionPointSets_ = reader_->GetRegionSelection()->GetNumberOfArrays();
addFields<pointSet>
(
reader_->GetRegionSelection(),
pointSetObjects
);
}
void Foam::vtkPV3Foam::updateInformationLagrangianFields()
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::updateInformationLagrangianFields"
<< endl;
}
const wordList selectedArrayEntries = getSelectedArrayEntries
(
reader_->GetLagrangianFieldSelection()
);
reader_->GetLagrangianFieldSelection()->RemoveAllArrays();
// TODO - currently hard-coded to ONE cloud
IOobjectList lagrangianObjects(dbPtr_(), dbPtr_().timeName(), "lagrangian"/cloudName_);
addFields<IOField<scalar> >
(
reader_->GetLagrangianFieldSelection(),
lagrangianObjects
);
addFields<IOField<vector> >
(
reader_->GetLagrangianFieldSelection(),
lagrangianObjects
);
addFields<IOField<sphericalTensor> >
(
reader_->GetLagrangianFieldSelection(),
lagrangianObjects
);
addFields<IOField<symmTensor> >
(
reader_->GetLagrangianFieldSelection(),
lagrangianObjects
);
addFields<IOField<tensor> >
(
reader_->GetLagrangianFieldSelection(),
lagrangianObjects
);
setSelectedArrayEntries
(
reader_->GetLagrangianFieldSelection(),
selectedArrayEntries
);
if (debug)
{
Info<< "lagrangianObjects.size() = " << lagrangianObjects.size()
<< endl;
}
}
// ************************************************************************* //

View File

@ -1,96 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
vtkPV3Foam
\*---------------------------------------------------------------------------*/
#ifndef vtkPV3FoamUpdateInformationFields_H
#define vtkPV3FoamUpdateInformationFields_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<template<class> class patchType, class meshType>
void Foam::vtkPV3Foam::updateInformationFields
(
vtkDataArraySelection *fieldSelection
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::updateInformationFields" << endl;
}
const wordList selectedArrayEntries = getSelectedArrayEntries
(
fieldSelection
);
fieldSelection->RemoveAllArrays();
// Search for list of objects for this time
IOobjectList objects(dbPtr_(), dbPtr_().timeName());
// Populate the GUI volume/point field arrays
//- Add volume fields to GUI
addFields<GeometricField<scalar, patchType, meshType> >
(
fieldSelection,
objects
);
addFields<GeometricField<vector, patchType, meshType> >
(
fieldSelection,
objects
);
addFields<GeometricField<sphericalTensor, patchType, meshType> >
(
fieldSelection,
objects
);
addFields<GeometricField<symmTensor, patchType, meshType> >
(
fieldSelection,
objects
);
addFields<GeometricField<tensor, patchType, meshType> >
(
fieldSelection,
objects
);
setSelectedArrayEntries
(
fieldSelection,
selectedArrayEntries
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //