suanPan
Converter.h
Go to the documentation of this file.
1/*******************************************************************************
2 * Copyright (C) 2017-2024 Theodore Chang
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ******************************************************************************/
17
18#ifndef CONVERTER_H
19#define CONVERTER_H
20
21#include <fstream>
22#include <unordered_map>
23
24struct Converter {
25 static std::istringstream clean(std::string);
26 static std::string extract_name(const std::string&, const std::string& = "");
27
28 int boundary_tag = 0;
29 int set_tag = 0;
31 int load_tag = 0;
32 int step_tag = 0;
35
36 std::string output_path;
37
38 std::unordered_map<std::string, int> node_set_pool;
39 std::unordered_map<std::string, int> element_set_pool;
40 std::unordered_map<std::string, int> amplitude_pool;
41 std::unordered_map<std::string, int> step_pool;
42
43 explicit Converter(std::string&&);
44
45 int process(std::ifstream&, std::ofstream&);
46
47 int process_amplitude(std::ifstream&, std::ofstream&, const std::string&, const std::string&);
48 int process_boundary(std::ifstream&, std::ofstream&, const std::string&, const std::string&);
49 int process_cload(std::ifstream&, std::ofstream&, const std::string&);
50 int process_element(std::ifstream&, std::ofstream&, const std::string&) const;
51 int process_node(std::ifstream&, std::ofstream&) const;
52 int process_node_set(std::ifstream&, std::ofstream&, const std::string&, bool);
53 int process_element_set(std::ifstream&, std::ofstream&, const std::string&, bool);
54 int process_step(std::ifstream&, std::ofstream&, const std::string&);
55
56 [[nodiscard]] std::string extract_element_type(const std::string&) const;
57
58 bool getline(std::istream&, std::string&) const;
59};
60
61#endif
Definition: Converter.h:24
int step_tag
Definition: Converter.h:32
int load_tag
Definition: Converter.h:31
std::unordered_map< std::string, int > step_pool
Definition: Converter.h:41
int process_cload(std::ifstream &, std::ofstream &, const std::string &)
Definition: Converter.cpp:208
int converger_tag
Definition: Converter.h:34
std::string output_path
Definition: Converter.h:36
static std::istringstream clean(std::string)
Definition: Converter.cpp:380
std::string extract_element_type(const std::string &) const
Definition: Converter.cpp:235
int process_node_set(std::ifstream &, std::ofstream &, const std::string &, bool)
Definition: Converter.cpp:271
int integrator_tag
Definition: Converter.h:33
int process(std::ifstream &, std::ofstream &)
Definition: Converter.cpp:26
std::unordered_map< std::string, int > node_set_pool
Definition: Converter.h:38
int process_step(std::ifstream &, std::ofstream &, const std::string &)
Definition: Converter.cpp:327
std::unordered_map< std::string, int > amplitude_pool
Definition: Converter.h:40
static std::string extract_name(const std::string &, const std::string &="")
Definition: Converter.cpp:386
int set_tag
Definition: Converter.h:29
int process_node(std::ifstream &, std::ofstream &) const
Definition: Converter.cpp:254
int boundary_tag
Definition: Converter.h:28
std::unordered_map< std::string, int > element_set_pool
Definition: Converter.h:39
int process_element(std::ifstream &, std::ofstream &, const std::string &) const
Definition: Converter.cpp:220
int amplitude_tag
Definition: Converter.h:30
bool getline(std::istream &, std::string &) const
Definition: Converter.cpp:368
int process_element_set(std::ifstream &, std::ofstream &, const std::string &, bool)
Definition: Converter.cpp:299
int process_boundary(std::ifstream &, std::ofstream &, const std::string &, const std::string &)
Definition: Converter.cpp:132
int process_amplitude(std::ifstream &, std::ofstream &, const std::string &, const std::string &)
Definition: Converter.cpp:71
Converter(std::string &&)
Definition: Converter.cpp:23