VTK  9.3.20240425
vtkIOSSWriter.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3// SPDX-License-Identifier: BSD-3-Clause
4
84#ifndef vtkIOSSWriter_h
85#define vtkIOSSWriter_h
86
87#include "vtkDeprecation.h" // For VTK_DEPRECATED
88#include "vtkIOIOSSModule.h" // For export macros
89#include "vtkIOSSReader.h" // For vtkIOSSReader::EntityType
90#include "vtkNew.h" // For vtkNew
91#include "vtkWriter.h"
92
93#include <memory> // for std::unique_ptr
94#include <set> // for std::set
95#include <string> // for std::string
96
97VTK_ABI_NAMESPACE_BEGIN
100
101class VTKIOIOSS_EXPORT vtkIOSSWriter : public vtkWriter
102{
103public:
105 vtkTypeMacro(vtkIOSSWriter, vtkWriter);
106 void PrintSelf(ostream& os, vtkIndent indent) override;
107
109
113 vtkSetStringMacro(FileName);
114 vtkGetStringMacro(FileName);
116
118
125 vtkSetStringMacro(AssemblyName);
126 vtkGetStringMacro(AssemblyName);
128
130
132
139 vtkSetMacro(ChooseFieldsToWrite, bool);
140 vtkGetMacro(ChooseFieldsToWrite, bool);
141 vtkBooleanMacro(ChooseFieldsToWrite, bool);
143
145 // Generic Entity API //
148
158 bool AddSelector(EntityType entity, const char* selector);
161
166 void SetSelector(EntityType entity, const char* selector);
167
169
173 const char* GetSelector(EntityType entity, int index) const;
174 std::set<std::string> GetSelectors(EntityType entity) const;
176
183
185 // Node Block API //
187
191 {
192 return this->GetFieldSelection(EntityType::NODEBLOCK);
193 }
195
197 // Edge Block API //
200
203 bool AddEdgeBlockSelector(const char* selector)
204 {
205 return this->AddSelector(EntityType::EDGEBLOCK, selector);
206 }
207 void ClearEdgeBlockSelectors() { this->ClearSelectors(EntityType::EDGEBLOCK); }
208 void SetEdgeBlockSelector(const char* selector)
209 {
210 this->SetSelector(EntityType::EDGEBLOCK, selector);
211 }
213 {
214 return this->GetNumberOfSelectors(EntityType::EDGEBLOCK);
215 }
216 const char* GetEdgeBlockSelector(int index) const
217 {
218 return this->GetSelector(EntityType::EDGEBLOCK, index);
219 }
220 std::set<std::string> GetEdgeBlockSelectors() const
221 {
222 return this->GetSelectors(EntityType::EDGEBLOCK);
223 }
225
230 {
231 return this->GetFieldSelection(EntityType::EDGEBLOCK);
232 }
234
236 // Face Block API //
239
242 bool AddFaceBlockSelector(const char* selector)
243 {
244 return this->AddSelector(EntityType::FACEBLOCK, selector);
245 }
246 void ClearFaceBlockSelectors() { this->ClearSelectors(EntityType::FACEBLOCK); }
247 void SetFaceBlockSelector(const char* selector)
248 {
249 this->SetSelector(EntityType::FACEBLOCK, selector);
250 }
252 {
253 return this->GetNumberOfSelectors(EntityType::FACEBLOCK);
254 }
255 const char* GetFaceBlockSelector(int index) const
256 {
257 return this->GetSelector(EntityType::FACEBLOCK, index);
258 }
259 std::set<std::string> GetFaceBlockSelectors() const
260 {
261 return this->GetSelectors(EntityType::FACEBLOCK);
262 }
264
269 {
270 return this->GetFieldSelection(EntityType::FACEBLOCK);
271 }
273
275 // Element Block API //
278
281 bool AddElementBlockSelector(const char* selector)
282 {
283 return this->AddSelector(EntityType::ELEMENTBLOCK, selector);
284 }
285 void ClearElementBlockSelectors() { this->ClearSelectors(EntityType::ELEMENTBLOCK); }
286 void SetElementBlockSelector(const char* selector)
287 {
288 this->SetSelector(EntityType::ELEMENTBLOCK, selector);
289 }
291 {
292 return this->GetNumberOfSelectors(EntityType::ELEMENTBLOCK);
293 }
294 const char* GetElementBlockSelector(int index) const
295 {
296 return this->GetSelector(EntityType::ELEMENTBLOCK, index);
297 }
298 std::set<std::string> GetElementBlockSelectors() const
299 {
300 return this->GetSelectors(EntityType::ELEMENTBLOCK);
301 }
303
308 {
309 return this->GetFieldSelection(EntityType::ELEMENTBLOCK);
310 }
312
314 // Node Set API //
317
320 bool AddNodeSetSelector(const char* selector)
321 {
322 return this->AddSelector(EntityType::NODESET, selector);
323 }
324 void ClearNodeSetSelectors() { this->ClearSelectors(EntityType::NODESET); }
325 void SetNodeSetSelector(const char* selector)
326 {
327 this->SetSelector(EntityType::NODESET, selector);
328 }
330 {
331 return this->GetNumberOfSelectors(EntityType::NODESET);
332 }
333 const char* GetNodeSetSelector(int index) const
334 {
335 return this->GetSelector(EntityType::NODESET, index);
336 }
337 std::set<std::string> GetNodeSetSelectors() const
338 {
339 return this->GetSelectors(EntityType::NODESET);
340 }
342
347 {
348 return this->GetFieldSelection(EntityType::NODESET);
349 }
351
353 // Edge Set API //
356
359 bool AddEdgeSetSelector(const char* selector)
360 {
361 return this->AddSelector(EntityType::SIDESET, selector);
362 }
363 void ClearEdgeSetSelectors() { this->ClearSelectors(EntityType::SIDESET); }
364 void SetEdgeSetSelector(const char* selector)
365 {
366 this->SetSelector(EntityType::SIDESET, selector);
367 }
369 {
370 return this->GetNumberOfSelectors(EntityType::SIDESET);
371 }
372 const char* GetEdgeSetSelector(int index) const
373 {
374 return this->GetSelector(EntityType::SIDESET, index);
375 }
376 std::set<std::string> GetEdgeSetSelectors() const
377 {
378 return this->GetSelectors(EntityType::SIDESET);
379 }
381
386 {
387 return this->GetFieldSelection(EntityType::SIDESET);
388 }
390
392 // Face Set API //
395
398 bool AddFaceSetSelector(const char* selector)
399 {
400 return this->AddSelector(EntityType::SIDESET, selector);
401 }
402 void ClearFaceSetSelectors() { this->ClearSelectors(EntityType::SIDESET); }
403 void SetFaceSetSelector(const char* selector)
404 {
405 this->SetSelector(EntityType::SIDESET, selector);
406 }
408 {
409 return this->GetNumberOfSelectors(EntityType::SIDESET);
410 }
411 const char* GetFaceSetSelector(int index) const
412 {
413 return this->GetSelector(EntityType::SIDESET, index);
414 }
415 std::set<std::string> GetFaceSetSelectors() const
416 {
417 return this->GetSelectors(EntityType::SIDESET);
418 }
420
425 {
426 return this->GetFieldSelection(EntityType::SIDESET);
427 }
429
431 // Element Set API //
434
437 bool AddElementSetSelector(const char* selector)
438 {
439 return this->AddSelector(EntityType::SIDESET, selector);
440 }
441 void ClearElementSetSelectors() { this->ClearSelectors(EntityType::SIDESET); }
442 void SetElementSetSelector(const char* selector)
443 {
444 this->SetSelector(EntityType::SIDESET, selector);
445 }
447 {
448 return this->GetNumberOfSelectors(EntityType::SIDESET);
449 }
450 const char* GetElementSetSelector(int index) const
451 {
452 return this->GetSelector(EntityType::SIDESET, index);
453 }
454 std::set<std::string> GetElementSetSelectors() const
455 {
456 return this->GetSelectors(EntityType::SIDESET);
457 }
459
464 {
465 return this->GetFieldSelection(EntityType::SIDESET);
466 }
468
470 // Side Set API //
473
476 bool AddSideSetSelector(const char* selector)
477 {
478 return this->AddSelector(EntityType::SIDESET, selector);
479 }
480 void ClearSideSetSelectors() { this->ClearSelectors(EntityType::SIDESET); }
481 void SetSideSetSelector(const char* selector)
482 {
483 this->SetSelector(EntityType::SIDESET, selector);
484 }
486 {
487 return this->GetNumberOfSelectors(EntityType::SIDESET);
488 }
489 const char* GetSideSetSelector(int index) const
490 {
491 return this->GetSelector(EntityType::SIDESET, index);
492 }
493 std::set<std::string> GetSideSetSelectors() const
494 {
495 return this->GetSelectors(EntityType::SIDESET);
496 }
498
503 {
504 return this->GetFieldSelection(EntityType::SIDESET);
505 }
507
509
514 vtkSetMacro(RemoveGhosts, bool);
515 vtkGetMacro(RemoveGhosts, bool);
517
519
525 vtkSetMacro(OffsetGlobalIds, bool);
526 vtkGetMacro(OffsetGlobalIds, bool);
527 vtkBooleanMacro(OffsetGlobalIds, bool);
529
531
538 VTK_DEPRECATED_IN_9_3_0("PreserveInputEntityGroups is no longer needed.")
539 void SetPreserveInputEntityGroups(bool) {}
540 VTK_DEPRECATED_IN_9_3_0("PreserveInputEntityGroups is no longer needed.")
541 bool GetPreserveInputEntityGroups() { return true; }
542 VTK_DEPRECATED_IN_9_3_0("PreserveInputEntityGroups is no longer needed.")
543 void PreserveInputEntityGroupsOn() {}
544 VTK_DEPRECATED_IN_9_3_0("PreserveInputEntityGroups is no longer needed.")
545 void PreserveInputEntityGroupsOff() {}
547
549
555 vtkSetMacro(PreserveOriginalIds, bool);
556 vtkGetMacro(PreserveOriginalIds, bool);
557 vtkBooleanMacro(PreserveOriginalIds, bool);
559
561 // Global Fields API //
564
571 vtkSetMacro(WriteQAAndInformationRecords, bool);
572 vtkGetMacro(WriteQAAndInformationRecords, bool);
573 vtkBooleanMacro(WriteQAAndInformationRecords, bool);
576
578
585 vtkSetClampMacro(DisplacementMagnitude, double, 0, VTK_DOUBLE_MAX);
586 vtkGetMacro(DisplacementMagnitude, double);
588
590
598 VTK_DEPRECATED_IN_9_3_0("Use TimeStepRange/TimeStepStride instead.")
599 void SetMaximumTimeStepsPerFile(int val)
600 {
601 this->SetTimeStepStride(1);
602 this->SetTimeStepRange(0, val - 1);
603 }
604 VTK_DEPRECATED_IN_9_3_0("Use TimeStepRange/TimeStepStride instead.")
605 int GetMaximumTimeStepsPerFile() { return this->TimeStepRange[1] + 1; }
607
609
617 vtkSetVector2Macro(TimeStepRange, int);
618 vtkGetVector2Macro(TimeStepRange, int);
619 vtkSetClampMacro(TimeStepStride, int, 1, VTK_INT_MAX);
620 vtkGetMacro(TimeStepStride, int);
622
624
632 vtkGetObjectMacro(Controller, vtkMultiProcessController);
634
635protected:
637 ~vtkIOSSWriter() override;
638
639 int FillInputPortInformation(int port, vtkInformation* info) override;
641 vtkInformationVector* outputVector) override;
643 vtkInformationVector* outputVector);
645 vtkInformationVector* outputVector);
647 vtkInformationVector* outputVector) override;
648
649 void WriteData() override;
650
651private:
652 vtkIOSSWriter(const vtkIOSSWriter&) = delete;
653 void operator=(const vtkIOSSWriter&) = delete;
654
655 class vtkInternals;
656 std::unique_ptr<vtkInternals> Internals;
657
658 vtkMultiProcessController* Controller;
659 char* FileName;
660 char* AssemblyName;
661 bool ChooseFieldsToWrite;
662 bool RemoveGhosts;
663 bool OffsetGlobalIds;
664 bool PreserveOriginalIds;
665 bool WriteQAAndInformationRecords;
666 double DisplacementMagnitude;
667 int TimeStepRange[2];
668 int TimeStepStride;
669
670 std::set<std::string> Selectors[EntityType::NUMBER_OF_ENTITY_TYPES];
671 vtkNew<vtkDataArraySelection> FieldSelection[EntityType::NUMBER_OF_ENTITY_TYPES];
672};
673VTK_ABI_NAMESPACE_END
674
675#endif
Store on/off settings for data arrays, etc.
Writer for IOSS (Sierra IO System)
void ClearEdgeBlockSelectors()
Add/Clear/Set/Get edge block selectors.
int RequestUpdateExtent(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
void SetSideSetSelector(const char *selector)
Add/Clear/Set/Get side set selectors.
~vtkIOSSWriter() override
bool AddElementSetSelector(const char *selector)
Add/Clear/Set/Get element set selectors.
void ClearNodeSetSelectors()
Add/Clear/Set/Get node set selectors.
void ClearFaceBlockSelectors()
Add/Clear/Set/Get face block selectors.
void SetController(vtkMultiProcessController *controller)
Get/Set the controller to use when working in parallel.
bool AddNodeSetSelector(const char *selector)
Add/Clear/Set/Get node set selectors.
static vtkIOSSWriter * New()
vtkTypeBool ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Upstream/Downstream requests form the generalized interface through which executives invoke a algorit...
void SetSelector(EntityType entity, const char *selector)
Convenience method to set a single entity selector.
vtkDataArraySelection * GetEdgeSetFieldSelection()
Returns the field selection object for the edge set arrays.
int GetNumberOfElementBlockSelectors() const
Add/Clear/Set/Get element block selectors.
void ClearFaceSetSelectors()
Add/Clear/Set/Get edge set selectors.
vtkDataArraySelection * GetElementSetFieldSelection()
Returns the field selection object for the element set arrays.
int GetNumberOfEdgeSetSelectors() const
Add/Clear/Set/Get edge set selectors.
void ClearSelectors(EntityType entity)
API to set entity selectors.
const char * GetEdgeSetSelector(int index) const
Add/Clear/Set/Get edge set selectors.
vtkDataArraySelection * GetNodeSetFieldSelection()
Returns the field selection object for the node set arrays.
bool AddEdgeBlockSelector(const char *selector)
Add/Clear/Set/Get edge block selectors.
bool AddElementBlockSelector(const char *selector)
Add/Clear/Set/Get element block selectors.
void ClearEdgeSetSelectors()
Add/Clear/Set/Get edge set selectors.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
std::set< std::string > GetEdgeSetSelectors() const
Add/Clear/Set/Get edge set selectors.
bool AddEdgeSetSelector(const char *selector)
Add/Clear/Set/Get edge set selectors.
bool AddSideSetSelector(const char *selector)
Add/Clear/Set/Get side set selectors.
int GetNumberOfSideSetSelectors() const
Add/Clear/Set/Get side set selectors.
void SetEdgeBlockSelector(const char *selector)
Add/Clear/Set/Get edge block selectors.
std::set< std::string > GetElementBlockSelectors() const
Add/Clear/Set/Get element block selectors.
void SetFaceSetSelector(const char *selector)
Add/Clear/Set/Get edge set selectors.
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
std::set< std::string > GetNodeSetSelectors() const
Add/Clear/Set/Get node set selectors.
vtkDataArraySelection * GetFaceBlockFieldSelection()
Returns the field selection object for the face block arrays.
void ClearSideSetSelectors()
Add/Clear/Set/Get side set selectors.
bool AddSelector(EntityType entity, const char *selector)
API to set entity selectors.
int GetNumberOfFaceSetSelectors() const
Add/Clear/Set/Get edge set selectors.
std::set< std::string > GetFaceBlockSelectors() const
Add/Clear/Set/Get face block selectors.
vtkDataArraySelection * GetSideSetFieldSelection()
Returns the field selection object for the side set arrays.
void SetElementBlockSelector(const char *selector)
Add/Clear/Set/Get element block selectors.
const char * GetFaceBlockSelector(int index) const
Add/Clear/Set/Get face block selectors.
int GetNumberOfNodeSetSelectors() const
Add/Clear/Set/Get node set selectors.
const char * GetElementSetSelector(int index) const
Add/Clear/Set/Get element set selectors.
void SetElementSetSelector(const char *selector)
Add/Clear/Set/Get element set selectors.
vtkDataArraySelection * GetFaceSetFieldSelection()
Returns the field selection object for the edge set arrays.
int GetNumberOfFaceBlockSelectors() const
Add/Clear/Set/Get face block selectors.
int GetNumberOfEdgeBlockSelectors() const
Add/Clear/Set/Get edge block selectors.
void SetEdgeSetSelector(const char *selector)
Add/Clear/Set/Get edge set selectors.
const char * GetSelector(EntityType entity, int index) const
API to access entity selectors.
const char * GetNodeSetSelector(int index) const
Add/Clear/Set/Get node set selectors.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
std::set< std::string > GetSelectors(EntityType entity) const
API to access entity selectors.
std::set< std::string > GetElementSetSelectors() const
Add/Clear/Set/Get element set selectors.
bool AddFaceSetSelector(const char *selector)
Add/Clear/Set/Get edge set selectors.
const char * GetEdgeBlockSelector(int index) const
Add/Clear/Set/Get edge block selectors.
void ClearElementSetSelectors()
Add/Clear/Set/Get element set selectors.
void WriteData() override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
const char * GetElementBlockSelector(int index) const
Add/Clear/Set/Get element block selectors.
std::set< std::string > GetFaceSetSelectors() const
Add/Clear/Set/Get edge set selectors.
std::set< std::string > GetEdgeBlockSelectors() const
Add/Clear/Set/Get edge block selectors.
vtkDataArraySelection * GetElementBlockFieldSelection()
Returns the field selection object for the element block arrays.
void ClearElementBlockSelectors()
Add/Clear/Set/Get element block selectors.
vtkDataArraySelection * GetFieldSelection(EntityType type)
Get the selection object for the given entity type.
const char * GetSideSetSelector(int index) const
Add/Clear/Set/Get side set selectors.
bool AddFaceBlockSelector(const char *selector)
Add/Clear/Set/Get face block selectors.
std::set< std::string > GetSideSetSelectors() const
Add/Clear/Set/Get side set selectors.
void SetFaceBlockSelector(const char *selector)
Add/Clear/Set/Get face block selectors.
vtkDataArraySelection * GetNodeBlockFieldSelection()
Returns the field selection object for the element block arrays.
const char * GetFaceSetSelector(int index) const
Add/Clear/Set/Get edge set selectors.
void SetNodeSetSelector(const char *selector)
Add/Clear/Set/Get node set selectors.
int GetNumberOfSelectors(EntityType entity) const
API to access entity selectors.
int GetNumberOfElementSetSelectors() const
Add/Clear/Set/Get element set selectors.
vtkDataArraySelection * GetEdgeBlockFieldSelection()
Returns the field selection object for the edge block arrays.
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Multiprocessing communication superclass.
Allocate and hold a VTK object.
Definition vtkNew.h:160
abstract class to write data to file(s)
Definition vtkWriter.h:35
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DEPRECATED_IN_9_3_0(reason)
#define VTK_DOUBLE_MAX
Definition vtkType.h:154
#define VTK_INT_MAX
Definition vtkType.h:144