1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
24 \*----------------------------------------------------------------------------*/
26 #include "ensightPart.H"
27 #include "dictionary.H"
29 #include "addToRunTimeSelectionTable.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(ensightPart, 0);
35 defineTemplateTypeNameAndDebug(IOPtrList<ensightPart>, 0);
36 defineRunTimeSelectionTable(ensightPart, istream);
39 const Foam::List<Foam::word> Foam::ensightPart::elemTypes_(0);
42 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
44 bool Foam::ensightPart::isFieldDefined(const List<scalar>& field) const
46 forAll(elemLists_, elemI)
48 const labelUList& idList = elemLists_[elemI];
52 const label id = idList[i];
54 if (id >= field.size() || isnan(field[id]))
64 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
66 Foam::ensightPart::ensightPart
76 points_(pointField::null())
80 Foam::ensightPart::ensightPart
83 const string& partDescription
87 name_(partDescription),
93 points_(pointField::null())
97 Foam::ensightPart::ensightPart
100 const string& partDescription,
101 const pointField& points
105 name_(partDescription),
115 Foam::ensightPart::ensightPart(const ensightPart& part)
117 number_(part.number_),
119 elemLists_(part.elemLists_),
120 offset_(part.offset_),
122 isCellData_(part.isCellData_),
124 points_(part.points_)
128 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
130 Foam::autoPtr<Foam::ensightPart> Foam::ensightPart::New(Istream& is)
132 const word partType(is);
134 istreamConstructorTable::iterator cstrIter =
135 istreamConstructorTablePtr_->find(partType);
137 if (cstrIter == istreamConstructorTablePtr_->end())
141 "ensightPart::New(Istream&)",
143 ) << "unknown ensightPart type "
144 << partType << nl << nl
145 << "Valid ensightPart types are :" << endl
146 << istreamConstructorTablePtr_->sortedToc()
147 << exit(FatalIOError);
150 return autoPtr<ensightPart>(cstrIter()(is));
154 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
156 Foam::ensightPart::~ensightPart()
160 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
162 void Foam::ensightPart::renumber(const labelUList& origId)
164 // transform to global values first
167 forAll(elemLists_, elemI)
169 labelList& idList = elemLists_[elemI];
172 idList[i] += offset_;
181 forAll(elemLists_, elemI)
183 inplaceRenumber(origId, elemLists_[elemI]);
189 // ************************************************************************* //