VTK  9.4.20250201
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
96VTK_ABI_NAMESPACE_BEGIN
99
100class VTKIOIOSS_EXPORT vtkIOSSWriter : public vtkWriter
101{
102public:
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);
160
165 void SetSelector(EntityType entity, const char* selector);
166
168
172 const char* GetSelector(EntityType entity, int index) const;
173 std::set<std::string> GetSelectors(EntityType entity) const;
175
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
594 vtkGetObjectMacro(Controller, vtkMultiProcessController);
596
597protected:
599 ~vtkIOSSWriter() override;
600
601 int FillInputPortInformation(int port, vtkInformation* info) override;
603 vtkInformationVector* outputVector) override;
605 vtkInformationVector* outputVector);
607 vtkInformationVector* outputVector);
609 vtkInformationVector* outputVector) override;
610
611 void WriteData() override;
612
613private:
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};
635VTK_ABI_NAMESPACE_END
636
637#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:167
abstract class to write data to file(s)
Definition vtkWriter.h:35
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DOUBLE_MAX
Definition vtkType.h:154
#define VTK_INT_MAX
Definition vtkType.h:144