IOSS 2.0

ParaViewCatalystIossAdapter.h
Go to the documentation of this file.
1 /*
2 * Copyright(C) 1999-2017 National Technology & Engineering Solutions
3 * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
4 * NTESS, the U.S. Government retains certain rights in this software.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 *
18 * * Neither the name of NTESS nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34 #ifndef __PARAVIEW_CATALYST_IOSS_ADAPTER_H
35 #define __PARAVIEW_CATALYST_IOSS_ADAPTER_H
36
37 #include "CatalystParserInterface.h"
38 #include <stdint.h>
39 #include <string>
40 #include <vector>
41
42 // Base class needed for Ioss's dynamic library
43 // registration.
44
45 class ParaViewCatalystIossAdapterBase
46 {
47 public:
48 ParaViewCatalystIossAdapterBase(){};
49 virtual ~ParaViewCatalystIossAdapterBase(){};
50 virtual std::string getName() const { return "ParaViewCatalystIossAdapterBase"; }
51 virtual void DeletePipeline(const char *results_output_filename) = 0;
52 virtual void CleanupCatalyst() = 0;
53 virtual void CreateNewPipeline(
54 const char *catalyst_python_filename, const char *catalyst_sierra_block_json,
55 const char *catalyst_sierra_separator_character, const char *catalyst_sierra_input_deck_name,
56 int UnderscoreVectors, int ApplyDisplacements, const char *restart_tag, int enable_logging,
57 int debug_level, const char *results_output_filename, const char *catalyst_output_directory,
58 std::vector<std::string> &catalyst_sierra_data) = 0;
59 virtual void PerformCoProcessing(const char * results_output_filename,
60 std::vector<int> & error_and_warning_codes,
61 std::vector<std::string> &error_and_warning_messages) = 0;
62 virtual void SetTimeData(double currentTime, int timeStep,
63 const char *results_output_filename) = 0;
64 virtual void CreateGlobalVariable(std::vector<std::string> &component_names, const double *data,
65 const char *results_output_filename) = 0;
66 virtual void CreateGlobalVariable(std::vector<std::string> &component_names, const int *data,
67 const char *results_output_filename) = 0;
68 virtual void InitializeGlobalPoints(int num_points, int dimension, const double *data,
69 const char *results_output_filename) = 0;
70 virtual void InitializeElementBlocks(const std::vector<int> &element_block_id_list,
71 const char * results_output_filename) = 0;
72 virtual void CreateElementBlock(const char *elem_block_name, int elem_block_id,
73 const std::string &elem_type, int nodes_per_elem, int num_elem,
74 const int64_t *global_elem_ids, int *connectivity,
75 const char *results_output_filename) = 0;
76 virtual void CreateElementBlock(const char *elem_block_name, int elem_block_id,
77 const std::string &elem_type, int nodes_per_elem, int num_elem,
78 const int64_t *global_elem_ids, int64_t *connectivity,
79 const char *results_output_filename) = 0;
80 virtual void CreateNodeSet(const char *node_set_name, int node_set_id, int num_ids,
81 const int *data, const char *results_output_filename) = 0;
82 virtual void CreateNodeSet(const char *node_set_name, int node_set_id, int num_ids,
83 const int64_t *data, const char *results_output_filename) = 0;
84 virtual void CreateSideSet(/*const char* side_set_name,*/
85 const char *ss_owner_name, int side_set_id, int num_ids,
86 const int *element_ids, const int *face_ids,
87 const char *results_output_filename) = 0;
88 virtual void CreateSideSet(/*const char* side_set_name,*/
89 const char *ss_owner_name, int side_set_id, int num_ids,
90 const int64_t *element_ids, const int64_t *face_ids,
91 const char *results_output_filename) = 0;
92 virtual void CreateElementVariable(std::vector<std::string> &component_names, int elem_block_id,
93 const double *data, const char *results_output_filename) = 0;
94 virtual void CreateElementVariable(std::vector<std::string> &component_names, int elem_block_id,
95 const int *data, const char *results_output_filename) = 0;
96 virtual void CreateElementVariable(std::vector<std::string> &component_names, int elem_block_id,
97 const int64_t *data, const char *results_output_filename) = 0;
98 virtual void CreateNodalVariable(std::vector<std::string> &component_names, const double *data,
99 const char *results_output_filename) = 0;
100 virtual void CreateNodalVariable(std::vector<std::string> &component_names, const int *data,
101 const char *results_output_filename) = 0;
102 virtual void CreateNodalVariable(std::vector<std::string> &component_names, const int64_t *data,
103 const char *results_output_filename) = 0;
104 virtual void ReleaseMemory(const char *results_output_filename) = 0;
105 virtual void logMemoryUsageAndTakeTimerReading(const char *results_output_filename) = 0;
106 virtual int parseFile(const std::string & filepath,
107 CatalystParserInterface::parse_info &pinfo) = 0;
108
109 virtual int parseString(const std::string &s, CatalystParserInterface::parse_info &pinfo) = 0;
110 };
111
112 typedef ParaViewCatalystIossAdapterBase *(*ParaViewCatalystIossAdapterBaseSignature)();
113
114 extern "C" {
115 ParaViewCatalystIossAdapterBase *ParaViewCatalystIossAdapterCreateInstance();
116 }
117
118 // ParaViewCatalystIossAdapter is a link between Ioss's mesh
119 // data structure and a ParaView vtkMultiBlockDataSet data structure.
120
121 class ParaViewCatalystIossAdapterImplementation;
122
123 class ParaViewCatalystIossAdapter : public ParaViewCatalystIossAdapterBase
124 {
125 public:
126 ParaViewCatalystIossAdapter() {}
127 virtual ~ParaViewCatalystIossAdapter() {}
128
129 // Description:
130 // Deletes pipeline with name results_output_filename and any associated
131 // logging data.
132 virtual void DeletePipeline(const char *results_output_filename);
133
134 // Description:
135 // Cleanup ParaView Catalyst and free resources.
136 virtual void CleanupCatalyst();
137
138 // Description:
139 // Initializes ParaView Catalyst to perform in-situ co-processing
140 // with the Python file catalyst_python_filename. This method can
141 // be called multiple times with different co-processing Python scripts.
142 // If initialization fails, co-processing will not occur in any other
143 // methods on this class.
144 // Additional arguments:
145 // UnderscoreVectors - joined vector variable names end in an underscore.
146 // ApplyDisplacements - a nodal variable named DISPL or displ is applied to
147 // the mesh node coordinates each time-step.
148 // restart_tag - if not empty, contains the current restart iteration string, ie s0001
149 // enable_logging - turn on logging in the adapter. Default is off.
150 // debug_level - enable catalyst debug output 0, 1, 2. Default is 0.
151 // results_output_filename - filename associated with the Ioss results output block.
152 // catalyst_output_directory - name of the output directory for storing Catalyst output.
153 // Default is CatalystOutput.
154 // catalyst_sierra_data - string data vector for development and debugging.
155 virtual void CreateNewPipeline(
156 const char *catalyst_python_filename, const char *catalyst_sierra_block_json,
157 const char *catalyst_sierra_separator_character, const char *catalyst_sierra_input_deck_name,
158 int UnderscoreVectors, int ApplyDisplacements, const char *restart_tag, int enable_logging,
159 int debug_level, const char *results_output_filename, const char *catalyst_output_directory,
160 std::vector<std::string> &catalyst_sierra_data);
161
162 // Description:
163 // Calls the ParaView Catalyst pipeline to run co-processing for this time iteration.
164 virtual void PerformCoProcessing(const char * results_output_filename,
165 std::vector<int> & error_and_warning_codes,
166 std::vector<std::string> &error_and_warning_messages);
167
168 // Description:
169 // Sets time data for this ParaView Catalyst co-processing iteration.
170 // currentTime is the current Ioss simulation time and timeStep is
171 // the current time iteration count.
172 virtual void SetTimeData(double currentTime, int timeStep, const char *results_output_filename);
173
174 // Description:
175 // Creates global vtkPoints array.
176 virtual void InitializeGlobalPoints(int num_points, int dimension, const double *data,
177 const char *results_output_filename);
178
179 // Description:
180 // Creates empty element blocks for the ids contained in element_block_id_list
181 virtual void InitializeElementBlocks(const std::vector<int> &element_block_id_list,
182 const char * results_output_filename);
183
184 // Description:
185 // Clears all nodal and element variables from the vtkMultiBlockDataSet.
186 // Clears the global vtkPoints.
187 virtual void ReleaseMemory(const char *results_output_filename);
188
189 // Description:
190 // Creates a global variable on the vtkMultiBlockDataSet.
191 virtual void CreateGlobalVariable(std::vector<std::string> &component_names, const double *data,
192 const char *results_output_filename);
193 virtual void CreateGlobalVariable(std::vector<std::string> &component_names, const int *data,
194 const char *results_output_filename);
195
196 // Description:
197 // Creates an element block on the vtkMultiBlockDataSet.
198 virtual void CreateElementBlock(const char *elem_block_name, int elem_block_id,
199 const std::string &elem_type, int nodes_per_elem, int num_elem,
200 const int64_t *global_elem_ids, int *connectivity,
201 const char *results_output_filename);
202 virtual void CreateElementBlock(const char *elem_block_name, int elem_block_id,
203 const std::string &elem_type, int nodes_per_elem, int num_elem,
204 const int64_t *global_elem_ids, int64_t *connectivity,
205 const char *results_output_filename);
206
207 // Description:
208 // Creates a node set on the vtkMultiBlockDataSet.
209 virtual void CreateNodeSet(const char *node_set_name, int node_set_id, int num_ids,
210 const int *data, const char *results_output_filename);
211 virtual void CreateNodeSet(const char *node_set_name, int node_set_id, int num_ids,
212 const int64_t *data, const char *results_output_filename);
213
214 // Description:
215 // Creates a side set (side block) on the vtkMultiBlockDataSet.
216 void CreateSideSet(/*const char* side_set_name,*/
217 const char *ss_owner_name, int side_set_id, int num_ids,
218 const int *element_ids, const int *face_ids,
219 const char *results_output_filename);
220 void CreateSideSet(/*const char* side_set_name,*/
221 const char *ss_owner_name, int side_set_id, int num_ids,
222 const int64_t *element_ids, const int64_t *face_ids,
223 const char *results_output_filename);
224
225 // Description:
226 // Creates an element variable on the vtkMultiBlockDataSet.
227 virtual void CreateElementVariable(std::vector<std::string> &component_names, int elem_block_id,
228 const double *data, const char *results_output_filename);
229 virtual void CreateElementVariable(std::vector<std::string> &component_names, int elem_block_id,
230 const int *data, const char *results_output_filename);
231 virtual void CreateElementVariable(std::vector<std::string> &component_names, int elem_block_id,
232 const int64_t *data, const char *results_output_filename);
233
234 // Description:
235 // Creates a nodal variable on the vtkMultiBlockDataSet.
236 virtual void CreateNodalVariable(std::vector<std::string> &component_names, const double *data,
237 const char *results_output_filename);
238 virtual void CreateNodalVariable(std::vector<std::string> &component_names, const int *data,
239 const char *results_output_filename);
240 virtual void CreateNodalVariable(std::vector<std::string> &component_names, const int64_t *data,
241 const char *results_output_filename);
242
243 // Description:
244 // Collects memory usage information from all processors and
245 // writes the min, max, and mean to the log file. Also writes the
246 // min, max, and mean of the elapsed time since this method was
247 // last called.
248 virtual void logMemoryUsageAndTakeTimerReading(const char *results_output_filename);
249
250 int parseFile(const std::string &filepath, CatalystParserInterface::parse_info &pinfo);
251
252 int parseString(const std::string &s, CatalystParserInterface::parse_info &pinfo);
253
254 virtual std::string getName() const { return "ParaViewCatalystIossAdapter"; }
255 };
256
257 #endif /* __PARAVIEW_CATALYST_IOSS_ADAPTER_H */
ParaViewCatalystIossAdapterBase
Definition: ParaViewCatalystIossAdapter.h:45
CatalystParserInterface.h
ParaViewCatalystIossAdapterBase::SetTimeData
virtual void SetTimeData(double currentTime, int timeStep, const char *results_output_filename)=0
ParaViewCatalystIossAdapter::~ParaViewCatalystIossAdapter
virtual ~ParaViewCatalystIossAdapter()
Definition: ParaViewCatalystIossAdapter.h:127
ParaViewCatalystIossAdapterBase::CreateNodalVariable
virtual void CreateNodalVariable(std::vector< std::string > &component_names, const double *data, const char *results_output_filename)=0
ParaViewCatalystIossAdapterBase::CreateElementBlock
virtual void CreateElementBlock(const char *elem_block_name, int elem_block_id, const std::string &elem_type, int nodes_per_elem, int num_elem, const int64_t *global_elem_ids, int *connectivity, const char *results_output_filename)=0
ParaViewCatalystIossAdapterBase::getName
virtual std::string getName() const
Definition: ParaViewCatalystIossAdapter.h:50
ParaViewCatalystIossAdapterBase::ReleaseMemory
virtual void ReleaseMemory(const char *results_output_filename)=0
ParaViewCatalystIossAdapterBase::~ParaViewCatalystIossAdapterBase
virtual ~ParaViewCatalystIossAdapterBase()
Definition: ParaViewCatalystIossAdapter.h:49
ParaViewCatalystIossAdapterBase::InitializeGlobalPoints
virtual void InitializeGlobalPoints(int num_points, int dimension, const double *data, const char *results_output_filename)=0
ParaViewCatalystIossAdapterBase::CreateNodeSet
virtual void CreateNodeSet(const char *node_set_name, int node_set_id, int num_ids, const int *data, const char *results_output_filename)=0
ParaViewCatalystIossAdapterBase::CreateGlobalVariable
virtual void CreateGlobalVariable(std::vector< std::string > &component_names, const double *data, const char *results_output_filename)=0
ParaViewCatalystIossAdapter::ParaViewCatalystIossAdapter
ParaViewCatalystIossAdapter()
Definition: ParaViewCatalystIossAdapter.h:126
ParaViewCatalystIossAdapterBase::CreateNewPipeline
virtual void CreateNewPipeline(const char *catalyst_python_filename, const char *catalyst_sierra_block_json, const char *catalyst_sierra_separator_character, const char *catalyst_sierra_input_deck_name, int UnderscoreVectors, int ApplyDisplacements, const char *restart_tag, int enable_logging, int debug_level, const char *results_output_filename, const char *catalyst_output_directory, std::vector< std::string > &catalyst_sierra_data)=0
ParaViewCatalystIossAdapterBase::InitializeElementBlocks
virtual void InitializeElementBlocks(const std::vector< int > &element_block_id_list, const char *results_output_filename)=0
ParaViewCatalystIossAdapter::getName
virtual std::string getName() const
Definition: ParaViewCatalystIossAdapter.h:254
ParaViewCatalystIossAdapterCreateInstance
ParaViewCatalystIossAdapterBase * ParaViewCatalystIossAdapterCreateInstance()
ParaViewCatalystIossAdapterBase::parseString
virtual int parseString(const std::string &s, CatalystParserInterface::parse_info &pinfo)=0
ParaViewCatalystIossAdapterBase::CreateSideSet
virtual void CreateSideSet(const char *ss_owner_name, int side_set_id, int num_ids, const int *element_ids, const int *face_ids, const char *results_output_filename)=0
ParaViewCatalystIossAdapterBase::ParaViewCatalystIossAdapterBase
ParaViewCatalystIossAdapterBase()
Definition: ParaViewCatalystIossAdapter.h:48
CatalystParserInterface::parse_info
Definition: CatalystParserInterface.h:60
ParaViewCatalystIossAdapterBase::CreateElementVariable
virtual void CreateElementVariable(std::vector< std::string > &component_names, int elem_block_id, const double *data, const char *results_output_filename)=0
ParaViewCatalystIossAdapterBase::CleanupCatalyst
virtual void CleanupCatalyst()=0
anonymous_namespace{Ioss_Utils.C}::data
std::vector< char > data
Definition: Ioss_Utils.C:78
ParaViewCatalystIossAdapterBase::DeletePipeline
virtual void DeletePipeline(const char *results_output_filename)=0
ParaViewCatalystIossAdapterBase::PerformCoProcessing
virtual void PerformCoProcessing(const char *results_output_filename, std::vector< int > &error_and_warning_codes, std::vector< std::string > &error_and_warning_messages)=0
ParaViewCatalystIossAdapterBase::logMemoryUsageAndTakeTimerReading
virtual void logMemoryUsageAndTakeTimerReading(const char *results_output_filename)=0
ParaViewCatalystIossAdapter
Definition: ParaViewCatalystIossAdapter.h:123
ParaViewCatalystIossAdapterBase::parseFile
virtual int parseFile(const std::string &filepath, CatalystParserInterface::parse_info &pinfo)=0