functionObjectLine.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 // OpenFOAM includes
27 #include "functionObjectLine.H"
28 #include "runTimePostProcessing.H"
30 
31 // VTK includes
32 #include "vtkActor.h"
33 #include "vtkRenderer.h"
34 #include "vtkSmartPointer.h"
35 #include "vtkPolyDataMapper.h"
36 #include "vtkPolyDataReader.h"
37 #include "vtkProperty.h"
38 
39 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
40 
41 namespace Foam
42 {
43  defineTypeNameAndDebug(functionObjectLine, 0);
44  addToRunTimeSelectionTable(pathline, functionObjectLine, dictionary);
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
51 (
52  const runTimePostProcessing& parent,
53  const dictionary& dict,
54  const HashPtrTable<DataEntry<vector>, word>& colours
55 )
56 :
57  pathline(parent, dict, colours),
58  fieldVisualisationBase(parent, dict, colours),
59  functionObject_(dict.lookup("functionObject")),
60  actor_()
61 {
63 }
64 
65 
66 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
67 
69 {}
70 
71 
72 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
73 
75 (
76  const scalar position,
77  vtkRenderer* renderer
78 )
79 {
80  if (!visible_)
81  {
82  return;
83  }
84 
85  const dictionary dict =
87  (
88  functionObject_,
89  fieldName_,
91  );
92 
93  fileName fName;
94  if (!dict.readIfPresent("file", fName))
95  {
97  << "Unable to find function object " << functionObject_
98  << " output for field " << fieldName_
99  << ". Line will not be processed"
100  << endl;
101  return;
102  }
103 
104  if (fName.ext() == "vtk")
105  {
106  vtkSmartPointer<vtkPolyDataReader> lines =
108  lines->SetFileName(fName.c_str());
109  lines->Update();
110 
111  vtkSmartPointer<vtkPolyDataMapper> mapper =
113  setField(position, fieldName_, mapper, renderer);
114 
115  actor_->SetMapper(mapper);
116 
117  addLines(position, actor_, lines->GetOutput());
118 
119  renderer->AddActor(actor_);
120  }
121 }
122 
123 
124 void Foam::functionObjectLine::updateActors(const scalar position)
125 {
126  actor_->GetProperty()->SetLineWidth(2);
127  actor_->GetProperty()->SetOpacity(opacity(position));
128 }
129 
130 
131 // ************************************************************************* //
Foam::geometryBase::parent_
const runTimePostProcessing & parent_
Reference to the parent function object.
Definition: geometryBase.H:89
Foam::functionObjectLine::functionObjectLine
functionObjectLine(const functionObjectLine &)
Disallow default bitwise copy construct.
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::dictionary::readIfPresent
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Definition: dictionaryTemplates.C:94
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::runTimePostProcessing
Function object to generate images during run-time.
Definition: runTimePostProcessing.H:83
functionObjectLine.H
Foam::pathline
Definition: pathline.H:53
Foam::functionObjectLine::updateActors
virtual void updateActors(const scalar position)
Update actors.
Definition: functionObjectLine.C:124
setField
surfacesMesh setField(triSurfaceToAgglom)
Foam::fieldVisualisationBase
Definition: fieldVisualisationBase.H:65
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fileName::ext
word ext() const
Return file name extension (part after last .)
Definition: fileName.C:329
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
runTimePostProcessing.H
Foam::HashPtrTable
A HashTable specialization for hashing pointers.
Definition: HashPtrTable.H:50
Foam::functionObjectState::getObjectProperty
Type getObjectProperty(const word &objectName, const word &entryName, const Type &defaultValue=pTraits< Type >::zero) const
Retrieve generic property from named object.
Definition: functionObjectStateTemplates.C:83
Foam::functionObjectLine::~functionObjectLine
virtual ~functionObjectLine()
Destructor.
Definition: functionObjectLine.C:68
Foam::functionObjectLine::addGeometryToScene
virtual void addGeometryToScene(const scalar position, vtkRenderer *renderer)
Add tube(s) to scene.
Definition: functionObjectLine.C:75
Foam::DataEntry
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: DataEntry.H:52
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
Foam::dictionary::null
static const dictionary null
Null dictionary.
Definition: dictionary.H:193