1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*----------------------------------------------------------------------------*/
26 #include "ensightPart.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "dictionary.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(ensightPart, 0);
35 defineTemplateTypeNameAndDebug(IOPtrList<ensightPart>, 0);
36 defineRunTimeSelectionTable(ensightPart, istream);
39 Foam::List<Foam::word> Foam::ensightPart::elemTypes_(0);
41 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43 bool Foam::ensightPart::isFieldDefined(const List<scalar>& field) const
45 forAll(elemLists_, elemI)
47 const labelList& idList = elemLists_[elemI];
54 if (id >= field.size() || std::isnan(field[id]))
56 if (id >= field.size())
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69 Foam::ensightPart::ensightPart
83 Foam::ensightPart::ensightPart
86 const string& partDescription
90 name_(partDescription),
100 Foam::ensightPart::ensightPart
103 const string& partDescription,
104 const polyMesh& pMesh
108 name_(partDescription),
118 Foam::ensightPart::ensightPart(const ensightPart& part)
120 number_(part.number_),
122 elemLists_(part.elemLists_),
123 offset_(part.offset_),
125 isCellData_(part.isCellData_),
127 meshPtr_(part.meshPtr_)
131 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
133 Foam::autoPtr<Foam::ensightPart> Foam::ensightPart::New(Istream& is)
137 istreamConstructorTable::iterator cstrIter =
138 istreamConstructorTablePtr_->find(partType);
140 if (cstrIter == istreamConstructorTablePtr_->end())
144 "ensightPart::New(Istream&)",
146 ) << "unknown ensightPart type " << partType << endl << endl
147 << "Valid ensightPart types are :" << endl
148 << istreamConstructorTablePtr_->sortedToc()
149 << exit(FatalIOError);
152 return autoPtr<ensightPart>(cstrIter()(is));
156 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
158 Foam::ensightPart::~ensightPart()
162 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
164 void Foam::ensightPart::reconstruct(Istream& is)
167 dict.lookup("id") >> number_;
168 dict.lookup("name") >> name_;
169 dict.readIfPresent("offset", offset_);
171 // populate elemLists_
172 elemLists_.setSize(elementTypes().size());
174 forAll(elementTypes(), elemI)
176 word key(elementTypes()[elemI]);
178 elemLists_[elemI].clear();
179 dict.readIfPresent(key, elemLists_[elemI]);
181 size_ += elemLists_[elemI].size();
184 is.check("ensightPart::reconstruct(Istream&)");
188 void Foam::ensightPart::renumber(labelList const& origId)
190 // transform to global values first
193 forAll(elemLists_, elemI)
195 labelList& idList = elemLists_[elemI];
198 idList[i] += offset_;
207 forAll(elemLists_, elemI)
209 inplaceRenumber(origId, elemLists_[elemI]);
215 // ************************************************************************* //