30 #include "vtkPVFoamReader.h" 39 #include "vtkDataArraySelection.h" 40 #include "vtkDataSet.h" 41 #include "vtkMultiBlockDataSet.h" 42 #include "vtkInformation.h" 50 inline word getFirstWord(
const char* str)
59 return word(str, n,
true);
75 void Foam::vtkPVFoam::AddToBlock
77 vtkMultiBlockDataSet* output,
79 const arrayRange& range,
80 const label datasetNo,
81 const std::string& datasetName
84 const int blockNo = range.block();
86 vtkDataObject* blockDO = output->GetBlock(blockNo);
87 vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
94 <<
"Block already has a vtkDataSet assigned to it" 100 output->SetBlock(blockNo, block);
106 Info<<
"block[" << blockNo <<
"] has " 107 << block->GetNumberOfBlocks()
108 <<
" datasets prior to adding set " << datasetNo
109 <<
" with name: " << datasetName <<
endl;
112 block->SetBlock(datasetNo, dataset);
117 output->GetMetaData(blockNo)->Set
119 vtkCompositeDataSet::NAME(),
124 if (datasetName.size())
126 block->GetMetaData(datasetNo)->Set
128 vtkCompositeDataSet::NAME(),
135 vtkDataSet* Foam::vtkPVFoam::GetDataSetFromBlock
137 vtkMultiBlockDataSet* output,
138 const arrayRange& range,
139 const label datasetNo
142 const int blockNo = range.block();
144 vtkDataObject* blockDO = output->GetBlock(blockNo);
145 vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
149 return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo));
159 vtkMultiBlockDataSet* output,
160 const arrayRange& range
163 const int blockNo = range.block();
165 vtkDataObject* blockDO = output->GetBlock(blockNo);
166 vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
169 return block->GetNumberOfBlocks();
176 Foam::word Foam::vtkPVFoam::getPartName(
const int partId)
178 return getFirstWord(reader_->GetPartArrayName(partId));
184 vtkDataArraySelection* select
187 int nElem = select->GetNumberOfArrays();
190 for (
int elemI=0; elemI < nElem; ++elemI)
192 if (select->GetArraySetting(elemI))
194 selections.insert(getFirstWord(select->GetArrayName(elemI)));
204 vtkDataArraySelection* select,
205 const arrayRange& range
208 int nElem = select->GetNumberOfArrays();
211 for (
int elemI = range.start(); elemI < range.end(); ++elemI)
213 if (select->GetArraySetting(elemI))
215 selections.insert(getFirstWord(select->GetArrayName(elemI)));
225 vtkDataArraySelection* select
228 stringList selections(select->GetNumberOfArrays());
233 if (select->GetArraySetting(elemI))
235 selections[nElem++] = select->GetArrayName(elemI);
238 selections.setSize(nElem);
243 label nElem = select->GetNumberOfArrays();
245 for (
int elemI = 0; elemI < nElem; ++elemI)
247 Info<<
" \"" << select->GetArrayName(elemI) <<
"\"";
249 Info<<
" )\nselected(";
253 Info<<
" " << selections[elemI];
264 vtkDataArraySelection* select,
265 const arrayRange& range
271 for (
int elemI = range.start(); elemI < range.end(); ++elemI)
273 if (select->GetArraySetting(elemI))
275 selections[nElem++] = select->GetArrayName(elemI);
278 selections.setSize(nElem);
284 for (
int elemI = range.start(); elemI < range.end(); ++elemI)
286 Info<<
" \"" << select->GetArrayName(elemI) <<
"\"";
288 Info<<
" )\nselected(";
292 Info<<
" " << selections[elemI];
301 void Foam::vtkPVFoam::setSelectedArrayEntries
303 vtkDataArraySelection* select,
307 const int nElem = select->GetNumberOfArrays();
308 select->DisableAllArrays();
311 for (
int elemI=0; elemI < nElem; ++elemI)
313 string arrayName(select->GetArrayName(elemI));
317 if (selections[elemI] == arrayName)
319 select->EnableArray(arrayName.c_str());
335 Info<<
"mem peak/size/rss: " << mem <<
"\n";
bool valid() const
True if the memory information appears valid.
static bool valid(char)
Is this character valid for a word.
A HashTable with keys but without contents.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static void printMemory()
Simple memory used debugging information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
A class for handling words, derived from string.
static const word null
An empty word.
HashSet wordHashSet
A HashSet with word keys.
Memory usage information for the process running this object.
List< string > stringList
A List of strings.