IOSS 2.0
Loading...
Searching...
No Matches
CatalystManager.h
Go to the documentation of this file.
1// Copyright(C) 1999-2021 National Technology & Engineering Solutions
2// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3// NTESS, the U.S. Government retains certain rights in this software.
4//
5// See packages/seacas/LICENSE for details
6
7#ifndef __CATALYST_MANAGER_H
8#define __CATALYST_MANAGER_H
9
10#include "vtkCPDataDescription.h"
11#include <map>
12#include <time.h>
14#include <vtkSmartPointer.h>
15
16class coProcessor;
17class vtkDoubleArray;
18class vtkCPPythonPipeline;
19class vtkCPProcessor;
20class vtkDataObject;
21
22namespace Iovs {
23
25
27 {
28
29 public:
30 const std::string catalystPluginVersion = "2.0.0";
31 using CatalystPipelineID = unsigned int;
32 using CatalystInputName = std::string;
33 using CatalystMultiInputPipelineName = std::string;
34
37
38 void parsePhactoriFile(const std::string &filepath, ParseResult &pres);
39
40 void parsePhactoriString(const std::string &phactori, ParseResult &pres);
41
43
44 std::unique_ptr<Iovs_exodus::CatalystExodusMeshBase>
46
47 std::unique_ptr<Iovs_cgns::CatalystCGNSMeshBase>
49
51
53 {
56 std::string getLogFileName() const
57 {
58 return catalystInputName + "_" + std::to_string(catalystPipelineID) + "_catalyst.log";
59 }
60 };
61
62 // Description:
63 // Deletes pipeline with name results_output_filename and any associated
64 // logging data.
66
67 // Description:
68 // Calls the ParaView Catalyst pipeline to run co-processing for this time iteration.
69 void PerformCoProcessing(std::vector<int> &error_and_warning_codes,
70 std::vector<std::string> &error_and_warning_messages,
71 const CatalystPipelineInfo &cpi);
72
73 // Description:
74 // Sets time data for this ParaView Catalyst co-processing iteration.
75 // currentTime is the current Ioss simulation time and timeStep is
76 // the current time iteration count.
77 void SetTimeData(double currentTime, int timeStep, const CatalystPipelineInfo &cpi);
78
79 // Description:
80 // Collects memory usage information from all processors and
81 // writes the min, max, and mean to the log file. Also writes the
82 // min, max, and mean of the elapsed time since this method was
83 // last called.
85
87
88 private:
90
92 {
93 public:
100
101 vtkSmartPointer<vtkCPPythonPipeline> &getPipeline() { return pipeline; }
102
103 vtkSmartPointer<vtkCPDataDescription> &getDataDescription() { return dataDescription; }
104
105 std::shared_ptr<CatalystMeshWriter> &getMeshWriter() { return meshWriter; }
106
108
110
112
113 private:
114 bool canDoOperation(unsigned int &operationCount)
115 {
116 bool retVal = true;
117 operationCount++;
118 if (operationCount == getNumberOfInputs()) {
119 operationCount = 0;
120 }
121 else {
122 retVal = false;
123 }
124 return retVal;
125 }
126
127 unsigned int getNumberOfInputs()
128 {
129 unsigned int retVal = 0;
130 if (getDataDescription() != nullptr) {
131 retVal = getDataDescription()->GetNumberOfInputDescriptions();
132 }
133 return retVal;
134 }
135
138 unsigned int setTimeDataCount;
139 vtkSmartPointer<vtkCPPythonPipeline> pipeline;
140 vtkSmartPointer<vtkCPDataDescription> dataDescription;
141 std::shared_ptr<CatalystMeshWriter> meshWriter;
142 };
143
144 typedef std::pair<clock_t, clock_t> TimerPair;
145 typedef std::pair<TimerPair, vtkDoubleArray *> LoggingPair;
146
149
157
159 void initCatalystPipeline(CatalystMeshInit &cmInit, vtkDataObject *vobj,
160 const CatalystPipelineInfo &cpi);
161 void addInputToPipeline(vtkDataObject *vobj, const CatalystPipelineInfo &cpi);
163 void registerMeshInPipeline(CatalystMeshInit &cmInit, vtkDataObject *vobj,
164 const CatalystPipelineInfo &cpi);
165
168 vtkCPProcessor *coProcessor;
169 std::map<CatalystPipelineID, CatalystPipelineState> pipelines;
170 std::map<CatalystPipelineID, LoggingPair> logging;
171 std::map<CatalystMultiInputPipelineName, CatalystPipelineID> multiInputPipelines;
172 };
173
174 extern "C" {
176 }
177
178} // namespace Iovs
179
180#endif /* __CATALYST_MANAGER_H */
Definition CatalystManagerBase.h:25
Definition CatalystManager.h:92
unsigned int performCoProcessingCount
Definition CatalystManager.h:136
std::shared_ptr< CatalystMeshWriter > meshWriter
Definition CatalystManager.h:141
vtkSmartPointer< vtkCPPythonPipeline > & getPipeline()
Definition CatalystManager.h:101
vtkSmartPointer< vtkCPDataDescription > & getDataDescription()
Definition CatalystManager.h:103
unsigned int deletePipelineCount
Definition CatalystManager.h:137
CatalystPipelineState()
Definition CatalystManager.h:94
vtkSmartPointer< vtkCPPythonPipeline > pipeline
Definition CatalystManager.h:139
unsigned int getNumberOfInputs()
Definition CatalystManager.h:127
bool canDoOperation(unsigned int &operationCount)
Definition CatalystManager.h:114
unsigned int setTimeDataCount
Definition CatalystManager.h:138
bool canPerformCoProcessing()
Definition CatalystManager.h:107
bool canDeletePipeline()
Definition CatalystManager.h:109
vtkSmartPointer< vtkCPDataDescription > dataDescription
Definition CatalystManager.h:140
bool canSetTimeData()
Definition CatalystManager.h:111
std::shared_ptr< CatalystMeshWriter > & getMeshWriter()
Definition CatalystManager.h:105
Definition CatalystManager.h:27
void initCatalystPipeline(CatalystMeshInit &cmInit, vtkDataObject *vobj, const CatalystPipelineInfo &cpi)
CatalystPipelineID getCatalystPipelineID(CatalystMeshInit &cmInit)
void initCatalystPythonSystemPaths()
void addInputToPipeline(vtkDataObject *vobj, const CatalystPipelineInfo &cpi)
CatalystPipelineInfo createCatalystPipelineInfo(CatalystMeshInit &cmInit)
bool writeMeshON(const CatalystPipelineInfo &cpi)
void PerformCoProcessing(std::vector< int > &error_and_warning_codes, std::vector< std::string > &error_and_warning_messages, const CatalystPipelineInfo &cpi)
std::map< CatalystMultiInputPipelineName, CatalystPipelineID > multiInputPipelines
Definition CatalystManager.h:171
void logMemoryUsageAndTakeTimerReading(const CatalystPipelineInfo &cpi)
std::map< CatalystPipelineID, LoggingPair > logging
Definition CatalystManager.h:170
void writeMesh(const CatalystPipelineInfo &cpi)
void parsePhactoriFile(const std::string &filepath, ParseResult &pres)
std::map< CatalystPipelineID, CatalystPipelineState > pipelines
Definition CatalystManager.h:169
CatalystManager & operator=(const CatalystManager &)=delete
std::string CatalystMultiInputPipelineName
Definition CatalystManager.h:33
CatalystManager(const CatalystManager &)=delete
std::pair< clock_t, clock_t > TimerPair
Definition CatalystManager.h:144
std::string getCatalystPluginVersion()
void SetTimeData(double currentTime, int timeStep, const CatalystPipelineInfo &cpi)
unsigned int CatalystPipelineID
Definition CatalystManager.h:31
vtkCPProcessor * coProcessor
Definition CatalystManager.h:168
CatalystPipelineID catalystOutputIDNumber
Definition CatalystManager.h:166
std::unique_ptr< Iovs_cgns::CatalystCGNSMeshBase > createCatalystCGNSMesh(CatalystMeshInit &cmInit)
std::pair< TimerPair, vtkDoubleArray * > LoggingPair
Definition CatalystManager.h:145
void parsePhactoriString(const std::string &phactori, ParseResult &pres)
void initCatalystLogging(const CatalystPipelineInfo &cpi)
std::string CatalystInputName
Definition CatalystManager.h:32
void WriteToLogFile(const CatalystPipelineInfo &cpi)
std::unique_ptr< Iovs_exodus::CatalystExodusMeshBase > createCatalystExodusMesh(CatalystExodusMeshInit &cmInit)
const std::string catalystPluginVersion
Definition CatalystManager.h:30
CatalystPipelineID catalystOutputReferenceCount
Definition CatalystManager.h:167
void DeletePipeline(const CatalystPipelineInfo &cpi)
void registerMeshInPipeline(CatalystMeshInit &cmInit, vtkDataObject *vobj, const CatalystPipelineInfo &cpi)
Definition CatalystMeshWriter.h:17
Definition CatalystManager.h:22
CatalystManagerBase * CreateCatalystManagerInstance()
Definition CatalystManagerBase.h:83
Definition CatalystManagerBase.h:55
Definition CatalystManagerBase.h:32
Definition CatalystManager.h:53
CatalystPipelineID catalystPipelineID
Definition CatalystManager.h:54
CatalystInputName catalystInputName
Definition CatalystManager.h:55
std::string getLogFileName() const
Definition CatalystManager.h:56