IOSS 2.0
Loading...
Searching...
No Matches
Iocatalyst_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 IOSS_IOVS_CATALYST_MANAGER_H
8#define IOSS_IOVS_CATALYST_MANAGER_H
9
10#include "iocatalyst_export.h"
11#include <Ioss_ParallelUtils.h>
12#include <catalyst.hpp>
13
14namespace Iocatalyst {
15
16 class IOCATALYST_EXPORT CatalystManager
17 {
18 public:
19 using CatalystPipelineID = unsigned int;
20
21 enum mState { mInit, mExecute, mFinalize };
22 enum pState { pWaitExecute, pExecute, pFinalize };
23
24 inline static const std::string ARGS = "args";
25 inline static const std::string CATALYST = "catalyst";
26 inline static const std::string CATALYST_BLOCK_PARSE_INPUT_DECK_NAME =
27 "CATALYST_BLOCK_PARSE_INPUT_DECK_NAME";
28 inline static const std::string CATALYST_BLOCK_PARSE_JSON_STRING =
29 "CATALYST_BLOCK_PARSE_JSON_STRING";
30 inline static const std::string CATALYST_DEBUG_LEVEL = "CATALYST_DEBUG_LEVEL";
31 inline static const std::string CATALYST_ENABLE_LOGGING = "CATALYST_ENABLE_LOGGING";
32 inline static const std::string CATALYST_OUTPUT_DIRECTORY = "CATALYST_OUTPUT_DIRECTORY";
33 inline static const std::string CATALYST_OUTPUT_DEFAULT = "CatalystOutput";
34 inline static const std::string CATALYST_INPUT_NAME = "CATALYST_INPUT_NAME";
35 inline static const std::string CATALYST_INPUT_DEFAULT = "input";
36 inline static const std::string CATALYST_MULTI_INPUT_PIPELINE_NAME =
37 "CATALYST_MULTI_INPUT_PIPELINE_NAME";
38 inline static const std::string CATALYST_SCRIPT = "CATALYST_SCRIPT";
39 inline static const std::string CATALYST_SCRIPT_EXTRA_FILE = "CATALYST_SCRIPT_EXTRA_FILE";
40 inline static const std::string CHANNELS = "channels";
41 inline static const std::string CYCLE = "cycle";
42 inline static const std::string DATA = "data";
43 inline static const std::string PHACTORI_JSON_SCRIPT = "PHACTORI_JSON_SCRIPT";
44 inline static const std::string PIPELINES = "pipelines";
45 inline static const std::string FILENAME = "filename";
46 inline static const std::string FS = "/";
47 inline static const std::string IOSS = "ioss";
48 inline static const std::string SCRIPTS = "scripts";
49 inline static const std::string STATE = "state";
50 inline static const std::string TIME = "time";
51 inline static const std::string TIMESTEP = "timestep";
52 inline static const std::string TYPE = "type";
53
55 {
56 static CatalystManager instance;
57 return instance;
58 }
59
60 std::string getCatalystPythonDriverPath() { return "/todo/create/real/path"; }
61
62 conduit_cpp::Node getInitializeConduit();
63
64 mState getManagerState() { return managerState; }
65
66 pState getPipelineState(CatalystPipelineID id);
67
68 void writeToCatalystLogFile(const Ioss::ParallelUtils &putils,
69 const Ioss::PropertyManager &props);
70
72 {
74 {
75 catalystPipelineID = 0;
76 enableLogging = false;
77 debugLevel = 0;
78 catalystOutputDirectory = CATALYST_OUTPUT_DEFAULT;
79 catalystInputName = CATALYST_INPUT_DEFAULT;
80 enableCatalystMultiInputPipeline = false;
81 pipelineState = pExecute;
82 state = 0;
83 time = 0.0;
84 }
85
91 conduit_cpp::Node data;
92 int state;
93 double time;
94
95 std::string catalystInputName;
96 std::string catalystBlockJSON;
102 };
103
104 CatalystPipelineID initialize(const Ioss::PropertyManager &props,
105 const Ioss::ParallelUtils &putils);
106 void execute(CatalystPipelineID id, int state, double time, conduit_cpp::Node &data);
107 void finalize(CatalystPipelineID id);
108 void addScriptProps(conduit_cpp::Node &n, const CatalystProps &p);
109 void addExecuteProps(conduit_cpp::Node &n, const CatalystProps &p, int state, double time);
110 void addExecuteData(conduit_cpp::Node &n, const std::string &channelName, int state,
111 double time, conduit_cpp::Node &data);
112 CatalystProps &getCatalystProps(CatalystPipelineID id);
113 std::string getCatDataPath(const Ioss::PropertyManager &props);
114 void setMultiInputWaitState(CatalystPipelineID id, int state, double time,
115 conduit_cpp::Node &data);
116 bool canExecuteMultiInputScript(CatalystPipelineID id);
117 void clearAllMultiInputWaitStates(CatalystPipelineID id);
118 void reset()
119 {
120 catalystOutputIDNumber = 0;
121 catPipes.clear();
122 managerState = mInit;
123 }
124
126 {
127 return getCatScriptPath(p) + FILENAME;
128 }
129
130 std::string getCatScriptArgsPath(const CatalystProps &p) { return getCatScriptPath(p) + ARGS; }
131
132 std::string getCatScriptPath(const CatalystProps &p)
133 {
134 return CATALYST + FS + SCRIPTS + FS + std::to_string(p.catalystPipelineID) + FS;
135 }
136
137 std::string getCatStatePath() { return CATALYST + FS + STATE + FS; }
138
139 std::string getCatChannelsPath() { return CATALYST + FS + CHANNELS + FS; }
140
141 private:
146
147 void broadCastString(std::string &s, const Ioss::ParallelUtils &putils);
148 void broadCastStatusCode(bool &statusCode, const Ioss::ParallelUtils &putils);
149
150 void incrementOutputCounts();
151
153 std::map<CatalystPipelineID, CatalystProps> catPipes;
155 };
156} // namespace Iocatalyst
157
158#endif
Definition Iocatalyst_CatalystManager.h:17
mState
Definition Iocatalyst_CatalystManager.h:21
@ mExecute
Definition Iocatalyst_CatalystManager.h:21
mState managerState
Definition Iocatalyst_CatalystManager.h:154
std::string getCatScriptArgsPath(const CatalystProps &p)
Definition Iocatalyst_CatalystManager.h:130
void reset()
Definition Iocatalyst_CatalystManager.h:118
mState getManagerState()
Definition Iocatalyst_CatalystManager.h:64
unsigned int CatalystPipelineID
Definition Iocatalyst_CatalystManager.h:19
pState
Definition Iocatalyst_CatalystManager.h:22
@ pExecute
Definition Iocatalyst_CatalystManager.h:22
CatalystManager & operator=(const CatalystManager &)=delete
std::string getCatScriptFnamePath(const CatalystProps &p)
Definition Iocatalyst_CatalystManager.h:125
CatalystManager(const CatalystManager &)=delete
CatalystPipelineID catalystOutputIDNumber
Definition Iocatalyst_CatalystManager.h:152
std::map< CatalystPipelineID, CatalystProps > catPipes
Definition Iocatalyst_CatalystManager.h:153
std::string getCatStatePath()
Definition Iocatalyst_CatalystManager.h:137
std::string getCatChannelsPath()
Definition Iocatalyst_CatalystManager.h:139
std::string getCatScriptPath(const CatalystProps &p)
Definition Iocatalyst_CatalystManager.h:132
static CatalystManager & getInstance()
Definition Iocatalyst_CatalystManager.h:54
std::string getCatalystPythonDriverPath()
Definition Iocatalyst_CatalystManager.h:60
Definition Ioss_ParallelUtils.h:32
A collection of Ioss::Property objects.
Definition Ioss_PropertyManager.h:36
A namespace for the Catalyst 2.0 database format.
Definition Iocatalyst_CatalystLogging.C:13
Definition Iocatalyst_CatalystManager.h:72
std::string catalystInputDeckName
Definition Iocatalyst_CatalystManager.h:98
std::string catalystBlockJSON
Definition Iocatalyst_CatalystManager.h:96
std::string catalystOutputDirectory
Definition Iocatalyst_CatalystManager.h:99
std::string catalystInputName
Definition Iocatalyst_CatalystManager.h:95
std::string catalystMultiInputPipelineName
Definition Iocatalyst_CatalystManager.h:89
int state
Definition Iocatalyst_CatalystManager.h:92
CatalystProps()
Definition Iocatalyst_CatalystManager.h:73
bool enableCatalystMultiInputPipeline
Definition Iocatalyst_CatalystManager.h:88
std::string catalystPythonFilename
Definition Iocatalyst_CatalystManager.h:90
conduit_cpp::Node data
Definition Iocatalyst_CatalystManager.h:91
CatalystPipelineID catalystPipelineID
Definition Iocatalyst_CatalystManager.h:86
double time
Definition Iocatalyst_CatalystManager.h:93
int debugLevel
Definition Iocatalyst_CatalystManager.h:101
std::string catalystScriptExtraFile
Definition Iocatalyst_CatalystManager.h:97
pState pipelineState
Definition Iocatalyst_CatalystManager.h:87
bool enableLogging
Definition Iocatalyst_CatalystManager.h:100