VTK  9.7.1
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 "vtkIOIOSSModule.h" // For export macros
88 #include "vtkIOSSReader.h" // For vtkIOSSReader::EntityType
89 #include "vtkNew.h" // For vtkNew
90 #include "vtkWriter.h"
91 
92 #include <memory> // for std::unique_ptr
93 #include <set> // for std::set
94 #include <string> // for std::string
95 
96 VTK_ABI_NAMESPACE_BEGIN
99 
100 class VTKIOIOSS_EXPORT vtkIOSSWriter : public vtkWriter
101 {
102 public:
103  static vtkIOSSWriter* New();
104  vtkTypeMacro(vtkIOSSWriter, vtkWriter);
105  void PrintSelf(ostream& os, vtkIndent indent) override;
106 
108 
112  vtkSetStringMacro(FileName);
113  vtkGetStringMacro(FileName);
115 
117 
124  vtkSetStringMacro(AssemblyName);
125  vtkGetStringMacro(AssemblyName);
127 
129 
131 
138  vtkSetMacro(ChooseFieldsToWrite, bool);
139  vtkGetMacro(ChooseFieldsToWrite, bool);
140  vtkBooleanMacro(ChooseFieldsToWrite, bool);
142 
144  // Generic Entity API //
147 
157  bool AddSelector(EntityType entity, const char* selector);
158  void ClearSelectors(EntityType entity);
160 
165  void SetSelector(EntityType entity, const char* selector);
166 
168 
171  int GetNumberOfSelectors(EntityType entity) const;
172  const char* GetSelector(EntityType entity, int index) const;
173  std::set<std::string> GetSelectors(EntityType entity) const;
175 
180  vtkDataArraySelection* GetFieldSelection(EntityType type);
182 
184  // Node Block API //
186 
190  {
191  return this->GetFieldSelection(EntityType::NODEBLOCK);
192  }
194 
196  // Edge Block API //
199 
202  bool AddEdgeBlockSelector(const char* selector)
203  {
204  return this->AddSelector(EntityType::EDGEBLOCK, selector);
205  }
206  void ClearEdgeBlockSelectors() { this->ClearSelectors(EntityType::EDGEBLOCK); }
207  void SetEdgeBlockSelector(const char* selector)
208  {
209  this->SetSelector(EntityType::EDGEBLOCK, selector);
210  }
212  {
213  return this->GetNumberOfSelectors(EntityType::EDGEBLOCK);
214  }
215  const char* GetEdgeBlockSelector(int index) const
216  {
217  return this->GetSelector(EntityType::EDGEBLOCK, index);
218  }
219  std::set<std::string> GetEdgeBlockSelectors() const
220  {
221  return this->GetSelectors(EntityType::EDGEBLOCK);
222  }
224 
229  {
230  return this->GetFieldSelection(EntityType::EDGEBLOCK);
231  }
233 
235  // Face Block API //
238 
241  bool AddFaceBlockSelector(const char* selector)
242  {
243  return this->AddSelector(EntityType::FACEBLOCK, selector);
244  }
245  void ClearFaceBlockSelectors() { this->ClearSelectors(EntityType::FACEBLOCK); }
246  void SetFaceBlockSelector(const char* selector)
247  {
248  this->SetSelector(EntityType::FACEBLOCK, selector);
249  }
251  {
252  return this->GetNumberOfSelectors(EntityType::FACEBLOCK);
253  }
254  const char* GetFaceBlockSelector(int index) const
255  {
256  return this->GetSelector(EntityType::FACEBLOCK, index);
257  }
258  std::set<std::string> GetFaceBlockSelectors() const
259  {
260  return this->GetSelectors(EntityType::FACEBLOCK);
261  }
263 
268  {
269  return this->GetFieldSelection(EntityType::FACEBLOCK);
270  }
272 
274  // Element Block API //
277 
280  bool AddElementBlockSelector(const char* selector)
281  {
282  return this->AddSelector(EntityType::ELEMENTBLOCK, selector);
283  }
284  void ClearElementBlockSelectors() { this->ClearSelectors(EntityType::ELEMENTBLOCK); }
285  void SetElementBlockSelector(const char* selector)
286  {
287  this->SetSelector(EntityType::ELEMENTBLOCK, selector);
288  }
290  {
291  return this->GetNumberOfSelectors(EntityType::ELEMENTBLOCK);
292  }
293  const char* GetElementBlockSelector(int index) const
294  {
295  return this->GetSelector(EntityType::ELEMENTBLOCK, index);
296  }
297  std::set<std::string> GetElementBlockSelectors() const
298  {
299  return this->GetSelectors(EntityType::ELEMENTBLOCK);
300  }
302 
307  {
308  return this->GetFieldSelection(EntityType::ELEMENTBLOCK);
309  }
311 
313  // Node Set API //
316 
319  bool AddNodeSetSelector(const char* selector)
320  {
321  return this->AddSelector(EntityType::NODESET, selector);
322  }
323  void ClearNodeSetSelectors() { this->ClearSelectors(EntityType::NODESET); }
324  void SetNodeSetSelector(const char* selector)
325  {
326  this->SetSelector(EntityType::NODESET, selector);
327  }
329  {
330  return this->GetNumberOfSelectors(EntityType::NODESET);
331  }
332  const char* GetNodeSetSelector(int index) const
333  {
334  return this->GetSelector(EntityType::NODESET, index);
335  }
336  std::set<std::string> GetNodeSetSelectors() const
337  {
338  return this->GetSelectors(EntityType::NODESET);
339  }
341 
346  {
347  return this->GetFieldSelection(EntityType::NODESET);
348  }
350 
352  // Edge Set API //
355 
358  bool AddEdgeSetSelector(const char* selector)
359  {
360  return this->AddSelector(EntityType::SIDESET, selector);
361  }
362  void ClearEdgeSetSelectors() { this->ClearSelectors(EntityType::SIDESET); }
363  void SetEdgeSetSelector(const char* selector)
364  {
365  this->SetSelector(EntityType::SIDESET, selector);
366  }
368  {
369  return this->GetNumberOfSelectors(EntityType::SIDESET);
370  }
371  const char* GetEdgeSetSelector(int index) const
372  {
373  return this->GetSelector(EntityType::SIDESET, index);
374  }
375  std::set<std::string> GetEdgeSetSelectors() const
376  {
377  return this->GetSelectors(EntityType::SIDESET);
378  }
380 
385  {
386  return this->GetFieldSelection(EntityType::SIDESET);
387  }
389 
391  // Face Set API //
394 
397  bool AddFaceSetSelector(const char* selector)
398  {
399  return this->AddSelector(EntityType::SIDESET, selector);
400  }
401  void ClearFaceSetSelectors() { this->ClearSelectors(EntityType::SIDESET); }
402  void SetFaceSetSelector(const char* selector)
403  {
404  this->SetSelector(EntityType::SIDESET, selector);
405  }
407  {
408  return this->GetNumberOfSelectors(EntityType::SIDESET);
409  }
410  const char* GetFaceSetSelector(int index) const
411  {
412  return this->GetSelector(EntityType::SIDESET, index);
413  }
414  std::set<std::string> GetFaceSetSelectors() const
415  {
416  return this->GetSelectors(EntityType::SIDESET);
417  }
419 
424  {
425  return this->GetFieldSelection(EntityType::SIDESET);
426  }
428 
430  // Element Set API //
433 
436  bool AddElementSetSelector(const char* selector)
437  {
438  return this->AddSelector(EntityType::SIDESET, selector);
439  }
440  void ClearElementSetSelectors() { this->ClearSelectors(EntityType::SIDESET); }
441  void SetElementSetSelector(const char* selector)
442  {
443  this->SetSelector(EntityType::SIDESET, selector);
444  }
446  {
447  return this->GetNumberOfSelectors(EntityType::SIDESET);
448  }
449  const char* GetElementSetSelector(int index) const
450  {
451  return this->GetSelector(EntityType::SIDESET, index);
452  }
453  std::set<std::string> GetElementSetSelectors() const
454  {
455  return this->GetSelectors(EntityType::SIDESET);
456  }
458 
463  {
464  return this->GetFieldSelection(EntityType::SIDESET);
465  }
467 
469  // Side Set API //
472 
475  bool AddSideSetSelector(const char* selector)
476  {
477  return this->AddSelector(EntityType::SIDESET, selector);
478  }
479  void ClearSideSetSelectors() { this->ClearSelectors(EntityType::SIDESET); }
480  void SetSideSetSelector(const char* selector)
481  {
482  this->SetSelector(EntityType::SIDESET, selector);
483  }
485  {
486  return this->GetNumberOfSelectors(EntityType::SIDESET);
487  }
488  const char* GetSideSetSelector(int index) const
489  {
490  return this->GetSelector(EntityType::SIDESET, index);
491  }
492  std::set<std::string> GetSideSetSelectors() const
493  {
494  return this->GetSelectors(EntityType::SIDESET);
495  }
497 
502  {
503  return this->GetFieldSelection(EntityType::SIDESET);
504  }
506 
508 
513  vtkSetMacro(RemoveGhosts, bool);
514  vtkGetMacro(RemoveGhosts, bool);
516 
518 
524  vtkSetMacro(OffsetGlobalIds, bool);
525  vtkGetMacro(OffsetGlobalIds, bool);
526  vtkBooleanMacro(OffsetGlobalIds, bool);
528 
530 
536  vtkSetMacro(PreserveOriginalIds, bool);
537  vtkGetMacro(PreserveOriginalIds, bool);
538  vtkBooleanMacro(PreserveOriginalIds, bool);
540 
542  // Global Fields API //
545 
552  vtkSetMacro(WriteQAAndInformationRecords, bool);
553  vtkGetMacro(WriteQAAndInformationRecords, bool);
554  vtkBooleanMacro(WriteQAAndInformationRecords, bool);
557 
559 
566  vtkSetClampMacro(DisplacementMagnitude, double, 0, VTK_DOUBLE_MAX);
567  vtkGetMacro(DisplacementMagnitude, double);
569 
571 
579  vtkSetVector2Macro(TimeStepRange, int);
580  vtkGetVector2Macro(TimeStepRange, int);
581  vtkSetClampMacro(TimeStepStride, int, 1, VTK_INT_MAX);
582  vtkGetMacro(TimeStepStride, int);
584 
586 
593  void SetController(vtkMultiProcessController* controller);
594  vtkGetObjectMacro(Controller, vtkMultiProcessController);
596 
597 protected:
598  vtkIOSSWriter();
599  ~vtkIOSSWriter() override;
600 
601  int FillInputPortInformation(int port, vtkInformation* info) override;
603  vtkInformationVector* outputVector) override;
604  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
605  vtkInformationVector* outputVector);
606  int RequestUpdateExtent(vtkInformation* request, vtkInformationVector** inputVector,
607  vtkInformationVector* outputVector);
608  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
609  vtkInformationVector* outputVector) override;
610 
611  bool WriteDataAndReturn() override;
612 
613 private:
614  vtkIOSSWriter(const vtkIOSSWriter&) = delete;
615  void operator=(const vtkIOSSWriter&) = delete;
616 
617  class vtkInternals;
618  std::unique_ptr<vtkInternals> Internals;
619 
620  vtkMultiProcessController* Controller;
621  char* FileName;
622  char* AssemblyName;
623  bool ChooseFieldsToWrite;
624  bool RemoveGhosts;
625  bool OffsetGlobalIds;
626  bool PreserveOriginalIds;
627  bool WriteQAAndInformationRecords;
628  double DisplacementMagnitude;
629  int TimeStepRange[2];
630  int TimeStepStride;
631 
632  std::set<std::string> Selectors[EntityType::NUMBER_OF_ENTITY_TYPES];
633  vtkNew<vtkDataArraySelection> FieldSelection[EntityType::NUMBER_OF_ENTITY_TYPES];
634 };
635 VTK_ABI_NAMESPACE_END
636 
637 #endif
void SetNodeSetSelector(const char *selector)
Add/Clear/Set/Get node set selectors.
void ClearEdgeSetSelectors()
Add/Clear/Set/Get edge set selectors.
#define VTK_DOUBLE_MAX
Definition: vtkType.h:202
bool AddSideSetSelector(const char *selector)
Add/Clear/Set/Get side set selectors.
bool AddNodeSetSelector(const char *selector)
Add/Clear/Set/Get node set selectors.
void ClearElementBlockSelectors()
Add/Clear/Set/Get element block selectors.
Store vtkAlgorithm input/output information.
#define VTK_INT_MAX
Definition: vtkType.h:192
int GetNumberOfEdgeSetSelectors() const
Add/Clear/Set/Get edge set selectors.
void SetSideSetSelector(const char *selector)
Add/Clear/Set/Get side set selectors.
std::set< std::string > GetEdgeBlockSelectors() const
Add/Clear/Set/Get edge block selectors.
int GetNumberOfSideSetSelectors() const
Add/Clear/Set/Get side set selectors.
const char * GetElementSetSelector(int index) const
Add/Clear/Set/Get element set selectors.
int GetNumberOfFaceBlockSelectors() const
Add/Clear/Set/Get face block selectors.
void ClearEdgeBlockSelectors()
Add/Clear/Set/Get edge block selectors.
void SetFaceBlockSelector(const char *selector)
Add/Clear/Set/Get face block selectors.
vtkDataArraySelection * GetElementSetFieldSelection()
Returns the field selection object for the element set arrays.
vtkDataArraySelection * GetNodeSetFieldSelection()
Returns the field selection object for the node set arrays.
const char * GetEdgeSetSelector(int index) const
Add/Clear/Set/Get edge set selectors.
const char * GetFaceSetSelector(int index) const
Add/Clear/Set/Get edge set selectors.
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.
vtkDataArraySelection * GetEdgeBlockFieldSelection()
Returns the field selection object for the edge block arrays.
int vtkTypeBool
Definition: vtkABI.h:64
abstract class to write data to file(s)
Definition: vtkWriter.h:35
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
const char * GetSideSetSelector(int index) const
Add/Clear/Set/Get side set selectors.
void SetEdgeBlockSelector(const char *selector)
Add/Clear/Set/Get edge block selectors.
bool AddElementSetSelector(const char *selector)
Add/Clear/Set/Get element set selectors.
std::set< std::string > GetElementSetSelectors() const
Add/Clear/Set/Get element set selectors.
a simple class to control print indentation
Definition: vtkIndent.h:28
bool AddElementBlockSelector(const char *selector)
Add/Clear/Set/Get element block selectors.
Store on/off settings for data arrays, etc.
vtkDataArraySelection * GetFaceBlockFieldSelection()
Returns the field selection object for the face block arrays.
std::set< std::string > GetFaceSetSelectors() const
Add/Clear/Set/Get edge set selectors.
std::set< std::string > GetFaceBlockSelectors() const
Add/Clear/Set/Get face block selectors.
void SetFaceSetSelector(const char *selector)
Add/Clear/Set/Get edge set selectors.
const char * GetNodeSetSelector(int index) const
Add/Clear/Set/Get node set selectors.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
virtual int FillInputPortInformation(int port, vtkInformation *info)
Fill the input port information objects for this algorithm.
vtkDataArraySelection * GetElementBlockFieldSelection()
Returns the field selection object for the element block arrays.
Writer for IOSS (Sierra IO System)
void ClearSideSetSelectors()
Add/Clear/Set/Get side set selectors.
void ClearElementSetSelectors()
Add/Clear/Set/Get element set selectors.
std::set< std::string > GetSideSetSelectors() const
Add/Clear/Set/Get side set selectors.
std::set< std::string > GetNodeSetSelectors() const
Add/Clear/Set/Get node set selectors.
void SetElementSetSelector(const char *selector)
Add/Clear/Set/Get element set selectors.
int GetNumberOfFaceSetSelectors() const
Add/Clear/Set/Get edge set selectors.
void SetEdgeSetSelector(const char *selector)
Add/Clear/Set/Get edge set selectors.
void SetElementBlockSelector(const char *selector)
Add/Clear/Set/Get element block selectors.
vtkDataArraySelection * GetEdgeSetFieldSelection()
Returns the field selection object for the edge set arrays.
int GetNumberOfNodeSetSelectors() const
Add/Clear/Set/Get node set selectors.
const char * GetEdgeBlockSelector(int index) const
Add/Clear/Set/Get edge block selectors.
void ClearFaceSetSelectors()
Add/Clear/Set/Get edge set selectors.
bool AddFaceBlockSelector(const char *selector)
Add/Clear/Set/Get face block selectors.
Store zero or more vtkInformation instances.
int GetNumberOfEdgeBlockSelectors() const
Add/Clear/Set/Get edge block selectors.
static vtkAlgorithm * New()
bool AddFaceSetSelector(const char *selector)
Add/Clear/Set/Get edge set selectors.
bool AddEdgeBlockSelector(const char *selector)
Add/Clear/Set/Get edge block selectors.
int GetNumberOfElementSetSelectors() const
Add/Clear/Set/Get element set selectors.
vtkDataArraySelection * GetNodeBlockFieldSelection()
Returns the field selection object for the element block arrays.
vtkDataArraySelection * GetSideSetFieldSelection()
Returns the field selection object for the side set arrays.
virtual bool WriteDataAndReturn()
void ClearNodeSetSelectors()
Add/Clear/Set/Get node set selectors.
vtkDataArraySelection * GetFaceSetFieldSelection()
Returns the field selection object for the edge set arrays.
vtkTypeBool ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Upstream/Downstream requests form the generalized interface through which executives invoke a algorit...
const char * GetElementBlockSelector(int index) const
Add/Clear/Set/Get element block selectors.
void ClearFaceBlockSelectors()
Add/Clear/Set/Get face block selectors.
const char * GetFaceBlockSelector(int index) const
Add/Clear/Set/Get face block selectors.
int GetNumberOfElementBlockSelectors() const
Add/Clear/Set/Get element block selectors.
std::set< std::string > GetElementBlockSelectors() const
Add/Clear/Set/Get element block selectors.
Multiprocessing communication superclass.