pathline.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 "pathline.H"
28 #include "runTimePostProcessing.H"
29 
30 // VTK includes
31 #include "vtkActor.h"
32 #include "vtkPolyDataMapper.h"
33 #include "vtkProperty.h"
34 #include "vtkRenderer.h"
35 #include "vtkSmartPointer.h"
36 #include "vtkTubeFilter.h"
37 #include "vtkLookupTable.h"
38 
39 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
40 
41 namespace Foam
42 {
43  template<>
45  {
46  "none",
47  "line",
48  "tube",
49  "vector"
50  };
51 
54 }
55 
58 
59 
60 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
61 
63 (
64  const label frameI,
65  vtkActor* actor,
66  vtkPolyData* data
67 ) const
68 {
69  geometryBase::initialiseActor(actor);
70 
71  vector colour = lineColour_->value(frameI);
72  actor->GetProperty()->SetColor(colour[0], colour[1], colour[2]);
73 
74  vtkPolyDataMapper* mapper =
75  vtkPolyDataMapper::SafeDownCast(actor->GetMapper());
76 
77  switch (representation_)
78  {
79  case rtNone:
80  {
81  actor->VisibilityOff();
82  break;
83  }
84  case rtLine:
85  {
86  mapper->SetInputData(data);
87  mapper->Update();
88  break;
89 
90  }
91  case rtTube:
92  {
93  vtkSmartPointer<vtkTubeFilter> tubes =
95  tubes->SetInputData(data);
96  tubes->SetRadius(tubeRadius_);
97  tubes->SetNumberOfSides(20);
98  tubes->CappingOn();
99  tubes->Update();
100 
101  mapper->SetInputConnection(tubes->GetOutputPort());
102  mapper->Update();
103 
104  break;
105 
106  }
107  case rtVector:
108  {
109  break;
110  }
111  }
112 }
113 
114 
115 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
116 
118 (
119  const runTimePostProcessing& parent,
120  const dictionary& dict,
121  const HashPtrTable<DataEntry<vector>, word>& colours
122 )
123 :
124  geometryBase(parent, dict, colours),
125  representation_
126  (
127  representationTypeNames.read(dict.lookup("representation"))
128  ),
129  tubeRadius_(0.0),
130  lineColour_(NULL)
131 {
132  if (dict.found("lineColour"))
133  {
134  lineColour_.reset(DataEntry<vector>::New("lineColour", dict).ptr());
135  }
136  else
137  {
138  lineColour_.reset(colours["line"]->clone().ptr());
139  }
140 
141  switch (representation_)
142  {
143  case rtNone:
144  {
145  break;
146  }
147  case rtLine:
148  {
149  break;
150  }
151  case rtTube:
152  {
153  dict.lookup("tubeRadius") >> tubeRadius_;
154  break;
155  }
156  case rtVector:
157  {
158  break;
159  }
160  }
161 
162 }
163 
164 
165 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
166 
168 (
169  const runTimePostProcessing& parent,
170  const dictionary& dict,
171  const HashPtrTable<DataEntry<vector>, word>& colours,
172  const word& pathlineType
173 )
174 {
175  if (debug)
176  {
177  Info<< "Selecting pathline " << pathlineType << endl;
178  }
179 
180  dictionaryConstructorTable::iterator cstrIter =
181  dictionaryConstructorTablePtr_->find(pathlineType);
182 
183  if (cstrIter == dictionaryConstructorTablePtr_->end())
184  {
186  << "Unknown pathline type "
187  << pathlineType << nl << nl
188  << "Valid pathline types are:" << endl
189  << dictionaryConstructorTablePtr_->sortedToc()
190  << exit(FatalError);
191  }
192 
193  return autoPtr<pathline>(cstrIter()(parent, dict, colours));
194 }
195 
196 
197 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
198 
200 {}
201 
202 
203 // ************************************************************************* //
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::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
pathline.H
Foam::pathline::addLines
void addLines(const label frameI, vtkActor *actor, vtkPolyData *data) const
Add the pathlines to the renderer.
Definition: pathline.C:63
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::geometryBase
Definition: geometryBase.H:56
Foam::pathline::New
static autoPtr< pathline > New(const runTimePostProcessing &parent, const dictionary &dict, const HashPtrTable< DataEntry< vector >, word > &colours, const word &pathlineName)
Return a reference to the selected RAS model.
Definition: pathline.C:168
Foam::pathline::representationTypeNames
static const NamedEnum< representationType, 4 > representationTypeNames
Definition: pathline.H:69
Foam::pathline::pathline
pathline(const pathline &)
Disallow default bitwise copy construct.
Foam::runTimePostProcessing
Function object to generate images during run-time.
Definition: runTimePostProcessing.H:83
Foam::pathline
Definition: pathline.H:53
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::pathline::~pathline
virtual ~pathline()
Destructor.
Definition: pathline.C:199
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
runTimePostProcessing.H
Foam::HashPtrTable
A HashTable specialization for hashing pointers.
Definition: HashPtrTable.H:50
Foam::Vector< scalar >
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)
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:52
Foam::NamedEnum
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:52