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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2015-2019 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 // OpenFOAM includes
29 #include "pathline.H"
30 #include "runTimePostProcessing.H"
31 
32 // VTK includes
33 #include "vtkActor.h"
34 #include "vtkPolyDataMapper.h"
35 #include "vtkProperty.h"
36 #include "vtkRenderer.h"
37 #include "vtkSmartPointer.h"
38 #include "vtkTubeFilter.h"
39 #include "vtkLookupTable.h"
40 
41 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 namespace functionObjects
46 {
47 namespace runTimePostPro
48 {
49  defineTypeName(pathline);
50  defineRunTimeSelectionTable(pathline, dictionary);
51 }
52 }
53 }
54 
55 const Foam::Enum
56 <
58 >
60 ({
61  { representationType::rtNone, "none" },
62  { representationType::rtLine, "line" },
63  { representationType::rtTube, "tube" },
64  { representationType::rtVector, "vector" },
65 });
66 
67 
68 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
69 
71 (
72  const label framei,
73  vtkActor* actor,
74  vtkPolyData* data
75 ) const
76 {
77  geometryBase::initialiseActor(actor);
78 
79  vector colour = lineColour_->value(framei);
80  actor->GetProperty()->SetColor(colour[0], colour[1], colour[2]);
81 
82  vtkPolyDataMapper* mapper =
83  vtkPolyDataMapper::SafeDownCast(actor->GetMapper());
84 
85  switch (representation_)
86  {
87  case rtNone:
88  {
89  actor->VisibilityOff();
90  break;
91  }
92  case rtLine:
93  {
94  mapper->SetInputData(data);
95  mapper->Update();
96  break;
97  }
98  case rtTube:
99  {
101  tubes->SetInputData(data);
102  tubes->SetRadius(tubeRadius_);
103  tubes->SetNumberOfSides(20);
104  tubes->CappingOn();
105  tubes->Update();
106 
107  mapper->SetInputConnection(tubes->GetOutputPort());
108  mapper->Update();
109  break;
110  }
111  case rtVector:
112  {
113  break;
114  }
115  }
116 }
117 
118 
119 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
120 
122 (
123  const runTimePostProcessing& parent,
124  const dictionary& dict,
125  const HashPtrTable<Function1<vector>>& colours
126 )
127 :
128  geometryBase(parent, dict, colours),
129  representation_
130  (
131  representationTypeNames.get("representation", dict)
132  ),
133  tubeRadius_(0.001),
134  lineColour_(nullptr)
135 {
136  if (dict.found("lineColour"))
137  {
138  lineColour_.reset(Function1<vector>::New("lineColour", dict));
139  }
140  else
141  {
142  lineColour_.reset(colours["line"]->clone().ptr());
143  }
144 
145  switch (representation_)
146  {
147  case rtNone:
148  {
149  break;
150  }
151  case rtLine:
152  {
153  break;
154  }
155  case rtTube:
156  {
157  dict.readEntry("tubeRadius", tubeRadius_);
158  break;
159  }
160  case rtVector:
161  {
162  break;
163  }
164  }
165 }
166 
167 
168 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
169 
172 (
173  const runTimePostProcessing& parent,
174  const dictionary& dict,
175  const HashPtrTable<Function1<vector>>& colours,
176  const word& pathlineType
177 )
178 {
179  DebugInfo << "Selecting pathline " << pathlineType << endl;
180 
181  auto cstrIter = dictionaryConstructorTablePtr_->cfind(pathlineType);
182 
183  if (!cstrIter.found())
184  {
186  (
187  dict,
188  "pathline",
189  pathlineType,
190  *dictionaryConstructorTablePtr_
191  ) << exit(FatalIOError);
192  }
193 
194  return autoPtr<pathline>(cstrIter()(parent, dict, colours));
195 }
196 
197 
198 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
199 
201 {}
202 
203 
204 // ************************************************************************* //
Foam::functionObjects::runTimePostPro::pathline::representationTypeNames
static const Enum< representationType > representationTypeNames
Names for line representations.
Definition: pathline.H:107
Foam::Enum
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: IOstreamOption.H:51
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::functionObjects::runTimePostPro::pathline::addLines
void addLines(const label framei, vtkActor *actor, vtkPolyData *data) const
Add the pathlines to the renderer.
Definition: pathline.C:71
Foam::functionObjects::runTimePostPro::pathline::New
static autoPtr< pathline > New(const runTimePostProcessing &parent, const dictionary &dict, const HashPtrTable< Function1< vector >> &colours, const word &pathlineName)
Return selected pathline.
Definition: pathline.C:172
pathline.H
Foam::functionObjects::runTimePostPro::pathline::representationType
representationType
Line representations.
Definition: pathline.H:98
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:56
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:380
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:62
Foam::functionObjects::runTimePostProcessing
Generate images during run-time.
Definition: runTimePostProcessing.H:170
Foam::functionObjects::runTimePostPro::pathline::pathline
pathline(const pathline &)=delete
No copy construct.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::functionObjects::runTimePostPro::geometryBase
Base class for surface, text handling etc.
Definition: geometryBase.H:101
runTimePostProcessing.H
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:350
Foam::HashPtrTable
A HashTable of pointers to objects of type <T>.
Definition: HashPtrTable.H:54
Foam::Vector< scalar >
Foam::functionObjects::runTimePostPro::defineTypeName
defineTypeName(contourFilter)
Foam::functionObjects::runTimePostPro::pathline::~pathline
virtual ~pathline()
Destructor.
Definition: pathline.C:200
Foam::functionObjects::runTimePostPro::defineRunTimeSelectionTable
defineRunTimeSelectionTable(pathline, dictionary)
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:54