mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: adjustments to runTimePostProcessing
- support VTP input in functionObjectCloud scene element - additional fallback lookup of cloud information from state properties instead of cloud OutputProperties
This commit is contained in:
@ -15,6 +15,7 @@ include_directories(
|
|||||||
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
|
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
|
||||||
$ENV{WM_PROJECT_DIR}/src/surfMesh/lnInclude
|
$ENV{WM_PROJECT_DIR}/src/surfMesh/lnInclude
|
||||||
$ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
|
$ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
|
||||||
|
$ENV{WM_PROJECT_DIR}/src/conversion/lnInclude
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
@ -58,6 +59,7 @@ file(GLOB SOURCE_FILES
|
|||||||
functionObjectLine.C
|
functionObjectLine.C
|
||||||
functionObjectSurface.C
|
functionObjectSurface.C
|
||||||
geometryBase.C
|
geometryBase.C
|
||||||
|
geometryPatches.C
|
||||||
geometrySurface.C
|
geometrySurface.C
|
||||||
pathline.C
|
pathline.C
|
||||||
pointData.C
|
pointData.C
|
||||||
@ -72,6 +74,7 @@ set(OPENFOAM_LIBRARIES
|
|||||||
OpenFOAM
|
OpenFOAM
|
||||||
surfMesh
|
surfMesh
|
||||||
finiteVolume
|
finiteVolume
|
||||||
|
conversion
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
|
|||||||
@ -44,11 +44,11 @@ namespace runTimePostPro
|
|||||||
bool Foam::functionObjects::runTimePostPro::functionObjectBase::removeFile
|
bool Foam::functionObjects::runTimePostPro::functionObjectBase::removeFile
|
||||||
(
|
(
|
||||||
const word& keyword,
|
const word& keyword,
|
||||||
const word& fieldName
|
const word& subDictName
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
dictionary dict;
|
dictionary dict;
|
||||||
state_.getObjectDict(functionObjectName_, fieldName, dict);
|
state_.getObjectDict(functionObjectName_, subDictName, dict);
|
||||||
|
|
||||||
fileName fName;
|
fileName fName;
|
||||||
if (dict.readIfPresent(keyword, fName))
|
if (dict.readIfPresent(keyword, fName))
|
||||||
@ -65,15 +65,13 @@ Foam::fileName
|
|||||||
Foam::functionObjects::runTimePostPro::functionObjectBase::getFileName
|
Foam::functionObjects::runTimePostPro::functionObjectBase::getFileName
|
||||||
(
|
(
|
||||||
const word& keyword,
|
const word& keyword,
|
||||||
const word& fieldName
|
const word& subDictName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
dictionary dict;
|
dictionary dict;
|
||||||
state_.getObjectDict(functionObjectName_, fieldName, dict);
|
state_.getObjectDict(functionObjectName_, subDictName, dict);
|
||||||
|
|
||||||
fileName fName(dict.lookupOrDefault(keyword, fileName::null));
|
return dict.lookupOrDefault<fileName>(keyword, fileName::null);
|
||||||
|
|
||||||
return fName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -88,11 +86,9 @@ Foam::functionObjects::runTimePostPro::functionObjectBase::functionObjectBase
|
|||||||
:
|
:
|
||||||
fieldVisualisationBase(dict, colours),
|
fieldVisualisationBase(dict, colours),
|
||||||
state_(state),
|
state_(state),
|
||||||
functionObjectName_(""),
|
functionObjectName_(dict.lookup("functionObject")),
|
||||||
clearObjects_(dict.lookupOrDefault("clearObjects", false))
|
clearObjects_(dict.lookupOrDefault("clearObjects", false))
|
||||||
{
|
{}
|
||||||
dict.lookup("functionObject") >> functionObjectName_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -27,6 +27,13 @@ Class
|
|||||||
Description
|
Description
|
||||||
Base class for function object visualisation
|
Base class for function object visualisation
|
||||||
|
|
||||||
|
Dictionary controls
|
||||||
|
\table
|
||||||
|
Property | Description | Required | Default
|
||||||
|
functionObject | The data source | yes |
|
||||||
|
clearObjects | Remove file after use | no | no
|
||||||
|
\endtable
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
functionObjectBase.C
|
functionObjectBase.C
|
||||||
|
|
||||||
@ -73,7 +80,7 @@ protected:
|
|||||||
//- Reference to the state
|
//- Reference to the state
|
||||||
const stateFunctionObject& state_;
|
const stateFunctionObject& state_;
|
||||||
|
|
||||||
//- Function object name
|
//- The function object name which provides the source data
|
||||||
word functionObjectName_;
|
word functionObjectName_;
|
||||||
|
|
||||||
//- Flag to indicate that source data should be cleared after use
|
//- Flag to indicate that source data should be cleared after use
|
||||||
@ -82,11 +89,36 @@ protected:
|
|||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
//- Retrieve file used to create the scene object
|
//- Retrieve the filename used to create the scene object
|
||||||
fileName getFileName(const word& keyword, const word& fieldName) const;
|
//- using information stored via the stateFunctionObject.
|
||||||
|
//
|
||||||
|
// \param keyword is normally "file"
|
||||||
|
// \param subDictName is the sub-dictionary name, which is often
|
||||||
|
// the fieldName when one file is used per field.
|
||||||
|
//
|
||||||
|
// Eg,
|
||||||
|
// \verbatim
|
||||||
|
// T
|
||||||
|
// {
|
||||||
|
// file "path/T_object.vtk";
|
||||||
|
// }
|
||||||
|
// defaultCloud
|
||||||
|
// {
|
||||||
|
// file "path/cloud_0001.vtp";
|
||||||
|
// fields (T U);
|
||||||
|
// }
|
||||||
|
// \endverbatim
|
||||||
|
fileName getFileName
|
||||||
|
(
|
||||||
|
const word& keyword,
|
||||||
|
const word& subDictName
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Remove file used to create the scene object
|
//- Remove file used to create the scene object.
|
||||||
bool removeFile(const word& keyword, const word& fieldName);
|
// Same naming semantics as getFileName.
|
||||||
|
//
|
||||||
|
// \note does not change the stateFunctionObject
|
||||||
|
bool removeFile(const word& keyword, const word& subDictName);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -28,12 +28,15 @@ License
|
|||||||
#include "fvMesh.H"
|
#include "fvMesh.H"
|
||||||
#include "runTimePostProcessing.H"
|
#include "runTimePostProcessing.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "stringOps.H"
|
||||||
|
|
||||||
// VTK includes
|
// VTK includes
|
||||||
#include "vtkActor.h"
|
#include "vtkActor.h"
|
||||||
#include "vtkRenderer.h"
|
#include "vtkRenderer.h"
|
||||||
#include "vtkSmartPointer.h"
|
#include "vtkSmartPointer.h"
|
||||||
|
#include "vtkPolyData.h"
|
||||||
#include "vtkPolyDataMapper.h"
|
#include "vtkPolyDataMapper.h"
|
||||||
|
#include "vtkXMLPolyDataReader.h"
|
||||||
#include "vtkPolyDataReader.h"
|
#include "vtkPolyDataReader.h"
|
||||||
#include "vtkProperty.h"
|
#include "vtkProperty.h"
|
||||||
|
|
||||||
@ -64,6 +67,7 @@ Foam::functionObjects::runTimePostPro::functionObjectCloud::functionObjectCloud
|
|||||||
pointData(parent, dict, colours),
|
pointData(parent, dict, colours),
|
||||||
functionObjectBase(parent, dict, colours),
|
functionObjectBase(parent, dict, colours),
|
||||||
cloudName_(dict.lookup("cloud")),
|
cloudName_(dict.lookup("cloud")),
|
||||||
|
inputFileName_(),
|
||||||
colourFieldName_(dict.lookup("colourField")),
|
colourFieldName_(dict.lookup("colourField")),
|
||||||
actor_()
|
actor_()
|
||||||
{
|
{
|
||||||
@ -92,23 +96,42 @@ addGeometryToScene
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inputFileName_.clear();
|
||||||
|
|
||||||
|
// The CloudToVTK functionObject from
|
||||||
|
//
|
||||||
|
// lagrangian/intermediate/submodels/CloudFunctionObjects/
|
||||||
|
//
|
||||||
|
// stores file state on cloud OutputProperties itself,
|
||||||
|
//
|
||||||
|
// whereas the vtkCloud functionObject treats it like other
|
||||||
|
// output and stores via the stateFunctionObject.
|
||||||
|
// Since it uses VTP format, there is only a single file with all fields
|
||||||
|
// - lookup by cloudName.
|
||||||
|
|
||||||
const dictionary& cloudDict =
|
const dictionary& cloudDict =
|
||||||
geometryBase::parent_.mesh().lookupObject<IOdictionary>
|
geometryBase::parent_.mesh().lookupObject<IOdictionary>
|
||||||
(
|
(
|
||||||
cloudName_ + "OutputProperties"
|
cloudName_ + "OutputProperties"
|
||||||
);
|
);
|
||||||
|
|
||||||
fileName fName;
|
if (cloudDict.found("cloudFunctionObject"))
|
||||||
if (cloudDict.found("functionObjectCloud"))
|
|
||||||
{
|
{
|
||||||
const dictionary& foDict = cloudDict.subDict("cloudFunctionObject");
|
const dictionary& foDict = cloudDict.subDict("cloudFunctionObject");
|
||||||
if (foDict.found(functionObjectName_))
|
if (foDict.found(functionObjectName_))
|
||||||
{
|
{
|
||||||
foDict.subDict(functionObjectName_).readIfPresent("file", fName);
|
foDict.subDict(functionObjectName_)
|
||||||
|
.readIfPresent("file", inputFileName_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inputFileName_ = getFileName("file", cloudName_);
|
||||||
|
}
|
||||||
|
|
||||||
if (fName.empty())
|
|
||||||
|
stringOps::inplaceExpand(inputFileName_);
|
||||||
|
if (inputFileName_.empty())
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Unable to find function object " << functionObjectName_
|
<< "Unable to find function object " << functionObjectName_
|
||||||
@ -118,12 +141,32 @@ addGeometryToScene
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fName.ext() == "vtk")
|
vtkSmartPointer<vtkPolyData> dataset;
|
||||||
{
|
|
||||||
auto points = vtkSmartPointer<vtkPolyDataReader>::New();
|
|
||||||
points->SetFileName(fName.c_str());
|
|
||||||
points->Update();
|
|
||||||
|
|
||||||
|
if (inputFileName_.hasExt("vtp"))
|
||||||
|
{
|
||||||
|
auto reader = vtkSmartPointer<vtkXMLPolyDataReader>::New();
|
||||||
|
reader->SetFileName(inputFileName_.c_str());
|
||||||
|
reader->Update();
|
||||||
|
|
||||||
|
dataset = reader->GetOutput();
|
||||||
|
}
|
||||||
|
else if (inputFileName_.hasExt("vtk"))
|
||||||
|
{
|
||||||
|
auto reader = vtkSmartPointer<vtkPolyDataReader>::New();
|
||||||
|
reader->SetFileName(inputFileName_.c_str());
|
||||||
|
reader->Update();
|
||||||
|
|
||||||
|
dataset = reader->GetOutput();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Invalid name - ignore
|
||||||
|
inputFileName_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataset)
|
||||||
|
{
|
||||||
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
|
|
||||||
actor_->SetMapper(mapper);
|
actor_->SetMapper(mapper);
|
||||||
@ -134,7 +177,7 @@ addGeometryToScene
|
|||||||
fieldName_,
|
fieldName_,
|
||||||
colourFieldName_,
|
colourFieldName_,
|
||||||
maxGlyphLength_,
|
maxGlyphLength_,
|
||||||
points->GetOutput(),
|
dataset,
|
||||||
actor_,
|
actor_,
|
||||||
renderer
|
renderer
|
||||||
);
|
);
|
||||||
@ -160,29 +203,12 @@ bool Foam::functionObjects::runTimePostPro::functionObjectCloud::clear()
|
|||||||
{
|
{
|
||||||
if (functionObjectBase::clear())
|
if (functionObjectBase::clear())
|
||||||
{
|
{
|
||||||
const dictionary& cloudDict =
|
if (inputFileName_.size() && Foam::rm(inputFileName_))
|
||||||
geometryBase::parent_.mesh().lookupObject<IOdictionary>
|
|
||||||
(
|
|
||||||
cloudName_ & "OutputProperties"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (cloudDict.found("functionObjectCloud"))
|
|
||||||
{
|
{
|
||||||
const dictionary& foDict = cloudDict.subDict("functionObjectCloud");
|
inputFileName_.clear();
|
||||||
if (foDict.found(functionObjectName_))
|
|
||||||
{
|
|
||||||
const dictionary& functionDict =
|
|
||||||
foDict.subDict(functionObjectName_);
|
|
||||||
|
|
||||||
fileName fName;
|
|
||||||
if (functionDict.readIfPresent("file", fName))
|
|
||||||
{
|
|
||||||
Foam::rm(fName);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -74,13 +74,15 @@ protected:
|
|||||||
//- Name of functionObjectCloud
|
//- Name of functionObjectCloud
|
||||||
word cloudName_;
|
word cloudName_;
|
||||||
|
|
||||||
|
//- The input filename used
|
||||||
|
fileName inputFileName_;
|
||||||
|
|
||||||
//- Name of field to colour by
|
//- Name of field to colour by
|
||||||
word colourFieldName_;
|
word colourFieldName_;
|
||||||
|
|
||||||
//- Actor
|
//- Actor
|
||||||
vtkSmartPointer<vtkActor> actor_;
|
vtkSmartPointer<vtkActor> actor_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Run-time type information
|
//- Run-time type information
|
||||||
|
|||||||
@ -99,7 +99,7 @@ addGeometryToScene
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fName.ext() == "vtk")
|
if (fName.hasExt("vtk"))
|
||||||
{
|
{
|
||||||
auto lines = vtkSmartPointer<vtkPolyDataReader>::New();
|
auto lines = vtkSmartPointer<vtkPolyDataReader>::New();
|
||||||
lines->SetFileName(fName.c_str());
|
lines->SetFileName(fName.c_str());
|
||||||
|
|||||||
@ -115,10 +115,10 @@ addGeometryToScene
|
|||||||
surfaceActor_,
|
surfaceActor_,
|
||||||
renderer
|
renderer
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
if (fName.hasExt("vtk"))
|
||||||
if (fName.ext() == "vtk")
|
|
||||||
{
|
{
|
||||||
auto surf = vtkSmartPointer<vtkPolyDataReader>::New();
|
auto surf = vtkSmartPointer<vtkPolyDataReader>::New();
|
||||||
surf->SetFileName(fName.c_str());
|
surf->SetFileName(fName.c_str());
|
||||||
@ -144,7 +144,6 @@ addGeometryToScene
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::functionObjects::runTimePostPro::functionObjectSurface::clear()
|
bool Foam::functionObjects::runTimePostPro::functionObjectSurface::clear()
|
||||||
|
|||||||
Reference in New Issue
Block a user