ensightPart.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "ensightPart.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "dictionary.H"
00030 #include "ListOps.H"
00031
00032
00033 namespace Foam
00034 {
00035 defineTypeNameAndDebug(ensightPart, 0);
00036 defineTemplateTypeNameAndDebug(IOPtrList<ensightPart>, 0);
00037 defineRunTimeSelectionTable(ensightPart, istream);
00038 }
00039
00040 Foam::List<Foam::word> Foam::ensightPart::elemTypes_(0);
00041
00042
00043
00044 bool Foam::ensightPart::isFieldDefined(const List<scalar>& field) const
00045 {
00046 forAll(elemLists_, elemI)
00047 {
00048 const labelList& idList = elemLists_[elemI];
00049
00050 forAll(idList, i)
00051 {
00052 label id = idList[i];
00053
00054 if (id >= field.size() || isnan(field[id]))
00055 {
00056 return false;
00057 }
00058 }
00059 }
00060 return true;
00061 }
00062
00063
00064
00065
00066 Foam::ensightPart::ensightPart
00067 ()
00068 :
00069 number_(0),
00070 name_(""),
00071 elemLists_(0),
00072 offset_(0),
00073 size_(0),
00074 isCellData_(true),
00075 matId_(0),
00076 meshPtr_(0)
00077 {}
00078
00079
00080 Foam::ensightPart::ensightPart
00081 (
00082 label partNumber,
00083 const string& partDescription
00084 )
00085 :
00086 number_(partNumber),
00087 name_(partDescription),
00088 elemLists_(0),
00089 offset_(0),
00090 size_(0),
00091 isCellData_(true),
00092 matId_(0),
00093 meshPtr_(0)
00094 {}
00095
00096
00097 Foam::ensightPart::ensightPart
00098 (
00099 label partNumber,
00100 const string& partDescription,
00101 const polyMesh& pMesh
00102 )
00103 :
00104 number_(partNumber),
00105 name_(partDescription),
00106 elemLists_(0),
00107 offset_(0),
00108 size_(0),
00109 isCellData_(true),
00110 matId_(0),
00111 meshPtr_(&pMesh)
00112 {}
00113
00114
00115 Foam::ensightPart::ensightPart(const ensightPart& part)
00116 :
00117 number_(part.number_),
00118 name_(part.name_),
00119 elemLists_(part.elemLists_),
00120 offset_(part.offset_),
00121 size_(part.size_),
00122 isCellData_(part.isCellData_),
00123 matId_(part.matId_),
00124 meshPtr_(part.meshPtr_)
00125 {}
00126
00127
00128
00129
00130 Foam::autoPtr<Foam::ensightPart> Foam::ensightPart::New(Istream& is)
00131 {
00132 word partType(is);
00133
00134 istreamConstructorTable::iterator cstrIter =
00135 istreamConstructorTablePtr_->find(partType);
00136
00137 if (cstrIter == istreamConstructorTablePtr_->end())
00138 {
00139 FatalIOErrorIn
00140 (
00141 "ensightPart::New(Istream&)",
00142 is
00143 ) << "unknown ensightPart type " << partType << endl << endl
00144 << "Valid ensightPart types are :" << endl
00145 << istreamConstructorTablePtr_->toc()
00146 << exit(FatalIOError);
00147 }
00148
00149 return autoPtr<ensightPart>(cstrIter()(is));
00150 }
00151
00152
00153
00154
00155 Foam::ensightPart::~ensightPart()
00156 {}
00157
00158
00159
00160
00161 void Foam::ensightPart::reconstruct(Istream& is)
00162 {
00163 dictionary dict(is);
00164 dict.lookup("id") >> number_;
00165 dict.lookup("name") >> name_;
00166 dict.readIfPresent("offset", offset_);
00167
00168
00169 elemLists_.setSize(elementTypes().size());
00170
00171 forAll(elementTypes(), elemI)
00172 {
00173 word key(elementTypes()[elemI]);
00174
00175 elemLists_[elemI].clear();
00176 dict.readIfPresent(key, elemLists_[elemI]);
00177
00178 size_ += elemLists_[elemI].size();
00179 }
00180
00181 is.check("ensightPart::reconstruct(Istream&)");
00182 }
00183
00184
00185 void Foam::ensightPart::renumber(labelList const& origId)
00186 {
00187
00188 if (offset_)
00189 {
00190 forAll(elemLists_, elemI)
00191 {
00192 labelList& idList = elemLists_[elemI];
00193 forAll(idList, i)
00194 {
00195 idList[i] += offset_;
00196 }
00197 }
00198
00199 offset_ = 0;
00200 }
00201
00202 if (origId.size())
00203 {
00204 forAll(elemLists_, elemI)
00205 {
00206 inplaceRenumber(origId, elemLists_[elemI]);
00207 }
00208 }
00209 }
00210
00211
00212
Copyright © 2000-2009 OpenCFD Ltd