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));
158 vtkMultiBlockDataSet* output,
159 const arrayRange& range
162 const int blockNo = range.block();
164 vtkDataObject* blockDO = output->GetBlock(blockNo);
165 vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
168 return block->GetNumberOfBlocks();
175 Foam::word Foam::vtkPVFoam::getPartName(
const int partId)
177 return getFirstWord(reader_->GetPartArrayName(partId));
183 vtkDataArraySelection* select
186 int nElem = select->GetNumberOfArrays();
189 for (
int elemI=0; elemI < nElem; ++elemI)
191 if (select->GetArraySetting(elemI))
193 selections.insert(getFirstWord(select->GetArrayName(elemI)));
203 vtkDataArraySelection* select,
204 const arrayRange& range
207 int nElem = select->GetNumberOfArrays();
210 for (
int elemI = range.start(); elemI < range.end(); ++elemI)
212 if (select->GetArraySetting(elemI))
214 selections.insert(getFirstWord(select->GetArrayName(elemI)));
224 vtkDataArraySelection* select
227 stringList selections(select->GetNumberOfArrays());
232 if (select->GetArraySetting(elemI))
234 selections[nElem++] = select->GetArrayName(elemI);
237 selections.setSize(nElem);
242 label nElem = select->GetNumberOfArrays();
244 for (
int elemI = 0; elemI < nElem; ++elemI)
246 Info<<
" \"" << select->GetArrayName(elemI) <<
"\"";
248 Info<<
" )\nselected(";
252 Info<<
" " << selections[elemI];
263 vtkDataArraySelection* select,
264 const arrayRange& range
270 for (
int elemI = range.start(); elemI < range.end(); ++elemI)
272 if (select->GetArraySetting(elemI))
274 selections[nElem++] = select->GetArrayName(elemI);
277 selections.setSize(nElem);
283 for (
int elemI = range.start(); elemI < range.end(); ++elemI)
285 Info<<
" \"" << select->GetArrayName(elemI) <<
"\"";
287 Info<<
" )\nselected(";
291 Info<<
" " << selections[elemI];
300 void Foam::vtkPVFoam::setSelectedArrayEntries
302 vtkDataArraySelection* select,
306 const int nElem = select->GetNumberOfArrays();
307 select->DisableAllArrays();
310 for (
int elemI=0; elemI < nElem; ++elemI)
312 string arrayName(select->GetArrayName(elemI));
316 if (selections[elemI] == arrayName)
318 select->EnableArray(arrayName.c_str());
334 Info<<
"mem peak/size/rss: " << mem <<
"\n";
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.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
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.
bool valid() const
True if the memory information appears valid.
Memory usage information for the process running this object.
List< string > stringList
A List of strings.