mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'runTimePostProcessing_bugFix' into 'master'
Multiple updates for run-time post-processing functionality See merge request !39
This commit is contained in:
@ -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 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -453,14 +453,12 @@ Foam::fieldVisualisationBase::fieldVisualisationBase
|
|||||||
{
|
{
|
||||||
case cbColour:
|
case cbColour:
|
||||||
{
|
{
|
||||||
|
scalarBar_.visible_ = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cbField:
|
case cbField:
|
||||||
{
|
{
|
||||||
dict.lookup("range") >> range_;
|
dict.lookup("range") >> range_;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dict.found("colourMap"))
|
if (dict.found("colourMap"))
|
||||||
{
|
{
|
||||||
@ -478,6 +476,9 @@ Foam::fieldVisualisationBase::fieldVisualisationBase
|
|||||||
sbarDict.lookup("labelFormat") >> scalarBar_.labelFormat_;
|
sbarDict.lookup("labelFormat") >> scalarBar_.labelFormat_;
|
||||||
sbarDict.lookup("numberOfLabels") >> scalarBar_.numberOfLabels_;
|
sbarDict.lookup("numberOfLabels") >> scalarBar_.numberOfLabels_;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -124,7 +124,7 @@ void Foam::functionObjectSurface::addGeometryToScene
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((colourBy_ == cbField) && (fName.ext() == "vtk"))
|
if (fName.ext() == "vtk")
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkPolyDataReader> surf =
|
vtkSmartPointer<vtkPolyDataReader> surf =
|
||||||
vtkSmartPointer<vtkPolyDataReader>::New();
|
vtkSmartPointer<vtkPolyDataReader>::New();
|
||||||
@ -147,7 +147,9 @@ void Foam::functionObjectSurface::addGeometryToScene
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
geometrySurface::addGeometryToScene(position, renderer);
|
WarningInFunction
|
||||||
|
<< "Only VTK file types are supported"
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -177,14 +177,20 @@ void Foam::runTimePostProcessing::write()
|
|||||||
surfaces_[i].addGeometryToScene(0, renderer);
|
surfaces_[i].addGeometryToScene(0, renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the text
|
||||||
|
forAll(text_, i)
|
||||||
|
{
|
||||||
|
text_[i].addGeometryToScene(0, renderer);
|
||||||
|
}
|
||||||
|
|
||||||
while (scene_.loop(renderer))
|
while (scene_.loop(renderer))
|
||||||
{
|
{
|
||||||
scalar position = scene_.position();
|
scalar position = scene_.position();
|
||||||
|
|
||||||
// Add the text
|
// Update the text
|
||||||
forAll(text_, i)
|
forAll(text_, i)
|
||||||
{
|
{
|
||||||
text_[i].addGeometryToScene(position, renderer);
|
text_[i].updateActors(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the points
|
// Update the points
|
||||||
|
|||||||
@ -67,14 +67,18 @@ void Foam::scene::readCamera(const dictionary& dict)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dict.readIfPresent("startPosition", position_))
|
if (dict.readIfPresent("startPosition", startPosition_))
|
||||||
{
|
{
|
||||||
if ((position_ < 0) || (position_ > 1))
|
if ((startPosition_ < 0) || (startPosition_ > 1))
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(dict)
|
FatalIOErrorInFunction(dict)
|
||||||
<< "startPosition must be in the range 0-1"
|
<< "startPosition must be in the range 0-1"
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
position_ = startPosition_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -89,7 +93,7 @@ void Foam::scene::readCamera(const dictionary& dict)
|
|||||||
<< "endPosition must be in the range 0-1"
|
<< "endPosition must be in the range 0-1"
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
dPosition_ = (endPosition - position_)/scalar(nFrameTotal_ - 1);
|
dPosition_ = (endPosition - startPosition_)/scalar(nFrameTotal_ - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
mode_ = modeTypeNames_.read(dict.lookup("mode"));
|
mode_ = modeTypeNames_.read(dict.lookup("mode"));
|
||||||
@ -134,15 +138,6 @@ void Foam::scene::readCamera(const dictionary& dict)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dict.found("zoom"))
|
|
||||||
{
|
|
||||||
cameraZoom_.reset(DataEntry<scalar>::New("zoom", dict).ptr());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cameraZoom_.reset(new Constant<scalar>("zoom", 1.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dict.found("viewAngle"))
|
if (dict.found("viewAngle"))
|
||||||
{
|
{
|
||||||
cameraViewAngle_.reset(DataEntry<scalar>::New("viewAngle", dict).ptr());
|
cameraViewAngle_.reset(DataEntry<scalar>::New("viewAngle", dict).ptr());
|
||||||
@ -168,11 +163,12 @@ void Foam::scene::readColours(const dictionary& dict)
|
|||||||
void Foam::scene::initialise(vtkRenderer* renderer, const word& outputName)
|
void Foam::scene::initialise(vtkRenderer* renderer, const word& outputName)
|
||||||
{
|
{
|
||||||
currentFrameI_ = 0;
|
currentFrameI_ = 0;
|
||||||
|
position_ = startPosition_;
|
||||||
|
|
||||||
outputName_ = outputName;
|
outputName_ = outputName;
|
||||||
|
|
||||||
// Set the background
|
// Set the background
|
||||||
const vector backgroundColour = colours_["background"]->value(position());
|
const vector backgroundColour = colours_["background"]->value(position_);
|
||||||
renderer->SetBackground
|
renderer->SetBackground
|
||||||
(
|
(
|
||||||
backgroundColour.x(),
|
backgroundColour.x(),
|
||||||
@ -184,7 +180,7 @@ void Foam::scene::initialise(vtkRenderer* renderer, const word& outputName)
|
|||||||
if (colours_.found("background2"))
|
if (colours_.found("background2"))
|
||||||
{
|
{
|
||||||
renderer->GradientBackgroundOn();
|
renderer->GradientBackgroundOn();
|
||||||
vector backgroundColour2 = colours_["background2"]->value(position());
|
vector backgroundColour2 = colours_["background2"]->value(position_);
|
||||||
|
|
||||||
renderer->SetBackground2
|
renderer->SetBackground2
|
||||||
(
|
(
|
||||||
@ -204,9 +200,24 @@ void Foam::scene::initialise(vtkRenderer* renderer, const word& outputName)
|
|||||||
camera->SetParallelProjection(parallelProjection_);
|
camera->SetParallelProjection(parallelProjection_);
|
||||||
renderer->SetActiveCamera(camera);
|
renderer->SetActiveCamera(camera);
|
||||||
|
|
||||||
setCamera(renderer, true);
|
|
||||||
|
|
||||||
// Initialise the extents
|
// Initialise the camera
|
||||||
|
const vector up = cameraUp_->value(position_);
|
||||||
|
const vector pos = cameraPosition_->value(position_);
|
||||||
|
const point focalPoint = cameraFocalPoint_->value(position_);
|
||||||
|
|
||||||
|
camera->SetViewUp(up.x(), up.y(), up.z());
|
||||||
|
camera->SetPosition(pos.x(), pos.y(), pos.z());
|
||||||
|
camera->SetFocalPoint(focalPoint.x(), focalPoint.y(), focalPoint.z());
|
||||||
|
camera->Modified();
|
||||||
|
|
||||||
|
|
||||||
|
// Add the lights
|
||||||
|
vtkSmartPointer<vtkLightKit> lightKit = vtkSmartPointer<vtkLightKit>::New();
|
||||||
|
lightKit->AddLightsToRenderer(renderer);
|
||||||
|
|
||||||
|
|
||||||
|
// For static mode initialise the clip box
|
||||||
if (mode_ == mtStatic)
|
if (mode_ == mtStatic)
|
||||||
{
|
{
|
||||||
const point& min = clipBox_.min();
|
const point& min = clipBox_.min();
|
||||||
@ -228,39 +239,38 @@ void Foam::scene::initialise(vtkRenderer* renderer, const word& outputName)
|
|||||||
|
|
||||||
vtkSmartPointer<vtkActor> clipActor = vtkSmartPointer<vtkActor>::New();
|
vtkSmartPointer<vtkActor> clipActor = vtkSmartPointer<vtkActor>::New();
|
||||||
clipActor->SetMapper(clipMapper);
|
clipActor->SetMapper(clipMapper);
|
||||||
clipActor->VisibilityOn();
|
clipActor->VisibilityOff();
|
||||||
renderer->AddActor(clipActor);
|
renderer->AddActor(clipActor);
|
||||||
|
|
||||||
|
// Call resetCamera to fit clip box in view
|
||||||
|
clipActor->VisibilityOn();
|
||||||
renderer->ResetCamera();
|
renderer->ResetCamera();
|
||||||
|
|
||||||
clipActor->VisibilityOff();
|
clipActor->VisibilityOff();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::scene::setCamera(vtkRenderer* renderer, const bool override) const
|
void Foam::scene::setCamera(vtkRenderer* renderer) const
|
||||||
{
|
{
|
||||||
if (mode_ == mtFlightPath || override)
|
if (mode_ == mtFlightPath)
|
||||||
{
|
{
|
||||||
|
const vector up = cameraUp_->value(position_);
|
||||||
|
const vector pos = cameraPosition_->value(position_);
|
||||||
|
const point focalPoint = cameraFocalPoint_->value(position_);
|
||||||
|
|
||||||
vtkCamera* camera = renderer->GetActiveCamera();
|
vtkCamera* camera = renderer->GetActiveCamera();
|
||||||
|
|
||||||
if (!parallelProjection_)
|
|
||||||
{
|
|
||||||
camera->SetViewAngle(cameraViewAngle_->value(position()));
|
|
||||||
}
|
|
||||||
|
|
||||||
const vector up = cameraUp_->value(position());
|
|
||||||
const vector pos = cameraPosition_->value(position());
|
|
||||||
const point focalPoint = cameraFocalPoint_->value(position());
|
|
||||||
|
|
||||||
camera->SetViewUp(up.x(), up.y(), up.z());
|
camera->SetViewUp(up.x(), up.y(), up.z());
|
||||||
camera->SetPosition(pos.x(), pos.y(), pos.z());
|
camera->SetPosition(pos.x(), pos.y(), pos.z());
|
||||||
camera->SetFocalPoint(focalPoint.x(), focalPoint.y(), focalPoint.z());
|
camera->SetFocalPoint(focalPoint.x(), focalPoint.y(), focalPoint.z());
|
||||||
camera->Modified();
|
camera->Modified();
|
||||||
|
}
|
||||||
|
|
||||||
vtkSmartPointer<vtkLightKit> lightKit =
|
if (!parallelProjection_)
|
||||||
vtkSmartPointer<vtkLightKit>::New();
|
{
|
||||||
lightKit->AddLightsToRenderer(renderer);
|
// Restore viewAngle (it might be reset by clipping)
|
||||||
|
vtkCamera* camera = renderer->GetActiveCamera();
|
||||||
|
camera->SetViewAngle(cameraViewAngle_->value(position_));
|
||||||
|
camera->Modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,11 +295,11 @@ Foam::scene::scene(const objectRegistry& obr, const word& name)
|
|||||||
cameraPosition_(NULL),
|
cameraPosition_(NULL),
|
||||||
cameraFocalPoint_(NULL),
|
cameraFocalPoint_(NULL),
|
||||||
cameraUp_(NULL),
|
cameraUp_(NULL),
|
||||||
cameraZoom_(NULL),
|
|
||||||
cameraViewAngle_(NULL),
|
cameraViewAngle_(NULL),
|
||||||
clipBox_(),
|
clipBox_(),
|
||||||
parallelProjection_(true),
|
parallelProjection_(true),
|
||||||
nFrameTotal_(1),
|
nFrameTotal_(1),
|
||||||
|
startPosition_(0),
|
||||||
position_(0),
|
position_(0),
|
||||||
dPosition_(0),
|
dPosition_(0),
|
||||||
currentFrameI_(0),
|
currentFrameI_(0),
|
||||||
@ -334,8 +344,7 @@ void Foam::scene::read(const dictionary& dict)
|
|||||||
bool Foam::scene::loop(vtkRenderer* renderer)
|
bool Foam::scene::loop(vtkRenderer* renderer)
|
||||||
{
|
{
|
||||||
static bool initialised = false;
|
static bool initialised = false;
|
||||||
|
setCamera(renderer);
|
||||||
setCamera(renderer, false);
|
|
||||||
|
|
||||||
if (!initialised)
|
if (!initialised)
|
||||||
{
|
{
|
||||||
@ -343,19 +352,16 @@ bool Foam::scene::loop(vtkRenderer* renderer)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that all objects can be seen without clipping
|
||||||
|
// Note: can only be done after all objects have been added!
|
||||||
|
renderer->ResetCameraClippingRange();
|
||||||
|
|
||||||
// Save image from last iteration
|
// Save image from last iteration
|
||||||
saveImage(renderer->GetRenderWindow());
|
saveImage(renderer->GetRenderWindow());
|
||||||
|
|
||||||
currentFrameI_++;
|
currentFrameI_++;
|
||||||
|
|
||||||
if (position_ > (1 + 0.5*dPosition_))
|
position_ = startPosition_ + currentFrameI_*dPosition_;
|
||||||
{
|
|
||||||
WarningInFunction
|
|
||||||
<< "Current position exceeded 1 - please check your setup"
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
position_ += dPosition_;
|
|
||||||
|
|
||||||
if (currentFrameI_ < nFrameTotal_)
|
if (currentFrameI_ < nFrameTotal_)
|
||||||
{
|
{
|
||||||
@ -363,6 +369,7 @@ bool Foam::scene::loop(vtkRenderer* renderer)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
initialised = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -375,7 +382,12 @@ void Foam::scene::saveImage(vtkRenderWindow* renderWindow) const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName prefix("postProcessing"/name_/obr_.time().timeName());
|
const Time& runTime = obr_.time();
|
||||||
|
|
||||||
|
fileName prefix(Pstream::parRun() ?
|
||||||
|
runTime.path()/".."/"postProcessing"/name_/obr_.time().timeName() :
|
||||||
|
runTime.path()/"postProcessing"/name_/obr_.time().timeName());
|
||||||
|
|
||||||
mkDir(prefix);
|
mkDir(prefix);
|
||||||
|
|
||||||
renderWindow->Render();
|
renderWindow->Render();
|
||||||
|
|||||||
@ -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 |
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -22,7 +22,7 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::camera
|
Foam::scene
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
|
||||||
@ -116,9 +116,6 @@ protected:
|
|||||||
//- Up direction
|
//- Up direction
|
||||||
autoPtr<DataEntry<vector> > cameraUp_;
|
autoPtr<DataEntry<vector> > cameraUp_;
|
||||||
|
|
||||||
//- Zoom level
|
|
||||||
autoPtr<DataEntry<scalar> > cameraZoom_;
|
|
||||||
|
|
||||||
//- View angle
|
//- View angle
|
||||||
autoPtr<DataEntry<scalar> > cameraViewAngle_;
|
autoPtr<DataEntry<scalar> > cameraViewAngle_;
|
||||||
|
|
||||||
@ -134,6 +131,9 @@ protected:
|
|||||||
//- Number of frames
|
//- Number of frames
|
||||||
label nFrameTotal_;
|
label nFrameTotal_;
|
||||||
|
|
||||||
|
//- Start position [0-1]
|
||||||
|
scalar startPosition_;
|
||||||
|
|
||||||
//- Position [0-1]
|
//- Position [0-1]
|
||||||
scalar position_;
|
scalar position_;
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ protected:
|
|||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
void setCamera(vtkRenderer* renderer, const bool override) const;
|
void setCamera(vtkRenderer* renderer) const;
|
||||||
|
|
||||||
string frameIndexStr() const;
|
string frameIndexStr() const;
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,8 @@ Foam::text::text
|
|||||||
position_(dict.lookup("position")),
|
position_(dict.lookup("position")),
|
||||||
size_(readScalar(dict.lookup("size"))),
|
size_(readScalar(dict.lookup("size"))),
|
||||||
colour_(NULL),
|
colour_(NULL),
|
||||||
bold_(readBool(dict.lookup("bold")))
|
bold_(readBool(dict.lookup("bold"))),
|
||||||
|
timeStamp_(dict.lookupOrDefault<bool>("timeStamp", false))
|
||||||
{
|
{
|
||||||
if (dict.found("colour"))
|
if (dict.found("colour"))
|
||||||
{
|
{
|
||||||
@ -81,7 +82,13 @@ void Foam::text::addGeometryToScene
|
|||||||
|
|
||||||
vtkSmartPointer<vtkTextActor> actor = vtkSmartPointer<vtkTextActor>::New();
|
vtkSmartPointer<vtkTextActor> actor = vtkSmartPointer<vtkTextActor>::New();
|
||||||
|
|
||||||
actor->SetInput(string_.c_str());
|
// Concatenate string with timeStamp if true
|
||||||
|
string textAndTime = string_;
|
||||||
|
if (timeStamp_)
|
||||||
|
{
|
||||||
|
textAndTime = textAndTime + " " + geometryBase::parent_.obr().time().timeName();
|
||||||
|
}
|
||||||
|
actor->SetInput(textAndTime.c_str());
|
||||||
actor->GetTextProperty()->SetFontFamilyToArial();
|
actor->GetTextProperty()->SetFontFamilyToArial();
|
||||||
actor->GetTextProperty()->SetFontSize(size_);
|
actor->GetTextProperty()->SetFontSize(size_);
|
||||||
actor->GetTextProperty()->SetJustificationToLeft();
|
actor->GetTextProperty()->SetJustificationToLeft();
|
||||||
|
|||||||
@ -25,6 +25,23 @@ Class
|
|||||||
Foam::text
|
Foam::text
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
Example of text object specification:
|
||||||
|
\verbatim
|
||||||
|
text1
|
||||||
|
{
|
||||||
|
string "text to display";
|
||||||
|
position (0.1 0.05);
|
||||||
|
size 18;
|
||||||
|
bold yes;
|
||||||
|
visible yes;
|
||||||
|
|
||||||
|
// Optionally override default colour
|
||||||
|
// colour (0 1 1);
|
||||||
|
|
||||||
|
// Optional entry
|
||||||
|
timeStamp yes; //Append solution time to string
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
text.C
|
text.C
|
||||||
@ -82,6 +99,9 @@ protected:
|
|||||||
//- Bold flag
|
//- Bold flag
|
||||||
bool bold_;
|
bool bold_;
|
||||||
|
|
||||||
|
//- Time stamp flag
|
||||||
|
bool timeStamp_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user