mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of ssh://noisy/home/noisy2/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -1,191 +1,211 @@
|
||||
<ServerManagerConfiguration>
|
||||
<ProxyGroup name="sources">
|
||||
<SourceProxy
|
||||
<ProxyGroup name="sources">
|
||||
<SourceProxy
|
||||
name="PV3FoamReader"
|
||||
class="vtkPV3FoamReader">
|
||||
|
||||
name="PV3FoamReader"
|
||||
class="vtkPV3FoamReader">
|
||||
<!-- File name - compulsory -->
|
||||
<StringVectorProperty
|
||||
name="FileName"
|
||||
command="SetFileName"
|
||||
number_of_elements="1"
|
||||
animateable="0">
|
||||
<FileListDomain name="files"/>
|
||||
<Documentation>
|
||||
Specifies the filename for the OpenFOAM Reader.
|
||||
</Documentation>
|
||||
</StringVectorProperty>
|
||||
|
||||
<!-- File name - compulsory -->
|
||||
<StringVectorProperty
|
||||
name="FileName"
|
||||
command="SetFileName"
|
||||
number_of_elements="1">
|
||||
<FileListDomain
|
||||
name="files"/>
|
||||
</StringVectorProperty>
|
||||
<!-- Send discrete time info to the animation panel -->
|
||||
<DoubleVectorProperty
|
||||
name="TimestepValues"
|
||||
repeatable="1"
|
||||
information_only="1">
|
||||
<TimeStepsInformationHelper/>
|
||||
<Documentation>
|
||||
Available timestep values.
|
||||
</Documentation>
|
||||
</DoubleVectorProperty>
|
||||
|
||||
<!-- Time info sent to animation controls (top of window) -->
|
||||
<!-- Send continuous time info to the animation panel -->
|
||||
<DoubleVectorProperty
|
||||
name="TimeRange"
|
||||
information_only="1">
|
||||
<TimeRangeInformationHelper/>
|
||||
</DoubleVectorProperty>
|
||||
|
||||
<DoubleVectorProperty
|
||||
name="TimestepValues"
|
||||
information_only="1">
|
||||
<TimeStepsInformationHelper/>
|
||||
<Documentation>
|
||||
Available timestep values.
|
||||
</Documentation>
|
||||
</DoubleVectorProperty>
|
||||
<!-- Available Parts (volume, patches, lagrangian) array -->
|
||||
<StringVectorProperty
|
||||
name="PartArrayInfo"
|
||||
information_only="1">
|
||||
<ArraySelectionInformationHelper attribute_name="Part"/>
|
||||
</StringVectorProperty>
|
||||
<StringVectorProperty
|
||||
name="PartStatus"
|
||||
label="Mesh Parts"
|
||||
command="SetPartArrayStatus"
|
||||
number_of_elements="0"
|
||||
repeat_command="1"
|
||||
number_of_elements_per_command="2"
|
||||
element_types="2 0"
|
||||
information_property="PartArrayInfo"
|
||||
animateable="0">
|
||||
<ArraySelectionDomain name="array_list">
|
||||
<RequiredProperties>
|
||||
<Property name="PartArrayInfo" function="ArrayList"/>
|
||||
</RequiredProperties>
|
||||
</ArraySelectionDomain>
|
||||
</StringVectorProperty>
|
||||
|
||||
<DoubleVectorProperty
|
||||
name="TimeRange"
|
||||
information_only="1">
|
||||
<TimeRangeInformationHelper/>
|
||||
</DoubleVectorProperty>
|
||||
<!-- Available volFields array -->
|
||||
<StringVectorProperty
|
||||
name="VolFieldArrayInfo"
|
||||
information_only="1">
|
||||
<ArraySelectionInformationHelper attribute_name="VolField"/>
|
||||
</StringVectorProperty>
|
||||
<StringVectorProperty
|
||||
name="VolFieldStatus"
|
||||
label="Volume Fields"
|
||||
command="SetVolFieldArrayStatus"
|
||||
number_of_elements="0"
|
||||
repeat_command="1"
|
||||
number_of_elements_per_command="2"
|
||||
element_types="2 0"
|
||||
information_property="VolFieldArrayInfo"
|
||||
animateable="0">
|
||||
<ArraySelectionDomain name="array_list">
|
||||
<RequiredProperties>
|
||||
<Property name="VolFieldArrayInfo" function="ArrayList"/>
|
||||
</RequiredProperties>
|
||||
</ArraySelectionDomain>
|
||||
</StringVectorProperty>
|
||||
|
||||
<!-- ExtrapolateWalls check box -->
|
||||
<IntVectorProperty
|
||||
name="ExtrapolateWalls"
|
||||
command="SetExtrapolateWalls"
|
||||
number_of_elements="1"
|
||||
default_values="0">
|
||||
<BooleanDomain
|
||||
name="bool"/>
|
||||
</IntVectorProperty>
|
||||
<!-- Available Lagrangian fields array -->
|
||||
<StringVectorProperty
|
||||
name="LagrangianFieldArrayInfo"
|
||||
information_only="1">
|
||||
<ArraySelectionInformationHelper attribute_name="LagrangianField"/>
|
||||
</StringVectorProperty>
|
||||
<StringVectorProperty
|
||||
name="LagrangianFieldStatus"
|
||||
label="Lagrangian Fields"
|
||||
command="SetLagrangianFieldArrayStatus"
|
||||
number_of_elements="0"
|
||||
repeat_command="1"
|
||||
number_of_elements_per_command="2"
|
||||
element_types="2 0"
|
||||
information_property="LagrangianFieldArrayInfo"
|
||||
animateable="0">
|
||||
<ArraySelectionDomain name="array_list">
|
||||
<RequiredProperties>
|
||||
<Property name="LagrangianFieldArrayInfo" function="ArrayList"/>
|
||||
</RequiredProperties>
|
||||
</ArraySelectionDomain>
|
||||
</StringVectorProperty>
|
||||
|
||||
<!-- Include sets check box -->
|
||||
<IntVectorProperty
|
||||
name="IncludeSets"
|
||||
command="SetIncludeSets"
|
||||
number_of_elements="1"
|
||||
default_values="0">
|
||||
<BooleanDomain
|
||||
name="bool"/>
|
||||
</IntVectorProperty>
|
||||
<!-- Available pointFields array -->
|
||||
<StringVectorProperty
|
||||
name="PointFieldArrayInfo"
|
||||
information_only="1">
|
||||
<ArraySelectionInformationHelper attribute_name="PointField"/>
|
||||
</StringVectorProperty>
|
||||
<StringVectorProperty
|
||||
name="PointFieldStatus"
|
||||
label="Point Fields"
|
||||
command="SetPointFieldArrayStatus"
|
||||
number_of_elements="0"
|
||||
repeat_command="1"
|
||||
number_of_elements_per_command="2"
|
||||
element_types="2 0"
|
||||
information_property="PointFieldArrayInfo"
|
||||
animateable="0">
|
||||
<ArraySelectionDomain name="array_list">
|
||||
<RequiredProperties>
|
||||
<Property name="PointFieldArrayInfo" function="ArrayList"/>
|
||||
</RequiredProperties>
|
||||
</ArraySelectionDomain>
|
||||
</StringVectorProperty>
|
||||
|
||||
<!-- Include zones check box -->
|
||||
<IntVectorProperty
|
||||
name="IncludeZones"
|
||||
command="SetIncludeZones"
|
||||
number_of_elements="1"
|
||||
default_values="0">
|
||||
<BooleanDomain
|
||||
name="bool"/>
|
||||
</IntVectorProperty>
|
||||
<!-- Extrapolate Walls check-box -->
|
||||
<IntVectorProperty
|
||||
name="ExtrapolateWalls"
|
||||
command="SetExtrapolateWalls"
|
||||
number_of_elements="1"
|
||||
default_values="0"
|
||||
animateable="0">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Extrapolate internalField to wall and empty patches
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Show patch names check box -->
|
||||
<IntVectorProperty
|
||||
name="ShowPatchNames"
|
||||
command="SetShowPatchNames"
|
||||
number_of_elements="1"
|
||||
default_values="0">
|
||||
<BooleanDomain name="bool"/>
|
||||
</IntVectorProperty>
|
||||
<!-- Include Sets check-box -->
|
||||
<IntVectorProperty
|
||||
name="IncludeSets"
|
||||
command="SetIncludeSets"
|
||||
number_of_elements="1"
|
||||
default_values="0"
|
||||
animateable="0">
|
||||
<Documentation>
|
||||
Searches the polyMesh/sets/ directory
|
||||
</Documentation>
|
||||
<BooleanDomain name="bool"/>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- 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>
|
||||
<!-- Include Zones check-box -->
|
||||
<IntVectorProperty
|
||||
name="IncludeZones"
|
||||
command="SetIncludeZones"
|
||||
number_of_elements="1"
|
||||
default_values="0"
|
||||
animateable="0">
|
||||
<Documentation>
|
||||
ZoneMesh information is used to find {cell,face,point}Zones.
|
||||
The polyMesh/ directory is only checked on startup.
|
||||
</Documentation>
|
||||
<BooleanDomain name="bool"/>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- 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>
|
||||
<!-- Show Patch Names check-box -->
|
||||
<IntVectorProperty
|
||||
name="ShowPatchNames"
|
||||
command="SetShowPatchNames"
|
||||
number_of_elements="1"
|
||||
default_values="0"
|
||||
animateable="0">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Show patch names in render window.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- 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>
|
||||
<!-- Cache Mesh check-box -->
|
||||
<IntVectorProperty
|
||||
name="CacheMesh"
|
||||
command="SetCacheMesh"
|
||||
number_of_elements="1"
|
||||
default_values="1"
|
||||
animateable="0">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Cache the fvMesh in memory.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- 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>
|
||||
|
||||
<!-- Cache mesh check box -->
|
||||
<IntVectorProperty
|
||||
name="CacheMesh"
|
||||
command="SetCacheMesh"
|
||||
number_of_elements="1"
|
||||
default_values="1">
|
||||
<BooleanDomain
|
||||
name="bool"/>
|
||||
</IntVectorProperty>
|
||||
<!-- Update GUI check box -->
|
||||
<IntVectorProperty
|
||||
name="UpdateGUI"
|
||||
command="SetUpdateGUI"
|
||||
number_of_elements="1"
|
||||
default_values="0"
|
||||
animateable="0">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
A simple way cause a reader GUI modification.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Update GUI check box -->
|
||||
<IntVectorProperty
|
||||
name="UpdateGUI"
|
||||
command="SetUpdateGUI"
|
||||
number_of_elements="1"
|
||||
default_values="0">
|
||||
<BooleanDomain
|
||||
name="bool"/>
|
||||
</IntVectorProperty>
|
||||
|
||||
</SourceProxy>
|
||||
</ProxyGroup>
|
||||
</SourceProxy>
|
||||
</ProxyGroup>
|
||||
</ServerManagerConfiguration>
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
vtkCxxRevisionMacro(vtkPV3FoamReader, "$Revision: 1.5$");
|
||||
vtkStandardNewMacro(vtkPV3FoamReader);
|
||||
|
||||
#undef EXPERIMENTAL_TIME_CACHING
|
||||
|
||||
vtkPV3FoamReader::vtkPV3FoamReader()
|
||||
{
|
||||
@ -47,23 +48,30 @@ vtkPV3FoamReader::vtkPV3FoamReader()
|
||||
FileName = NULL;
|
||||
foamData_ = NULL;
|
||||
|
||||
output1_ = NULL;
|
||||
output0_ = NULL;
|
||||
|
||||
// Add second output for the Lagrangian
|
||||
this->SetNumberOfOutputPorts(2);
|
||||
vtkMultiBlockDataSet *lagrangian;
|
||||
lagrangian = vtkMultiBlockDataSet::New();
|
||||
lagrangian->ReleaseData();
|
||||
|
||||
this->GetExecutive()->SetOutputData(1, lagrangian);
|
||||
lagrangian->Delete();
|
||||
|
||||
TimeStep = 0;
|
||||
TimeStepRange[0] = 0;
|
||||
TimeStepRange[1] = 0;
|
||||
|
||||
CacheMesh = 0;
|
||||
CacheMesh = 1;
|
||||
|
||||
ExtrapolateWalls = 0;
|
||||
IncludeSets = 0;
|
||||
IncludeZones = 0;
|
||||
ShowPatchNames = 0;
|
||||
|
||||
UpdateGUI = 1;
|
||||
UpdateGUIOld = 1;
|
||||
UpdateGUI = 0;
|
||||
|
||||
RegionSelection = vtkDataArraySelection::New();
|
||||
PartSelection = vtkDataArraySelection::New();
|
||||
VolFieldSelection = vtkDataArraySelection::New();
|
||||
PointFieldSelection = vtkDataArraySelection::New();
|
||||
LagrangianFieldSelection = vtkDataArraySelection::New();
|
||||
@ -77,7 +85,7 @@ vtkPV3FoamReader::vtkPV3FoamReader()
|
||||
);
|
||||
SelectionObserver->SetClientData(this);
|
||||
|
||||
RegionSelection->AddObserver
|
||||
PartSelection->AddObserver
|
||||
(
|
||||
vtkCommand::ModifiedEvent,
|
||||
this->SelectionObserver
|
||||
@ -114,14 +122,20 @@ vtkPV3FoamReader::~vtkPV3FoamReader()
|
||||
delete [] FileName;
|
||||
}
|
||||
|
||||
RegionSelection->RemoveObserver(this->SelectionObserver);
|
||||
if (output0_)
|
||||
{
|
||||
output0_->Delete();
|
||||
}
|
||||
|
||||
|
||||
PartSelection->RemoveObserver(this->SelectionObserver);
|
||||
VolFieldSelection->RemoveObserver(this->SelectionObserver);
|
||||
PointFieldSelection->RemoveObserver(this->SelectionObserver);
|
||||
LagrangianFieldSelection->RemoveObserver(this->SelectionObserver);
|
||||
|
||||
SelectionObserver->Delete();
|
||||
|
||||
RegionSelection->Delete();
|
||||
PartSelection->Delete();
|
||||
VolFieldSelection->Delete();
|
||||
PointFieldSelection->Delete();
|
||||
LagrangianFieldSelection->Delete();
|
||||
@ -149,38 +163,40 @@ int vtkPV3FoamReader::RequestInformation
|
||||
return 0;
|
||||
}
|
||||
|
||||
vtkInformation *outInfo = outputVector->GetInformationObject(0);
|
||||
int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
|
||||
if (Foam::vtkPV3Foam::debug)
|
||||
{
|
||||
cout<<"RequestInformation with " << nInfo << " item(s)\n";
|
||||
for (int infoI = 0; infoI < nInfo; ++infoI)
|
||||
{
|
||||
outputVector->GetInformationObject(infoI)->Print(cout);
|
||||
}
|
||||
}
|
||||
|
||||
if (!foamData_)
|
||||
{
|
||||
vtkDebugMacro("RequestInformation: creating foamData_");
|
||||
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
|
||||
(
|
||||
outInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT())
|
||||
);
|
||||
|
||||
if (Foam::vtkPV3Foam::debug)
|
||||
{
|
||||
cout<< "constructed vtkPV3Foam with output: ";
|
||||
output->Print(cout);
|
||||
}
|
||||
|
||||
foamData_ = new Foam::vtkPV3Foam(FileName, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
foamData_->UpdateInformation();
|
||||
foamData_->updateInfo();
|
||||
}
|
||||
|
||||
int nTimeSteps = 0;
|
||||
double* timeSteps = foamData_->findTimes(nTimeSteps);
|
||||
|
||||
outInfo->Set
|
||||
(
|
||||
vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
|
||||
timeSteps,
|
||||
nTimeSteps
|
||||
);
|
||||
|
||||
// set identical time steps for all ports
|
||||
for (int infoI = 0; infoI < nInfo; ++infoI)
|
||||
{
|
||||
outputVector->GetInformationObject(infoI)->Set
|
||||
(
|
||||
vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
|
||||
timeSteps,
|
||||
nTimeSteps
|
||||
);
|
||||
}
|
||||
|
||||
double timeRange[2];
|
||||
if (nTimeSteps)
|
||||
@ -190,21 +206,25 @@ int vtkPV3FoamReader::RequestInformation
|
||||
|
||||
if (Foam::vtkPV3Foam::debug > 1)
|
||||
{
|
||||
cout<<"nTimeSteps " << nTimeSteps << "\n";
|
||||
cout<<"timeRange " << timeRange[0] << " to " << timeRange[1] << "\n";
|
||||
cout<<"nTimeSteps " << nTimeSteps << "\n"
|
||||
<<"timeRange " << timeRange[0] << " to " << timeRange[1]
|
||||
<< "\n";
|
||||
|
||||
for (int i = 0; i < nTimeSteps; ++i)
|
||||
for (int timeI = 0; timeI < nTimeSteps; ++timeI)
|
||||
{
|
||||
cout<< "step[" << i << "] = " << timeSteps[i] << "\n";
|
||||
cout<< "step[" << timeI << "] = " << timeSteps[timeI] << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
outInfo->Set
|
||||
(
|
||||
vtkStreamingDemandDrivenPipeline::TIME_RANGE(),
|
||||
timeRange,
|
||||
2
|
||||
);
|
||||
for (int infoI = 0; infoI < nInfo; ++infoI)
|
||||
{
|
||||
outputVector->GetInformationObject(infoI)->Set
|
||||
(
|
||||
vtkStreamingDemandDrivenPipeline::TIME_RANGE(),
|
||||
timeRange,
|
||||
2
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
delete timeSteps;
|
||||
@ -229,75 +249,41 @@ int vtkPV3FoamReader::RequestData
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
|
||||
if (Foam::vtkPV3Foam::debug)
|
||||
{
|
||||
int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
cout<<"requestData with " << nInfo << " items\n";
|
||||
|
||||
for (int i = 0; i < nInfo; ++i)
|
||||
cout<<"RequestData with " << nInfo << " item(s)\n";
|
||||
for (int infoI = 0; infoI < nInfo; ++infoI)
|
||||
{
|
||||
vtkInformation *info = outputVector->GetInformationObject(i);
|
||||
info->Print(cout);
|
||||
outputVector->GetInformationObject(infoI)->Print(cout);
|
||||
}
|
||||
}
|
||||
|
||||
vtkInformation* outInfo = outputVector->GetInformationObject(0);
|
||||
// take port0 as the lead for other outputs
|
||||
vtkInformation *outInfo = outputVector->GetInformationObject(0);
|
||||
|
||||
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
|
||||
(
|
||||
outInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT())
|
||||
outInfo->Get
|
||||
(
|
||||
vtkMultiBlockDataSet::DATA_OBJECT()
|
||||
)
|
||||
);
|
||||
|
||||
if (Foam::vtkPV3Foam::debug)
|
||||
{
|
||||
vtkInformation* outputInfo = this->GetOutputPortInformation(0);
|
||||
outputInfo->Print(cout);
|
||||
|
||||
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
|
||||
vtkMultiBlockDataSet* lagrangianOutput = vtkMultiBlockDataSet::SafeDownCast
|
||||
(
|
||||
outputVector->GetInformationObject(1)->Get
|
||||
(
|
||||
outputInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT())
|
||||
);
|
||||
if (output)
|
||||
{
|
||||
output->Print(cout);
|
||||
}
|
||||
else
|
||||
{
|
||||
cout<< "no output\n";
|
||||
}
|
||||
|
||||
vtkInformation* execInfo = this->GetExecutive()->GetOutputInformation(0);
|
||||
execInfo->Print(cout);
|
||||
|
||||
outInfo->Print(cout);
|
||||
|
||||
vtkMultiBlockDataSet* dobj = vtkMultiBlockDataSet::SafeDownCast
|
||||
(
|
||||
outInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT())
|
||||
);
|
||||
if (dobj)
|
||||
{
|
||||
dobj->Print(cout);
|
||||
|
||||
vtkInformation* dobjInfo = dobj->GetInformation();
|
||||
dobjInfo->Print(cout);
|
||||
}
|
||||
else
|
||||
{
|
||||
cout<< "no data_object\n";
|
||||
}
|
||||
}
|
||||
vtkMultiBlockDataSet::DATA_OBJECT()
|
||||
)
|
||||
);
|
||||
|
||||
if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()))
|
||||
{
|
||||
if (Foam::vtkPV3Foam::debug)
|
||||
{
|
||||
cout<<"Has UPDATE_TIME_STEPS\n";
|
||||
cout<<"output->GetNumberOfBlocks() = "
|
||||
<< output->GetNumberOfBlocks() << "\n";
|
||||
}
|
||||
|
||||
// Get the requested time step.
|
||||
// We only supprt requests of a single time step
|
||||
// We only support requests for a single time step
|
||||
int nRequestedTimeSteps = outInfo->Length
|
||||
(
|
||||
vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()
|
||||
@ -313,24 +299,65 @@ int vtkPV3FoamReader::RequestData
|
||||
}
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
(UpdateGUIOld == GetUpdateGUI())
|
||||
|| (output->GetNumberOfBlocks() == 0)
|
||||
)
|
||||
if (Foam::vtkPV3Foam::debug)
|
||||
{
|
||||
cout<< "update output with "
|
||||
<< output->GetNumberOfBlocks() << " blocks\n";
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_TIME_CACHING
|
||||
bool needsUpdate = false;
|
||||
|
||||
if (!output0_)
|
||||
{
|
||||
output0_ = vtkMultiBlockDataSet::New();
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
||||
// This experimental bit of code seems to work for the geometry,
|
||||
// but trashes the fields and still triggers the GeometryFilter
|
||||
if (needsUpdate)
|
||||
{
|
||||
foamData_->Update(output);
|
||||
output0_->ShallowCopy(output);
|
||||
}
|
||||
else
|
||||
{
|
||||
output->ShallowCopy(output0_);
|
||||
}
|
||||
|
||||
if (ShowPatchNames == 1)
|
||||
if (Foam::vtkPV3Foam::debug)
|
||||
{
|
||||
if (needsUpdate)
|
||||
{
|
||||
addPatchNamesToView();
|
||||
cout<< "full UPDATE ---------\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
removePatchNamesFromView();
|
||||
cout<< "cached UPDATE ---------\n";
|
||||
}
|
||||
|
||||
cout<< "UPDATED output: ";
|
||||
output->Print(cout);
|
||||
|
||||
cout<< "UPDATED output0_: ";
|
||||
output0_->Print(cout);
|
||||
}
|
||||
UpdateGUIOld = GetUpdateGUI();
|
||||
|
||||
#else
|
||||
|
||||
foamData_->Update(output, lagrangianOutput);
|
||||
|
||||
if (ShowPatchNames)
|
||||
{
|
||||
addPatchNamesToView();
|
||||
}
|
||||
else
|
||||
{
|
||||
removePatchNamesFromView();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -389,52 +416,57 @@ void vtkPV3FoamReader::PrintSelf(ostream& os, vtkIndent indent)
|
||||
os<< indent << "Time step range: "
|
||||
<< this->TimeStepRange[0] << " - " << this->TimeStepRange[1]
|
||||
<< "\n";
|
||||
os<< indent << "Time step: " << this->TimeStep << endl;
|
||||
os<< indent << "Time step: " << this->GetTimeStep() << endl;
|
||||
}
|
||||
|
||||
|
||||
int vtkPV3FoamReader::GetTimeStep()
|
||||
{
|
||||
return foamData_ ? foamData_->timeIndex() : -1;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Region selection list control
|
||||
// Parts selection list control
|
||||
|
||||
vtkDataArraySelection* vtkPV3FoamReader::GetRegionSelection()
|
||||
vtkDataArraySelection* vtkPV3FoamReader::GetPartSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetRegionSelection");
|
||||
return RegionSelection;
|
||||
vtkDebugMacro(<<"GetPartSelection");
|
||||
return PartSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPV3FoamReader::GetNumberOfRegionArrays()
|
||||
int vtkPV3FoamReader::GetNumberOfPartArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfRegionArrays");
|
||||
return RegionSelection->GetNumberOfArrays();
|
||||
vtkDebugMacro(<<"GetNumberOfPartArrays");
|
||||
return PartSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPV3FoamReader::GetRegionArrayName(int index)
|
||||
const char* vtkPV3FoamReader::GetPartArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetRegionArrayName");
|
||||
return RegionSelection->GetArrayName(index);
|
||||
vtkDebugMacro(<<"GetPartArrayName");
|
||||
return PartSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPV3FoamReader::GetRegionArrayStatus(const char* name)
|
||||
int vtkPV3FoamReader::GetPartArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetRegionArrayStatus");
|
||||
return RegionSelection->ArrayIsEnabled(name);
|
||||
vtkDebugMacro(<<"GetPartArrayStatus");
|
||||
return PartSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPV3FoamReader::SetRegionArrayStatus(const char* name, int status)
|
||||
void vtkPV3FoamReader::SetPartArrayStatus(const char* name, int status)
|
||||
{
|
||||
vtkDebugMacro(<<"SetRegionArrayStatus");
|
||||
|
||||
vtkDebugMacro(<<"SetPartArrayStatus");
|
||||
if (status)
|
||||
{
|
||||
RegionSelection->EnableArray(name);
|
||||
PartSelection->EnableArray(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
RegionSelection->DisableArray(name);
|
||||
PartSelection->DisableArray(name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -597,4 +629,19 @@ void vtkPV3FoamReader::SelectionModified()
|
||||
Modified();
|
||||
}
|
||||
|
||||
|
||||
int vtkPV3FoamReader::FillOutputPortInformation
|
||||
(
|
||||
int port,
|
||||
vtkInformation* info
|
||||
)
|
||||
{
|
||||
if (port == 0)
|
||||
{
|
||||
return this->Superclass::FillOutputPortInformation(port, info);
|
||||
}
|
||||
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -21,20 +21,16 @@
|
||||
#ifndef __vtkPV3FoamReader_h
|
||||
#define __vtkPV3FoamReader_h
|
||||
|
||||
#include "vtkMultiBlockDataSetAlgorithm.h"
|
||||
|
||||
// Foam forward declarations
|
||||
namespace Foam
|
||||
{
|
||||
class vtkPV3Foam;
|
||||
}
|
||||
|
||||
// VTK includes
|
||||
#include "vtkMultiBlockDataSetAlgorithm.h"
|
||||
|
||||
// VTK forward declarations
|
||||
class vtkUnstructuredGrid;
|
||||
class vtkPoints;
|
||||
class vtkIntArray;
|
||||
class vtkFloatArray;
|
||||
class vtkDoubleArray;
|
||||
class vtkDataArraySelection;
|
||||
class vtkCallbackCommand;
|
||||
|
||||
@ -44,41 +40,31 @@ class VTK_IO_EXPORT vtkPV3FoamReader
|
||||
public vtkMultiBlockDataSetAlgorithm
|
||||
{
|
||||
public:
|
||||
vtkTypeRevisionMacro(vtkPV3FoamReader,vtkMultiBlockDataSetAlgorithm);
|
||||
void PrintSelf(ostream&, vtkIndent);
|
||||
|
||||
static vtkPV3FoamReader* New();
|
||||
|
||||
vtkTypeRevisionMacro
|
||||
(
|
||||
vtkPV3FoamReader,
|
||||
vtkMultiBlockDataSetAlgorithm
|
||||
);
|
||||
|
||||
void PrintSelf
|
||||
(
|
||||
ostream& os,
|
||||
vtkIndent indent
|
||||
);
|
||||
// Description:
|
||||
// Get the current timestep and the timestep range.
|
||||
vtkGetVector2Macro(TimeStepRange, int);
|
||||
|
||||
// Description:
|
||||
// Set/Get the filename.
|
||||
vtkSetStringMacro(FileName);
|
||||
vtkGetStringMacro(FileName);
|
||||
|
||||
// Time control
|
||||
// Set/Get the timestep and the timestep range
|
||||
vtkSetMacro(TimeStep, int);
|
||||
vtkGetMacro(TimeStep, int);
|
||||
vtkSetVector2Macro(TimeStepRange, int);
|
||||
vtkGetVector2Macro(TimeStepRange, int);
|
||||
|
||||
// Description:
|
||||
// GUI update control
|
||||
vtkSetMacro(UpdateGUI, int);
|
||||
vtkGetMacro(UpdateGUI, int);
|
||||
|
||||
// Description:
|
||||
// FOAM mesh caching control
|
||||
vtkSetMacro(CacheMesh, int);
|
||||
vtkGetMacro(CacheMesh, int);
|
||||
|
||||
// Description:
|
||||
// FOAM extrapolate internal values onto the walls
|
||||
vtkSetMacro(ExtrapolateWalls, int);
|
||||
vtkGetMacro(ExtrapolateWalls, int);
|
||||
@ -87,42 +73,53 @@ public:
|
||||
vtkSetMacro(IncludeSets, int);
|
||||
vtkGetMacro(IncludeSets, int);
|
||||
|
||||
// Description:
|
||||
// FOAM read zones control
|
||||
vtkSetMacro(IncludeZones, int);
|
||||
vtkGetMacro(IncludeZones, int);
|
||||
|
||||
// Description:
|
||||
// FOAM display patch names control
|
||||
vtkSetMacro(ShowPatchNames, int);
|
||||
vtkGetMacro(ShowPatchNames, int);
|
||||
|
||||
// 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);
|
||||
// Description:
|
||||
// Get the current timestep
|
||||
int GetTimeStep();
|
||||
|
||||
// Description:
|
||||
// Parts selection list control
|
||||
vtkDataArraySelection* GetPartSelection();
|
||||
int GetNumberOfPartArrays();
|
||||
int GetPartArrayStatus(const char* name);
|
||||
void SetPartArrayStatus(const char* name, int status);
|
||||
const char* GetPartArrayName(int index);
|
||||
|
||||
// Description:
|
||||
// volField selection list control
|
||||
vtkDataArraySelection* GetVolFieldSelection();
|
||||
int GetNumberOfVolFieldArrays();
|
||||
const char* GetVolFieldArrayName(int index);
|
||||
int GetVolFieldArrayStatus(const char* name);
|
||||
int GetNumberOfVolFieldArrays();
|
||||
int GetVolFieldArrayStatus(const char* name);
|
||||
void SetVolFieldArrayStatus(const char* name, int status);
|
||||
const char* GetVolFieldArrayName(int index);
|
||||
|
||||
// Description:
|
||||
// pointField selection list control
|
||||
vtkDataArraySelection* GetPointFieldSelection();
|
||||
int GetNumberOfPointFieldArrays();
|
||||
int GetPointFieldArrayStatus(const char* name);
|
||||
int GetNumberOfPointFieldArrays();
|
||||
int GetPointFieldArrayStatus(const char* name);
|
||||
void SetPointFieldArrayStatus(const char* name, int status);
|
||||
const char* GetPointFieldArrayName(int index);
|
||||
|
||||
// Description:
|
||||
// lagrangianField selection list control
|
||||
vtkDataArraySelection* GetLagrangianFieldSelection();
|
||||
int GetNumberOfLagrangianFieldArrays();
|
||||
int GetLagrangianFieldArrayStatus(const char* name);
|
||||
int GetNumberOfLagrangianFieldArrays();
|
||||
int GetLagrangianFieldArrayStatus(const char* name);
|
||||
void SetLagrangianFieldArrayStatus(const char* name, int status);
|
||||
const char* GetLagrangianFieldArrayName(int index);
|
||||
|
||||
// Description:
|
||||
// Callback registered with the SelectionObserver
|
||||
// for all the selection lists
|
||||
static void SelectionModifiedCallback
|
||||
@ -138,18 +135,13 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
//- Construct null
|
||||
vtkPV3FoamReader();
|
||||
|
||||
//- Destructor
|
||||
~vtkPV3FoamReader();
|
||||
|
||||
char* FileName;
|
||||
|
||||
virtual int RequestData
|
||||
(
|
||||
vtkInformation*,
|
||||
vtkInformationVector**,
|
||||
vtkInformationVector*
|
||||
);
|
||||
|
||||
//- Return information about mesh, times, etc without loading anything
|
||||
virtual int RequestInformation
|
||||
(
|
||||
vtkInformation*,
|
||||
@ -157,15 +149,30 @@ protected:
|
||||
vtkInformationVector*
|
||||
);
|
||||
|
||||
// The observer to modify this object when the array selections
|
||||
// are modified
|
||||
//- Get the mesh/fields for a particular time
|
||||
//- Destructor
|
||||
virtual int RequestData
|
||||
(
|
||||
vtkInformation*,
|
||||
vtkInformationVector**,
|
||||
vtkInformationVector*
|
||||
);
|
||||
|
||||
//- Fill in additional port information
|
||||
virtual int FillOutputPortInformation(int, vtkInformation*);
|
||||
|
||||
// The observer to modify this object when array selections are modified
|
||||
vtkCallbackCommand* SelectionObserver;
|
||||
|
||||
char* FileName;
|
||||
|
||||
private:
|
||||
|
||||
vtkPV3FoamReader(const vtkPV3FoamReader&); // Not implemented.
|
||||
void operator=(const vtkPV3FoamReader&); // Not implemented.
|
||||
//- Disallow default bitwise copy construct
|
||||
vtkPV3FoamReader(const vtkPV3FoamReader&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vtkPV3FoamReader&);
|
||||
|
||||
//- Add patch names to the view
|
||||
void addPatchNamesToView();
|
||||
@ -173,9 +180,7 @@ private:
|
||||
//- Remove patch names from the view
|
||||
void removePatchNamesFromView();
|
||||
|
||||
int TimeStep;
|
||||
int TimeStepRange[2];
|
||||
|
||||
int CacheMesh;
|
||||
|
||||
int ExtrapolateWalls;
|
||||
@ -183,16 +188,16 @@ private:
|
||||
int IncludeZones;
|
||||
int ShowPatchNames;
|
||||
|
||||
//- Dummy variable/switch for invoke a reader update
|
||||
int UpdateGUI;
|
||||
int UpdateGUIOld;
|
||||
|
||||
vtkDataArraySelection* RegionSelection;
|
||||
vtkDataArraySelection* PartSelection;
|
||||
vtkDataArraySelection* VolFieldSelection;
|
||||
vtkDataArraySelection* PointFieldSelection;
|
||||
vtkDataArraySelection* LagrangianFieldSelection;
|
||||
|
||||
//- Access to the output port1
|
||||
vtkMultiBlockDataSet* output1_;
|
||||
//- Cached data for output port0 (experimental!)
|
||||
vtkMultiBlockDataSet* output0_;
|
||||
|
||||
//BTX
|
||||
Foam::vtkPV3Foam* foamData_;
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
vtkPV3Foam.C
|
||||
vtkPV3FoamAddVolumeMesh.C
|
||||
vtkPV3FoamAddLagrangianMesh.C
|
||||
vtkPV3FoamAddPatchMesh.C
|
||||
vtkPV3FoamAddZoneMesh.C
|
||||
vtkPV3FoamAddSetMesh.C
|
||||
vtkPV3FoamUpdate.C
|
||||
vtkPV3FoamUpdateInformation.C
|
||||
vtkPV3FoamConvertMesh.C
|
||||
vtkPV3FoamFields.C
|
||||
vtkPV3FoamMesh.C
|
||||
vtkPV3FoamMeshLagrangian.C
|
||||
vtkPV3FoamMeshPatch.C
|
||||
vtkPV3FoamMeshSet.C
|
||||
vtkPV3FoamMeshVolume.C
|
||||
vtkPV3FoamMeshZone.C
|
||||
vtkPV3FoamUpdateInfo.C
|
||||
vtkPV3FoamUtilities.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libvtkPV3Foam
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -32,23 +32,23 @@ SourceFiles
|
||||
vtkPV3Foam.C
|
||||
vtkPV3Foam.H
|
||||
vtkPV3FoamI.H
|
||||
vtkPV3FoamAddLagrangianMesh.C
|
||||
vtkPV3FoamAddPatchMesh.C
|
||||
vtkPV3FoamAddSetMesh.C
|
||||
vtkPV3FoamFields.C
|
||||
vtkPV3FoamMesh.C
|
||||
vtkPV3FoamMeshLagrangian.C
|
||||
vtkPV3FoamMeshPatch.C
|
||||
vtkPV3FoamMeshSet.C
|
||||
vtkPV3FoamMeshVolume.C
|
||||
vtkPV3FoamMeshZone.C
|
||||
vtkPV3FoamFaceField.H
|
||||
vtkPV3FoamLagrangianFields.H
|
||||
vtkPV3FoamPatchField.H
|
||||
vtkPV3FoamPointFields.H
|
||||
vtkPV3FoamPoints.H
|
||||
vtkPV3FoamUpdateInfo.C
|
||||
vtkPV3FoamUpdateInfoFields.H
|
||||
vtkPV3FoamUtilities.C
|
||||
vtkPV3FoamVolFields.H
|
||||
vtkPV3FoamAddToSelection.H
|
||||
vtkPV3FoamAddVolumeMesh.C
|
||||
vtkPV3FoamAddZoneMesh.C
|
||||
vtkPV3FoamConvertFaceField.H
|
||||
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
|
||||
@ -104,24 +104,22 @@ class List;
|
||||
|
||||
class vtkPV3Foam
|
||||
{
|
||||
public:
|
||||
// Private classes
|
||||
|
||||
// Public data
|
||||
|
||||
//- bookkeeping for the GUI checklists and the multi-block organization
|
||||
class selectionInfo
|
||||
//- Bookkeeping for GUI checklists and the multi-block organization
|
||||
class partInfo
|
||||
{
|
||||
int block_;
|
||||
const char *name_;
|
||||
int block_;
|
||||
int start_;
|
||||
int size_;
|
||||
|
||||
public:
|
||||
|
||||
selectionInfo(const int blockNo, const char *name)
|
||||
partInfo(const char *name, const int blockNo=0)
|
||||
:
|
||||
block_(blockNo),
|
||||
name_(name),
|
||||
block_(blockNo),
|
||||
start_(-1),
|
||||
size_(0)
|
||||
{}
|
||||
@ -132,6 +130,13 @@ public:
|
||||
return block_;
|
||||
}
|
||||
|
||||
int block(int blockNo)
|
||||
{
|
||||
int prev = block_;
|
||||
block_ = blockNo;
|
||||
return prev;
|
||||
}
|
||||
|
||||
const char* name() const
|
||||
{
|
||||
return name_;
|
||||
@ -172,26 +177,67 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//BTX
|
||||
//- Indices for datasets in vtkMultiBlockDataSet
|
||||
enum
|
||||
//- bookkeeping for polyhedral cell decomposition
|
||||
// hide in extra pointMap (cellSet/cellZone) for now
|
||||
class polyDecomp
|
||||
{
|
||||
VOLUME = 0, // internal mesh
|
||||
PATCHES = 1, // patches
|
||||
LAGRANGIAN = 2,
|
||||
CELLZONE = 3,
|
||||
FACEZONE = 4,
|
||||
POINTZONE = 5,
|
||||
CELLSET = 6,
|
||||
FACESET = 7,
|
||||
POINTSET = 8
|
||||
labelList superCells_;
|
||||
labelList addPointCellLabels_;
|
||||
labelList pointMap_;
|
||||
|
||||
public:
|
||||
|
||||
polyDecomp()
|
||||
{}
|
||||
|
||||
//- Label of original cell for decomposed cells
|
||||
labelList& superCells()
|
||||
{
|
||||
return superCells_;
|
||||
}
|
||||
|
||||
//- Label of original cell for decomposed cells
|
||||
const labelList& superCells() const
|
||||
{
|
||||
return superCells_;
|
||||
}
|
||||
|
||||
//- Cell-centre labels for additional points of decomposed cells
|
||||
labelList& addPointCellLabels()
|
||||
{
|
||||
return addPointCellLabels_;
|
||||
}
|
||||
|
||||
//- Cell-centre labels for additional points of decomposed cells
|
||||
const labelList& addPointCellLabels() const
|
||||
{
|
||||
return addPointCellLabels_;
|
||||
}
|
||||
|
||||
//- Point labels for subsetted meshes
|
||||
labelList& pointMap()
|
||||
{
|
||||
return pointMap_;
|
||||
}
|
||||
|
||||
//- Point labels for subsetted meshes
|
||||
const labelList& pointMap() const
|
||||
{
|
||||
return pointMap_;
|
||||
}
|
||||
|
||||
|
||||
//- Clear
|
||||
void clear()
|
||||
{
|
||||
superCells_.clear();
|
||||
addPointCellLabels_.clear();
|
||||
pointMap_.clear();
|
||||
}
|
||||
};
|
||||
//ETX
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Access to the controlling vtkPV3FoamReader
|
||||
vtkPV3FoamReader* reader_;
|
||||
@ -202,64 +248,51 @@ private:
|
||||
//- Foam mesh
|
||||
fvMesh* meshPtr_;
|
||||
|
||||
//- First instance and size of various regions
|
||||
selectionInfo selectInfoVolume_;
|
||||
selectionInfo selectInfoPatches_;
|
||||
selectionInfo selectInfoLagrangian_;
|
||||
selectionInfo selectInfoCellZones_;
|
||||
selectionInfo selectInfoFaceZones_;
|
||||
selectionInfo selectInfoPointZones_;
|
||||
selectionInfo selectInfoCellSets_;
|
||||
selectionInfo selectInfoFaceSets_;
|
||||
selectionInfo selectInfoPointSets_;
|
||||
//- Number of meshes
|
||||
// TODO - for info only - only set up to process ONE mesh
|
||||
int nMesh_;
|
||||
|
||||
//- Selected regions
|
||||
// [0] = internal mesh, then lagrangian, patches, zones, sets
|
||||
boolList selectedRegions_;
|
||||
//- The time index
|
||||
int timeIndex_;
|
||||
|
||||
//- Selected regions indices in each respective block
|
||||
labelList selectedRegionDatasetIds_;
|
||||
//- Track changes in mesh geometry
|
||||
bool meshChanged_;
|
||||
|
||||
//- Labels of cell-centres used as additional points when decomposing
|
||||
// polyhedra
|
||||
labelList addPointCellLabels_;
|
||||
//- Track changes in fields
|
||||
bool fieldsChanged_;
|
||||
|
||||
//- Label of original cell for decomposed cells
|
||||
// - internal mesh
|
||||
labelList superCells_;
|
||||
//- Selected geometrical parts (internalMesh, patches, ...)
|
||||
boolList partStatus_;
|
||||
|
||||
//- Label of original cell for decomposed cells
|
||||
// - cellZone meshes
|
||||
List<labelList> zoneSuperCells_;
|
||||
//- Datasets corresponding to selected geometrical pieces
|
||||
// a negative number indicates that no vtkmesh exists for this piece
|
||||
labelList partDataset_;
|
||||
|
||||
//- Label of original cell for decomposed cells
|
||||
// - cellSet meshes
|
||||
List<labelList> csetSuperCells_;
|
||||
//- First instance and size of various mesh parts
|
||||
// used to index into partStatus_ and partDataset_
|
||||
partInfo partInfoVolume_;
|
||||
partInfo partInfoPatches_;
|
||||
partInfo partInfoLagrangian_;
|
||||
partInfo partInfoCellZones_;
|
||||
partInfo partInfoFaceZones_;
|
||||
partInfo partInfoPointZones_;
|
||||
partInfo partInfoCellSets_;
|
||||
partInfo partInfoFaceSets_;
|
||||
partInfo partInfoPointSets_;
|
||||
|
||||
//- List of patch names
|
||||
//- Decomposed cells information (mesh regions)
|
||||
// TODO: regions
|
||||
List<polyDecomp> regionPolyDecomp_;
|
||||
|
||||
//- Decomposed cells information (cellZone meshes)
|
||||
List<polyDecomp> zonePolyDecomp_;
|
||||
|
||||
//- Decomposed cells information (cellSet meshes)
|
||||
List<polyDecomp> csetPolyDecomp_;
|
||||
|
||||
//- List of patch names for rendering to window
|
||||
List<vtkTextActor*> patchTextActorsPtrs_;
|
||||
|
||||
|
||||
// Dataset sizes
|
||||
|
||||
//- Number of meshes
|
||||
// TODO - for info only - only set up to process ONE mesh
|
||||
int nMesh_;
|
||||
|
||||
//- Cloud name to be processed
|
||||
// TODO - currently only set up to process ONE cloud
|
||||
word cloudName_;
|
||||
|
||||
//- The time index
|
||||
int timeIndex_;
|
||||
|
||||
//- Track changes in mesh geometry
|
||||
bool meshChanged_;
|
||||
|
||||
//- Track changes in fields
|
||||
bool fieldsChanged_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
// Convenience method use to convert the readers from VTK 5
|
||||
@ -267,10 +300,10 @@ private:
|
||||
static void AddToBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo&,
|
||||
const label datasetNo,
|
||||
vtkDataSet* dataset,
|
||||
const string& blockName = string::null
|
||||
const partInfo&,
|
||||
const label datasetNo,
|
||||
const string& datasetName
|
||||
);
|
||||
|
||||
// Convenience method use to convert the readers from VTK 5
|
||||
@ -278,7 +311,7 @@ private:
|
||||
static vtkDataSet* GetDataSetFromBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo&,
|
||||
const partInfo&,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
@ -287,7 +320,7 @@ private:
|
||||
static label GetNumberOfDataSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo&
|
||||
const partInfo&
|
||||
);
|
||||
|
||||
//- Reset data counters
|
||||
@ -295,45 +328,42 @@ private:
|
||||
|
||||
// Update information helper functions
|
||||
|
||||
//- Update the regions selected in the GUI
|
||||
void updateSelectedRegions();
|
||||
//- Update the mesh parts selected in the GUI
|
||||
void updateMeshPartsStatus();
|
||||
|
||||
//- Internal mesh info
|
||||
void updateInformationInternalMesh();
|
||||
void updateInfoInternalMesh();
|
||||
|
||||
//- Lagrangian info
|
||||
void updateInformationLagrangian();
|
||||
void updateInfoLagrangian();
|
||||
|
||||
//- Patch info
|
||||
void updateInformationPatches();
|
||||
void updateInfoPatches();
|
||||
|
||||
//- Set info
|
||||
void updateInformationSets();
|
||||
void updateInfoSets();
|
||||
|
||||
//- Zone info
|
||||
void updateInfoZones();
|
||||
|
||||
//- Read zone names for zoneType from file
|
||||
wordList readZoneNames(const word& zoneType);
|
||||
|
||||
//- Zone info
|
||||
void updateInformationZones();
|
||||
|
||||
//- Add to paraview array selection
|
||||
//- Add objects of Type to paraview array selection
|
||||
template<class Type>
|
||||
label addToSelection
|
||||
(
|
||||
vtkDataArraySelection *arraySelection,
|
||||
vtkDataArraySelection*,
|
||||
const IOobjectList&,
|
||||
const string& suffix = ""
|
||||
const string& suffix=string::null
|
||||
);
|
||||
|
||||
//- Field info
|
||||
template<template<class> class patchType, class meshType>
|
||||
void updateInformationFields
|
||||
(
|
||||
vtkDataArraySelection *fieldSelection
|
||||
);
|
||||
void updateInfoFields(vtkDataArraySelection*);
|
||||
|
||||
//- Lagrangian field info
|
||||
void updateInformationLagrangianFields();
|
||||
void updateInfoLagrangianFields();
|
||||
|
||||
|
||||
// Update helper functions
|
||||
@ -341,118 +371,112 @@ private:
|
||||
//- Foam mesh
|
||||
void updateFoamMesh();
|
||||
|
||||
//- Reduce memory footprint after conversion
|
||||
void reduceMemory();
|
||||
|
||||
//- Volume fields
|
||||
void updateVolFields(vtkMultiBlockDataSet* output);
|
||||
void updateVolFields(vtkMultiBlockDataSet*);
|
||||
|
||||
//- Point fields
|
||||
void updatePointFields(vtkMultiBlockDataSet* output);
|
||||
void updatePointFields(vtkMultiBlockDataSet*);
|
||||
|
||||
//- Lagrangian fields
|
||||
void updateLagrangianFields(vtkMultiBlockDataSet* output);
|
||||
void updateLagrangianFields(vtkMultiBlockDataSet*);
|
||||
|
||||
|
||||
// Mesh conversion functions
|
||||
|
||||
//- Volume mesh
|
||||
void convertMeshVolume(vtkMultiBlockDataSet* output);
|
||||
void convertMeshVolume(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Lagrangian mesh
|
||||
void convertMeshLagrangian(vtkMultiBlockDataSet* output);
|
||||
void convertMeshLagrangian(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Patch meshes
|
||||
void convertMeshPatches(vtkMultiBlockDataSet* output);
|
||||
void convertMeshPatches(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Cell zone meshes
|
||||
void convertMeshCellZones(vtkMultiBlockDataSet* output);
|
||||
void convertMeshCellZones(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Face zone meshes
|
||||
void convertMeshFaceZones(vtkMultiBlockDataSet* output);
|
||||
void convertMeshFaceZones(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Point zone meshes
|
||||
void convertMeshPointZones(vtkMultiBlockDataSet* output);
|
||||
void convertMeshPointZones(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Cell set meshes
|
||||
void convertMeshCellSets(vtkMultiBlockDataSet* output);
|
||||
void convertMeshCellSets(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Face set meshes
|
||||
void convertMeshFaceSets(vtkMultiBlockDataSet* output);
|
||||
void convertMeshFaceSets(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Point set meshes
|
||||
void convertMeshPointSets(vtkMultiBlockDataSet* output);
|
||||
void convertMeshPointSets(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
|
||||
// Add mesh functions
|
||||
|
||||
//- Add internal mesh/cell set meshes
|
||||
void addVolumeMesh
|
||||
(
|
||||
const fvMesh&,
|
||||
vtkUnstructuredGrid*,
|
||||
labelList& superCells
|
||||
);
|
||||
vtkUnstructuredGrid* volumeVTKMesh(const fvMesh&, polyDecomp&);
|
||||
|
||||
//- Add Lagrangian mesh
|
||||
void addLagrangianMesh
|
||||
vtkPolyData* lagrangianVTKMesh
|
||||
(
|
||||
const fvMesh&,
|
||||
vtkPolyData*
|
||||
const word& cloudName
|
||||
);
|
||||
|
||||
//- Add patch mesh
|
||||
void addPatchMesh
|
||||
(
|
||||
const polyPatch&,
|
||||
vtkPolyData*
|
||||
);
|
||||
vtkPolyData* patchVTKMesh(const polyPatch&);
|
||||
|
||||
//- Add face zone mesh
|
||||
void addFaceZoneMesh
|
||||
vtkPolyData* faceZoneVTKMesh
|
||||
(
|
||||
const fvMesh&,
|
||||
const labelList& faceLabels,
|
||||
vtkPolyData*
|
||||
const labelList& faceLabels
|
||||
);
|
||||
|
||||
//- Add point zone
|
||||
void addPointZoneMesh
|
||||
vtkPolyData* pointZoneVTKMesh
|
||||
(
|
||||
const fvMesh&,
|
||||
const labelList& pointLabels,
|
||||
vtkPolyData*
|
||||
);
|
||||
|
||||
//- Add cell set mesh
|
||||
void addCellSetMesh
|
||||
(
|
||||
const fvMesh&,
|
||||
vtkUnstructuredGrid*
|
||||
const labelList& pointLabels
|
||||
);
|
||||
|
||||
//- Add face set mesh
|
||||
void addFaceSetMesh
|
||||
vtkPolyData* faceSetVTKMesh
|
||||
(
|
||||
const fvMesh&,
|
||||
const faceSet&,
|
||||
vtkPolyData*
|
||||
const faceSet&
|
||||
);
|
||||
|
||||
//- Add point mesh
|
||||
void addPointSetMesh
|
||||
vtkPolyData* pointSetVTKMesh
|
||||
(
|
||||
const fvMesh&,
|
||||
const pointSet&,
|
||||
vtkPolyData*
|
||||
const pointSet&
|
||||
);
|
||||
|
||||
// Field conversion functions
|
||||
|
||||
//- Convert volume fields
|
||||
void convertVolFields(vtkMultiBlockDataSet*);
|
||||
|
||||
//- Convert point fields
|
||||
void convertPointFields(vtkMultiBlockDataSet*);
|
||||
|
||||
//- Convert Lagrangian fields
|
||||
void convertLagrangianFields(vtkMultiBlockDataSet*);
|
||||
|
||||
|
||||
//- Add the fields in the selected time directory to the selection
|
||||
// lists
|
||||
template<class GeoField>
|
||||
label addObjectsToSelection
|
||||
(
|
||||
vtkDataArraySelection* fieldSelection,
|
||||
const IOobjectList& objects,
|
||||
const string& suffix = string::null
|
||||
vtkDataArraySelection*,
|
||||
const IOobjectList&,
|
||||
const string& suffix=string::null
|
||||
);
|
||||
|
||||
|
||||
@ -463,32 +487,42 @@ private:
|
||||
void convertVolFields
|
||||
(
|
||||
const fvMesh&,
|
||||
const volPointInterpolation& pInterp,
|
||||
const volPointInterpolation&,
|
||||
const PtrList<PrimitivePatchInterpolation<primitivePatch> >&,
|
||||
const IOobjectList& objects,
|
||||
vtkDataArraySelection* fieldSelection,
|
||||
const IOobjectList&,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
|
||||
//- Volume field - all types except scalar
|
||||
//- Volume field - all selected parts
|
||||
template<class Type>
|
||||
void convertVolFieldBlock
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
const GeometricField<Type, pointPatchField, pointMesh>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector,
|
||||
const List<polyDecomp>& decompLst
|
||||
);
|
||||
|
||||
//- Volume field
|
||||
template<class Type>
|
||||
void convertVolField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo&,
|
||||
const partInfo&,
|
||||
const label datasetNo,
|
||||
labelList& superCells
|
||||
const polyDecomp&
|
||||
);
|
||||
|
||||
//- Patch field
|
||||
template<class Type>
|
||||
void convertPatchFaceField
|
||||
void convertPatchField
|
||||
(
|
||||
const word& name,
|
||||
const Field<Type>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo&,
|
||||
const partInfo&,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
@ -498,7 +532,7 @@ private:
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo&,
|
||||
const partInfo&,
|
||||
const label datasetNo,
|
||||
const fvMesh&,
|
||||
const labelList& faceLabels
|
||||
@ -510,7 +544,7 @@ private:
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo&,
|
||||
const partInfo&,
|
||||
const label datasetNo,
|
||||
const fvMesh&,
|
||||
const faceSet&
|
||||
@ -520,19 +554,18 @@ private:
|
||||
template<class Type>
|
||||
void convertLagrangianFields
|
||||
(
|
||||
const fvMesh&,
|
||||
const IOobjectList& objects,
|
||||
vtkDataArraySelection *fieldSelection,
|
||||
vtkMultiBlockDataSet* output
|
||||
const IOobjectList&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
//- Lagrangian field - all types except scalar
|
||||
//- Lagrangian field
|
||||
template<class Type>
|
||||
void convertLagrangianField
|
||||
(
|
||||
const IOField<Type>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo&,
|
||||
const partInfo&,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
@ -540,31 +573,42 @@ private:
|
||||
template<class Type>
|
||||
void convertPointFields
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
vtkDataArraySelection *fieldSelection,
|
||||
const fvMesh&,
|
||||
const pointMesh&,
|
||||
const IOobjectList&,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
|
||||
//- Point fields - all types except scalar
|
||||
//- Point field - all selected parts
|
||||
template<class Type>
|
||||
void convertPointFieldBlock
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector,
|
||||
const List<polyDecomp>&
|
||||
);
|
||||
|
||||
//- Point fields
|
||||
template<class Type>
|
||||
void convertPointField
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& ptf,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& tf,
|
||||
const GeometricField<Type, pointPatchField, pointMesh>&,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo&,
|
||||
const label datasetNo
|
||||
const partInfo&,
|
||||
const label datasetNo,
|
||||
const polyDecomp&
|
||||
);
|
||||
|
||||
//- Patch point field - all types except scalar
|
||||
//- Patch point field
|
||||
template<class Type>
|
||||
void convertPatchPointField
|
||||
(
|
||||
const word& name,
|
||||
const Field<Type>& tf,
|
||||
const Field<Type>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo&,
|
||||
const partInfo&,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
@ -574,28 +618,43 @@ private:
|
||||
//- Extract up to the first non-word characters
|
||||
inline static word getFirstWord(const char*);
|
||||
|
||||
//- Store the current selection(s)
|
||||
static stringList getSelectedArrayEntries
|
||||
//- Only keep what is listed in hashSet
|
||||
static void pruneObjectList
|
||||
(
|
||||
vtkDataArraySelection* arraySelection,
|
||||
const bool firstWord = false
|
||||
IOobjectList&,
|
||||
const wordHashSet&
|
||||
);
|
||||
|
||||
//- Store the current selection(s) for a sub-selection
|
||||
//- Retrieve the current selections
|
||||
static wordHashSet getSelected(vtkDataArraySelection*);
|
||||
|
||||
//- Retrieve a sub-list of the current selections
|
||||
static wordHashSet getSelected
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const partInfo&
|
||||
);
|
||||
|
||||
//- Retrieve the current selections
|
||||
static stringList getSelectedArrayEntries(vtkDataArraySelection*);
|
||||
|
||||
//- Retrieve a sub-list of the current selections
|
||||
static stringList getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* arraySelection,
|
||||
const selectionInfo&,
|
||||
const bool firstWord = false
|
||||
vtkDataArraySelection*,
|
||||
const partInfo&
|
||||
);
|
||||
|
||||
//- Set selection(s)
|
||||
static void setSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* arraySelection,
|
||||
const stringList& selectedEntries
|
||||
vtkDataArraySelection*,
|
||||
const stringList&
|
||||
);
|
||||
|
||||
//- Get the first word from the mesh parts selection
|
||||
word getPartName(int);
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
vtkPV3Foam(const vtkPV3Foam&);
|
||||
@ -629,9 +688,13 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Update
|
||||
void UpdateInformation();
|
||||
void updateInfo();
|
||||
|
||||
void Update(vtkMultiBlockDataSet* output);
|
||||
void Update
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
vtkMultiBlockDataSet* lagrangianOutput
|
||||
);
|
||||
|
||||
//- Allocate and return a list of selected times
|
||||
// returns the count via the parameter
|
||||
@ -643,10 +706,15 @@ public:
|
||||
//- Remove patch names from the display
|
||||
void removePatchNames(vtkRenderer* renderer);
|
||||
|
||||
//- set the runTime to the requested time
|
||||
// sets to "constant" on error
|
||||
bool setTime(const double& requestedTime);
|
||||
//- set the runTime to the requested time, returns the timeIndex
|
||||
// sets to "constant" on error and returns -1
|
||||
int setTime(const double& requestedTime);
|
||||
|
||||
//- The current time index
|
||||
int timeIndex() const
|
||||
{
|
||||
return timeIndex_;
|
||||
}
|
||||
|
||||
// Access
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ License
|
||||
#define vtkPV3FoamAddToSelection_H
|
||||
|
||||
// FOAM includes
|
||||
#include "IOobjectList.H"
|
||||
#include "SortableList.H"
|
||||
|
||||
// VTK includes
|
||||
@ -38,51 +39,26 @@ License
|
||||
template<class Type>
|
||||
Foam::label Foam::vtkPV3Foam::addToSelection
|
||||
(
|
||||
vtkDataArraySelection *arraySelection,
|
||||
vtkDataArraySelection *select,
|
||||
const IOobjectList& objectLst,
|
||||
const string& suffix
|
||||
)
|
||||
{
|
||||
IOobjectList objects(objectLst.lookupClass(Type::typeName));
|
||||
SortableList<word> names(objectLst.names(Type::typeName));
|
||||
|
||||
SortableList<word> objectNames(objects.size());
|
||||
|
||||
label count = 0;
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
forAll(names, nameI)
|
||||
{
|
||||
objectNames[count++] = iter()->name();
|
||||
}
|
||||
|
||||
if (count)
|
||||
{
|
||||
objectNames.sort();
|
||||
|
||||
forAll (objectNames, objI)
|
||||
if (suffix.size())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<<" addToSelection<" << Type::typeName << "> to GUI "
|
||||
<< ":" << objectNames[objI] << endl;
|
||||
}
|
||||
|
||||
if (suffix.size())
|
||||
{
|
||||
arraySelection->AddArray
|
||||
(
|
||||
(objectNames[objI] + suffix).c_str()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
arraySelection->AddArray
|
||||
(
|
||||
objectNames[objI].c_str()
|
||||
);
|
||||
}
|
||||
select->AddArray((names[nameI] + suffix).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
select->AddArray(names[nameI].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
return names.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,139 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
vtkPV3Foam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPV3FoamConvertLagrangianFields_H
|
||||
#define vtkPV3FoamConvertLagrangianFields_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertLagrangianFields
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
vtkDataArraySelection* fieldSelection,
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
const selectionInfo& selector = selectInfoLagrangian_;
|
||||
const label datasetId = 0;
|
||||
|
||||
if (!selector.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IOobjectList fieldObjects
|
||||
(
|
||||
objects.lookupClass
|
||||
(
|
||||
IOField<Type>::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))
|
||||
{
|
||||
IOField<Type> iotf
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName,
|
||||
mesh.time().timeName(),
|
||||
"lagrangian"/cloudName_,
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
);
|
||||
|
||||
convertLagrangianField(iotf, output, selector, datasetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertLagrangianField
|
||||
(
|
||||
const IOField<Type>& tf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo& selector,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, selector, datasetNo)
|
||||
);
|
||||
|
||||
vtkFloatArray *pointData = vtkFloatArray::New();
|
||||
pointData->SetNumberOfTuples(tf.size());
|
||||
pointData->SetNumberOfComponents(nComp);
|
||||
pointData->Allocate(nComp*tf.size());
|
||||
pointData->SetName(tf.name().c_str());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "converting Lagrangian <Type>Field: " << tf.name() << nl
|
||||
<< "tf.size() = " << tf.size() << nl
|
||||
<< "nComp = " << nComp << endl;
|
||||
}
|
||||
|
||||
float vec[nComp];
|
||||
|
||||
forAll(tf, i)
|
||||
{
|
||||
for (direction d=0; d<nComp; d++)
|
||||
{
|
||||
vec[d] = component(tf[i], d);
|
||||
}
|
||||
|
||||
pointData->InsertTuple(i, vec);
|
||||
}
|
||||
|
||||
vtkmesh->GetPointData()->AddArray(pointData);
|
||||
pointData->Delete();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,649 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkPV3Foam.H"
|
||||
|
||||
// Foam includes
|
||||
#include "cellSet.H"
|
||||
#include "faceSet.H"
|
||||
#include "pointSet.H"
|
||||
#include "fvMeshSubset.H"
|
||||
#include "vtkPV3FoamReader.h"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshVolume
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshVolume" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const selectionInfo& selector = selectInfoVolume_;
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
// Create the internal mesh and add as dataset 0
|
||||
for
|
||||
(
|
||||
int regionId = selector.start();
|
||||
regionId < selector.end();
|
||||
++regionId
|
||||
)
|
||||
{
|
||||
if (!selectedRegions_[regionId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// word selectName = getFirstWord
|
||||
// (
|
||||
// arraySelection->GetArrayName(regionId)
|
||||
// );
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTK internalMesh" << endl;
|
||||
}
|
||||
|
||||
const label datasetId = 0;
|
||||
|
||||
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
|
||||
addVolumeMesh(mesh, vtkmesh, superCells_);
|
||||
|
||||
AddToBlock(output, selector, datasetId, vtkmesh, "internalMesh");
|
||||
selectedRegionDatasetIds_[regionId] = datasetId;
|
||||
vtkmesh->Delete();
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshVolume" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshLagrangian
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshLagrangian" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const selectionInfo& selector = selectInfoLagrangian_;
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
// Create the Lagrangian mesh and add as dataset 0
|
||||
for
|
||||
(
|
||||
int regionId = selector.start();
|
||||
regionId < selector.end();
|
||||
++regionId
|
||||
)
|
||||
{
|
||||
if (!selectedRegions_[regionId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTK Lagrangian mesh" << endl;
|
||||
}
|
||||
|
||||
const label datasetId = 0;
|
||||
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
addLagrangianMesh(mesh, vtkmesh);
|
||||
|
||||
AddToBlock(output, selector, datasetId, vtkmesh, cloudName_);
|
||||
selectedRegionDatasetIds_[regionId] = datasetId;
|
||||
vtkmesh->Delete();
|
||||
}
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshLagrangian" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshPatches
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshPatches" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const selectionInfo& selector = selectInfoPatches_;
|
||||
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
|
||||
|
||||
if (selector.size())
|
||||
{
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
// Create the patches and add as dataset ...
|
||||
for
|
||||
(
|
||||
int regionId = selector.start();
|
||||
regionId < selector.end();
|
||||
++regionId
|
||||
)
|
||||
{
|
||||
if (!selectedRegions_[regionId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
word selectName = getFirstWord
|
||||
(
|
||||
arraySelection->GetArrayName(regionId)
|
||||
);
|
||||
|
||||
const label patchId = patches.findPatchID(selectName);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTK mesh for patch: " << selectName
|
||||
<< " region index: " << regionId << endl;
|
||||
}
|
||||
|
||||
const label datasetId = GetNumberOfDataSets(output, selector);
|
||||
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
addPatchMesh
|
||||
(
|
||||
patches[patchId],
|
||||
vtkmesh
|
||||
);
|
||||
|
||||
AddToBlock
|
||||
(
|
||||
output, selector, datasetId, vtkmesh,
|
||||
selectName + ":patch"
|
||||
);
|
||||
selectedRegionDatasetIds_[regionId] = datasetId;
|
||||
vtkmesh->Delete();
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshPatches" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshCellZones
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const selectionInfo& selector = selectInfoCellZones_;
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
// Create the cell zone(s) and add as DataSet(CELLZONE, 0..n)
|
||||
if (selector.size())
|
||||
{
|
||||
const cellZoneMesh& czMesh = mesh.cellZones();
|
||||
|
||||
// use the zoneId directly instead of the name
|
||||
for (int zoneI=0; zoneI < selector.size(); ++zoneI)
|
||||
{
|
||||
const int regionId = selector.start() + zoneI;
|
||||
|
||||
if (!selectedRegions_[regionId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTK mesh for cellZone: "
|
||||
<< zoneI << endl;
|
||||
}
|
||||
|
||||
fvMeshSubset subsetter(mesh);
|
||||
subsetter.setLargeCellSubset(czMesh[zoneI]);
|
||||
|
||||
const label datasetId = GetNumberOfDataSets(output, selector);
|
||||
|
||||
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
|
||||
|
||||
addVolumeMesh
|
||||
(
|
||||
subsetter.subMesh(),
|
||||
vtkmesh,
|
||||
zoneSuperCells_[datasetId]
|
||||
);
|
||||
|
||||
// renumber - superCells must contain global cell ids
|
||||
inplaceRenumber
|
||||
(
|
||||
subsetter.cellMap(),
|
||||
zoneSuperCells_[datasetId]
|
||||
);
|
||||
|
||||
AddToBlock
|
||||
(
|
||||
output, selector, datasetId, vtkmesh,
|
||||
czMesh.names()[zoneI] + ":cellZone"
|
||||
);
|
||||
selectedRegionDatasetIds_[regionId] = datasetId;
|
||||
vtkmesh->Delete();
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshCellZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshCellSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const selectionInfo& selector = selectInfoCellSets_;
|
||||
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
|
||||
|
||||
// Create the cell sets and add as dataset
|
||||
if (selector.size())
|
||||
{
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
for
|
||||
(
|
||||
int regionId = selector.start();
|
||||
regionId < selector.end();
|
||||
++regionId)
|
||||
{
|
||||
if (!selectedRegions_[regionId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
word selectName = getFirstWord
|
||||
(
|
||||
arraySelection->GetArrayName(regionId)
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTK mesh for cellSet: " << selectName
|
||||
<< " region index: " << regionId << endl;
|
||||
}
|
||||
|
||||
const cellSet cSet(mesh, selectName);
|
||||
fvMeshSubset subsetter(mesh);
|
||||
subsetter.setLargeCellSubset(cSet);
|
||||
|
||||
const label datasetId = GetNumberOfDataSets(output, selector);
|
||||
|
||||
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
|
||||
|
||||
addVolumeMesh
|
||||
(
|
||||
subsetter.subMesh(),
|
||||
vtkmesh,
|
||||
csetSuperCells_[datasetId]
|
||||
);
|
||||
|
||||
// renumber - superCells must contain global cell ids
|
||||
inplaceRenumber
|
||||
(
|
||||
subsetter.cellMap(),
|
||||
csetSuperCells_[datasetId]
|
||||
);
|
||||
|
||||
AddToBlock
|
||||
(
|
||||
output, selector, datasetId, vtkmesh,
|
||||
selectName + ":cellSet"
|
||||
);
|
||||
selectedRegionDatasetIds_[regionId] = datasetId;
|
||||
vtkmesh->Delete();
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshCellSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshFaceZones
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshFaceZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const selectionInfo& selector = selectInfoFaceZones_;
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
// Create the cell zone(s) and add as datasets
|
||||
if (selector.size())
|
||||
{
|
||||
const faceZoneMesh& fzMesh = mesh.faceZones();
|
||||
|
||||
// use the zoneId directly instead of the name
|
||||
for (int zoneI=0; zoneI < selector.size(); ++zoneI)
|
||||
{
|
||||
const int regionId = selector.start() + zoneI;
|
||||
|
||||
if (!selectedRegions_[regionId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTK mesh for faceZone: "
|
||||
<< zoneI << endl;
|
||||
}
|
||||
|
||||
const label datasetId = GetNumberOfDataSets(output, selector);
|
||||
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
|
||||
addFaceZoneMesh
|
||||
(
|
||||
mesh,
|
||||
fzMesh[zoneI],
|
||||
vtkmesh
|
||||
);
|
||||
|
||||
AddToBlock
|
||||
(
|
||||
output, selector, datasetId, vtkmesh,
|
||||
fzMesh.names()[zoneI] + ":faceZone"
|
||||
);
|
||||
selectedRegionDatasetIds_[regionId] = datasetId;
|
||||
vtkmesh->Delete();
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshFaceSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshFaceSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const selectionInfo& selector = selectInfoFaceSets_;
|
||||
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
|
||||
|
||||
// Create the face sets and add as dataset
|
||||
if (selector.size())
|
||||
{
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
for
|
||||
(
|
||||
int regionId = selector.start();
|
||||
regionId < selector.end();
|
||||
++regionId
|
||||
)
|
||||
{
|
||||
if (!selectedRegions_[regionId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
word selectName = getFirstWord
|
||||
(
|
||||
arraySelection->GetArrayName(regionId)
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTK mesh for faceSet: " << selectName
|
||||
<< " region index: " << regionId << endl;
|
||||
}
|
||||
|
||||
const faceSet fSet(mesh, selectName);
|
||||
|
||||
const label datasetId = GetNumberOfDataSets(output, selector);
|
||||
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
addFaceSetMesh
|
||||
(
|
||||
mesh,
|
||||
fSet,
|
||||
vtkmesh
|
||||
);
|
||||
|
||||
AddToBlock
|
||||
(
|
||||
output, selector, datasetId, vtkmesh,
|
||||
selectName + ":faceSet"
|
||||
);
|
||||
selectedRegionDatasetIds_[regionId] = datasetId;
|
||||
vtkmesh->Delete();
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshPointZones
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshPointZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const selectionInfo& selector = selectInfoPointZones_;
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
// Create the point sets and add as dataset
|
||||
if (selector.size())
|
||||
{
|
||||
const pointZoneMesh& pzMesh = mesh.pointZones();
|
||||
|
||||
// use the zoneId directly instead of the name
|
||||
for (int zoneI=0; zoneI < selector.size(); ++zoneI)
|
||||
{
|
||||
const int regionId = selector.start() + zoneI;
|
||||
|
||||
if (!selectedRegions_[regionId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTK mesh for pointZone: "
|
||||
<< zoneI << endl;
|
||||
}
|
||||
|
||||
const label datasetId = GetNumberOfDataSets(output, selector);
|
||||
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
|
||||
addPointZoneMesh
|
||||
(
|
||||
mesh,
|
||||
pzMesh[zoneI],
|
||||
vtkmesh
|
||||
);
|
||||
|
||||
AddToBlock
|
||||
(
|
||||
output, selector, datasetId, vtkmesh,
|
||||
pzMesh.names()[zoneI] + ":pointZone"
|
||||
);
|
||||
selectedRegionDatasetIds_[regionId] = datasetId;
|
||||
vtkmesh->Delete();
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshPointZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshPointSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshPointSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const selectionInfo& selector = selectInfoPointSets_;
|
||||
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
|
||||
|
||||
// Create the point sets and add as dataset
|
||||
if (selector.size())
|
||||
{
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
for
|
||||
(
|
||||
int regionId = selector.start();
|
||||
regionId < selector.end();
|
||||
++regionId
|
||||
)
|
||||
{
|
||||
if (!selectedRegions_[regionId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
word selectName = getFirstWord
|
||||
(
|
||||
arraySelection->GetArrayName(regionId)
|
||||
);
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTK mesh for pointSet: " << selectName
|
||||
<< " region index: " << regionId << endl;
|
||||
}
|
||||
|
||||
const pointSet pSet(mesh, selectName);
|
||||
|
||||
const label datasetId = GetNumberOfDataSets(output, selector);
|
||||
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
addPointSetMesh
|
||||
(
|
||||
mesh,
|
||||
pSet,
|
||||
vtkmesh
|
||||
);
|
||||
AddToBlock
|
||||
(
|
||||
output, selector, datasetId, vtkmesh,
|
||||
selectName + ":pointSet"
|
||||
);
|
||||
selectedRegionDatasetIds_[regionId] = datasetId;
|
||||
vtkmesh->Delete();
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshPointSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,211 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
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();
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
for (label i=0; i<nSelectedFields; i++)
|
||||
{
|
||||
if (fieldSelection->GetArraySetting(i))
|
||||
{
|
||||
word fieldName = fieldSelection->GetArrayName(i);
|
||||
|
||||
if (fieldObjects.found(fieldName))
|
||||
{
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Foam::vtkPV3Foam::convertPointFields : " << fieldName
|
||||
<< endl;
|
||||
}
|
||||
|
||||
pointMesh pMesh(mesh);
|
||||
|
||||
GeometricField<Type, pointPatchField, pointMesh> ptf
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
),
|
||||
pMesh
|
||||
);
|
||||
|
||||
// Convert internal mesh
|
||||
for
|
||||
(
|
||||
int regionId = selectInfoVolume_.start();
|
||||
regionId < selectInfoVolume_.end();
|
||||
++regionId
|
||||
)
|
||||
{
|
||||
if (selectedRegions_[regionId])
|
||||
{
|
||||
convertPointField
|
||||
(
|
||||
ptf,
|
||||
GeometricField<Type, fvPatchField, volMesh>::null(),
|
||||
output,
|
||||
selectInfoVolume_,
|
||||
selectedRegionDatasetIds_[regionId]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Convert patches
|
||||
label regionId = selectInfoPatches_.start();
|
||||
forAll (patches, patchI)
|
||||
{
|
||||
if (patches[patchI].size())
|
||||
{
|
||||
if (selectedRegions_[regionId])
|
||||
{
|
||||
convertPatchPointField
|
||||
(
|
||||
fieldName,
|
||||
ptf.boundaryField()[patchI]
|
||||
.patchInternalField()(),
|
||||
output,
|
||||
selectInfoPatches_,
|
||||
selectedRegionDatasetIds_[regionId]
|
||||
);
|
||||
}
|
||||
regionId++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertPointField
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& ptf,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& tf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo& selector,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
vtkUnstructuredGrid* internalMesh = vtkUnstructuredGrid::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, selector, datasetNo)
|
||||
);
|
||||
|
||||
vtkFloatArray *pointData = vtkFloatArray::New();
|
||||
pointData->SetNumberOfTuples(ptf.size() + addPointCellLabels_.size());
|
||||
pointData->SetNumberOfComponents(nComp);
|
||||
pointData->Allocate(nComp*ptf.size());
|
||||
pointData->SetName(tf.name().c_str());
|
||||
|
||||
float vec[nComp];
|
||||
|
||||
forAll(ptf, i)
|
||||
{
|
||||
for (direction d=0; d<nComp; d++)
|
||||
{
|
||||
vec[d] = component(ptf[i], d);
|
||||
}
|
||||
|
||||
pointData->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<nComp; d++)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
|
||||
pointData->InsertTuple(i++, vec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(addPointCellLabels_, api)
|
||||
{
|
||||
Type t = interpolatePointToCell(ptf, addPointCellLabels_[api]);
|
||||
|
||||
for (direction d=0; d<nComp; d++)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
|
||||
pointData->InsertTuple(i++, vec);
|
||||
}
|
||||
}
|
||||
|
||||
internalMesh->GetPointData()->AddArray(pointData);
|
||||
pointData->Delete();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,416 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
vtkPV3Foam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPV3FoamConvertVolFields_H
|
||||
#define vtkPV3FoamConvertVolFields_H
|
||||
|
||||
// Foam includes
|
||||
#include "emptyFvPatchField.H"
|
||||
#include "wallPolyPatch.H"
|
||||
#include "faceSet.H"
|
||||
#include "vtkPV3FoamConvertPatchFaceField.H"
|
||||
#include "vtkPV3FoamConvertPatchPointField.H"
|
||||
#include "vtkPV3FoamConvertFaceField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertVolFields
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const volPointInterpolation& pInterp,
|
||||
const PtrList<PrimitivePatchInterpolation<primitivePatch> >& ppInterpList,
|
||||
const IOobjectList& objects,
|
||||
vtkDataArraySelection *fieldSelection,
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
IOobjectList fieldObjects
|
||||
(
|
||||
objects.lookupClass
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>::typeName
|
||||
)
|
||||
);
|
||||
|
||||
label nFields = fieldSelection->GetNumberOfArrays();
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
vtkDataArraySelection* arraySelector = reader_->GetRegionSelection();
|
||||
|
||||
for (label i=0; i<nFields; i++)
|
||||
{
|
||||
const word fieldName = fieldSelection->GetArrayName(i);
|
||||
|
||||
if
|
||||
(
|
||||
!fieldSelection->GetArraySetting(i)
|
||||
|| !fieldObjects.found(fieldName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
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
|
||||
for
|
||||
(
|
||||
int regionId = selectInfoVolume_.start();
|
||||
regionId < selectInfoVolume_.end();
|
||||
++regionId
|
||||
)
|
||||
{
|
||||
if (selectedRegions_[regionId])
|
||||
{
|
||||
convertVolField
|
||||
(
|
||||
tf,
|
||||
output,
|
||||
selectInfoVolume_,
|
||||
selectedRegionDatasetIds_[regionId],
|
||||
superCells_
|
||||
);
|
||||
convertPointField
|
||||
(
|
||||
tptf(),
|
||||
tf,
|
||||
output,
|
||||
selectInfoVolume_,
|
||||
selectedRegionDatasetIds_[regionId]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Convert patches
|
||||
for
|
||||
(
|
||||
int regionId = selectInfoPatches_.start();
|
||||
regionId < selectInfoPatches_.end();
|
||||
++regionId
|
||||
)
|
||||
{
|
||||
if (!selectedRegions_[regionId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
word selectName = getFirstWord
|
||||
(
|
||||
arraySelector->GetArrayName(regionId)
|
||||
);
|
||||
|
||||
const label patchId = patches.findPatchID(selectName);
|
||||
|
||||
const fvPatchField<Type>& ptf
|
||||
(
|
||||
tf.boundaryField()[patchId]
|
||||
);
|
||||
|
||||
if
|
||||
(
|
||||
isType<emptyFvPatchField<Type> >(ptf)
|
||||
||
|
||||
(
|
||||
typeid(patches[patchId]) == typeid(wallPolyPatch)
|
||||
&& reader_->GetExtrapolateWalls()
|
||||
)
|
||||
)
|
||||
{
|
||||
fvPatch p
|
||||
(
|
||||
ptf.patch().patch(),
|
||||
tf.mesh().boundary()
|
||||
);
|
||||
|
||||
convertPatchFaceField
|
||||
(
|
||||
tf.name(),
|
||||
fvPatchField<Type>(p, tf).patchInternalField()(),
|
||||
output,
|
||||
selectInfoPatches_,
|
||||
selectedRegionDatasetIds_[regionId]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
convertPatchFaceField
|
||||
(
|
||||
tf.name(),
|
||||
ptf,
|
||||
output,
|
||||
selectInfoPatches_,
|
||||
selectedRegionDatasetIds_[regionId]
|
||||
);
|
||||
}
|
||||
|
||||
convertPatchPointField
|
||||
(
|
||||
tf.name(),
|
||||
ppInterpList[patchId].faceToPointInterpolate(ptf)(),
|
||||
output,
|
||||
selectInfoPatches_,
|
||||
selectedRegionDatasetIds_[regionId]
|
||||
);
|
||||
}
|
||||
|
||||
// Convert cell zones
|
||||
for
|
||||
(
|
||||
int regionId = selectInfoCellZones_.start();
|
||||
regionId < selectInfoCellZones_.end();
|
||||
++regionId
|
||||
)
|
||||
{
|
||||
if (!selectedRegions_[regionId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
|
||||
word selectName = getFirstWord
|
||||
(
|
||||
arraySelector->GetArrayName(regionId)
|
||||
);
|
||||
|
||||
Info<< "wish to convert cellzone: " << selectName
|
||||
<< " regionId: " << regionId
|
||||
<< " volume field: " << fieldName
|
||||
<< endl;
|
||||
}
|
||||
|
||||
const label datasetId =
|
||||
selectedRegionDatasetIds_[regionId];
|
||||
|
||||
convertVolField
|
||||
(
|
||||
tf,
|
||||
output, selectInfoCellZones_, datasetId,
|
||||
zoneSuperCells_[datasetId]
|
||||
);
|
||||
}
|
||||
|
||||
// Convert cell sets
|
||||
for
|
||||
(
|
||||
int regionId = selectInfoCellSets_.start();
|
||||
regionId < selectInfoCellSets_.end();
|
||||
++regionId
|
||||
)
|
||||
{
|
||||
if (!selectedRegions_[regionId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
word selectName = getFirstWord
|
||||
(
|
||||
arraySelector->GetArrayName(regionId)
|
||||
);
|
||||
|
||||
Info<< "wish to convert cellset: " << selectName
|
||||
<< " regionId: " << regionId
|
||||
<< " volume field: " << fieldName
|
||||
<< endl;
|
||||
}
|
||||
|
||||
const label datasetId =
|
||||
selectedRegionDatasetIds_[regionId];
|
||||
|
||||
convertVolField
|
||||
(
|
||||
tf,
|
||||
output, selectInfoCellSets_, datasetId,
|
||||
csetSuperCells_[datasetId]
|
||||
);
|
||||
}
|
||||
|
||||
// Convert face zones
|
||||
for
|
||||
(
|
||||
int regionId = selectInfoFaceZones_.start();
|
||||
regionId < selectInfoFaceZones_.end();
|
||||
++regionId
|
||||
)
|
||||
{
|
||||
if (!selectedRegions_[regionId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
word selectName = getFirstWord
|
||||
(
|
||||
arraySelector->GetArrayName(regionId)
|
||||
);
|
||||
|
||||
Info<< "wish to convert facezone: " << selectName
|
||||
<< " regionId: " << regionId
|
||||
<< " volume field: " << fieldName
|
||||
<< endl;
|
||||
}
|
||||
|
||||
const faceZoneMesh& fzMesh = mesh.faceZones();
|
||||
const label zoneI = regionId - selectInfoFaceZones_.start();
|
||||
|
||||
const label datasetId =
|
||||
selectedRegionDatasetIds_[regionId];
|
||||
|
||||
convertFaceField
|
||||
(
|
||||
tf,
|
||||
output, selectInfoFaceZones_, datasetId,
|
||||
mesh,
|
||||
fzMesh[zoneI]
|
||||
);
|
||||
}
|
||||
|
||||
// Convert face sets
|
||||
for
|
||||
(
|
||||
int regionId = selectInfoFaceSets_.start();
|
||||
regionId < selectInfoFaceSets_.end();
|
||||
++regionId
|
||||
)
|
||||
{
|
||||
if (!selectedRegions_[regionId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
word selectName = getFirstWord
|
||||
(
|
||||
arraySelector->GetArrayName(regionId)
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "wish to convert faceset: " << selectName
|
||||
<< " regionId: " << regionId
|
||||
<< " volume field: " << fieldName
|
||||
<< endl;
|
||||
}
|
||||
|
||||
const faceSet fSet(mesh, selectName);
|
||||
|
||||
const label datasetId =
|
||||
selectedRegionDatasetIds_[regionId];
|
||||
|
||||
convertFaceField
|
||||
(
|
||||
tf,
|
||||
output, selectInfoFaceSets_, datasetId,
|
||||
mesh,
|
||||
fSet
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertVolField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& tf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo& selector,
|
||||
const label datasetNo,
|
||||
labelList& superCells
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, selector, datasetNo)
|
||||
);
|
||||
|
||||
vtkFloatArray* celldata = vtkFloatArray::New();
|
||||
celldata->SetNumberOfTuples(superCells.size());
|
||||
celldata->SetNumberOfComponents(nComp);
|
||||
celldata->Allocate(nComp*superCells.size());
|
||||
celldata->SetName(tf.name().c_str());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "converting vol<Type>Field: " << tf.name() << nl
|
||||
<< "field size = " << tf.size() << nl
|
||||
<< "nTuples = " << superCells.size() << nl
|
||||
<< "nComp = " << nComp << endl;
|
||||
}
|
||||
|
||||
float vec[nComp];
|
||||
|
||||
forAll(superCells, scI)
|
||||
{
|
||||
const Type& t = tf[superCells[scI]];
|
||||
for (direction d=0; d<nComp; d++)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
|
||||
celldata->InsertTuple(scI, vec);
|
||||
}
|
||||
|
||||
vtkmesh->GetCellData()->AddArray(celldata);
|
||||
celldata->Delete();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -27,8 +27,8 @@ InClass
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPV3FoamConvertFaceField_H
|
||||
#define vtkPV3FoamConvertFaceField_H
|
||||
#ifndef vtkPV3FoamFaceField_H
|
||||
#define vtkPV3FoamFaceField_H
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellData.h"
|
||||
@ -42,31 +42,36 @@ void Foam::vtkPV3Foam::convertFaceField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& tf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo& selector,
|
||||
const partInfo& selector,
|
||||
const label datasetNo,
|
||||
const fvMesh& mesh,
|
||||
const labelList& faceLabels
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, selector, datasetNo)
|
||||
);
|
||||
|
||||
const label nInternalFaces = mesh.nInternalFaces();
|
||||
const labelList& faceOwner = mesh.faceOwner();
|
||||
const labelList& faceNeigh = mesh.faceNeighbour();
|
||||
|
||||
vtkFloatArray *cellData = vtkFloatArray::New();
|
||||
cellData->SetNumberOfTuples(faceLabels.size());
|
||||
cellData->SetNumberOfComponents(nComp);
|
||||
cellData->Allocate(nComp*faceLabels.size());
|
||||
cellData->SetName(tf.name().c_str());
|
||||
cellData->SetNumberOfTuples( faceLabels.size() );
|
||||
cellData->SetNumberOfComponents( nComp );
|
||||
cellData->Allocate( nComp*faceLabels.size() );
|
||||
cellData->SetName( tf.name().c_str() );
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convert convertFaceField: "
|
||||
<< tf.name()
|
||||
<< " size = " << tf.size()
|
||||
<< " nComp=" << nComp
|
||||
<< " nTuples = " << faceLabels.size() << endl;
|
||||
}
|
||||
|
||||
float vec[nComp];
|
||||
|
||||
// for interior faces: average owner/neighbour
|
||||
// for boundary faces: owner
|
||||
forAll(faceLabels, faceI)
|
||||
{
|
||||
const label faceNo = faceLabels[faceI];
|
||||
@ -91,7 +96,13 @@ void Foam::vtkPV3Foam::convertFaceField
|
||||
cellData->InsertTuple(faceI, vec);
|
||||
}
|
||||
|
||||
vtkmesh->GetCellData()->AddArray(cellData);
|
||||
|
||||
vtkPolyData::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, selector, datasetNo)
|
||||
) ->GetCellData()
|
||||
->AddArray(cellData);
|
||||
|
||||
cellData->Delete();
|
||||
}
|
||||
|
||||
@ -101,31 +112,36 @@ void Foam::vtkPV3Foam::convertFaceField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& tf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo& selector,
|
||||
const partInfo& selector,
|
||||
const label datasetNo,
|
||||
const fvMesh& mesh,
|
||||
const faceSet& fSet
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, selector, datasetNo)
|
||||
);
|
||||
|
||||
const label nInternalFaces = mesh.nInternalFaces();
|
||||
const labelList& faceOwner = mesh.faceOwner();
|
||||
const labelList& faceNeigh = mesh.faceNeighbour();
|
||||
|
||||
vtkFloatArray *cellData = vtkFloatArray::New();
|
||||
cellData->SetNumberOfTuples(fSet.size());
|
||||
cellData->SetNumberOfComponents(nComp);
|
||||
cellData->Allocate(nComp*fSet.size());
|
||||
cellData->SetName(tf.name().c_str());
|
||||
cellData->SetNumberOfTuples( fSet.size() );
|
||||
cellData->SetNumberOfComponents( nComp );
|
||||
cellData->Allocate( nComp*fSet.size() );
|
||||
cellData->SetName( tf.name().c_str() );
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convert convertFaceField: "
|
||||
<< tf.name()
|
||||
<< " size = " << tf.size()
|
||||
<< " nComp=" << nComp
|
||||
<< " nTuples = " << fSet.size() << endl;
|
||||
}
|
||||
|
||||
float vec[nComp];
|
||||
|
||||
// for interior faces: average owner/neighbour
|
||||
// for boundary faces: owner
|
||||
label faceI = 0;
|
||||
forAllConstIter(faceSet, fSet, iter)
|
||||
{
|
||||
@ -153,11 +169,16 @@ void Foam::vtkPV3Foam::convertFaceField
|
||||
++faceI;
|
||||
}
|
||||
|
||||
vtkmesh->GetCellData()->AddArray(cellData);
|
||||
|
||||
vtkPolyData::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, selector, datasetNo)
|
||||
) ->GetCellData()
|
||||
->AddArray(cellData);
|
||||
|
||||
cellData->Delete();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,319 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkPV3Foam.H"
|
||||
|
||||
// Foam includes
|
||||
#include "IOobjectList.H"
|
||||
#include "vtkPV3FoamReader.h"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
#include "vtkPV3FoamVolFields.H"
|
||||
#include "vtkPV3FoamPointFields.H"
|
||||
#include "vtkPV3FoamLagrangianFields.H"
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::pruneObjectList
|
||||
(
|
||||
IOobjectList& objects,
|
||||
const wordHashSet& selected
|
||||
)
|
||||
{
|
||||
// hash all the selected field names
|
||||
if (!selected.size())
|
||||
{
|
||||
objects.clear();
|
||||
}
|
||||
|
||||
// only keep selected fields
|
||||
forAllIter(IOobjectList, objects, iter)
|
||||
{
|
||||
if (!selected.found(iter()->name()))
|
||||
{
|
||||
objects.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertVolFields
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
wordHashSet selectedFields = getSelected
|
||||
(
|
||||
reader_->GetVolFieldSelection()
|
||||
);
|
||||
|
||||
if (!selectedFields.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
// Get objects (fields) for this time - only keep selected fields
|
||||
IOobjectList objects(mesh, dbPtr_().timeName());
|
||||
pruneObjectList(objects, selectedFields);
|
||||
|
||||
if (!objects.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertVolFields" << nl
|
||||
<< "converting Foam volume fields" << endl;
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
Info<< " " << iter()->name()
|
||||
<< " == " << iter()->objectPath() << nl;
|
||||
}
|
||||
printMemory();
|
||||
}
|
||||
|
||||
// Construct interpolation on the raw mesh
|
||||
pointMesh pMesh(mesh);
|
||||
volPointInterpolation pInterp(mesh, pMesh);
|
||||
|
||||
PtrList<PrimitivePatchInterpolation<primitivePatch> >
|
||||
ppInterpList(mesh.boundaryMesh().size());
|
||||
|
||||
forAll(ppInterpList, i)
|
||||
{
|
||||
ppInterpList.set
|
||||
(
|
||||
i,
|
||||
new PrimitivePatchInterpolation<primitivePatch>
|
||||
(
|
||||
mesh.boundaryMesh()[i]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
convertVolFields<scalar>
|
||||
(
|
||||
mesh, pInterp, ppInterpList, objects, output
|
||||
);
|
||||
convertVolFields<vector>
|
||||
(
|
||||
mesh, pInterp, ppInterpList, objects, output
|
||||
);
|
||||
convertVolFields<sphericalTensor>
|
||||
(
|
||||
mesh, pInterp, ppInterpList, objects, output
|
||||
);
|
||||
convertVolFields<symmTensor>
|
||||
(
|
||||
mesh, pInterp, ppInterpList, objects, output
|
||||
);
|
||||
convertVolFields<tensor>
|
||||
(
|
||||
mesh, pInterp, ppInterpList, objects, output
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertVolFields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertPointFields
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
wordHashSet selectedFields = getSelected
|
||||
(
|
||||
reader_->GetPointFieldSelection()
|
||||
);
|
||||
|
||||
if (!selectedFields.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
// Get objects (fields) for this time - only keep selected fields
|
||||
IOobjectList objects(mesh, dbPtr_().timeName());
|
||||
pruneObjectList(objects, selectedFields);
|
||||
|
||||
if (!objects.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertPointFields" << nl
|
||||
<< "converting Foam volume fields" << endl;
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
Info<< " " << iter()->name()
|
||||
<< " == " << iter()->objectPath() << nl;
|
||||
}
|
||||
printMemory();
|
||||
}
|
||||
|
||||
// Construct interpolation on the raw mesh
|
||||
pointMesh pMesh(mesh);
|
||||
|
||||
|
||||
convertPointFields<scalar>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
convertPointFields<vector>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
convertPointFields<sphericalTensor>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
convertPointFields<symmTensor>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
convertPointFields<tensor>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertPointFields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertLagrangianFields
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
partInfo& selector = partInfoLagrangian_;
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
wordHashSet selectedFields = getSelected
|
||||
(
|
||||
reader_->GetLagrangianFieldSelection()
|
||||
);
|
||||
|
||||
if (!selectedFields.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertLagrangianFields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
for (int partId = selector.start(); partId < selector.end(); ++partId)
|
||||
{
|
||||
const word cloudName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
|
||||
if (!partStatus_[partId] || datasetNo < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the Lagrangian fields for this time and this cloud
|
||||
// but only keep selected fields
|
||||
IOobjectList objects
|
||||
(
|
||||
mesh,
|
||||
dbPtr_().timeName(),
|
||||
"lagrangian"/cloudName
|
||||
);
|
||||
pruneObjectList(objects, selectedFields);
|
||||
|
||||
if (!objects.size())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "converting Foam lagrangian fields" << nl;
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
Info<< " " << iter()->name()
|
||||
<< " == " << iter()->objectPath() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
convertLagrangianFields<label>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<scalar>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<vector>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<sphericalTensor>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<symmTensor>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<tensor>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertLagrangianFields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -27,54 +27,81 @@ InClass
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPV3FoamConvertPatchPointField_H
|
||||
#define vtkPV3FoamConvertPatchPointField_H
|
||||
|
||||
// VTK includes
|
||||
#include "vtkPointData.h"
|
||||
#ifndef vtkPV3FoamLagrangianFields_H
|
||||
#define vtkPV3FoamLagrangianFields_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertPatchPointField
|
||||
void Foam::vtkPV3Foam::convertLagrangianFields
|
||||
(
|
||||
const word& name,
|
||||
const Field<Type>& pptf,
|
||||
const IOobjectList& objects,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo& selector,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const partInfo& selector = partInfoLagrangian_;
|
||||
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
// restrict to this IOField<Type>
|
||||
if (iter()->headerClassName() == IOField<Type>::typeName)
|
||||
{
|
||||
IOField<Type> tf(*iter());
|
||||
convertLagrangianField(tf, output, selector, datasetNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertLagrangianField
|
||||
(
|
||||
const IOField<Type>& tf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, selector, datasetNo)
|
||||
);
|
||||
|
||||
vtkFloatArray *pointData = vtkFloatArray::New();
|
||||
pointData->SetNumberOfTuples(pptf.size());
|
||||
pointData->SetNumberOfComponents(nComp);
|
||||
pointData->Allocate(nComp*pptf.size());
|
||||
pointData->SetName(name.c_str());
|
||||
pointData->SetNumberOfTuples( tf.size() );
|
||||
pointData->SetNumberOfComponents( nComp );
|
||||
pointData->Allocate( nComp*tf.size() );
|
||||
pointData->SetName( tf.name().c_str() );
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convert LagrangianField: "
|
||||
<< tf.name()
|
||||
<< " size = " << tf.size()
|
||||
<< " nComp=" << nComp
|
||||
<< " nTuples = " << tf.size() << endl;
|
||||
}
|
||||
|
||||
float vec[nComp];
|
||||
|
||||
forAll(pptf, i)
|
||||
forAll(tf, i)
|
||||
{
|
||||
const Type& t = tf[i];
|
||||
for (direction d=0; d<nComp; d++)
|
||||
{
|
||||
vec[d] = component(pptf[i], d);
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
|
||||
pointData->InsertTuple(i, vec);
|
||||
}
|
||||
|
||||
vtkmesh->GetPointData()->AddArray(pointData);
|
||||
|
||||
vtkPolyData::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, selector, datasetNo)
|
||||
) ->GetPointData()
|
||||
->AddArray(pointData);
|
||||
|
||||
pointData->Delete();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,623 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkPV3Foam.H"
|
||||
|
||||
// Foam includes
|
||||
#include "cellSet.H"
|
||||
#include "faceSet.H"
|
||||
#include "pointSet.H"
|
||||
#include "fvMeshSubset.H"
|
||||
#include "vtkPV3FoamReader.h"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshVolume
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
int& blockNo
|
||||
)
|
||||
{
|
||||
partInfo& selector = partInfoVolume_;
|
||||
selector.block(blockNo); // set output block
|
||||
label datasetNo = 0; // restart at dataset 0
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
// resize for decomposed polyhedra
|
||||
regionPolyDecomp_.setSize(selector.size());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshVolume" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
// Convert the internalMesh
|
||||
// TODO: multiple mesh regions
|
||||
for (int partId = selector.start(); partId < selector.end(); ++partId)
|
||||
{
|
||||
const word partName = "internalMesh";
|
||||
|
||||
if (!partStatus_[partId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
|
||||
(
|
||||
mesh,
|
||||
regionPolyDecomp_[datasetNo]
|
||||
);
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, selector, datasetNo, partName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
}
|
||||
}
|
||||
|
||||
// anything added?
|
||||
if (datasetNo)
|
||||
{
|
||||
++blockNo;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshVolume" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshLagrangian
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
int& blockNo
|
||||
)
|
||||
{
|
||||
partInfo& selector = partInfoLagrangian_;
|
||||
selector.block(blockNo); // set output block
|
||||
label datasetNo = 0; // restart at dataset 0
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshLagrangian" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
for (int partId = selector.start(); partId < selector.end(); ++partId)
|
||||
{
|
||||
const word cloudName = getPartName(partId);
|
||||
|
||||
if (!partStatus_[partId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vtkPolyData* vtkmesh = lagrangianVTKMesh(mesh, cloudName);
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, selector, datasetNo, cloudName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
}
|
||||
}
|
||||
|
||||
// anything added?
|
||||
if (datasetNo)
|
||||
{
|
||||
++blockNo;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshLagrangian" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshPatches
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
int& blockNo
|
||||
)
|
||||
{
|
||||
partInfo& selector = partInfoPatches_;
|
||||
selector.block(blockNo); // set output block
|
||||
label datasetNo = 0; // restart at dataset 0
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshPatches" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
for (int partId = selector.start(); partId < selector.end(); ++partId)
|
||||
{
|
||||
const word patchName = getPartName(partId);
|
||||
const label patchId = patches.findPatchID(patchName);
|
||||
|
||||
if (!partStatus_[partId] || patchId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTK mesh for patch[" << patchId <<"] "
|
||||
<< patchName << endl;
|
||||
}
|
||||
|
||||
vtkPolyData* vtkmesh = patchVTKMesh(patches[patchId]);
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, selector, datasetNo, patchName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
}
|
||||
}
|
||||
|
||||
// anything added?
|
||||
if (datasetNo)
|
||||
{
|
||||
++blockNo;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshPatches" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshCellZones
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
int& blockNo
|
||||
)
|
||||
{
|
||||
partInfo& selector = partInfoCellZones_;
|
||||
selector.block(blockNo); // set output block
|
||||
label datasetNo = 0; // restart at dataset 0
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
// resize for decomposed polyhedra
|
||||
zonePolyDecomp_.setSize(selector.size());
|
||||
|
||||
if (!selector.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const cellZoneMesh& zMesh = mesh.cellZones();
|
||||
|
||||
for (int partId = selector.start(); partId < selector.end(); ++partId)
|
||||
{
|
||||
const word zoneName = getPartName(partId);
|
||||
const label zoneId = zMesh.findZoneID(zoneName);
|
||||
|
||||
if (!partStatus_[partId] || zoneId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTK mesh for cellZone[" << zoneId << "] "
|
||||
<< zoneName << endl;
|
||||
}
|
||||
|
||||
fvMeshSubset subsetter(mesh);
|
||||
subsetter.setLargeCellSubset(zMesh[zoneId]);
|
||||
|
||||
vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
|
||||
(
|
||||
subsetter.subMesh(),
|
||||
zonePolyDecomp_[datasetNo]
|
||||
);
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
// superCells + addPointCellLabels must contain global cell ids
|
||||
inplaceRenumber
|
||||
(
|
||||
subsetter.cellMap(),
|
||||
zonePolyDecomp_[datasetNo].superCells()
|
||||
);
|
||||
inplaceRenumber
|
||||
(
|
||||
subsetter.cellMap(),
|
||||
zonePolyDecomp_[datasetNo].addPointCellLabels()
|
||||
);
|
||||
|
||||
// copy pointMap as well, otherwise pointFields fail
|
||||
zonePolyDecomp_[datasetNo].pointMap() = subsetter.pointMap();
|
||||
|
||||
AddToBlock(output, vtkmesh, selector, datasetNo, zoneName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
}
|
||||
}
|
||||
|
||||
// anything added?
|
||||
if (datasetNo)
|
||||
{
|
||||
++blockNo;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshCellZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshCellSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
int& blockNo
|
||||
)
|
||||
{
|
||||
partInfo& selector = partInfoCellSets_;
|
||||
selector.block(blockNo); // set output block
|
||||
label datasetNo = 0; // restart at dataset 0
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
// resize for decomposed polyhedra
|
||||
csetPolyDecomp_.setSize(selector.size());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
for (int partId = selector.start(); partId < selector.end(); ++partId)
|
||||
{
|
||||
const word partName = getPartName(partId);
|
||||
|
||||
if (!partStatus_[partId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTK mesh for cellSet=" << partName << endl;
|
||||
}
|
||||
|
||||
const cellSet cSet(mesh, partName);
|
||||
fvMeshSubset subsetter(mesh);
|
||||
subsetter.setLargeCellSubset(cSet);
|
||||
|
||||
vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
|
||||
(
|
||||
subsetter.subMesh(),
|
||||
csetPolyDecomp_[datasetNo]
|
||||
);
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
// superCells + addPointCellLabels must contain global cell ids
|
||||
inplaceRenumber
|
||||
(
|
||||
subsetter.cellMap(),
|
||||
csetPolyDecomp_[datasetNo].superCells()
|
||||
);
|
||||
inplaceRenumber
|
||||
(
|
||||
subsetter.cellMap(),
|
||||
csetPolyDecomp_[datasetNo].addPointCellLabels()
|
||||
);
|
||||
|
||||
// copy pointMap as well, otherwise pointFields fail
|
||||
csetPolyDecomp_[datasetNo].pointMap() = subsetter.pointMap();
|
||||
|
||||
AddToBlock(output, vtkmesh, selector, datasetNo, partName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
}
|
||||
}
|
||||
|
||||
// anything added?
|
||||
if (datasetNo)
|
||||
{
|
||||
++blockNo;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshCellSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshFaceZones
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
int& blockNo
|
||||
)
|
||||
{
|
||||
partInfo& selector = partInfoFaceZones_;
|
||||
selector.block(blockNo); // set output block
|
||||
label datasetNo = 0; // restart at dataset 0
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
if (!selector.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshFaceZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const faceZoneMesh& zMesh = mesh.faceZones();
|
||||
|
||||
for (int partId = selector.start(); partId < selector.end(); ++partId)
|
||||
{
|
||||
const word zoneName = getPartName(partId);
|
||||
const label zoneId = zMesh.findZoneID(zoneName);
|
||||
|
||||
if (!partStatus_[partId] || zoneId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTKmesh for faceZone[" << zoneId << "] "
|
||||
<< zoneName << endl;
|
||||
}
|
||||
|
||||
vtkPolyData* vtkmesh = faceZoneVTKMesh(mesh, zMesh[zoneId]);
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, selector, datasetNo, zoneName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
}
|
||||
}
|
||||
|
||||
// anything added?
|
||||
if (datasetNo)
|
||||
{
|
||||
++blockNo;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshFaceSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
int& blockNo
|
||||
)
|
||||
{
|
||||
partInfo& selector = partInfoFaceSets_;
|
||||
selector.block(blockNo); // set output block
|
||||
label datasetNo = 0; // restart at dataset 0
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshFaceSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
for (int partId = selector.start(); partId < selector.end(); ++partId)
|
||||
{
|
||||
const word partName = getPartName(partId);
|
||||
|
||||
if (!partStatus_[partId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTK mesh for faceSet=" << partName << endl;
|
||||
}
|
||||
|
||||
const faceSet fSet(mesh, partName);
|
||||
|
||||
vtkPolyData* vtkmesh = faceSetVTKMesh(mesh, fSet);
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, selector, datasetNo, partName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
}
|
||||
}
|
||||
|
||||
// anything added?
|
||||
if (datasetNo)
|
||||
{
|
||||
++blockNo;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshPointZones
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
int& blockNo
|
||||
)
|
||||
{
|
||||
partInfo& selector = partInfoPointZones_;
|
||||
selector.block(blockNo); // set output block
|
||||
label datasetNo = 0; // restart at dataset 0
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshPointZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
if (selector.size())
|
||||
{
|
||||
const pointZoneMesh& zMesh = mesh.pointZones();
|
||||
|
||||
for (int partId = selector.start(); partId < selector.end(); ++partId)
|
||||
{
|
||||
word zoneName = getPartName(partId);
|
||||
label zoneId = zMesh.findZoneID(zoneName);
|
||||
|
||||
if (!partStatus_[partId] || zoneId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vtkPolyData* vtkmesh = pointZoneVTKMesh(mesh, zMesh[zoneId]);
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, selector, datasetNo, zoneName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// anything added?
|
||||
if (datasetNo)
|
||||
{
|
||||
++blockNo;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshPointZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::convertMeshPointSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
int& blockNo
|
||||
)
|
||||
{
|
||||
partInfo& selector = partInfoPointSets_;
|
||||
selector.block(blockNo); // set output block
|
||||
label datasetNo = 0; // restart at dataset 0
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::convertMeshPointSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
for (int partId = selector.start(); partId < selector.end(); ++partId)
|
||||
{
|
||||
word partName = getPartName(partId);
|
||||
|
||||
if (!partStatus_[partId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating VTK mesh for pointSet=" << partName << endl;
|
||||
}
|
||||
|
||||
const pointSet pSet(mesh, partName);
|
||||
|
||||
vtkPolyData* vtkmesh = pointSetVTKMesh(mesh, pSet);
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, selector, datasetNo, partName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
}
|
||||
}
|
||||
|
||||
// anything added?
|
||||
if (datasetNo)
|
||||
{
|
||||
++blockNo;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::convertMeshPointSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -31,81 +31,68 @@ Description
|
||||
// Foam includes
|
||||
#include "Cloud.H"
|
||||
#include "fvMesh.H"
|
||||
#include "passiveParticle.H"
|
||||
#include "vtkPV3FoamInsertNextPoint.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "passiveParticle.H"
|
||||
#include "vtkPV3FoamPoints.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellArray.h"
|
||||
#include "vtkPoints.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPV3Foam::addLagrangianMesh
|
||||
vtkPolyData* Foam::vtkPV3Foam::lagrangianVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
vtkPolyData *vtkmesh
|
||||
const word& cloudName
|
||||
)
|
||||
{
|
||||
vtkPolyData* vtkmesh = NULL;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::addLagrangianMesh - timePath "
|
||||
<< mesh.time().timePath()/"lagrangian" << endl;
|
||||
Info<< "<beg> Foam::vtkPV3Foam::lagrangianVTKMesh - timePath "
|
||||
<< mesh.time().timePath()/"lagrangian"/cloudName << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
fileNameList cloudDirs
|
||||
IOobjectList sprayObjs
|
||||
(
|
||||
readDir(mesh.time().timePath()/"lagrangian", fileName::DIRECTORY)
|
||||
mesh,
|
||||
mesh.time().timeName(),
|
||||
"lagrangian"/cloudName
|
||||
);
|
||||
|
||||
if (debug && cloudDirs.size())
|
||||
IOobject* positionsPtr = sprayObjs.lookup("positions");
|
||||
if (positionsPtr)
|
||||
{
|
||||
Info<< "... check cloudDirs: " << cloudDirs << endl;
|
||||
}
|
||||
Cloud<passiveParticle> parcels(mesh, cloudName, false);
|
||||
|
||||
bool foundCloud = false;
|
||||
forAll(cloudDirs, i)
|
||||
{
|
||||
IOobjectList sprayObjs
|
||||
(
|
||||
mesh,
|
||||
mesh.time().timeName(),
|
||||
"lagrangian"/cloudDirs[i]
|
||||
);
|
||||
|
||||
IOobject* positionsPtr = sprayObjs.lookup("positions");
|
||||
|
||||
if (positionsPtr && !foundCloud)
|
||||
if (debug)
|
||||
{
|
||||
foundCloud = true;
|
||||
|
||||
Cloud<passiveParticle> parcels(mesh, cloudDirs[i], false);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "cloud with " << parcels.size() << " parcels" << endl;
|
||||
}
|
||||
|
||||
vtkPoints* vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate(parcels.size());
|
||||
|
||||
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
|
||||
{
|
||||
vtkPV3FoamInsertNextPoint(vtkpoints, elmnt().position());
|
||||
}
|
||||
|
||||
vtkmesh->SetPoints(vtkpoints);
|
||||
vtkpoints->Delete();
|
||||
Info<< "cloud with " << parcels.size() << " parcels" << endl;
|
||||
}
|
||||
|
||||
vtkmesh = vtkPolyData::New();
|
||||
vtkPoints* vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate( parcels.size() );
|
||||
|
||||
forAllConstIter(Cloud<passiveParticle>, parcels, iter)
|
||||
{
|
||||
vtkPV3FoamInsertNextPoint(vtkpoints, iter().position());
|
||||
}
|
||||
|
||||
vtkmesh->SetPoints(vtkpoints);
|
||||
vtkpoints->Delete();
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::addLagrangianMesh" << endl;
|
||||
Info<< "<end> Foam::vtkPV3Foam::lagrangianVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ Description
|
||||
// Foam includes
|
||||
#include "polyPatch.H"
|
||||
#include "primitivePatch.H"
|
||||
#include "vtkPV3FoamInsertNextPoint.H"
|
||||
#include "vtkPV3FoamPoints.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellArray.h"
|
||||
@ -40,15 +40,16 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPV3Foam::addPatchMesh
|
||||
vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh
|
||||
(
|
||||
const polyPatch& p,
|
||||
vtkPolyData *vtkmesh
|
||||
const polyPatch& p
|
||||
)
|
||||
{
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::addPatchMesh - " << p.name() << endl;
|
||||
Info<< "<beg> Foam::vtkPV3Foam::patchVTKMesh - " << p.name() << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -56,7 +57,7 @@ void Foam::vtkPV3Foam::addPatchMesh
|
||||
const Foam::pointField& points = p.localPoints();
|
||||
|
||||
vtkPoints *vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate(points.size());
|
||||
vtkpoints->Allocate( points.size() );
|
||||
forAll(points, i)
|
||||
{
|
||||
vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
|
||||
@ -69,14 +70,14 @@ void Foam::vtkPV3Foam::addPatchMesh
|
||||
// Add faces as polygons
|
||||
const faceList& faces = p.localFaces();
|
||||
|
||||
vtkCellArray * vtkcells = vtkCellArray::New();
|
||||
vtkcells->Allocate(faces.size());
|
||||
vtkCellArray* vtkcells = vtkCellArray::New();
|
||||
vtkcells->Allocate( faces.size() );
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
const face& f = faces[faceI];
|
||||
vtkIdType nodeIds[f.size()];
|
||||
|
||||
forAll (f, fp)
|
||||
forAll(f, fp)
|
||||
{
|
||||
nodeIds[fp] = f[fp];
|
||||
}
|
||||
@ -88,9 +89,11 @@ void Foam::vtkPV3Foam::addPatchMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::addPatchMesh - " << p.name() << endl;
|
||||
Info<< "<end> Foam::vtkPV3Foam::patchVTKMesh - " << p.name() << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ Description
|
||||
// Foam includes
|
||||
#include "faceSet.H"
|
||||
#include "pointSet.H"
|
||||
#include "vtkPV3FoamInsertNextPoint.H"
|
||||
#include "vtkPV3FoamPoints.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkPoints.h"
|
||||
@ -40,16 +40,17 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPV3Foam::addFaceSetMesh
|
||||
vtkPolyData* Foam::vtkPV3Foam::faceSetVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const faceSet& fSet,
|
||||
vtkPolyData* vtkmesh
|
||||
const faceSet& fSet
|
||||
)
|
||||
{
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::addFaceSetMesh" << endl;
|
||||
Info<< "<beg> Foam::vtkPV3Foam::faceSetVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -65,13 +66,13 @@ void Foam::vtkPV3Foam::addFaceSetMesh
|
||||
primitiveFacePatch p(patchFaces, mesh.points());
|
||||
|
||||
|
||||
// The balance of this routine should be identical to addPatchMesh
|
||||
// The balance of this routine should be identical to patchVTKMesh
|
||||
|
||||
// Convert Foam mesh vertices to VTK
|
||||
const pointField& points = p.localPoints();
|
||||
|
||||
vtkPoints *vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate(points.size());
|
||||
vtkpoints->Allocate( points.size() );
|
||||
forAll(points, i)
|
||||
{
|
||||
vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
|
||||
@ -83,13 +84,14 @@ void Foam::vtkPV3Foam::addFaceSetMesh
|
||||
const faceList& faces = p.localFaces();
|
||||
|
||||
vtkCellArray* vtkcells = vtkCellArray::New();
|
||||
vtkcells->Allocate(p.size());
|
||||
vtkcells->Allocate( faces.size() );
|
||||
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
const face& f = faces[faceI];
|
||||
vtkIdType nodeIds[f.size()];
|
||||
|
||||
forAll (f, fp)
|
||||
forAll(f, fp)
|
||||
{
|
||||
nodeIds[fp] = f[fp];
|
||||
}
|
||||
@ -101,29 +103,32 @@ void Foam::vtkPV3Foam::addFaceSetMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::addFaceSetMesh" << endl;
|
||||
Info<< "<end> Foam::vtkPV3Foam::faceSetVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::addPointSetMesh
|
||||
vtkPolyData* Foam::vtkPV3Foam::pointSetVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const pointSet& pSet,
|
||||
vtkPolyData* vtkmesh
|
||||
const pointSet& pSet
|
||||
)
|
||||
{
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::addPointSetMesh" << endl;
|
||||
Info<< "<beg> Foam::vtkPV3Foam::pointSetVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const pointField& meshPoints = mesh.points();
|
||||
|
||||
vtkPoints *vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate(pSet.size());
|
||||
vtkpoints->Allocate( pSet.size() );
|
||||
|
||||
forAllConstIter(pointSet, pSet, iter)
|
||||
{
|
||||
@ -135,9 +140,12 @@ void Foam::vtkPV3Foam::addPointSetMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::addPointSetMesh" << endl;
|
||||
Info<< "<end> Foam::vtkPV3Foam::pointSetVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -26,35 +26,30 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPV3FoamAddVolumeMesh_H
|
||||
#define vtkPV3FoamAddVolumeMesh_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "vtkPV3Foam.H"
|
||||
|
||||
// Foam includes
|
||||
#include "fvMesh.H"
|
||||
#include "cellModeller.H"
|
||||
#include "vtkPV3FoamInsertNextPoint.H"
|
||||
#include "vtkPV3FoamPoints.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellArray.h"
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPV3Foam::addVolumeMesh
|
||||
vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
vtkUnstructuredGrid* vtkmesh,
|
||||
labelList& superCells
|
||||
polyDecomp& decompInfo
|
||||
)
|
||||
{
|
||||
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::addVolumeMesh" << endl;
|
||||
Info<< "<beg> Foam::vtkPV3Foam::volumeVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -64,6 +59,9 @@ void Foam::vtkPV3Foam::addVolumeMesh
|
||||
// Number of additional cells generated by the decomposition of polyhedra
|
||||
label nAddCells = 0;
|
||||
|
||||
labelList& superCells = decompInfo.superCells();
|
||||
labelList& addPointCellLabels = decompInfo.addPointCellLabels();
|
||||
|
||||
const cellModel& tet = *(cellModeller::lookup("tet"));
|
||||
const cellModel& pyr = *(cellModeller::lookup("pyr"));
|
||||
const cellModel& prism = *(cellModeller::lookup("prism"));
|
||||
@ -117,17 +115,17 @@ void Foam::vtkPV3Foam::addVolumeMesh
|
||||
|
||||
// Set size of additional point addressing array
|
||||
// (from added point to original cell)
|
||||
addPointCellLabels_.setSize(nAddPoints);
|
||||
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;
|
||||
Info<<" mesh nCells = " << mesh.nCells() << nl
|
||||
<<" nPoints = " << mesh.nPoints() << nl
|
||||
<<" nAddCells = " << nAddCells << nl
|
||||
<<" nAddPoints = " << nAddPoints << endl;
|
||||
}
|
||||
|
||||
superCells.setSize(mesh.nCells() + nAddCells);
|
||||
@ -139,7 +137,7 @@ void Foam::vtkPV3Foam::addVolumeMesh
|
||||
|
||||
// Convert Foam mesh vertices to VTK
|
||||
vtkPoints *vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate(mesh.nPoints() + nAddPoints);
|
||||
vtkpoints->Allocate( mesh.nPoints() + nAddPoints );
|
||||
|
||||
const Foam::pointField& points = mesh.points();
|
||||
|
||||
@ -154,21 +152,21 @@ void Foam::vtkPV3Foam::addVolumeMesh
|
||||
Info<< "... converting cells" << endl;
|
||||
}
|
||||
|
||||
vtkmesh->Allocate(mesh.nCells() + nAddCells);
|
||||
vtkmesh->Allocate( mesh.nCells() + nAddCells );
|
||||
|
||||
// Set counters for additional points and additional cells
|
||||
label api = 0, aci = 0;
|
||||
label addPointI = 0, addCellI = 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)
|
||||
forAll(cellShapes, cellI)
|
||||
{
|
||||
const cellShape& cellShape = cellShapes[celli];
|
||||
const cellShape& cellShape = cellShapes[cellI];
|
||||
const cellModel& cellModel = cellShape.model();
|
||||
|
||||
superCells[aci++] = celli;
|
||||
superCells[addCellI++] = cellI;
|
||||
|
||||
if (cellModel == tet)
|
||||
{
|
||||
@ -265,16 +263,16 @@ void Foam::vtkPV3Foam::addVolumeMesh
|
||||
// Polyhedral cell. Decompose into tets + prisms.
|
||||
|
||||
// Mapping from additional point to cell
|
||||
addPointCellLabels_[api] = celli;
|
||||
addPointCellLabels[addPointI] = cellI;
|
||||
|
||||
// Insert the new vertex from the cell-centre
|
||||
label newVertexLabel = mesh.nPoints() + api;
|
||||
vtkPV3FoamInsertNextPoint(vtkpoints, mesh.C()[celli]);
|
||||
label newVertexLabel = mesh.nPoints() + addPointI;
|
||||
vtkPV3FoamInsertNextPoint(vtkpoints, mesh.C()[cellI]);
|
||||
|
||||
// Whether to insert cell in place of original or not.
|
||||
bool substituteCell = true;
|
||||
|
||||
const labelList& cFaces = mesh.cells()[celli];
|
||||
const labelList& cFaces = mesh.cells()[cellI];
|
||||
|
||||
forAll(cFaces, cFaceI)
|
||||
{
|
||||
@ -293,13 +291,13 @@ void Foam::vtkPV3Foam::addVolumeMesh
|
||||
|
||||
if (substituteCell)
|
||||
{
|
||||
thisCellI = celli;
|
||||
thisCellI = cellI;
|
||||
substituteCell = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
thisCellI = mesh.nCells() + aci;
|
||||
superCells[aci++] = celli;
|
||||
thisCellI = mesh.nCells() + addCellI;
|
||||
superCells[addCellI++] = cellI;
|
||||
}
|
||||
|
||||
nodeIds[0] = f[0];
|
||||
@ -323,13 +321,13 @@ void Foam::vtkPV3Foam::addVolumeMesh
|
||||
|
||||
if (substituteCell)
|
||||
{
|
||||
thisCellI = celli;
|
||||
thisCellI = cellI;
|
||||
substituteCell = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
thisCellI = mesh.nCells() + aci;
|
||||
superCells[aci++] = celli;
|
||||
thisCellI = mesh.nCells() + addCellI;
|
||||
superCells[addCellI++] = cellI;
|
||||
}
|
||||
|
||||
nodeIds[0] = f[0];
|
||||
@ -345,7 +343,7 @@ void Foam::vtkPV3Foam::addVolumeMesh
|
||||
}
|
||||
}
|
||||
|
||||
api++;
|
||||
addPointI++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -354,14 +352,11 @@ void Foam::vtkPV3Foam::addVolumeMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::addVolumeMesh" << endl;
|
||||
Info<< "<end> Foam::vtkPV3Foam::volumeVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -29,7 +29,7 @@ Description
|
||||
#include "vtkPV3Foam.H"
|
||||
|
||||
// Foam includes
|
||||
#include "vtkPV3FoamInsertNextPoint.H"
|
||||
#include "vtkPV3FoamPoints.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkPoints.h"
|
||||
@ -39,20 +39,21 @@ Description
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::addFaceZoneMesh
|
||||
vtkPolyData* Foam::vtkPV3Foam::faceZoneVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelList& faceLabels,
|
||||
vtkPolyData* vtkmesh
|
||||
const labelList& faceLabels
|
||||
)
|
||||
{
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::addFaceZoneMesh" << endl;
|
||||
Info<< "<beg> Foam::vtkPV3Foam::faceZoneVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
// Construct primitivePatch of faces in fSet.
|
||||
// Construct primitivePatch of faces in faceZone
|
||||
|
||||
const faceList& meshFaces = mesh.faces();
|
||||
faceList patchFaces(faceLabels.size());
|
||||
@ -63,31 +64,34 @@ void Foam::vtkPV3Foam::addFaceZoneMesh
|
||||
primitiveFacePatch p(patchFaces, mesh.points());
|
||||
|
||||
|
||||
// The balance of this routine should be identical to addPatchMesh
|
||||
// The balance of this routine should be identical to patchVTKMesh
|
||||
|
||||
// Convert Foam mesh vertices to VTK
|
||||
const pointField& points = p.localPoints();
|
||||
|
||||
vtkPoints *vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate(p.size());
|
||||
vtkPoints* vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate( points.size() );
|
||||
forAll(points, i)
|
||||
{
|
||||
vtkPV3FoamInsertNextPoint(vtkpoints, points[i]);
|
||||
}
|
||||
|
||||
vtkmesh->SetPoints(vtkpoints);
|
||||
vtkpoints->Delete();
|
||||
|
||||
|
||||
// Add faces as polygons
|
||||
const faceList& faces = p.localFaces();
|
||||
|
||||
vtkCellArray* vtkcells = vtkCellArray::New();
|
||||
vtkcells->Allocate(points.size());
|
||||
vtkcells->Allocate( faces.size() );
|
||||
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
const face& f = faces[faceI];
|
||||
vtkIdType nodeIds[f.size()];
|
||||
|
||||
forAll (f, fp)
|
||||
forAll(f, fp)
|
||||
{
|
||||
nodeIds[fp] = f[fp];
|
||||
}
|
||||
@ -99,30 +103,33 @@ void Foam::vtkPV3Foam::addFaceZoneMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::addFaceZoneMesh" << endl;
|
||||
Info<< "<end> Foam::vtkPV3Foam::faceZoneVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::addPointZoneMesh
|
||||
vtkPolyData* Foam::vtkPV3Foam::pointZoneVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelList& pointLabels,
|
||||
vtkPolyData* vtkmesh
|
||||
const labelList& pointLabels
|
||||
)
|
||||
{
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl;
|
||||
Info<< "<beg> Foam::vtkPV3Foam::pointZoneVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const pointField& meshPoints = mesh.points();
|
||||
|
||||
vtkPoints *vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate(pointLabels.size());
|
||||
vtkpoints->Allocate( pointLabels.size() );
|
||||
|
||||
forAll(pointLabels, pointI)
|
||||
{
|
||||
@ -134,9 +141,11 @@ void Foam::vtkPV3Foam::addPointZoneMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl;
|
||||
Info<< "<beg> Foam::vtkPV3Foam::pointZoneVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -27,42 +27,37 @@ InClass
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPV3FoamConvertPatchFaceField_H
|
||||
#define vtkPV3FoamConvertPatchFaceField_H
|
||||
#ifndef vtkPV3FoamPatchField_H
|
||||
#define vtkPV3FoamPatchField_H
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellData.h"
|
||||
#include "vtkFloatArray.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
#include "vtkPointData.h"
|
||||
#include "vtkPolyData.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertPatchFaceField
|
||||
void Foam::vtkPV3Foam::convertPatchField
|
||||
(
|
||||
const word& name,
|
||||
const Field<Type>& ptf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const selectionInfo& selector,
|
||||
const partInfo& selector,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, selector, datasetNo)
|
||||
);
|
||||
|
||||
vtkFloatArray *cellData = vtkFloatArray::New();
|
||||
cellData->SetNumberOfTuples(ptf.size());
|
||||
cellData->SetNumberOfComponents(nComp);
|
||||
cellData->Allocate(nComp*ptf.size());
|
||||
cellData->SetName(name.c_str());
|
||||
vtkFloatArray* cellData = vtkFloatArray::New();
|
||||
cellData->SetNumberOfTuples( ptf.size() );
|
||||
cellData->SetNumberOfComponents( nComp );
|
||||
cellData->Allocate( nComp*ptf.size() );
|
||||
cellData->SetName( name.c_str() );
|
||||
|
||||
float vec[nComp];
|
||||
|
||||
forAll(ptf, i)
|
||||
{
|
||||
const Type& t = ptf[i];
|
||||
@ -70,15 +65,59 @@ void Foam::vtkPV3Foam::convertPatchFaceField
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
|
||||
cellData->InsertTuple(i, vec);
|
||||
}
|
||||
|
||||
vtkmesh->GetCellData()->AddArray(cellData);
|
||||
vtkPolyData::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, selector, datasetNo)
|
||||
) ->GetCellData()
|
||||
->AddArray(cellData);
|
||||
|
||||
cellData->Delete();
|
||||
}
|
||||
|
||||
|
||||
// as above, but with PointData()
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertPatchPointField
|
||||
(
|
||||
const word& name,
|
||||
const Field<Type>& pptf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
vtkFloatArray *pointData = vtkFloatArray::New();
|
||||
pointData->SetNumberOfTuples( pptf.size() );
|
||||
pointData->SetNumberOfComponents( nComp );
|
||||
pointData->Allocate( nComp*pptf.size() );
|
||||
pointData->SetName( name.c_str() );
|
||||
|
||||
float vec[nComp];
|
||||
forAll(pptf, i)
|
||||
{
|
||||
const Type& t = pptf[i];
|
||||
for (direction d=0; d<nComp; d++)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
|
||||
pointData->InsertTuple(i, vec);
|
||||
}
|
||||
|
||||
vtkPolyData::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, selector, datasetNo)
|
||||
) ->GetPointData()
|
||||
->AddArray(pointData);
|
||||
|
||||
pointData->Delete();
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,277 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
vtkPV3Foam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPV3FoamPointFields_H
|
||||
#define vtkPV3FoamPointFields_H
|
||||
|
||||
// Foam includes
|
||||
#include "interpolatePointToCell.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertPointFields
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const pointMesh& pMesh,
|
||||
const IOobjectList& objects,
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
const word& fieldName = iter()->name();
|
||||
// restrict to this GeometricField<Type, ...>
|
||||
if
|
||||
(
|
||||
iter()->headerClassName()
|
||||
!= GeometricField<Type, pointPatchField, pointMesh>::typeName
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Foam::vtkPV3Foam::convertPointFields : "
|
||||
<< fieldName << endl;
|
||||
}
|
||||
|
||||
GeometricField<Type, pointPatchField, pointMesh> ptf
|
||||
(
|
||||
*iter(),
|
||||
pMesh
|
||||
);
|
||||
|
||||
|
||||
// Convert activated internalMesh regions
|
||||
convertPointFieldBlock
|
||||
(
|
||||
ptf,
|
||||
output,
|
||||
partInfoVolume_,
|
||||
regionPolyDecomp_
|
||||
);
|
||||
|
||||
// Convert activated cellZones
|
||||
convertPointFieldBlock
|
||||
(
|
||||
ptf,
|
||||
output,
|
||||
partInfoCellZones_,
|
||||
zonePolyDecomp_
|
||||
);
|
||||
|
||||
// Convert activated cellSets
|
||||
convertPointFieldBlock
|
||||
(
|
||||
ptf,
|
||||
output,
|
||||
partInfoCellSets_,
|
||||
csetPolyDecomp_
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Convert patches - if activated
|
||||
//
|
||||
for
|
||||
(
|
||||
int partId = partInfoPatches_.start();
|
||||
partId < partInfoPatches_.end();
|
||||
++partId
|
||||
)
|
||||
{
|
||||
const word patchName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
const label patchId = patches.findPatchID(patchName);
|
||||
|
||||
if (!partStatus_[partId] || datasetNo < 0 || patchId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
convertPatchPointField
|
||||
(
|
||||
fieldName,
|
||||
ptf.boundaryField()[patchId].patchInternalField()(),
|
||||
output,
|
||||
partInfoPatches_,
|
||||
datasetNo
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertPointFieldBlock
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& ptf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector,
|
||||
const List<polyDecomp>& decompLst
|
||||
)
|
||||
{
|
||||
for (int partId = selector.start(); partId < selector.end(); ++partId)
|
||||
{
|
||||
const label datasetNo = partDataset_[partId];
|
||||
|
||||
if (datasetNo >= 0 && partStatus_[partId])
|
||||
{
|
||||
convertPointField
|
||||
(
|
||||
ptf,
|
||||
GeometricField<Type, fvPatchField, volMesh>::null(),
|
||||
output,
|
||||
selector,
|
||||
datasetNo,
|
||||
decompLst[datasetNo]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertPointField
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& ptf,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& tf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector,
|
||||
const label datasetNo,
|
||||
const polyDecomp& decomp
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
const labelList& addPointCellLabels = decomp.addPointCellLabels();
|
||||
const labelList& pointMap = decomp.pointMap();
|
||||
|
||||
// use a pointMap or address directly into mesh
|
||||
label nPoints;
|
||||
if (pointMap.size())
|
||||
{
|
||||
nPoints = pointMap.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
nPoints = ptf.size();
|
||||
}
|
||||
|
||||
vtkFloatArray *pointData = vtkFloatArray::New();
|
||||
pointData->SetNumberOfTuples( nPoints + addPointCellLabels.size() );
|
||||
pointData->SetNumberOfComponents( nComp );
|
||||
pointData->Allocate( nComp*(nPoints + addPointCellLabels.size()) );
|
||||
pointData->SetName( tf.name().c_str() );
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convert convertPointField: "
|
||||
<< tf.name()
|
||||
<< " size = " << nPoints
|
||||
<< " nComp=" << nComp
|
||||
<< " nTuples = " << (nPoints + addPointCellLabels.size())
|
||||
<< endl;
|
||||
}
|
||||
|
||||
float vec[nComp];
|
||||
|
||||
if (pointMap.size())
|
||||
{
|
||||
forAll(pointMap, i)
|
||||
{
|
||||
const Type& t = ptf[pointMap[i]];
|
||||
for (direction d=0; d<nComp; d++)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
pointData->InsertTuple(i, vec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(ptf, i)
|
||||
{
|
||||
const Type& t = ptf[i];
|
||||
for (direction d=0; d<nComp; d++)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
pointData->InsertTuple(i, vec);
|
||||
}
|
||||
}
|
||||
|
||||
// continue insertion from here
|
||||
label i = nPoints;
|
||||
|
||||
if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null())
|
||||
{
|
||||
forAll(addPointCellLabels, apI)
|
||||
{
|
||||
const Type& t = tf[addPointCellLabels[apI]];
|
||||
for (direction d=0; d<nComp; d++)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
pointData->InsertTuple(i++, vec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(addPointCellLabels, apI)
|
||||
{
|
||||
Type t = interpolatePointToCell(ptf, addPointCellLabels[apI]);
|
||||
for (direction d=0; d<nComp; d++)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
pointData->InsertTuple(i++, vec);
|
||||
}
|
||||
}
|
||||
|
||||
vtkUnstructuredGrid::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, selector, datasetNo)
|
||||
) ->GetPointData()
|
||||
->AddArray(pointData);
|
||||
|
||||
pointData->Delete();
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -27,8 +27,8 @@ InClass
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPV3FoamInsertNextPoint_H
|
||||
#define vtkPV3FoamInsertNextPoint_H
|
||||
#ifndef vtkPV3FoamPoints_H
|
||||
#define vtkPV3FoamPoints_H
|
||||
|
||||
// VTK includes
|
||||
#include "vtkPoints.h"
|
||||
@ -44,6 +44,34 @@ inline void vtkPV3FoamInsertNextPoint
|
||||
points->InsertNextPoint(p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
#if 0
|
||||
// this should be faster, but didn't get it working ...
|
||||
inline void vtkPV3FoamSetPoint
|
||||
(
|
||||
vtkPoints *points,
|
||||
const Foam::label id,
|
||||
const Foam::point& p
|
||||
)
|
||||
{
|
||||
points->SetPoint(id, p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
|
||||
// Convert Foam mesh vertices to VTK
|
||||
inline vtkPoints* vtkPV3FoamVTKPoints(const Foam::pointField& points)
|
||||
{
|
||||
vtkPoints *vtkpoints = vtkPoints::New();
|
||||
vtkpoints->SetNumberOfPoints(points.size());
|
||||
forAll(points, i)
|
||||
{
|
||||
const Foam::point& p = points[i];
|
||||
vtkpoints->SetPoint(i, p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
return vtkpoints;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -1,291 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkPV3Foam.H"
|
||||
|
||||
// Foam includes
|
||||
#include "IOobjectList.H"
|
||||
#include "vtkPV3FoamReader.h"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
#include "vtkPV3FoamConvertVolFields.H"
|
||||
#include "vtkPV3FoamConvertPointFields.H"
|
||||
#include "vtkPV3FoamConvertLagrangianFields.H"
|
||||
|
||||
void Foam::vtkPV3Foam::updateFoamMesh()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateFoamMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
if (!reader_->GetCacheMesh())
|
||||
{
|
||||
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_()
|
||||
)
|
||||
);
|
||||
|
||||
meshChanged_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Using existing Foam mesh" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateFoamMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::updateVolFields
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateVolFields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
// Construct interpolation on the raw mesh
|
||||
pointMesh pMesh(mesh);
|
||||
|
||||
// Search for list of objects for this time
|
||||
IOobjectList objects(mesh, dbPtr_().timeName());
|
||||
|
||||
vtkDataArraySelection* arraySelection = reader_->GetVolFieldSelection();
|
||||
|
||||
// Convert volume fields
|
||||
if (debug)
|
||||
{
|
||||
Info<< "converting Foam volume fields" << endl;
|
||||
}
|
||||
|
||||
volPointInterpolation pInterp(mesh, pMesh);
|
||||
|
||||
PtrList<PrimitivePatchInterpolation<primitivePatch> >
|
||||
ppInterpList(mesh.boundaryMesh().size());
|
||||
|
||||
forAll(ppInterpList, i)
|
||||
{
|
||||
ppInterpList.set
|
||||
(
|
||||
i,
|
||||
new PrimitivePatchInterpolation<primitivePatch>
|
||||
(
|
||||
mesh.boundaryMesh()[i]
|
||||
)
|
||||
);
|
||||
}
|
||||
/*
|
||||
convertVolFields<Foam::label>
|
||||
(
|
||||
mesh, pInterp, objects, arraySelection, output
|
||||
);
|
||||
*/
|
||||
convertVolFields<Foam::scalar>
|
||||
(
|
||||
mesh, pInterp, ppInterpList, objects, arraySelection, output
|
||||
);
|
||||
convertVolFields<Foam::vector>
|
||||
(
|
||||
mesh, pInterp, ppInterpList, objects, arraySelection, output
|
||||
);
|
||||
convertVolFields<Foam::sphericalTensor>
|
||||
(
|
||||
mesh, pInterp, ppInterpList, objects, arraySelection, output
|
||||
);
|
||||
convertVolFields<Foam::symmTensor>
|
||||
(
|
||||
mesh, pInterp, ppInterpList, objects, arraySelection, output
|
||||
);
|
||||
convertVolFields<Foam::tensor>
|
||||
(
|
||||
mesh, pInterp, ppInterpList, objects, arraySelection, output
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateVolFields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::updatePointFields
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updatePointFields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
// Search for list of objects for this time
|
||||
IOobjectList objects(mesh, dbPtr_().timeName());
|
||||
|
||||
vtkDataArraySelection* arraySelection = reader_->GetPointFieldSelection();
|
||||
|
||||
/*
|
||||
convertPointFields<Foam::label>
|
||||
(
|
||||
mesh, objects, arraySelection, output
|
||||
);
|
||||
*/
|
||||
convertPointFields<Foam::scalar>
|
||||
(
|
||||
mesh, objects, arraySelection, output
|
||||
);
|
||||
convertPointFields<Foam::vector>
|
||||
(
|
||||
mesh, objects, arraySelection, output
|
||||
);
|
||||
convertPointFields<Foam::sphericalTensor>
|
||||
(
|
||||
mesh, objects, arraySelection, output
|
||||
);
|
||||
convertPointFields<Foam::symmTensor>
|
||||
(
|
||||
mesh, objects, arraySelection, output
|
||||
);
|
||||
convertPointFields<Foam::tensor>
|
||||
(
|
||||
mesh, objects, arraySelection, output
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::updatePointFields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::updateLagrangianFields
|
||||
(
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateLagrangianFields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
// Search for list of objects for this time
|
||||
//- TODO - currently hard-coded to ONE cloud
|
||||
IOobjectList objects
|
||||
(
|
||||
mesh,
|
||||
dbPtr_().timeName(),
|
||||
"lagrangian"/cloudName_
|
||||
);
|
||||
|
||||
vtkDataArraySelection* arraySelection =
|
||||
reader_->GetLagrangianFieldSelection();
|
||||
|
||||
// Convert Lagrangian fields
|
||||
if (debug)
|
||||
{
|
||||
Info<< "converting Foam Lagrangian fields" << endl;
|
||||
}
|
||||
|
||||
convertLagrangianFields<Foam::label>
|
||||
(
|
||||
mesh, objects, arraySelection, output
|
||||
);
|
||||
|
||||
convertLagrangianFields<Foam::scalar>
|
||||
(
|
||||
mesh, objects, arraySelection, output
|
||||
);
|
||||
convertLagrangianFields<Foam::vector>
|
||||
(
|
||||
mesh, objects, arraySelection, output
|
||||
);
|
||||
convertLagrangianFields<Foam::sphericalTensor>
|
||||
(
|
||||
mesh, objects, arraySelection, output
|
||||
);
|
||||
convertLagrangianFields<Foam::symmTensor>
|
||||
(
|
||||
mesh, objects, arraySelection, output
|
||||
);
|
||||
convertLagrangianFields<Foam::tensor>
|
||||
(
|
||||
mesh, objects, arraySelection, output
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateLagrangianFields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -38,7 +38,7 @@ License
|
||||
|
||||
// local headers
|
||||
#include "vtkPV3FoamAddToSelection.H"
|
||||
#include "vtkPV3FoamUpdateInformationFields.H"
|
||||
#include "vtkPV3FoamUpdateInfoFields.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
@ -107,7 +107,7 @@ Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType)
|
||||
zonesEntries zones(ioObj);
|
||||
|
||||
zoneNames.setSize(zones.size());
|
||||
forAll (zones, zoneI)
|
||||
forAll(zones, zoneI)
|
||||
{
|
||||
zoneNames[zoneI] = zones[zoneI].keyword();
|
||||
}
|
||||
@ -117,115 +117,100 @@ Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType)
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::updateInformationInternalMesh()
|
||||
void Foam::vtkPV3Foam::updateInfoInternalMesh()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateInformationInternalMesh" << endl;
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateInfoInternalMesh" << endl;
|
||||
}
|
||||
|
||||
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
|
||||
vtkDataArraySelection* partSelection = reader_->GetPartSelection();
|
||||
|
||||
// Determine number of meshes available
|
||||
HashTable<const fvMesh*> meshObjects = dbPtr_().lookupClass<const fvMesh>();
|
||||
nMesh_ = meshObjects.size();
|
||||
|
||||
// Determine regions (internal mesh and patches...)
|
||||
// Determine mesh parts (internalMesh, patches...)
|
||||
//- Add internal mesh as first entry
|
||||
selectInfoVolume_ = arraySelection->GetNumberOfArrays();
|
||||
arraySelection->AddArray("internalMesh");
|
||||
selectInfoVolume_ += 1;
|
||||
partInfoVolume_ = partSelection->GetNumberOfArrays();
|
||||
partSelection->AddArray("internalMesh");
|
||||
partInfoVolume_ += 1;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
getSelectedArrayEntries(partSelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateInformationInternalMesh" << endl;
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateInfoInternalMesh" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::updateInformationLagrangian()
|
||||
void Foam::vtkPV3Foam::updateInfoLagrangian()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateInformationLagrangian" << nl
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateInfoLagrangian" << nl
|
||||
<< " " << dbPtr_->timePath()/"lagrangian" << endl;
|
||||
}
|
||||
|
||||
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
|
||||
|
||||
// Search for list of lagrangian objects for this time
|
||||
fileNameList cloudDirs
|
||||
(
|
||||
readDir(dbPtr_->timePath()/"lagrangian", fileName::DIRECTORY)
|
||||
);
|
||||
|
||||
selectInfoLagrangian_ = arraySelection->GetNumberOfArrays();
|
||||
vtkDataArraySelection* partSelection = reader_->GetPartSelection();
|
||||
partInfoLagrangian_ = partSelection->GetNumberOfArrays();
|
||||
|
||||
if (cloudDirs.size())
|
||||
int nClouds = 0;
|
||||
forAll(cloudDirs, cloudI)
|
||||
{
|
||||
arraySelection->AddArray("lagrangian");
|
||||
selectInfoLagrangian_ += 1;
|
||||
// Add cloud to GUI list
|
||||
partSelection->AddArray
|
||||
(
|
||||
(cloudDirs[cloudI] + " - lagrangian").c_str()
|
||||
);
|
||||
|
||||
Info<< "... added cloudDirs\n";
|
||||
++nClouds;
|
||||
}
|
||||
|
||||
if (cloudDirs.size() > 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];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "... no clouds identified in " <<nl
|
||||
<< " " <<dbPtr_->timePath()/"lagrangian" << endl;
|
||||
}
|
||||
}
|
||||
partInfoLagrangian_ += nClouds;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
getSelectedArrayEntries(partSelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateInformationLagrangian" << endl;
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateInfoLagrangian" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::updateInformationPatches()
|
||||
void Foam::vtkPV3Foam::updateInfoPatches()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateInformationPatches"
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateInfoPatches"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl;
|
||||
}
|
||||
|
||||
vtkDataArraySelection *arraySelection = reader_->GetRegionSelection();
|
||||
selectInfoPatches_ = arraySelection->GetNumberOfArrays();
|
||||
vtkDataArraySelection* partSelection = reader_->GetPartSelection();
|
||||
partInfoPatches_ = partSelection->GetNumberOfArrays();
|
||||
|
||||
int nPatches = 0;
|
||||
|
||||
if (meshPtr_)
|
||||
{
|
||||
const polyBoundaryMesh& patches = meshPtr_->boundaryMesh();
|
||||
forAll (patches, patchI)
|
||||
forAll(patches, patchI)
|
||||
{
|
||||
const polyPatch& pp = patches[patchI];
|
||||
|
||||
if (pp.size())
|
||||
{
|
||||
// Add patch to GUI region list
|
||||
arraySelection->AddArray
|
||||
// Add patch to GUI list
|
||||
partSelection->AddArray
|
||||
(
|
||||
(pp.name() + " - patch").c_str()
|
||||
);
|
||||
@ -251,8 +236,8 @@ void Foam::vtkPV3Foam::updateInformationPatches()
|
||||
)
|
||||
);
|
||||
|
||||
// Start regions at patches
|
||||
forAll (patchEntries, entryI)
|
||||
// Add (non-zero) patches to the list of mesh parts
|
||||
forAll(patchEntries, entryI)
|
||||
{
|
||||
label nFaces
|
||||
(
|
||||
@ -262,8 +247,8 @@ void Foam::vtkPV3Foam::updateInformationPatches()
|
||||
// Valid patch if nFace > 0
|
||||
if (nFaces)
|
||||
{
|
||||
// Add patch to GUI region list
|
||||
arraySelection->AddArray
|
||||
// Add patch to GUI list
|
||||
partSelection->AddArray
|
||||
(
|
||||
(patchEntries[entryI].keyword() + " - patch").c_str()
|
||||
);
|
||||
@ -273,28 +258,32 @@ void Foam::vtkPV3Foam::updateInformationPatches()
|
||||
}
|
||||
}
|
||||
|
||||
selectInfoPatches_ += nPatches;
|
||||
partInfoPatches_ += nPatches;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
getSelectedArrayEntries(partSelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateInformationPatches" << endl;
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateInfoPatches" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::updateInformationZones()
|
||||
void Foam::vtkPV3Foam::updateInfoZones()
|
||||
{
|
||||
if (!reader_->GetIncludeZones())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateInformationZones"
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateInfoZones"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl;
|
||||
}
|
||||
|
||||
vtkDataArraySelection *arraySelection = reader_->GetRegionSelection();
|
||||
|
||||
vtkDataArraySelection* partSelection = reader_->GetPartSelection();
|
||||
wordList namesLst;
|
||||
|
||||
//
|
||||
@ -309,13 +298,12 @@ void Foam::vtkPV3Foam::updateInformationZones()
|
||||
namesLst = readZoneNames("cellZones");
|
||||
}
|
||||
|
||||
selectInfoCellZones_ = arraySelection->GetNumberOfArrays();
|
||||
forAll (namesLst, elemI)
|
||||
partInfoCellZones_ = partSelection->GetNumberOfArrays();
|
||||
forAll(namesLst, elemI)
|
||||
{
|
||||
arraySelection->AddArray((namesLst[elemI] + " - cellZone").c_str());
|
||||
partSelection->AddArray((namesLst[elemI] + " - cellZone").c_str());
|
||||
}
|
||||
selectInfoCellZones_ += namesLst.size();
|
||||
zoneSuperCells_.setSize(selectInfoCellZones_.size());
|
||||
partInfoCellZones_ += namesLst.size();
|
||||
|
||||
|
||||
//
|
||||
@ -330,12 +318,15 @@ void Foam::vtkPV3Foam::updateInformationZones()
|
||||
namesLst = readZoneNames("faceZones");
|
||||
}
|
||||
|
||||
selectInfoFaceZones_ = arraySelection->GetNumberOfArrays();
|
||||
forAll (namesLst, elemI)
|
||||
partInfoFaceZones_ = partSelection->GetNumberOfArrays();
|
||||
forAll(namesLst, elemI)
|
||||
{
|
||||
arraySelection->AddArray((namesLst[elemI] + " - faceZone").c_str());
|
||||
partSelection->AddArray
|
||||
(
|
||||
(namesLst[elemI] + " - faceZone").c_str()
|
||||
);
|
||||
}
|
||||
selectInfoFaceZones_ += namesLst.size();
|
||||
partInfoFaceZones_ += namesLst.size();
|
||||
|
||||
|
||||
//
|
||||
@ -350,32 +341,40 @@ void Foam::vtkPV3Foam::updateInformationZones()
|
||||
namesLst = readZoneNames("pointZones");
|
||||
}
|
||||
|
||||
selectInfoPointZones_ = arraySelection->GetNumberOfArrays();
|
||||
forAll (namesLst, elemI)
|
||||
partInfoPointZones_ = partSelection->GetNumberOfArrays();
|
||||
forAll(namesLst, elemI)
|
||||
{
|
||||
arraySelection->AddArray((namesLst[elemI] + " - pointZone").c_str());
|
||||
partSelection->AddArray
|
||||
(
|
||||
(namesLst[elemI] + " - pointZone").c_str()
|
||||
);
|
||||
}
|
||||
selectInfoPointZones_ += namesLst.size();
|
||||
partInfoPointZones_ += namesLst.size();
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
getSelectedArrayEntries(partSelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateInformationZones" << endl;
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateInfoZones" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::updateInformationSets()
|
||||
void Foam::vtkPV3Foam::updateInfoSets()
|
||||
{
|
||||
if (debug)
|
||||
if (!reader_->GetIncludeSets())
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateInformationSets" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
vtkDataArraySelection *arraySelection = reader_->GetRegionSelection();
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateInfoSets" << endl;
|
||||
}
|
||||
|
||||
vtkDataArraySelection* partSelection = reader_->GetPartSelection();
|
||||
|
||||
// Add names of sets
|
||||
IOobjectList objects
|
||||
@ -386,27 +385,26 @@ void Foam::vtkPV3Foam::updateInformationSets()
|
||||
);
|
||||
|
||||
|
||||
selectInfoCellSets_ = arraySelection->GetNumberOfArrays();
|
||||
selectInfoCellSets_ += addToSelection<cellSet>
|
||||
partInfoCellSets_ = partSelection->GetNumberOfArrays();
|
||||
partInfoCellSets_ += addToSelection<cellSet>
|
||||
(
|
||||
arraySelection,
|
||||
partSelection,
|
||||
objects,
|
||||
" - cellSet"
|
||||
);
|
||||
csetSuperCells_.setSize(selectInfoCellSets_.size());
|
||||
|
||||
selectInfoFaceSets_ = arraySelection->GetNumberOfArrays();
|
||||
selectInfoFaceSets_ += addToSelection<faceSet>
|
||||
partInfoFaceSets_ = partSelection->GetNumberOfArrays();
|
||||
partInfoFaceSets_ += addToSelection<faceSet>
|
||||
(
|
||||
arraySelection,
|
||||
partSelection,
|
||||
objects,
|
||||
" - faceSet"
|
||||
);
|
||||
|
||||
selectInfoPointSets_ = arraySelection->GetNumberOfArrays();
|
||||
selectInfoPointSets_ += addToSelection<pointSet>
|
||||
partInfoPointSets_ = partSelection->GetNumberOfArrays();
|
||||
partInfoPointSets_ += addToSelection<pointSet>
|
||||
(
|
||||
arraySelection,
|
||||
partSelection,
|
||||
objects,
|
||||
" - pointSet"
|
||||
);
|
||||
@ -414,85 +412,92 @@ void Foam::vtkPV3Foam::updateInformationSets()
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
getSelectedArrayEntries(partSelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateInformationSets" << endl;
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateInfoSets" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::updateInformationLagrangianFields()
|
||||
void Foam::vtkPV3Foam::updateInfoLagrangianFields()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateInformationLagrangianFields"
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateInfoLagrangianFields"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
vtkDataArraySelection *arraySelection =
|
||||
vtkDataArraySelection *fieldSelection =
|
||||
reader_->GetLagrangianFieldSelection();
|
||||
|
||||
// preserve the currently selected values
|
||||
const stringList selectedEntries = getSelectedArrayEntries
|
||||
(
|
||||
arraySelection
|
||||
);
|
||||
arraySelection->RemoveAllArrays();
|
||||
// preserve the enabled selections
|
||||
stringList enabledEntries = getSelectedArrayEntries(fieldSelection);
|
||||
fieldSelection->RemoveAllArrays();
|
||||
|
||||
//
|
||||
// TODO - currently only get fields from ONE cloud
|
||||
// have to decide if the second set of fields get mixed in
|
||||
// or dealt with separately
|
||||
|
||||
const partInfo& selector = partInfoLagrangian_;
|
||||
int partId = selector.start();
|
||||
|
||||
if (!selector.size() || partId < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
word cloudName = getPartName(partId);
|
||||
|
||||
// TODO - currently hard-coded to ONE cloud
|
||||
IOobjectList objects
|
||||
(
|
||||
dbPtr_(),
|
||||
dbPtr_().timeName(),
|
||||
"lagrangian"/cloudName_
|
||||
"lagrangian"/cloudName
|
||||
);
|
||||
|
||||
addToSelection<IOField<label> >
|
||||
(
|
||||
arraySelection,
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<scalar> >
|
||||
(
|
||||
arraySelection,
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<vector> >
|
||||
(
|
||||
arraySelection,
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<sphericalTensor> >
|
||||
(
|
||||
arraySelection,
|
||||
fieldSelection,
|
||||
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<symmTensor> >
|
||||
(
|
||||
arraySelection,
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<tensor> >
|
||||
(
|
||||
arraySelection,
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
|
||||
// restore the currently enabled values
|
||||
setSelectedArrayEntries
|
||||
(
|
||||
arraySelection,
|
||||
selectedEntries
|
||||
);
|
||||
// restore the enabled selections
|
||||
setSelectedArrayEntries(fieldSelection, enabledEntries);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateInformationLagrangianFields - "
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateInfoLagrangianFields - "
|
||||
<< "lagrangian objects.size() = " << objects.size() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -27,95 +27,78 @@ InClass
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPV3FoamUpdateInformationFields_H
|
||||
#define vtkPV3FoamUpdateInformationFields_H
|
||||
#ifndef vtkPV3FoamUpdateInfoFields_H
|
||||
#define vtkPV3FoamUpdateInfoFields_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<template<class> class patchType, class meshType>
|
||||
void Foam::vtkPV3Foam::updateInformationFields
|
||||
void Foam::vtkPV3Foam::updateInfoFields
|
||||
(
|
||||
vtkDataArraySelection *arraySelection
|
||||
vtkDataArraySelection *select
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateInformationFields" << endl;
|
||||
Info<< "<beg> Foam::vtkPV3Foam::updateInfoFields" << endl;
|
||||
}
|
||||
|
||||
stringList selectedEntries;
|
||||
stringList enabledEntries;
|
||||
// enable 'p' and 'U' on the first call
|
||||
if (arraySelection->GetNumberOfArrays() == 0 && !meshPtr_)
|
||||
if (select->GetNumberOfArrays() == 0 && !meshPtr_)
|
||||
{
|
||||
selectedEntries.setSize(2);
|
||||
selectedEntries[0] = "p";
|
||||
selectedEntries[1] = "U";
|
||||
enabledEntries.setSize(2);
|
||||
enabledEntries[0] = "p";
|
||||
enabledEntries[1] = "U";
|
||||
}
|
||||
else
|
||||
{
|
||||
// preserve the currently selected values
|
||||
selectedEntries = getSelectedArrayEntries
|
||||
(
|
||||
arraySelection
|
||||
);
|
||||
// preserve the enabled selections
|
||||
enabledEntries = getSelectedArrayEntries(select);
|
||||
}
|
||||
|
||||
arraySelection->RemoveAllArrays();
|
||||
select->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
|
||||
/*
|
||||
addToSelection<GeometricField<label, patchType, meshType> >
|
||||
(
|
||||
arraySelection,
|
||||
objects
|
||||
);
|
||||
*/
|
||||
addToSelection<GeometricField<scalar, patchType, meshType> >
|
||||
(
|
||||
arraySelection,
|
||||
select,
|
||||
objects
|
||||
);
|
||||
addToSelection<GeometricField<vector, patchType, meshType> >
|
||||
(
|
||||
arraySelection,
|
||||
select,
|
||||
objects
|
||||
);
|
||||
addToSelection<GeometricField<sphericalTensor, patchType, meshType> >
|
||||
(
|
||||
arraySelection,
|
||||
select,
|
||||
objects
|
||||
);
|
||||
addToSelection<GeometricField<symmTensor, patchType, meshType> >
|
||||
(
|
||||
arraySelection,
|
||||
select,
|
||||
objects
|
||||
);
|
||||
addToSelection<GeometricField<tensor, patchType, meshType> >
|
||||
(
|
||||
arraySelection,
|
||||
select,
|
||||
objects
|
||||
);
|
||||
|
||||
// restore the currently enabled values
|
||||
setSelectedArrayEntries
|
||||
(
|
||||
arraySelection,
|
||||
selectedEntries
|
||||
);
|
||||
// restore the enabled selections
|
||||
setSelectedArrayEntries(select, enabledEntries);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateInformationFields" << endl;
|
||||
Info<< "<end> Foam::vtkPV3Foam::updateInfoFields" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,341 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Misc helper methods and utilities
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkPV3Foam.H"
|
||||
#include "vtkPV3FoamReader.h"
|
||||
|
||||
// Foam includes
|
||||
#include "fvMesh.H"
|
||||
#include "Time.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkDataSet.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
#include "vtkInformation.h"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPV3Foam::AddToBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
vtkDataSet* dataset,
|
||||
const partInfo& selector,
|
||||
const label datasetNo,
|
||||
const string& datasetName
|
||||
)
|
||||
{
|
||||
const int blockNo = selector.block();
|
||||
|
||||
vtkDataObject* blockDO = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
|
||||
|
||||
if (!block)
|
||||
{
|
||||
if (blockDO)
|
||||
{
|
||||
FatalErrorIn("Foam::vtkPV3Foam::AddToBlock")
|
||||
<< "Block already has a vtkDataSet assigned to it"
|
||||
<< endl;
|
||||
return;
|
||||
}
|
||||
|
||||
block = vtkMultiBlockDataSet::New();
|
||||
output->SetBlock(blockNo, block);
|
||||
block->Delete();
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "block[" << blockNo << "] has "
|
||||
<< block->GetNumberOfBlocks()
|
||||
<< " datasets prior to adding set " << datasetNo
|
||||
<< " with name: " << datasetName << endl;
|
||||
}
|
||||
|
||||
block->SetBlock(datasetNo, dataset);
|
||||
|
||||
// name the block when assigning dataset 0
|
||||
if (datasetNo == 0)
|
||||
{
|
||||
output->GetMetaData(blockNo)->Set
|
||||
(
|
||||
vtkCompositeDataSet::NAME(),
|
||||
selector.name()
|
||||
);
|
||||
}
|
||||
|
||||
if (datasetName.size())
|
||||
{
|
||||
block->GetMetaData(datasetNo)->Set
|
||||
(
|
||||
vtkCompositeDataSet::NAME(),
|
||||
datasetName.c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vtkDataSet* Foam::vtkPV3Foam::GetDataSetFromBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const int blockNo = selector.block();
|
||||
|
||||
vtkDataObject* blockDO = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
|
||||
|
||||
if (block)
|
||||
{
|
||||
return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ununsed at the moment
|
||||
Foam::label Foam::vtkPV3Foam::GetNumberOfDataSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector
|
||||
)
|
||||
{
|
||||
const int blockNo = selector.block();
|
||||
|
||||
vtkDataObject* blockDO = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
|
||||
if (block)
|
||||
{
|
||||
return block->GetNumberOfBlocks();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::vtkPV3Foam::getPartName(int partId)
|
||||
{
|
||||
return getFirstWord(reader_->GetPartArrayName(partId));
|
||||
}
|
||||
|
||||
|
||||
Foam::wordHashSet Foam::vtkPV3Foam::getSelected
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
)
|
||||
{
|
||||
int nElem = select->GetNumberOfArrays();
|
||||
wordHashSet selections(2*nElem);
|
||||
|
||||
for (int elemI=0; elemI < nElem; ++elemI)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
{
|
||||
selections.insert(getFirstWord(select->GetArrayName(elemI)));
|
||||
}
|
||||
}
|
||||
|
||||
return selections;
|
||||
}
|
||||
|
||||
|
||||
Foam::wordHashSet Foam::vtkPV3Foam::getSelected
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const partInfo& selector
|
||||
)
|
||||
{
|
||||
int nElem = select->GetNumberOfArrays();
|
||||
wordHashSet selections(2*nElem);
|
||||
|
||||
for (int elemI = selector.start(); elemI < selector.end(); ++elemI)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
{
|
||||
selections.insert(getFirstWord(select->GetArrayName(elemI)));
|
||||
}
|
||||
}
|
||||
|
||||
return selections;
|
||||
}
|
||||
|
||||
|
||||
Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
)
|
||||
{
|
||||
stringList selections(select->GetNumberOfArrays());
|
||||
label nElem = 0;
|
||||
|
||||
forAll(selections, elemI)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
{
|
||||
selections[nElem++] = select->GetArrayName(elemI);
|
||||
}
|
||||
}
|
||||
selections.setSize(nElem);
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
label nElem = select->GetNumberOfArrays();
|
||||
Info<< "available(";
|
||||
for (int elemI = 0; elemI < nElem; ++elemI)
|
||||
{
|
||||
Info<< " \"" << select->GetArrayName(elemI) << "\"";
|
||||
}
|
||||
Info<< " )\nselected(";
|
||||
|
||||
forAll(selections, elemI)
|
||||
{
|
||||
Info<< " " << selections[elemI];
|
||||
}
|
||||
Info<< " )\n";
|
||||
}
|
||||
|
||||
return selections;
|
||||
}
|
||||
|
||||
|
||||
Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const partInfo& selector
|
||||
)
|
||||
{
|
||||
stringList selections(selector.size());
|
||||
label nElem = 0;
|
||||
|
||||
for (int elemI = selector.start(); elemI < selector.end(); ++elemI)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
{
|
||||
selections[nElem++] = select->GetArrayName(elemI);
|
||||
}
|
||||
}
|
||||
selections.setSize(nElem);
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "available(";
|
||||
for (int elemI = selector.start(); elemI < selector.end(); ++elemI)
|
||||
{
|
||||
Info<< " \"" << select->GetArrayName(elemI) << "\"";
|
||||
}
|
||||
Info<< " )\nselected(";
|
||||
|
||||
forAll(selections, elemI)
|
||||
{
|
||||
Info<< " " << selections[elemI];
|
||||
}
|
||||
Info<< " )\n";
|
||||
}
|
||||
|
||||
return selections;
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPV3Foam::setSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const stringList& selections
|
||||
)
|
||||
{
|
||||
const int nElem = select->GetNumberOfArrays();
|
||||
select->DisableAllArrays();
|
||||
|
||||
// Loop through entries, setting values from selectedEntries
|
||||
for (int elemI=0; elemI < nElem; ++elemI)
|
||||
{
|
||||
string arrayName(select->GetArrayName(elemI));
|
||||
|
||||
forAll(selections, elemI)
|
||||
{
|
||||
if (selections[elemI] == arrayName)
|
||||
{
|
||||
select->EnableArray(arrayName.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// parse these bits of info from /proc/meminfo (Linux)
|
||||
//
|
||||
// MemTotal: 2062660 kB
|
||||
// MemFree: 1124400 kB
|
||||
//
|
||||
// used = MemTotal - MemFree is what the free(1) uses.
|
||||
//
|
||||
void Foam::vtkPV3Foam::printMemory()
|
||||
{
|
||||
const char* meminfo = "/proc/meminfo";
|
||||
|
||||
if (exists(meminfo))
|
||||
{
|
||||
IFstream is(meminfo);
|
||||
label memTotal = 0;
|
||||
label memFree = 0;
|
||||
|
||||
string line;
|
||||
|
||||
while (is.getLine(line).good())
|
||||
{
|
||||
char tag[32];
|
||||
int value;
|
||||
|
||||
if (sscanf(line.c_str(), "%30s %d", tag, &value) == 2)
|
||||
{
|
||||
if (!strcmp(tag, "MemTotal:"))
|
||||
{
|
||||
memTotal = value;
|
||||
}
|
||||
else if (!strcmp(tag, "MemFree:"))
|
||||
{
|
||||
memFree = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Info << "memUsed: " << (memTotal - memFree) << " kB\n";
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,354 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
vtkPV3Foam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPV3FoamVolFields_H
|
||||
#define vtkPV3FoamVolFields_H
|
||||
|
||||
// Foam includes
|
||||
#include "emptyFvPatchField.H"
|
||||
#include "wallPolyPatch.H"
|
||||
#include "faceSet.H"
|
||||
#include "vtkPV3FoamFaceField.H"
|
||||
#include "vtkPV3FoamPatchField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertVolFields
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const volPointInterpolation& pInterp,
|
||||
const PtrList<PrimitivePatchInterpolation<primitivePatch> >& ppInterpList,
|
||||
const IOobjectList& objects,
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
// restrict to GeometricField<Type, ...>
|
||||
if
|
||||
(
|
||||
iter()->headerClassName()
|
||||
!= GeometricField<Type, fvPatchField, volMesh>::typeName
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
GeometricField<Type, fvPatchField, volMesh> tf
|
||||
(
|
||||
*iter(),
|
||||
mesh
|
||||
);
|
||||
|
||||
tmp<GeometricField<Type, pointPatchField, pointMesh> > tptf
|
||||
(
|
||||
pInterp.interpolate(tf)
|
||||
);
|
||||
|
||||
|
||||
// Convert activated internalMesh regions
|
||||
convertVolFieldBlock
|
||||
(
|
||||
tf,
|
||||
tptf(),
|
||||
output,
|
||||
partInfoVolume_,
|
||||
regionPolyDecomp_
|
||||
);
|
||||
|
||||
// Convert activated cellZones
|
||||
convertVolFieldBlock
|
||||
(
|
||||
tf,
|
||||
tptf(),
|
||||
output,
|
||||
partInfoCellZones_,
|
||||
zonePolyDecomp_
|
||||
);
|
||||
|
||||
// Convert activated cellSets
|
||||
convertVolFieldBlock
|
||||
(
|
||||
tf,
|
||||
tptf(),
|
||||
output,
|
||||
partInfoCellSets_,
|
||||
csetPolyDecomp_
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Convert patches - if activated
|
||||
//
|
||||
for
|
||||
(
|
||||
int partId = partInfoPatches_.start();
|
||||
partId < partInfoPatches_.end();
|
||||
++partId
|
||||
)
|
||||
{
|
||||
const word patchName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
const label patchId = patches.findPatchID(patchName);
|
||||
|
||||
if (!partStatus_[partId] || datasetNo < 0 || patchId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const fvPatchField<Type>& ptf = tf.boundaryField()[patchId];
|
||||
|
||||
if
|
||||
(
|
||||
isType<emptyFvPatchField<Type> >(ptf)
|
||||
||
|
||||
(
|
||||
typeid(patches[patchId]) == typeid(wallPolyPatch)
|
||||
&& reader_->GetExtrapolateWalls()
|
||||
)
|
||||
)
|
||||
{
|
||||
fvPatch p(ptf.patch().patch(), tf.mesh().boundary());
|
||||
|
||||
tmp<Field<Type> > tpptf
|
||||
(
|
||||
fvPatchField<Type>(p, tf).patchInternalField()
|
||||
);
|
||||
|
||||
convertPatchField
|
||||
(
|
||||
tf.name(),
|
||||
tpptf(),
|
||||
output,
|
||||
partInfoPatches_,
|
||||
datasetNo
|
||||
);
|
||||
|
||||
convertPatchPointField
|
||||
(
|
||||
tf.name(),
|
||||
ppInterpList[patchId].faceToPointInterpolate(tpptf)(),
|
||||
output,
|
||||
partInfoPatches_,
|
||||
datasetNo
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
convertPatchField
|
||||
(
|
||||
tf.name(),
|
||||
ptf,
|
||||
output,
|
||||
partInfoPatches_,
|
||||
datasetNo
|
||||
);
|
||||
|
||||
convertPatchPointField
|
||||
(
|
||||
tf.name(),
|
||||
ppInterpList[patchId].faceToPointInterpolate(ptf)(),
|
||||
output,
|
||||
partInfoPatches_,
|
||||
datasetNo
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Convert face zones - if activated
|
||||
//
|
||||
for
|
||||
(
|
||||
int partId = partInfoFaceZones_.start();
|
||||
partId < partInfoFaceZones_.end();
|
||||
++partId
|
||||
)
|
||||
{
|
||||
const word zoneName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
|
||||
if (!partStatus_[partId] || datasetNo < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const faceZoneMesh& zMesh = mesh.faceZones();
|
||||
const label zoneId = zMesh.findZoneID(zoneName);
|
||||
|
||||
if (zoneId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
convertFaceField
|
||||
(
|
||||
tf,
|
||||
output,
|
||||
partInfoFaceZones_,
|
||||
datasetNo,
|
||||
mesh,
|
||||
zMesh[zoneId]
|
||||
);
|
||||
|
||||
// TODO: points
|
||||
}
|
||||
|
||||
//
|
||||
// Convert face sets - if activated
|
||||
//
|
||||
for
|
||||
(
|
||||
int partId = partInfoFaceSets_.start();
|
||||
partId < partInfoFaceSets_.end();
|
||||
++partId
|
||||
)
|
||||
{
|
||||
const word selectName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
|
||||
if (!partStatus_[partId] || datasetNo < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const faceSet fSet(mesh, selectName);
|
||||
|
||||
convertFaceField
|
||||
(
|
||||
tf,
|
||||
output,
|
||||
partInfoFaceSets_,
|
||||
datasetNo,
|
||||
mesh,
|
||||
fSet
|
||||
);
|
||||
|
||||
// TODO: points
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertVolFieldBlock
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& tf,
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& ptf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector,
|
||||
const List<polyDecomp>& decompLst
|
||||
)
|
||||
{
|
||||
for (int partId = selector.start(); partId < selector.end(); ++partId)
|
||||
{
|
||||
const label datasetNo = partDataset_[partId];
|
||||
|
||||
if (datasetNo >= 0 && partStatus_[partId])
|
||||
{
|
||||
convertVolField
|
||||
(
|
||||
tf,
|
||||
output,
|
||||
selector,
|
||||
datasetNo,
|
||||
decompLst[datasetNo]
|
||||
);
|
||||
|
||||
convertPointField
|
||||
(
|
||||
ptf,
|
||||
tf,
|
||||
output,
|
||||
selector,
|
||||
datasetNo,
|
||||
decompLst[datasetNo]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPV3Foam::convertVolField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& tf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector,
|
||||
const label datasetNo,
|
||||
const polyDecomp& decompInfo
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
const labelList& superCells = decompInfo.superCells();
|
||||
|
||||
vtkFloatArray* celldata = vtkFloatArray::New();
|
||||
celldata->SetNumberOfTuples( superCells.size() );
|
||||
celldata->SetNumberOfComponents( nComp );
|
||||
celldata->Allocate( nComp*superCells.size() );
|
||||
celldata->SetName( tf.name().c_str() );
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convert volField: "
|
||||
<< tf.name()
|
||||
<< " size = " << tf.size()
|
||||
<< " nComp=" << nComp
|
||||
<< " nTuples = " << superCells.size() << endl;
|
||||
}
|
||||
|
||||
float vec[nComp];
|
||||
forAll(superCells, i)
|
||||
{
|
||||
const Type& t = tf[superCells[i]];
|
||||
for (direction d=0; d<nComp; d++)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
celldata->InsertTuple(i, vec);
|
||||
}
|
||||
|
||||
vtkUnstructuredGrid::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, selector, datasetNo)
|
||||
) ->GetCellData()
|
||||
->AddArray(celldata);
|
||||
|
||||
celldata->Delete();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user