ensightPart.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) 2011-2016 OpenFOAM Foundation
6  \\/ M anipulation |
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 #include "ensightPart.H"
27 #include "dictionary.H"
28 #include "ListOps.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace Foam
33 {
34  defineTypeNameAndDebug(ensightPart, 0);
35  defineTemplateTypeNameAndDebug(IOPtrList<ensightPart>, 0);
36  defineRunTimeSelectionTable(ensightPart, istream);
37 }
38 
39 const Foam::List<Foam::word> Foam::ensightPart::elemTypes_(0);
40 
41 
42 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
43 
45 {
46  forAll(elemLists_, elemI)
47  {
48  const labelUList& idList = elemLists_[elemI];
49 
50  forAll(idList, i)
51  {
52  const label id = idList[i];
53 
54  if (id >= field.size() || std::isnan(field[id]))
55  {
56  return false;
57  }
58  }
59  }
60  return true;
61 }
62 
63 
64 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
65 
67 ()
68 :
69  number_(0),
70  name_(""),
71  elemLists_(0),
72  offset_(0),
73  size_(0),
74  isCellData_(true),
75  matId_(0),
76  points_(pointField::null())
77 {}
78 
79 
81 (
82  label partNumber,
83  const string& partDescription
84 )
85 :
86  number_(partNumber),
87  name_(partDescription),
88  elemLists_(0),
89  offset_(0),
90  size_(0),
91  isCellData_(true),
92  matId_(0),
93  points_(pointField::null())
94 {}
95 
96 
98 (
99  label partNumber,
100  const string& partDescription,
101  const pointField& points
102 )
103 :
104  number_(partNumber),
105  name_(partDescription),
106  elemLists_(0),
107  offset_(0),
108  size_(0),
109  isCellData_(true),
110  matId_(0),
111  points_(points)
112 {}
113 
114 
116 :
117  number_(part.number_),
118  name_(part.name_),
119  elemLists_(part.elemLists_),
120  offset_(part.offset_),
121  size_(part.size_),
122  isCellData_(part.isCellData_),
123  matId_(part.matId_),
124  points_(part.points_)
125 {}
126 
127 
128 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
129 
131 {
132  const word partType(is);
133 
134  istreamConstructorTable::iterator cstrIter =
135  istreamConstructorTablePtr_->find(partType);
136 
137  if (cstrIter == istreamConstructorTablePtr_->end())
138  {
140  (
141  is
142  ) << "unknown ensightPart type "
143  << partType << nl << nl
144  << "Valid ensightPart types are :" << endl
145  << istreamConstructorTablePtr_->sortedToc()
146  << exit(FatalIOError);
147  }
148 
149  return autoPtr<ensightPart>(cstrIter()(is));
150 }
151 
152 
153 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
154 
156 {}
157 
158 
159 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
160 
162 {
163  // transform to global values first
164  if (offset_)
165  {
166  forAll(elemLists_, elemI)
167  {
168  labelList& idList = elemLists_[elemI];
169  forAll(idList, i)
170  {
171  idList[i] += offset_;
172  }
173  }
174 
175  offset_ = 0;
176  }
177 
178  if (origId.size())
179  {
180  forAll(elemLists_, elemI)
181  {
182  inplaceRenumber(origId, elemLists_[elemI]);
183  }
184  }
185 }
186 
187 
188 // ************************************************************************* //
virtual ~ensightPart()
Destructor.
Definition: ensightPart.C:155
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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
ensightPart()
Construct null.
Definition: ensightPart.C:67
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
labelListList elemLists_
Simple labelList with a name.
Definition: ensightPart.H:84
Macros for easy insertion into run-time selection tables.
Various functions to operate on Lists.
A class for handling words, derived from string.
Definition: word.H:59
static autoPtr< ensightPart > New(Istream &)
Reconstruct part characteristics on freestore from Istream.
Definition: ensightPart.C:130
defineTemplateTypeNameAndDebug(IOPtrList< ensightPart >, 0)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:61
void renumber(const labelUList &)
Renumber elements.
Definition: ensightPart.C:161
static const char nl
Definition: Ostream.H:262
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Base class for ensightPartCells and ensightPartFaces.
Definition: ensightPart.H:65
defineTypeNameAndDebug(combustionModel, 0)
bool isFieldDefined(const List< scalar > &) const
Check for fully defined fields.
Definition: ensightPart.C:44
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:331
label offset_
Start offset for elemLists_.
Definition: ensightPart.H:87
static const Field< vector > & null()
Return a null field.
Definition: Field.H:100
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
label size() const
Return the number of elements in the UList.
Definition: UListI.H:299
Namespace for OpenFOAM.
IOerror FatalIOError