7#include "iotm_export.h"
21#include <unordered_map>
37 using ErrorHandler = std::function<void(
const std::ostringstream &)>;
44 case AssemblyType::ASSEMBLY:
return out <<
"ASSEMBLY";
break;
45 case AssemblyType::BLOCK:
return out <<
"ELEMENT_BLOCK";
break;
46 case AssemblyType::SIDESET:
return out <<
"SIDESET";
break;
47 case AssemblyType::NODESET:
return out <<
"NODESET";
break;
48 default:
return out <<
"INVALID";
break;
50 return out <<
"INVALID[" << (unsigned)t <<
"]";
114 if (
nullptr != assemblyData) {
120 for (
const std::string &member : assemblyData->
data) {
130 bool isCyclic =
false;
132 if (
nullptr != assemblyData) {
140 for (
const std::string &member : assemblyData->
data) {
168 ErrorHandler errorHandler = [](
const std::ostringstream &errmsg) {
169 default_error_handler(errmsg);
171 set_error_handler(errorHandler);
185 void parse(
const std::string &parseData)
189 for (
const auto &option : options) {
190 parse_option_group(option);
197 std::ostringstream errmsg;
198 errmsg <<
"Error! Assembly with name: " << m_name <<
" does not have a defined type.";
199 m_errorHandler(errmsg);
204 void parse_option(std::string optionName,
const std::string &optionValue)
208 if (optionName ==
"name") {
209 parse_name(optionValue);
211 else if (optionName ==
"type") {
212 parse_assembly_type(optionValue);
214 else if (optionName ==
"member") {
215 parse_assembly_members(optionValue);
218 std::ostringstream errmsg;
219 errmsg <<
"Unrecognized assembly option: " << optionName;
220 m_errorHandler(errmsg);
226 if (!option.empty()) {
229 if (optionTokens.size() != 2) {
230 std::ostringstream errmsg;
231 errmsg <<
"Unrecognized assembly option: " << option;
232 m_errorHandler(errmsg);
235 parse_option(optionTokens[0], optionTokens[1]);
245 if (type ==
"assembly") {
246 m_assemblyType = ASSEMBLY;
248 else if (type ==
"block") {
249 m_assemblyType =
BLOCK;
251 else if (type ==
"sideset") {
252 m_assemblyType = SIDESET;
254 else if (type ==
"nodeset") {
255 m_assemblyType = NODESET;
258 std::ostringstream errmsg;
259 errmsg <<
"Unrecognized assembly type: " << type;
260 m_errorHandler(errmsg);
266 std::vector<std::string> assemblyData =
get_tokens(data,
",");
267 for (std::string &member : assemblyData) {
271 m_members = assemblyData;
274 std::vector<std::string> m_members{};
275 std::string m_name{};
Definition Iotm_TextMeshDataTypes.h:312
std::vector< std::string > && get_forward_traversal_list(const std::string &assembly) const
Definition Iotm_TextMeshAssembly.h:92
std::vector< std::string > m_traversalList
Definition Iotm_TextMeshAssembly.h:160
void fill_traversal(const std::string &assembly) const
Definition Iotm_TextMeshAssembly.h:111
bool is_cyclic(const std::string &assembly) const
Definition Iotm_TextMeshAssembly.h:76
std::vector< std::string > && get_reverse_traversal_list(const std::string &assembly) const
Definition Iotm_TextMeshAssembly.h:100
std::unordered_map< std::string, bool > m_visitedNodes
Definition Iotm_TextMeshAssembly.h:159
bool check_for_cycle(const std::string &assembly) const
Definition Iotm_TextMeshAssembly.h:128
Assemblies()
Definition Iotm_TextMeshAssembly.h:71
void initialize_graph() const
Definition Iotm_TextMeshAssembly.h:149
bool is_cyclic() const
Definition Iotm_TextMeshAssembly.h:82
Definition Iotm_TextMeshAssembly.h:164
void parse_assembly_members(const std::string &data)
Definition Iotm_TextMeshAssembly.h:264
void parse(const std::string &parseData)
Definition Iotm_TextMeshAssembly.h:185
void parse_assembly_type(std::string type)
Definition Iotm_TextMeshAssembly.h:241
void parse_option_group(const std::string &option)
Definition Iotm_TextMeshAssembly.h:224
AssemblyType get_assembly_type() const
Definition Iotm_TextMeshAssembly.h:178
const std::vector< std::string > & get_assembly_data()
Definition Iotm_TextMeshAssembly.h:180
std::string get_name()
Definition Iotm_TextMeshAssembly.h:176
void verify_parse() const
Definition Iotm_TextMeshAssembly.h:194
void set_error_handler(ErrorHandler errorHandler)
Definition Iotm_TextMeshAssembly.h:174
ErrorHandler m_errorHandler
Definition Iotm_TextMeshAssembly.h:277
void parse_name(const std::string &data)
Definition Iotm_TextMeshAssembly.h:239
AssemblyParser()
Definition Iotm_TextMeshAssembly.h:166
void parse_option(std::string optionName, const std::string &optionValue)
Definition Iotm_TextMeshAssembly.h:204
Definition Iotm_TextMeshEntityGroup.h:53
const std::vector< std::string > & get_part_names() const
Definition Iotm_TextMeshEntityGroup.h:105
const std::vector< AssemblyData > & get_group_data() const
Definition Iotm_TextMeshEntityGroup.h:103
size_t size() const
Definition Iotm_TextMeshEntityGroup.h:101
void convert_to_upper_case(std::string &str)
Definition Iotm_TextMeshFuncs.h:88
std::function< void(const std::ostringstream &)> ErrorHandler
Definition Iotm_TextMeshAdjacencyGraph.h:35
std::string AssemblyDataType
Definition Iotm_TextMeshAssembly.h:53
AssemblyType
Definition Iotm_TextMeshAssembly.h:39
@ INVALID_ASSEMBLY
Definition Iotm_TextMeshAssembly.h:39
@ NODESET
Definition Iotm_TextMeshAssembly.h:39
@ ASSEMBLY
Definition Iotm_TextMeshAssembly.h:39
@ SIDESET
Definition Iotm_TextMeshAssembly.h:39
@ BLOCK
Definition Iotm_TextMeshAssembly.h:39
std::ostream & operator<<(std::ostream &out, const AssemblyType &t)
Definition Iotm_TextMeshAssembly.h:41
std::vector< std::string > get_tokens(const std::string &str, const std::string &separators)
Definition Iotm_TextMeshFuncs.h:68
void convert_to_lower_case(std::string &str)
Definition Iotm_TextMeshFuncs.h:93
A namespace for the textmesh database format.
Definition Iotm_DatabaseIO.C:95
Definition Iotm_TextMeshAssembly.h:56
AssemblyDataType DataType
Definition Iotm_TextMeshAssembly.h:57
AssemblyType get_assembly_type() const
Definition Iotm_TextMeshAssembly.h:60
void set_assembly_type(AssemblyType type_)
Definition Iotm_TextMeshAssembly.h:59
Definition Iotm_TextMeshEntityGroup.h:37
std::vector< DataType > data
Definition Iotm_TextMeshEntityGroup.h:45