From 76faea6e5670b140d876134f4c335608b5405a36 Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Sat, 27 Jul 2024 18:03:43 +0200 Subject: [PATCH 01/17] distinction between command and option --- src/conv/k-g/k_parser.cpp | 216 +++++++++++++++++++++++++++++++++++++- 1 file changed, 212 insertions(+), 4 deletions(-) diff --git a/src/conv/k-g/k_parser.cpp b/src/conv/k-g/k_parser.cpp index bc5faf686c..816026ff26 100644 --- a/src/conv/k-g/k_parser.cpp +++ b/src/conv/k-g/k_parser.cpp @@ -37,8 +37,39 @@ enum class KState { Ignore, Include, Node, + Element_Beam, + Element_Beam_Pulley, + Element_Beam_Source, + Element_Bearing, + Element_Blanking, + Element_Direct_Matrix_Input, + Element_Discrete, + Element_Discrete_Sphere, + Element_Generalized_Shell, + Element_Generalized_Solid, + Element_Inertia, + Element_Interpolation_Shell, + Element_Interpolation_Solid, + Element_Lancing, + Element_Mass, + Element_Mass_Matrix, + Element_Mass_Part, + Element_Plotel, + Element_Seatbealt, + Element_Seatbealt_Accelerometer, + Element_Seatbealt_Pretensioner, + Element_Seatbealt_Retractor, + Element_Seatbealt_Sensor, + Element_Seatbealt_Slipring, Element_Shell, + Element_Shell_Nurbs_Patch, + Element_Shell_Source_Sink, Element_Solid, + Element_Solid_Nurbs_Patch, + Element_Solid_Peri, + Element_Sph, + Element_Trim, + Element_Tshell, Part, Part_Adaptive_Failure, Section_Shell, @@ -188,6 +219,7 @@ bool parse_k std::string line = read_line(is); std::vector tokens; const size_t FirstNode = 2; + std::vector elementOptions; if (line.size() > 0) tokens = parse_line(line.c_str()); @@ -222,10 +254,186 @@ bool parse_k std::cout << "Unexpected command " << tokens[0] << " in k-file " << fileName << "\n"; } else if (command[0] == "ELEMENT") { - if ((command.size() == 2) && (command[1] == "SHELL")) - state = KState::Element_Shell; - else if ((command.size() == 2) && (command[1] == "SOLID")) { - state = KState::Element_Solid; + if ((command.size() > 1) && (command[1] == "BEAM")) { + if ((command.size() > 2) && (command[2] == "PULLEY")) { + state = KState::Element_Beam_Pulley; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + else if ((command.size() > 2) && (command[2] == "SOURCE")) { + state = KState::Element_Beam_Source; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + else { + state = KState::Element_Beam; + + elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + } + } + else if ((command.size() > 1) && (command[1] == "BEARING")) { + state = KState::Element_Bearing; + + elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + } + else if ((command.size() > 1) && (command[1] == "BLANKING")) { + state = KState::Element_Blanking; + + elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + } + else if ((command.size() > 3) && (command[1] == "DIRECT") && (command[2] == "MATRIX") && (command[3] == "INPUT")) { + state = KState::Element_Direct_Matrix_Input; + + elementOptions.insert(elementOptions.end(), command.begin() + 4, command.end()); + } + else if ((command.size() > 1) && (command[1] == "DISCRETE")) { + if ((command.size() > 2) && (command[2] == "SPHERE")) { + state = KState::Element_Discrete_Sphere; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + else { + state = KState::Element_Discrete; + + elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + } + } + else if ((command.size() > 2) && (command[1] == "GENERALIZED")) { + if ((command[2] == "SHELL")) { + state = KState::Element_Generalized_Shell; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + else { + state = KState::Element_Generalized_Solid; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + } + else if ((command.size() > 1) && (command[1] == "INERTIA")) { + state = KState::Element_Inertia; + + elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + } + else if ((command.size() > 2) && (command[1] == "INTERPOLATION")) { + if (command[2] == "SHELL") { + state = KState::Element_Interpolation_Shell; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + else { + state = KState::Element_Interpolation_Solid; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + } + else if ((command.size() > 1) && (command[1] == "LANCING")) { + state = KState::Element_Lancing; + + elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + } + else if ((command.size() > 1) && (command[1] == "MASS")) { + if ((command.size() > 2) && (command[2] == "MATRIX")) { + state = KState::Element_Mass_Matrix; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + else if ((command.size() > 2) && (command[2] == "PART")) { + state = KState::Element_Mass_Part; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + else { + state = KState::Element_Mass; + + elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + } + } + else if ((command.size() > 1) && (command[1] == "PLOTEL")) { + state = KState::Element_Plotel; + + elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + } + else if ((command.size() > 1) && (command[1] == "SEATBELT")) { + if ((command.size() > 2) && (command[2] == "ACCELEROMETER")) { + state = KState::Element_Seatbealt_Accelerometer; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + else if ((command.size() > 2) && (command[2] == "PRETENSIONER")) { + state = KState::Element_Seatbealt_Pretensioner; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + else if ((command.size() > 2) && (command[2] == "RETRACTOR")) { + state = KState::Element_Seatbealt_Retractor; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + else if ((command.size() > 2) && (command[2] == "SENSOR")) { + state = KState::Element_Seatbealt_Sensor; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + else if ((command.size() > 2) && (command[2] == "SLIPRING")) { + state = KState::Element_Seatbealt_Slipring; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + else { + state = KState::Element_Seatbealt; + + elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + } + } + else if ((command.size() > 1) && (command[1] == "SHELL")) { + if ((command.size() > 2) && (command[2] == "NURBS")) { + state = KState::Element_Shell_Nurbs_Patch; + + elementOptions.insert(elementOptions.end(), command.begin() + 4, command.end()); + } + else if ((command.size() > 2) && (command[2] == "SOURCE")) { + state = KState::Element_Shell_Source_Sink; + + elementOptions.insert(elementOptions.end(), command.begin() + 4, command.end()); + } + else { + state = KState::Element_Shell; + + elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + } + } + else if ((command.size() > 1) && (command[1] == "SOLID")) { + if ((command.size() > 2) && (command[2] == "NURBS")) { + state = KState::Element_Solid_Nurbs_Patch; + + elementOptions.insert(elementOptions.end(), command.begin() + 4, command.end()); + } + else if ((command.size() > 2) && (command[2] == "PERI")) { + state = KState::Element_Solid_Peri; + + elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + } + else { + state = KState::Element_Solid; + + elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + } + } + else if ((command.size() > 1) && (command[1] == "SPH")) { + state = KState::Element_Sph; + + elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + } + else if ((command.size() > 1) && (command[1] == "TRIM")) { + state = KState::Element_Trim; + + elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + } + else if ((command.size() > 1) && (command[1] == "TSHELL")) { + state = KState::Element_Tshell; + + elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); } else std::cout << "Unexpected command " << tokens[0] << " in k-file " << fileName << "\n"; From 8d68d75d2c2940fc0d96546371a57ddfca57f1df Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Wed, 31 Jul 2024 17:46:34 +0200 Subject: [PATCH 02/17] a solution for handling element options --- src/conv/k-g/k_parser.cpp | 169 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 163 insertions(+), 6 deletions(-) diff --git a/src/conv/k-g/k_parser.cpp b/src/conv/k-g/k_parser.cpp index 816026ff26..01e056831e 100644 --- a/src/conv/k-g/k_parser.cpp +++ b/src/conv/k-g/k_parser.cpp @@ -72,10 +72,33 @@ enum class KState { Element_Tshell, Part, Part_Adaptive_Failure, + Section_Ale1d, + Section_Ale2d, + Section_Beam, + Section_Beam_AISC, + Section_Discrete, + Section_Fpd, + Section_Point_Source, + Section_Point_source_Mixture, + Section_Seatbelt, Section_Shell, - Section_Solid + Section_Solid, + Section_Solid_Peri, + Section_Sph, + Section_Tshell }; +enum class Element_Beam_Options { + Thickness, + Scalar, + Scalr, + Section, + Pid, + Offset, + Orientation, + Warpage, + Elbow +}; static std::string read_line ( @@ -214,12 +237,17 @@ bool parse_k size_t partLinesRead = 0; std::string partTitle; size_t sectionLinesRead = 0; + size_t elementOptionsCounter = 0; std::string sectionTitle; int sectionId = -1; std::string line = read_line(is); std::vector tokens; const size_t FirstNode = 2; std::vector elementOptions; + std::vector sectionOptions; + std::vector elementBeamOptions; + //Elment_beam_options.push_back(Elmenent_Beam_Options::Pid); + //std::map elementOptions; if (line.size() > 0) tokens = parse_line(line.c_str()); @@ -258,17 +286,51 @@ bool parse_k if ((command.size() > 2) && (command[2] == "PULLEY")) { state = KState::Element_Beam_Pulley; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + //elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end());//ElEMENT_BEAM_PULLEY doesn't have options } else if ((command.size() > 2) && (command[2] == "SOURCE")) { state = KState::Element_Beam_Source; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + //elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end());//ELEMENT_BEAM_SOURCE doesn't have options } else { state = KState::Element_Beam; elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + + if (elementOptions.size() > 0) { + for (size_t i_o = 0; i_o < elementOptions.size(); ++i_o) { + if (elementOptions[i_o] == "ThICKNESS") { + elementBeamOptions.push_back(Element_Beam_Options::Thickness); + } + else if (elementOptions[i_o] == "SCALAR") { + elementBeamOptions.push_back(Element_Beam_Options::Scalar); + } + else if (elementOptions[i_o] == "SCALR") { + elementBeamOptions.push_back(Element_Beam_Options::Scalr); + } + else if (elementOptions[i_o] == "SECTION") { + elementBeamOptions.push_back(Element_Beam_Options::Section); + } + else if (elementOptions[i_o] == "PID") { + elementBeamOptions.push_back(Element_Beam_Options::Pid); + } + else if (elementOptions[i_o] == "OFFSET") { + elementBeamOptions.push_back(Element_Beam_Options::Offset); + } + else if (elementOptions[i_o] == "ORIENTATION") { + elementBeamOptions.push_back(Element_Beam_Options::Orientation); + } + else if (elementOptions[i_o] == "WARPAGE") { + elementBeamOptions.push_back(Element_Beam_Options::Warpage); + } + else if (elementOptions[i_o] == "ELBOW") { + elementBeamOptions.push_back(Element_Beam_Options::Elbow); + } + else + std::cout << "Unhandeled Element_Beam option" << elementOptions[i_o] << "in k-file" << fileName << "\n"; + } + } } } else if ((command.size() > 1) && (command[1] == "BEARING")) { @@ -440,9 +502,9 @@ bool parse_k } else if (command[0] == "PART") { if ((command.size() == 1) || (command[1] == "INERTIA")) { - state = KState::Part; + state = KState::Part; partLinesRead = 0; - partTitle = ""; + partTitle = ""; } else if ((command.size() == 3) && (command[1] == "ADAPTIVE") && (command[2] == "FAILURE")) { state = KState::Part_Adaptive_Failure; @@ -451,7 +513,19 @@ bool parse_k std::cout << "Unexpected command " << tokens[0] << " in k-file " << fileName << "\n"; } else if (command[0] == "SECTION") { - if (command[1] == "SHELL") { + if (command[1] == "ALE1D"){ + state = KState::Section_Ale1d; + sectionTitle = ""; + sectionId = -1; + + if (command.size() > 2) { + if (command[2] == "TITLE") + sectionLinesRead = 0; + else + sectionOptions.insert(sectionOptions.end(), command.begin() + 2, command.end()); + } + } + else if (command[1] == "SHELL") { state = KState::Section_Shell; sectionTitle = ""; sectionId = -1; @@ -685,6 +759,89 @@ bool parse_k } break; } + case KState::Element_Beam: { + if (elementBeamOptions.size() == 0 || elementOptionsCounter == 0) { + if (tokens.size() < 10) { + std::cout << "Too short ELEMENT_BEAM in k-file" << fileName << "\n"; + break; + } + int eid = stoi(tokens[0]); + + if (data.elements.find(eid) != data.elements.end()) { + std::cout << "Duplicat Element ID" << eid << " in k-file" << fileName << "\n"; + break; + } + + KElement element; + + for (int i_n = 0; i_n < 5; ++i_n) { + element.nodes.push_back(stoi(tokens[i_n + FirstNode])); + } + + data.elements[eid] = element; + + int pid = stoi(tokens[1]); + data.parts[pid].elements.insert(eid); + break; + } + else if (elementBeamOptions.size() > 0) { + Element_Beam_Options currentOption = elementBeamOptions[elementOptionsCounter]; + switch (currentOption) + { + case Element_Beam_Options::Thickness: { + //handle the thickness line + elementOptionsCounter++; + break; + } + case Element_Beam_Options::Scalar: { + //handle the Scalar line + elementOptionsCounter++; + break; + } + case Element_Beam_Options::Scalr: { + //handle the Scalr line + elementOptionsCounter++; + break; + } + case Element_Beam_Options::Section: { + //handle the section line + elementOptionsCounter++; + break; + } + case Element_Beam_Options::Pid: { + //handle the Pid line + elementOptionsCounter++; + break; + } + case Element_Beam_Options::Offset: { + //handle the offset line + elementOptionsCounter++; + break; + } + case Element_Beam_Options::Orientation: { + //handle the Orientation line + elementOptionsCounter++; + break; + } + case Element_Beam_Options::Warpage: { + //handle the Warpage line + elementOptionsCounter++; + break; + } + case Element_Beam_Options::Elbow: { + // handle the Elbow line + elementOptionsCounter++; + break; + } + default: + break; + } + + if (elementOptionsCounter == elementBeamOptions.size() - 1) { + elementOptionsCounter = 0; + } + } + } } } From f4c3d7f897e8ae678ce080308bdafd4186cfa7a4 Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Wed, 31 Jul 2024 17:53:56 +0200 Subject: [PATCH 03/17] minor fix --- src/conv/k-g/k_parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conv/k-g/k_parser.cpp b/src/conv/k-g/k_parser.cpp index 01e056831e..f7f7b7c7d3 100644 --- a/src/conv/k-g/k_parser.cpp +++ b/src/conv/k-g/k_parser.cpp @@ -784,7 +784,7 @@ bool parse_k data.parts[pid].elements.insert(eid); break; } - else if (elementBeamOptions.size() > 0) { + else if ((elementBeamOptions.size()) > 0 && (elementOptionsCounter < elementBeamOptions.size())) { Element_Beam_Options currentOption = elementBeamOptions[elementOptionsCounter]; switch (currentOption) { From 663dfb3f3dff8dc63e053fccd0186aa1a108e367 Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Sat, 3 Aug 2024 13:49:33 +0200 Subject: [PATCH 04/17] handling element beam options --- src/conv/k-g/k_parser.cpp | 240 ++++++++++++++++++++++++++++++-------- src/conv/k-g/k_parser.h | 9 +- 2 files changed, 194 insertions(+), 55 deletions(-) diff --git a/src/conv/k-g/k_parser.cpp b/src/conv/k-g/k_parser.cpp index f7f7b7c7d3..4381c61230 100644 --- a/src/conv/k-g/k_parser.cpp +++ b/src/conv/k-g/k_parser.cpp @@ -88,7 +88,7 @@ enum class KState { Section_Tshell }; -enum class Element_Beam_Options { +enum class Options { Thickness, Scalar, Scalr, @@ -237,7 +237,7 @@ bool parse_k size_t partLinesRead = 0; std::string partTitle; size_t sectionLinesRead = 0; - size_t elementOptionsCounter = 0; + size_t optionsCounter = 0; std::string sectionTitle; int sectionId = -1; std::string line = read_line(is); @@ -245,7 +245,7 @@ bool parse_k const size_t FirstNode = 2; std::vector elementOptions; std::vector sectionOptions; - std::vector elementBeamOptions; + std::vector options; //Elment_beam_options.push_back(Elmenent_Beam_Options::Pid); //std::map elementOptions; @@ -300,32 +300,32 @@ bool parse_k if (elementOptions.size() > 0) { for (size_t i_o = 0; i_o < elementOptions.size(); ++i_o) { - if (elementOptions[i_o] == "ThICKNESS") { - elementBeamOptions.push_back(Element_Beam_Options::Thickness); + if (elementOptions[i_o] == "THICKNESS") { + options.push_back(Options::Thickness); } else if (elementOptions[i_o] == "SCALAR") { - elementBeamOptions.push_back(Element_Beam_Options::Scalar); + options.push_back(Options::Scalar); } else if (elementOptions[i_o] == "SCALR") { - elementBeamOptions.push_back(Element_Beam_Options::Scalr); + options.push_back(Options::Scalr); } else if (elementOptions[i_o] == "SECTION") { - elementBeamOptions.push_back(Element_Beam_Options::Section); + options.push_back(Options::Section); } else if (elementOptions[i_o] == "PID") { - elementBeamOptions.push_back(Element_Beam_Options::Pid); + options.push_back(Options::Pid); } else if (elementOptions[i_o] == "OFFSET") { - elementBeamOptions.push_back(Element_Beam_Options::Offset); + options.push_back(Options::Offset); } else if (elementOptions[i_o] == "ORIENTATION") { - elementBeamOptions.push_back(Element_Beam_Options::Orientation); + options.push_back(Options::Orientation); } else if (elementOptions[i_o] == "WARPAGE") { - elementBeamOptions.push_back(Element_Beam_Options::Warpage); + options.push_back(Options::Warpage); } else if (elementOptions[i_o] == "ELBOW") { - elementBeamOptions.push_back(Element_Beam_Options::Elbow); + options.push_back(Options::Elbow); } else std::cout << "Unhandeled Element_Beam option" << elementOptions[i_o] << "in k-file" << fileName << "\n"; @@ -760,86 +760,224 @@ bool parse_k break; } case KState::Element_Beam: { - if (elementBeamOptions.size() == 0 || elementOptionsCounter == 0) { + KElement element; + int pid; + int eid; + + if (options.size() == 0 || optionsCounter == 0) { if (tokens.size() < 10) { std::cout << "Too short ELEMENT_BEAM in k-file" << fileName << "\n"; break; } - int eid = stoi(tokens[0]); + eid = stoi(tokens[0]); if (data.elements.find(eid) != data.elements.end()) { std::cout << "Duplicat Element ID" << eid << " in k-file" << fileName << "\n"; break; } - KElement element; - for (int i_n = 0; i_n < 5; ++i_n) { element.nodes.push_back(stoi(tokens[i_n + FirstNode])); } data.elements[eid] = element; - int pid = stoi(tokens[1]); + pid = stoi(tokens[1]); data.parts[pid].elements.insert(eid); break; } - else if ((elementBeamOptions.size()) > 0 && (elementOptionsCounter < elementBeamOptions.size())) { - Element_Beam_Options currentOption = elementBeamOptions[elementOptionsCounter]; + else if ((options.size() > 0)) { + Options currentOption; + + if (optionsCounter < options.size()) { + currentOption = options[optionsCounter]; + } + else { + optionsCounter = 0; + currentOption = options[optionsCounter]; + } + switch (currentOption) { - case Element_Beam_Options::Thickness: { - //handle the thickness line - elementOptionsCounter++; + case Options::Thickness: { + if (tokens.size() < 5) { + std::cout << "Too short option THICKNESS in k-file " << fileName << "\n"; + break; + } + + for (size_t i_p = 0; i_p < tokens.size(); ++i_p) { + double param = stod(tokens[i_p]); + element.options["THICKNESS"].push_back(param); + } + + data.elements[eid] = element; + + ++optionsCounter; break; } - case Element_Beam_Options::Scalar: { - //handle the Scalar line - elementOptionsCounter++; + case Options::Scalar: { + //Nothing to do + ++optionsCounter; break; } - case Element_Beam_Options::Scalr: { - //handle the Scalr line - elementOptionsCounter++; + case Options::Scalr: { + //Nothing to do + ++optionsCounter; break; } - case Element_Beam_Options::Section: { - //handle the section line - elementOptionsCounter++; + case Options::Section: { + if (tokens.size() < 7) { + std::cout << "Too short option Section in k-file " << fileName << "\n"; + break; + } + double temp; + + if (tokens[0] == "EQ.SECTION_01") { + temp = 1.0; + } + else if (tokens[0] == "EQ.SECTION_02") { + temp = 2.0; + } + else if (tokens[0] == "EQ.SECTION_03") { + temp = 3.0; + } + else if (tokens[0] == "EQ.SECTION_04") { + temp = 4.0; + } + else if (tokens[0] == "EQ.SECTION_05") { + temp = 5.0; + } + else if (tokens[0] == "EQ.SECTION_06") { + temp = 6.0; + } + else if (tokens[0] == "EQ.SECTION_07") { + temp = 7.0; + } + else if (tokens[0] == "EQ.SECTION_08") { + temp = 8.0; + } + else if (tokens[0] == "EQ.SECTION_09") { + temp = 9.0; + } + else if (tokens[0] == "EQ.SECTION_10") { + temp = 10.0; + } + else if (tokens[0] == "EQ.SECTION_11") { + temp = 11.0; + } + else if (tokens[0] == "EQ.SECTION_12") { + temp = 12.0; + } + else if (tokens[0] == "EQ.SECTION_13") { + temp = 13.0; + } + else if (tokens[0] == "EQ.SECTION_14") { + temp = 14.0; + } + else if (tokens[0] == "EQ.SECTION_15") { + temp = 15.0; + } + else if (tokens[0] == "EQ.SECTION_16") { + temp = 16.0; + } + else if (tokens[0] == "EQ.SECTION_17") { + temp = 17.0; + } + else if (tokens[0] == "EQ.SECTION_18") { + temp = 18.0; + } + else if (tokens[0] == "EQ.SECTION_19") { + temp = 19.0; + } + else if (tokens[0] == "EQ.SECTION_20") { + temp = 20.0; + } + else if (tokens[0] == "EQ.SECTION_21") { + temp = 21.0; + } + else if (tokens[0] == "EQ.SECTION_22") { + temp = 22.0; + } + + element.options["SECTION"].push_back(temp); + + for (size_t i_p = 1; i_p < tokens.size(); ++i_p) { + temp = stod(tokens[1]); + element.options["SECTION"].push_back(temp); + } + data.elements[eid] = element; + ++optionsCounter; break; } - case Element_Beam_Options::Pid: { - //handle the Pid line - elementOptionsCounter++; + case Options::Pid: { + //Nothing to do + ++optionsCounter; break; } - case Element_Beam_Options::Offset: { - //handle the offset line - elementOptionsCounter++; + case Options::Offset: { + if (tokens.size() < 6) { + std::cout << "To short OFFSET option in k-file " << fileName << "\n"; + break; + } + + for (size_t i_p = 0; i_p < tokens.size(); ++i_p) { + double temp = stod(tokens[i_p]); + element.options["OFFSET"].push_back(temp); + } + + data.elements[eid] = element; + + ++optionsCounter; break; } - case Element_Beam_Options::Orientation: { - //handle the Orientation line - elementOptionsCounter++; + case Options::Orientation: { + if (tokens.size() < 3) { + std::cout << "To short ORIENTATION option in k-file" << fileName << "\n"; + break; + } + + for (size_t i_p = 0; i_p < tokens.size(); ++i_p) { + double temp = stod(tokens[i_p]); + element.options["ORIENTATION"].push_back(temp); + } + + data.elements[eid] = element; + + ++optionsCounter; break; } - case Element_Beam_Options::Warpage: { - //handle the Warpage line - elementOptionsCounter++; + case Options::Warpage: { + if (tokens.size() < 2) { + std::cout << "To short WARPAGE option in k-file" << fileName << "\n"; + break; + } + + for (size_t i_p = 0; i_p < tokens.size(); ++i_p) { + double temp = stod(tokens[i_p]); + element.options["WARPAGE"].push_back(temp); + } + + data.elements[eid] = element; + + ++optionsCounter; break; } - case Element_Beam_Options::Elbow: { - // handle the Elbow line - elementOptionsCounter++; + case Options::Elbow: { + if (tokens.size() < 1) { + std::cout << "empty ELBOW option in k-file" << fileName << "\n"; + break; + } + double temp = stod(tokens[0]); + element.options["ELBOW"].push_back(temp); + + data.elements[eid] = element; + + ++optionsCounter; break; } default: break; } - - if (elementOptionsCounter == elementBeamOptions.size() - 1) { - elementOptionsCounter = 0; - } } } diff --git a/src/conv/k-g/k_parser.h b/src/conv/k-g/k_parser.h index 299ff46f33..860f13c0bf 100644 --- a/src/conv/k-g/k_parser.h +++ b/src/conv/k-g/k_parser.h @@ -42,14 +42,15 @@ struct KNode { struct KElement { - std::vector nodes; + std::vector nodes; + std::map> options; }; struct KPart { - std::string title; - std::set elements; - int section; + std::string title; + std::set elements; + int section; std::map attributes; }; From b2937c3a05836d46c41a165229bbf2a97ca83175 Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Mon, 5 Aug 2024 22:10:21 +0200 Subject: [PATCH 05/17] small modifications and element pulley --- src/conv/k-g/k_parser.cpp | 31 ++++++++++++++++++++++++------- src/conv/k-g/k_parser.h | 16 ++++++++++++---- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/conv/k-g/k_parser.cpp b/src/conv/k-g/k_parser.cpp index 4381c61230..609ff72991 100644 --- a/src/conv/k-g/k_parser.cpp +++ b/src/conv/k-g/k_parser.cpp @@ -246,8 +246,6 @@ bool parse_k std::vector elementOptions; std::vector sectionOptions; std::vector options; - //Elment_beam_options.push_back(Elmenent_Beam_Options::Pid); - //std::map elementOptions; if (line.size() > 0) tokens = parse_line(line.c_str()); @@ -285,13 +283,9 @@ bool parse_k if ((command.size() > 1) && (command[1] == "BEAM")) { if ((command.size() > 2) && (command[2] == "PULLEY")) { state = KState::Element_Beam_Pulley; - - //elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end());//ElEMENT_BEAM_PULLEY doesn't have options } else if ((command.size() > 2) && (command[2] == "SOURCE")) { state = KState::Element_Beam_Source; - - //elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end());//ELEMENT_BEAM_SOURCE doesn't have options } else { state = KState::Element_Beam; @@ -964,7 +958,7 @@ bool parse_k } case Options::Elbow: { if (tokens.size() < 1) { - std::cout << "empty ELBOW option in k-file" << fileName << "\n"; + std::cout << "Empty ELBOW option in k-file" << fileName << "\n"; break; } double temp = stod(tokens[0]); @@ -979,6 +973,29 @@ bool parse_k break; } } + break; + } + case KState::Element_Beam_Pulley: { + if (tokens.size() < 8) { + std::cout << "Too short ELEMENT_BEAM_PULLEY in k-file " << fileName << "\n"; + break; + } + KElementPulley pulley; + int pulleyID= stoi(tokens[0]); + + pulley.truss1ID = stoi(tokens[1]); + pulley.truss2ID = stoi(tokens[2]); + pulley.pulleyNode = stoi(tokens[3]); + + data.elementsPulley[pulleyID] = pulley; + break; + } + case KState::Element_Beam_Source: { + // we are ignoring this element. + break; + } + case KState::Element_Bearing: { + } } diff --git a/src/conv/k-g/k_parser.h b/src/conv/k-g/k_parser.h index 860f13c0bf..7b9b6b7a89 100644 --- a/src/conv/k-g/k_parser.h +++ b/src/conv/k-g/k_parser.h @@ -47,6 +47,13 @@ struct KElement { }; +struct KElementPulley { + int truss1ID; + int truss2ID; + int pulleyNode; +}; + + struct KPart { std::string title; std::set elements; @@ -65,10 +72,11 @@ struct KSection { struct KData { - std::map nodes; - std::map elements; - std::map parts; - std::map sections; + std::map nodes; + std::map elements; + std::map elementsPulley; + std::map parts; + std::map sections; }; From afe6b2a638243e277c65208a112a17a58547158a Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Wed, 7 Aug 2024 21:57:08 +0200 Subject: [PATCH 06/17] some elements --- src/conv/k-g/k_parser.cpp | 86 ++++++++++++++++++++++++++++++++++++++- src/conv/k-g/k_parser.h | 39 +++++++++++++++--- 2 files changed, 119 insertions(+), 6 deletions(-) diff --git a/src/conv/k-g/k_parser.cpp b/src/conv/k-g/k_parser.cpp index 609ff72991..0f161e615d 100644 --- a/src/conv/k-g/k_parser.cpp +++ b/src/conv/k-g/k_parser.cpp @@ -237,6 +237,7 @@ bool parse_k size_t partLinesRead = 0; std::string partTitle; size_t sectionLinesRead = 0; + size_t elementLinesRead = 0; size_t optionsCounter = 0; std::string sectionTitle; int sectionId = -1; @@ -331,6 +332,10 @@ bool parse_k state = KState::Element_Bearing; elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + + if (elementOptions.size() > 0) { + elementLinesRead = 0;//element Bearing has only the Tilte option + } } else if ((command.size() > 1) && (command[1] == "BLANKING")) { state = KState::Element_Blanking; @@ -991,11 +996,90 @@ bool parse_k break; } case KState::Element_Beam_Source: { - // we are ignoring this element. + if (tokens.size() < 7) { + std::cout << "Too short ELEMENT_BEAM_SOURCE in k-file" << fileName << "\n"; + break; + } + + KElementBeamSource source; + + int eid = stoi(tokens[0]); + + source.sourceNodeID = stoi(tokens[1]); + source.sourceElementID = stoi(tokens[2]); + source.nElements = stoi(tokens[3]); + source.beamElementLength = stof(tokens[4]); + source.minmumLengthToPullOut = stof(tokens[6]); + + data.elementsBeamSource[eid] = source; break; } case KState::Element_Bearing: { + KElementBearing bearing; + int eid; + + switch (elementLinesRead) + { + case 0: { + bearing.title = line; + + break; + } + case 1: { + if (tokens.size() < 7) { + std::cout << "Too short ELEMENT_BEARING in k-file " << fileName << "\n"; + break; + } + eid = stoi(tokens[0]); + bearing.bearingType = stoi(tokens[1]); + bearing.n1 = stoi(tokens[2]); + bearing.coordinateID1 = stoi(tokens[3]); + bearing.n2 = stoi(tokens[4]); + bearing.coordinateID2 = stoi(tokens[5]); + bearing.numberOfBallsOrRollers = stoi(tokens[6]); + + break; + } + case 2: { + //Nothing related to Geometry here. + break; + } + case 3: { + if (tokens.size() < 4) { + std::cout << "Too short ELEMENT_BEARING in k-file " << fileName << "\n"; + break; + } + + bearing.diameterOfBallsOrRollers = stof(tokens[0]); + bearing.boreInnerDiameter = stof(tokens[1]); + bearing.boreOuterDiameter = stof(tokens[2]); + bearing.pitchDiameter = stof(tokens[3]); + + break; + } + case 4: { + if (tokens.size() < 4) { + std::cout << "Too short ELEMENT_BEARING in k-file " << fileName << "\n"; + break; + } + + bearing.ineerGroveRadiusToBallDiameterRatioOrRollerLength = stof(tokens[1]); + bearing.outerRaceGrooveRadiusToBallDiameterRatio = stof(tokens[2]); + bearing.totalRadianceClearenceBetweenBallAndRaces = stof(tokens[3]); + + break; + } + case 5: { + //nothing related to Geometry. + break; + } + + } + + data.elementBearing[eid] = bearing; + ++elementLinesRead; + break; } } diff --git a/src/conv/k-g/k_parser.h b/src/conv/k-g/k_parser.h index 7b9b6b7a89..d37e7cb9d5 100644 --- a/src/conv/k-g/k_parser.h +++ b/src/conv/k-g/k_parser.h @@ -54,6 +54,33 @@ struct KElementPulley { }; +struct KElementBeamSource { + int sourceNodeID; + int sourceElementID; + int nElements; + float beamElementLength; + float minmumLengthToPullOut; +}; + + +struct KElementBearing { + std::string title; + int bearingType; + int n1; + int coordinateID1; + int n2; + int coordinateID2; + int numberOfBallsOrRollers; + float diameterOfBallsOrRollers; + float boreInnerDiameter; + float boreOuterDiameter; + float pitchDiameter; + float ineerGroveRadiusToBallDiameterRatioOrRollerLength; + float outerRaceGrooveRadiusToBallDiameterRatio; + float totalRadianceClearenceBetweenBallAndRaces; +}; + + struct KPart { std::string title; std::set elements; @@ -72,11 +99,13 @@ struct KSection { struct KData { - std::map nodes; - std::map elements; - std::map elementsPulley; - std::map parts; - std::map sections; + std::map nodes; + std::map elements; + std::map elementsPulley; + std::map elementsBeamSource; + std::map elementBearing; + std::map parts; + std::map sections; }; From 649705ee379ee539865176fc8a8b3b6d0df1f225 Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Fri, 9 Aug 2024 19:16:48 +0200 Subject: [PATCH 07/17] SECTION_BEAM --- src/conv/k-g/k_parser.cpp | 304 +++++++++++++++++++++++++++++++------- src/conv/k-g/k_parser.h | 26 +++- 2 files changed, 267 insertions(+), 63 deletions(-) diff --git a/src/conv/k-g/k_parser.cpp b/src/conv/k-g/k_parser.cpp index 0f161e615d..d1d4546a25 100644 --- a/src/conv/k-g/k_parser.cpp +++ b/src/conv/k-g/k_parser.cpp @@ -89,6 +89,7 @@ enum class KState { }; enum class Options { + Title, Thickness, Scalar, Scalr, @@ -238,14 +239,16 @@ bool parse_k std::string partTitle; size_t sectionLinesRead = 0; size_t elementLinesRead = 0; + size_t cardCounter = 0;// this will replace sectionLinesRead elementLinesRead, and partLinesRead size_t optionsCounter = 0; std::string sectionTitle; int sectionId = -1; + int sectionElForm = 0; + int CST = 0; std::string line = read_line(is); std::vector tokens; const size_t FirstNode = 2; - std::vector elementOptions; - std::vector sectionOptions; + std::vector optionsContainer; std::vector options; if (line.size() > 0) @@ -291,39 +294,39 @@ bool parse_k else { state = KState::Element_Beam; - elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); - if (elementOptions.size() > 0) { - for (size_t i_o = 0; i_o < elementOptions.size(); ++i_o) { - if (elementOptions[i_o] == "THICKNESS") { + if (optionsContainer.size() > 0) { + for (size_t i_o = 0; i_o < optionsContainer.size(); ++i_o) { + if (optionsContainer[i_o] == "THICKNESS") { options.push_back(Options::Thickness); } - else if (elementOptions[i_o] == "SCALAR") { + else if (optionsContainer[i_o] == "SCALAR") { options.push_back(Options::Scalar); } - else if (elementOptions[i_o] == "SCALR") { + else if (optionsContainer[i_o] == "SCALR") { options.push_back(Options::Scalr); } - else if (elementOptions[i_o] == "SECTION") { + else if (optionsContainer[i_o] == "SECTION") { options.push_back(Options::Section); } - else if (elementOptions[i_o] == "PID") { + else if (optionsContainer[i_o] == "PID") { options.push_back(Options::Pid); } - else if (elementOptions[i_o] == "OFFSET") { + else if (optionsContainer[i_o] == "OFFSET") { options.push_back(Options::Offset); } - else if (elementOptions[i_o] == "ORIENTATION") { + else if (optionsContainer[i_o] == "ORIENTATION") { options.push_back(Options::Orientation); } - else if (elementOptions[i_o] == "WARPAGE") { + else if (optionsContainer[i_o] == "WARPAGE") { options.push_back(Options::Warpage); } - else if (elementOptions[i_o] == "ELBOW") { + else if (optionsContainer[i_o] == "ELBOW") { options.push_back(Options::Elbow); } else - std::cout << "Unhandeled Element_Beam option" << elementOptions[i_o] << "in k-file" << fileName << "\n"; + std::cout << "Unhandeled Element_Beam option" << optionsContainer[i_o] << "in k-file" << fileName << "\n"; } } } @@ -331,170 +334,170 @@ bool parse_k else if ((command.size() > 1) && (command[1] == "BEARING")) { state = KState::Element_Bearing; - elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); - if (elementOptions.size() > 0) { + if (optionsContainer.size() > 0) { elementLinesRead = 0;//element Bearing has only the Tilte option } } else if ((command.size() > 1) && (command[1] == "BLANKING")) { state = KState::Element_Blanking; - elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } else if ((command.size() > 3) && (command[1] == "DIRECT") && (command[2] == "MATRIX") && (command[3] == "INPUT")) { state = KState::Element_Direct_Matrix_Input; - elementOptions.insert(elementOptions.end(), command.begin() + 4, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 4, command.end()); } else if ((command.size() > 1) && (command[1] == "DISCRETE")) { if ((command.size() > 2) && (command[2] == "SPHERE")) { state = KState::Element_Discrete_Sphere; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else { state = KState::Element_Discrete; - elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } } else if ((command.size() > 2) && (command[1] == "GENERALIZED")) { if ((command[2] == "SHELL")) { state = KState::Element_Generalized_Shell; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else { state = KState::Element_Generalized_Solid; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } } else if ((command.size() > 1) && (command[1] == "INERTIA")) { state = KState::Element_Inertia; - elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } else if ((command.size() > 2) && (command[1] == "INTERPOLATION")) { if (command[2] == "SHELL") { state = KState::Element_Interpolation_Shell; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else { state = KState::Element_Interpolation_Solid; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } } else if ((command.size() > 1) && (command[1] == "LANCING")) { state = KState::Element_Lancing; - elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } else if ((command.size() > 1) && (command[1] == "MASS")) { if ((command.size() > 2) && (command[2] == "MATRIX")) { state = KState::Element_Mass_Matrix; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else if ((command.size() > 2) && (command[2] == "PART")) { state = KState::Element_Mass_Part; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else { state = KState::Element_Mass; - elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } } else if ((command.size() > 1) && (command[1] == "PLOTEL")) { state = KState::Element_Plotel; - elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } else if ((command.size() > 1) && (command[1] == "SEATBELT")) { if ((command.size() > 2) && (command[2] == "ACCELEROMETER")) { state = KState::Element_Seatbealt_Accelerometer; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else if ((command.size() > 2) && (command[2] == "PRETENSIONER")) { state = KState::Element_Seatbealt_Pretensioner; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else if ((command.size() > 2) && (command[2] == "RETRACTOR")) { state = KState::Element_Seatbealt_Retractor; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else if ((command.size() > 2) && (command[2] == "SENSOR")) { state = KState::Element_Seatbealt_Sensor; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else if ((command.size() > 2) && (command[2] == "SLIPRING")) { state = KState::Element_Seatbealt_Slipring; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else { state = KState::Element_Seatbealt; - elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } } else if ((command.size() > 1) && (command[1] == "SHELL")) { if ((command.size() > 2) && (command[2] == "NURBS")) { state = KState::Element_Shell_Nurbs_Patch; - elementOptions.insert(elementOptions.end(), command.begin() + 4, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 4, command.end()); } else if ((command.size() > 2) && (command[2] == "SOURCE")) { state = KState::Element_Shell_Source_Sink; - elementOptions.insert(elementOptions.end(), command.begin() + 4, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 4, command.end()); } else { state = KState::Element_Shell; - elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } } else if ((command.size() > 1) && (command[1] == "SOLID")) { if ((command.size() > 2) && (command[2] == "NURBS")) { state = KState::Element_Solid_Nurbs_Patch; - elementOptions.insert(elementOptions.end(), command.begin() + 4, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 4, command.end()); } else if ((command.size() > 2) && (command[2] == "PERI")) { state = KState::Element_Solid_Peri; - elementOptions.insert(elementOptions.end(), command.begin() + 3, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else { state = KState::Element_Solid; - elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } } else if ((command.size() > 1) && (command[1] == "SPH")) { state = KState::Element_Sph; - elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } else if ((command.size() > 1) && (command[1] == "TRIM")) { state = KState::Element_Trim; - elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } else if ((command.size() > 1) && (command[1] == "TSHELL")) { state = KState::Element_Tshell; - elementOptions.insert(elementOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } else std::cout << "Unexpected command " << tokens[0] << " in k-file " << fileName << "\n"; @@ -521,8 +524,38 @@ bool parse_k if (command[2] == "TITLE") sectionLinesRead = 0; else - sectionOptions.insert(sectionOptions.end(), command.begin() + 2, command.end()); + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } + else + sectionLinesRead = 1; + } + else if (command[1] == "ALE2D") { + state = KState::Section_Ale2d; + sectionTitle = ""; + sectionId = -1; + + if (command.size() > 2) { + if (command[2] == "TITLE") + sectionLinesRead = 0; + else + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); + } + else + sectionLinesRead = 1; + } + else if (command[1] == "BEAM") { + state = KState::Section_Beam; + sectionTitle = ""; + sectionId = -1; + + if (command.size() > 2) { + if (command[2] == "TITLE") + sectionLinesRead = 0; + else + optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); + } + else + sectionLinesRead = 1; } else if (command[1] == "SHELL") { state = KState::Section_Shell; @@ -673,7 +706,161 @@ bool parse_k case KState::Ignore: break; } + case KState::Section_Ale1d: { + switch (sectionLinesRead) + { + case 0: { + sectionTitle = line; + break; + } + case 1: { + if (tokens.size() < 4) { + std::cout << "Too short SECTION_ALE1D in k-file " << fileName << "\n"; + break; + } + sectionId = stoi(tokens[0]); + data.sections[sectionId].title = sectionTitle; + break; + } + case 2: { + if (sectionId < 0) { + std::cout << "Bad SECTION in k-file " << fileName << "\n"; + break; + } + + if (tokens.size() < 2) { + std::cout << "Too short SECTION_ALE1D in k-file " << fileName << "\n"; + break; + } + + data.sections[sectionId].thickness1 = stod(tokens[0]); + data.sections[sectionId].thickness2 = stod(tokens[1]); + } + } + ++sectionLinesRead; + break; + } + case KState::Section_Ale2d: { + switch (sectionLinesRead) + { + case 0: { + sectionTitle = line; + break; + } + case 1: { + if (tokens.size() < 4) { + std::cout << "Too short SECTION_ALE2D in k-file " << fileName << "\n"; + break; + } + sectionId = stoi(tokens[0]); + data.sections[sectionId].title = sectionTitle; + break; + } + } + + ++sectionLinesRead; + break; + } + case KState::Section_Beam: { + KSectionBeam sectionBeam; + switch (sectionLinesRead) + { + case 0: { + sectionTitle = line; + break; + } + case 1: { + if (tokens.size() < 8) { + std::cout << "Too short SECTION_BEAM in k-file " << fileName << "\n"; + break; + } + sectionId = stoi(tokens[0]); + sectionElForm = stoi(tokens[1]); + + sectionBeam.title = sectionTitle; + sectionBeam.CST = stoi(tokens[4]); + + break; + } + case 2: { + if ((sectionElForm == 1) || (sectionElForm == 11)) { + if (tokens.size() < 6) { + std::cout << "Too short SECTION_BEAM card 2a in k-file " << fileName << "\n"; + break; + } + + sectionBeam.TS1 = stod(tokens[0]); + sectionBeam.TS2 = stod(tokens[1]); + sectionBeam.TT1 = stod(tokens[2]); + sectionBeam.TT2 = stod(tokens[3]); + } + else if ((sectionElForm == 2) || (sectionElForm == 3) || (sectionElForm == 12)||(sectionElForm == 13)) { + std::string first7characters; + + if (tokens[0].size() > 7) { + first7characters = tokens[0].substr(0, 7); + } + + if ((first7characters == "SECTION")) { + sectionBeam.sectionType = tokens[0]; + + for (size_t i_d = 1; i_d < 7; ++i_d) { + sectionBeam.D[i_d - 1] = stod(tokens[i_d]); + } + } + else { + sectionBeam.CrossSectionalArea = stod(tokens[0]); + } + } + else if ((sectionElForm == 4) || (sectionElForm == 5)) { + if (tokens.size() < 4) { + std::cout << "Too short SECTION_BEAM card 2e in k-file " << fileName << "\n"; + break; + } + + sectionBeam.TS1 = stod(tokens[0]); + sectionBeam.TS2 = stod(tokens[1]); + sectionBeam.TT1 = stod(tokens[2]); + sectionBeam.TT2 = stod(tokens[3]); + } + else if (sectionElForm == 6) { + //nothing to do. + break; + } + else if ((sectionElForm == 7) || (sectionElForm == 8)) { + if (tokens.size() < 2) { + std::cout << "Too short SECTION_BEAM card 2h in k-file " << fileName << "\n"; + break; + } + + sectionBeam.TS1 = stod(tokens[0]); + sectionBeam.TS2 = stod(tokens[1]); + } + else if (sectionElForm == 9) { + if (tokens.size() < 4) { + std::cout << "Too short SECTION_BEAM card 2i in k-file " << fileName << "\n"; + break; + } + } + else if (sectionElForm == 14) { + //nothing to do + break; + } + break; + } + case 3: { + if (sectionElForm == 12) { + //No information related to geometry. + break; + } + + break; + } + } + ++sectionLinesRead; + break; + } case KState::Section_Shell: { switch (sectionLinesRead) { case 0: @@ -717,6 +904,7 @@ bool parse_k ++sectionLinesRead; break; } + case KState::Section_Solid: { switch (sectionLinesRead) { case 0: @@ -742,6 +930,7 @@ bool parse_k ++sectionLinesRead; break; } + case KState::Part_Adaptive_Failure: { if (tokens.size() < 2) { std::cout << "Too short PART_ADAPTIVE_FAILURE in k-file " << fileName << "\n"; @@ -758,6 +947,7 @@ bool parse_k } break; } + case KState::Element_Beam: { KElement element; int pid; @@ -980,19 +1170,20 @@ bool parse_k } break; } + case KState::Element_Beam_Pulley: { if (tokens.size() < 8) { std::cout << "Too short ELEMENT_BEAM_PULLEY in k-file " << fileName << "\n"; break; } KElementPulley pulley; - int pulleyID= stoi(tokens[0]); + int pulleyId= stoi(tokens[0]); - pulley.truss1ID = stoi(tokens[1]); - pulley.truss2ID = stoi(tokens[2]); + pulley.truss1Id = stoi(tokens[1]); + pulley.truss2Id = stoi(tokens[2]); pulley.pulleyNode = stoi(tokens[3]); - data.elementsPulley[pulleyID] = pulley; + data.elementsPulley[pulleyId] = pulley; break; } case KState::Element_Beam_Source: { @@ -1005,8 +1196,8 @@ bool parse_k int eid = stoi(tokens[0]); - source.sourceNodeID = stoi(tokens[1]); - source.sourceElementID = stoi(tokens[2]); + source.sourceNodeId = stoi(tokens[1]); + source.sourceElementId = stoi(tokens[2]); source.nElements = stoi(tokens[3]); source.beamElementLength = stof(tokens[4]); source.minmumLengthToPullOut = stof(tokens[6]); @@ -1014,6 +1205,7 @@ bool parse_k data.elementsBeamSource[eid] = source; break; } + case KState::Element_Bearing: { KElementBearing bearing; int eid; @@ -1034,9 +1226,9 @@ bool parse_k eid = stoi(tokens[0]); bearing.bearingType = stoi(tokens[1]); bearing.n1 = stoi(tokens[2]); - bearing.coordinateID1 = stoi(tokens[3]); + bearing.coordinateId1 = stoi(tokens[3]); bearing.n2 = stoi(tokens[4]); - bearing.coordinateID2 = stoi(tokens[5]); + bearing.coordinateId2 = stoi(tokens[5]); bearing.numberOfBallsOrRollers = stoi(tokens[6]); break; @@ -1064,7 +1256,7 @@ bool parse_k break; } - bearing.ineerGroveRadiusToBallDiameterRatioOrRollerLength = stof(tokens[1]); + bearing.innerGroveRadiusToBallDiameterRatioOrRollerLength = stof(tokens[1]); bearing.outerRaceGrooveRadiusToBallDiameterRatio = stof(tokens[2]); bearing.totalRadianceClearenceBetweenBallAndRaces = stof(tokens[3]); diff --git a/src/conv/k-g/k_parser.h b/src/conv/k-g/k_parser.h index d37e7cb9d5..4a9a1aa13f 100644 --- a/src/conv/k-g/k_parser.h +++ b/src/conv/k-g/k_parser.h @@ -48,15 +48,15 @@ struct KElement { struct KElementPulley { - int truss1ID; - int truss2ID; + int truss1Id; + int truss2Id; int pulleyNode; }; struct KElementBeamSource { - int sourceNodeID; - int sourceElementID; + int sourceNodeId; + int sourceElementId; int nElements; float beamElementLength; float minmumLengthToPullOut; @@ -67,15 +67,15 @@ struct KElementBearing { std::string title; int bearingType; int n1; - int coordinateID1; + int coordinateId1; int n2; - int coordinateID2; + int coordinateId2; int numberOfBallsOrRollers; float diameterOfBallsOrRollers; float boreInnerDiameter; float boreOuterDiameter; float pitchDiameter; - float ineerGroveRadiusToBallDiameterRatioOrRollerLength; + float innerGroveRadiusToBallDiameterRatioOrRollerLength; float outerRaceGrooveRadiusToBallDiameterRatio; float totalRadianceClearenceBetweenBallAndRaces; }; @@ -97,6 +97,17 @@ struct KSection { double thickness4; }; +struct KSectionBeam { + std::string title; + int CST;//cross section type + std::string sectionType;//this is different from cross section type + double TS1; + double TS2; + double TT1; + double TT2; + std::vector D; + double CrossSectionalArea;//The definition on *ELEMENT_BEAM_THICKNESS overrides the value defined here. +}; struct KData { std::map nodes; @@ -106,6 +117,7 @@ struct KData { std::map elementBearing; std::map parts; std::map sections; + std::map sectionsBeam; }; From 5b1e5adf473d2ed9bc7e45fdb979918d1332f144 Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Mon, 12 Aug 2024 18:13:13 +0200 Subject: [PATCH 08/17] preparations for section type (CST= 1)Tubular (circular only) --- src/conv/k-g/k-g.cpp | 7 ++++++- src/conv/k-g/k_parser.cpp | 13 ++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/conv/k-g/k-g.cpp b/src/conv/k-g/k-g.cpp index d7411082df..84ce066230 100644 --- a/src/conv/k-g/k-g.cpp +++ b/src/conv/k-g/k-g.cpp @@ -136,7 +136,12 @@ int main std::cout << "Missing section to part" << partName.c_str() << '\n'; for (std::set::iterator itr = (it->second).elements.begin(); itr != (it->second).elements.end(); itr++) { - if (kData.elements[*itr].nodes.size() == 4) { + if ((kData.elements[*itr].nodes.size() == 3)) { + int x = 1; + KSectionBeam beamSection = kData.sectionsBeam[section]; + //check the first element Beam + } + else if (kData.elements[*itr].nodes.size() == 4) { point_t point1; point_t point2; diff --git a/src/conv/k-g/k_parser.cpp b/src/conv/k-g/k_parser.cpp index d1d4546a25..1f0c0c2301 100644 --- a/src/conv/k-g/k_parser.cpp +++ b/src/conv/k-g/k_parser.cpp @@ -779,7 +779,7 @@ bool parse_k sectionBeam.title = sectionTitle; sectionBeam.CST = stoi(tokens[4]); - + data.sections[sectionId].title = sectionTitle; break; } case 2: { @@ -841,11 +841,18 @@ bool parse_k std::cout << "Too short SECTION_BEAM card 2i in k-file " << fileName << "\n"; break; } + + sectionBeam.TS1 = stod(tokens[0]); + sectionBeam.TS2 = stod(tokens[1]); + sectionBeam.TT1 = stod(tokens[2]); + sectionBeam.TT2 = stod(tokens[3]); } else if (sectionElForm == 14) { //nothing to do break; } + + data.sectionsBeam[sectionId] = sectionBeam; break; } case 3: { @@ -857,7 +864,7 @@ bool parse_k break; } } - + data.sectionsBeam[sectionId] = sectionBeam; ++sectionLinesRead; break; } @@ -965,7 +972,7 @@ bool parse_k break; } - for (int i_n = 0; i_n < 5; ++i_n) { + for (int i_n = 0; i_n < 3; ++i_n) { element.nodes.push_back(stoi(tokens[i_n + FirstNode])); } From 92542429905cfa16084a4364a97db59264ec3590 Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Tue, 13 Aug 2024 21:46:28 +0200 Subject: [PATCH 09/17] beam class --- src/conv/k-g/CMakeLists.txt | 2 ++ src/conv/k-g/geometry.cpp | 19 +++++++++++-------- src/conv/k-g/geometry.h | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/conv/k-g/CMakeLists.txt b/src/conv/k-g/CMakeLists.txt index aeaa65e8af..3e50643fc8 100644 --- a/src/conv/k-g/CMakeLists.txt +++ b/src/conv/k-g/CMakeLists.txt @@ -5,6 +5,7 @@ set(k-g_SRCF region_list.cpp arbs.cpp geometry.cpp + beam.cpp ) BRLCAD_ADDEXEC(k-g "${k-g_SRCF}" "libwdb;librt;libbu" FOLDER Conv) @@ -15,6 +16,7 @@ set(k-g_ignore_files region_list.h arbs.h geometry.h + beam.h ) CMAKEFILES(${k-g_ignore_files}) diff --git a/src/conv/k-g/geometry.cpp b/src/conv/k-g/geometry.cpp index 62258d4872..e1d360a441 100644 --- a/src/conv/k-g/geometry.cpp +++ b/src/conv/k-g/geometry.cpp @@ -26,14 +26,7 @@ #include "geometry.h" -// Local Variables: -// tab-width: 8 -// mode: C++ -// c-basic-offset: 4 -// indent-tabs-mode: t -// c-file-style: "stroustrup" -// End: -// ex: shiftwidth=4 tabstop=8 + void Geometry::setBaseName @@ -107,3 +100,13 @@ std::vector Geometry::write return ret; } + + +// Local Variables: +// tab-width: 8 +// mode: C++ +// c-basic-offset: 4 +// indent-tabs-mode: t +// c-file-style: "stroustrup" +// End: +// ex: shiftwidth=4 tabstop=8 \ No newline at end of file diff --git a/src/conv/k-g/geometry.h b/src/conv/k-g/geometry.h index 08cfe8c928..1ec283aaf5 100644 --- a/src/conv/k-g/geometry.h +++ b/src/conv/k-g/geometry.h @@ -17,7 +17,7 @@ * License along with this file; see the file named COPYING for more * information. */ - /** @file region_list.cpp + /** @file geometry.h * * LS Dyna keyword file to BRL-CAD converter: * intermediate geometry structure implementation From e8241067f27ac8b6a4b3f5d6391cc708afcbf28a Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Thu, 15 Aug 2024 13:12:47 +0200 Subject: [PATCH 10/17] first try with Pipe premative --- src/conv/k-g/beam.cpp | 104 ++++++++++++++++++++++++++++++++++++++ src/conv/k-g/beam.h | 70 +++++++++++++++++++++++++ src/conv/k-g/geometry.cpp | 16 ++++-- src/conv/k-g/geometry.h | 5 ++ src/conv/k-g/k-g.cpp | 25 ++++++++- 5 files changed, 216 insertions(+), 4 deletions(-) create mode 100644 src/conv/k-g/beam.cpp create mode 100644 src/conv/k-g/beam.h diff --git a/src/conv/k-g/beam.cpp b/src/conv/k-g/beam.cpp new file mode 100644 index 0000000000..da920def4d --- /dev/null +++ b/src/conv/k-g/beam.cpp @@ -0,0 +1,104 @@ +/* G E O M E T R Y . C P P + * BRL-CAD + * + * Copyright (c) 2024 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ + /** @file beam.cpp + * + * LS Dyna keyword file to BRL-CAD converter: + * intermediate beam implementation + */ + +#include "beam.h" + + + + + + +Beam::Beam(void):name() {} + +void Beam::setName(const char* value) +{ + name = value; +} + +void Beam::addBeam(const char* beamName, const beamPoint& point1, const beamPoint& point2) +{ + struct wdb_pipe_pnt* temp1; + struct wdb_pipe_pnt* temp2; + struct bu_list tempList; + BU_LIST_INIT(&tempList); + + BU_ALLOC(temp1, struct wdb_pipe_pnt); + BU_ALLOC(temp2, struct wdb_pipe_pnt); + + temp1->l.magic = WDB_PIPESEG_MAGIC; + temp1->pp_id = point1.innerDiameter; + temp1->pp_od = point1.outerDiameter; + temp1->pp_bendradius = 25.0; + VMOVE(temp1->pp_coord, point1.coords); + + temp2->l.magic = WDB_PIPESEG_MAGIC; + temp2->pp_id = point2.innerDiameter; + temp2->pp_od = point2.outerDiameter; + temp2->pp_bendradius = 25.0; + VMOVE(temp2->pp_coord, point2.coords); + + BU_LIST_INSERT(&tempList, &temp1->l); + BU_LIST_INSERT(&tempList, &temp2->l); + + m_list[beamName] = tempList; +} + +void Beam::addBeam(const char* beamName, const beamPoint& point1, const beamPoint& point2, const beamPoint& point3) +{ +} + +std::vector Beam::write +( + rt_wdb* wdbp +) { + std::vector ret; + + for (std::map::iterator it = m_list.begin(); it != m_list.end(); ++it) { + std::string beamName = name; + beamName += "."; + beamName += it->first; + beamName += ".beam"; + ret.push_back(beamName); + + rt_pipe_internal* pipe_wdb; + BU_GET(pipe_wdb, rt_pipe_internal); + pipe_wdb->pipe_magic = RT_PIPE_INTERNAL_MAGIC; + BU_LIST_INIT(&pipe_wdb->pipe_segs_head); + BU_LIST_APPEND_LIST(&pipe_wdb->pipe_segs_head, &(it->second)); + wdb_export(wdbp, beamName.c_str(), pipe_wdb, ID_PIPE, 1); + } + + return ret; +} + + +// Local Variables: +// tab-width: 8 +// mode: C++ +// c-basic-offset: 4 +// indent-tabs-mode: t +// c-file-style: "stroustrup" +// End: +// ex: shiftwidth=4 tabstop=8 \ No newline at end of file diff --git a/src/conv/k-g/beam.h b/src/conv/k-g/beam.h new file mode 100644 index 0000000000..58dcac9b96 --- /dev/null +++ b/src/conv/k-g/beam.h @@ -0,0 +1,70 @@ +/* G E O M E T R Y . H + * BRL-CAD + * + * Copyright (c) 2024 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ + /** @file beam.h + * + * LS Dyna keyword file to BRL-CAD converter: + * intermediate beam implementation + */ +#ifndef BEAM_INCLUDED +#define BEAM_INCLUDED + +#include "common.h" +#include "wdb.h" + +struct beamPoint { + point_t coords; + double innerDiameter; + double outerDiameter; +}; + +class Beam { +public: + Beam(void); + + void setName(const char* value); + + void addBeam(const char* beamName, + const beamPoint& point1, + const beamPoint& point2); + + void addBeam(const char* beamName, + const beamPoint& point1, + const beamPoint& point2, + const beamPoint& point3); + + std::vector write(rt_wdb* wdbp); +private: + std::string name; + std::map m_list; + //rt_pipe_internal m_pipe; +}; + + +#endif // !BEAM_INCLUDED + + +// Local Variables: +// tab-width: 8 +// mode: C++ +// c-basic-offset: 4 +// indent-tabs-mode: t +// c-file-style: "stroustrup" +// End: +// ex: shiftwidth=4 tabstop=8 \ No newline at end of file diff --git a/src/conv/k-g/geometry.cpp b/src/conv/k-g/geometry.cpp index e1d360a441..be567e6c06 100644 --- a/src/conv/k-g/geometry.cpp +++ b/src/conv/k-g/geometry.cpp @@ -40,6 +40,7 @@ void Geometry::setBaseName m_bot.setName(name.c_str()); m_arbs.setName(name.c_str()); + m_beams.setName(name.c_str()); } void Geometry::setThickness @@ -74,6 +75,14 @@ void Geometry::addArb m_arbs.addArb(arbName, point1, point2, point3, point4, point5, point6, point7, point8); } +void Geometry::addBeam +(const char* beamName, + const beamPoint point1, + const beamPoint point2) +{ + m_beams.addBeam(beamName, point1, point2); +} + const char* Geometry::getBaseName(void) const{ return name.c_str(); @@ -93,11 +102,12 @@ std::vector Geometry::write ( rt_wdb* wdbp ) { - std::vector ret = m_bot.write(wdbp); - std::vector arbNames = m_arbs.write(wdbp); + std::vector ret = m_bot.write(wdbp); + std::vector arbNames = m_arbs.write(wdbp); + std::vector beamNames = m_beams.write(wdbp); ret.insert(ret.end(), arbNames.begin(), arbNames.end()); - + ret.insert(ret.end(), beamNames.begin(), beamNames.end()); return ret; } diff --git a/src/conv/k-g/geometry.h b/src/conv/k-g/geometry.h index 1ec283aaf5..464a5cd3e6 100644 --- a/src/conv/k-g/geometry.h +++ b/src/conv/k-g/geometry.h @@ -29,6 +29,7 @@ #include "bot.h" #include "arbs.h" +#include "beam.h" class Geometry { @@ -48,6 +49,9 @@ class Geometry { const point_t& point6, const point_t& point7, const point_t& point8); + void addBeam(const char* beamName, + const beamPoint point1, + const beamPoint point2); const char* getBaseName(void) const; Bot& getBot(void); @@ -58,6 +62,7 @@ class Geometry { std::string name; Bot m_bot; Arbs m_arbs; + Beam m_beams; }; diff --git a/src/conv/k-g/k-g.cpp b/src/conv/k-g/k-g.cpp index 84ce066230..09995677d8 100644 --- a/src/conv/k-g/k-g.cpp +++ b/src/conv/k-g/k-g.cpp @@ -33,6 +33,7 @@ #include "k_parser.h" #include "region_list.h" +#include "beam.h" static void AddArb(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8,KData& kData, std::string arbNumber, Geometry& geometry) { @@ -139,7 +140,29 @@ int main if ((kData.elements[*itr].nodes.size() == 3)) { int x = 1; KSectionBeam beamSection = kData.sectionsBeam[section]; - //check the first element Beam + + + beamPoint point1; + beamPoint point2; + + + int n1 = kData.elements[*itr].nodes[0]; + int n2 = kData.elements[*itr].nodes[1]; + int n3 = kData.elements[*itr].nodes[2]; + point1.coords[X] = kData.nodes[n1].x * factor; + point1.coords[Y] = kData.nodes[n1].y * factor; + point1.coords[Z] = kData.nodes[n1].z * factor; + point1.outerDiameter = beamSection.TS1; + point1.innerDiameter = beamSection.TT1; + + point2.coords[X] = kData.nodes[n2].x * factor; + point2.coords[Y] = kData.nodes[n2].y * factor; + point2.coords[Z] = kData.nodes[n2].z * factor; + point2.outerDiameter = beamSection.TS2; + point2.innerDiameter = beamSection.TT2; + + std::string beamNumber = std::to_string(*itr); + geometry.addBeam(beamNumber.c_str(), point1, point2); } else if (kData.elements[*itr].nodes.size() == 4) { From 9607c363bd88a4971f31b60fcd64040dd4642573 Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Fri, 16 Aug 2024 19:49:33 +0200 Subject: [PATCH 11/17] Pipe class --- src/conv/k-g/CMakeLists.txt | 4 +- src/conv/k-g/beam.cpp | 104 -------------------------------- src/conv/k-g/geometry.cpp | 8 +-- src/conv/k-g/geometry.h | 8 +-- src/conv/k-g/k-g.cpp | 51 +++++++++------- src/conv/k-g/pipe.cpp | 91 ++++++++++++++++++++++++++++ src/conv/k-g/{beam.h => pipe.h} | 30 ++++----- 7 files changed, 138 insertions(+), 158 deletions(-) delete mode 100644 src/conv/k-g/beam.cpp create mode 100644 src/conv/k-g/pipe.cpp rename src/conv/k-g/{beam.h => pipe.h} (67%) diff --git a/src/conv/k-g/CMakeLists.txt b/src/conv/k-g/CMakeLists.txt index 3e50643fc8..cc84e7adec 100644 --- a/src/conv/k-g/CMakeLists.txt +++ b/src/conv/k-g/CMakeLists.txt @@ -5,7 +5,7 @@ set(k-g_SRCF region_list.cpp arbs.cpp geometry.cpp - beam.cpp + pipe.cpp ) BRLCAD_ADDEXEC(k-g "${k-g_SRCF}" "libwdb;librt;libbu" FOLDER Conv) @@ -16,7 +16,7 @@ set(k-g_ignore_files region_list.h arbs.h geometry.h - beam.h + pipe.h ) CMAKEFILES(${k-g_ignore_files}) diff --git a/src/conv/k-g/beam.cpp b/src/conv/k-g/beam.cpp deleted file mode 100644 index da920def4d..0000000000 --- a/src/conv/k-g/beam.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* G E O M E T R Y . C P P - * BRL-CAD - * - * Copyright (c) 2024 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - */ - /** @file beam.cpp - * - * LS Dyna keyword file to BRL-CAD converter: - * intermediate beam implementation - */ - -#include "beam.h" - - - - - - -Beam::Beam(void):name() {} - -void Beam::setName(const char* value) -{ - name = value; -} - -void Beam::addBeam(const char* beamName, const beamPoint& point1, const beamPoint& point2) -{ - struct wdb_pipe_pnt* temp1; - struct wdb_pipe_pnt* temp2; - struct bu_list tempList; - BU_LIST_INIT(&tempList); - - BU_ALLOC(temp1, struct wdb_pipe_pnt); - BU_ALLOC(temp2, struct wdb_pipe_pnt); - - temp1->l.magic = WDB_PIPESEG_MAGIC; - temp1->pp_id = point1.innerDiameter; - temp1->pp_od = point1.outerDiameter; - temp1->pp_bendradius = 25.0; - VMOVE(temp1->pp_coord, point1.coords); - - temp2->l.magic = WDB_PIPESEG_MAGIC; - temp2->pp_id = point2.innerDiameter; - temp2->pp_od = point2.outerDiameter; - temp2->pp_bendradius = 25.0; - VMOVE(temp2->pp_coord, point2.coords); - - BU_LIST_INSERT(&tempList, &temp1->l); - BU_LIST_INSERT(&tempList, &temp2->l); - - m_list[beamName] = tempList; -} - -void Beam::addBeam(const char* beamName, const beamPoint& point1, const beamPoint& point2, const beamPoint& point3) -{ -} - -std::vector Beam::write -( - rt_wdb* wdbp -) { - std::vector ret; - - for (std::map::iterator it = m_list.begin(); it != m_list.end(); ++it) { - std::string beamName = name; - beamName += "."; - beamName += it->first; - beamName += ".beam"; - ret.push_back(beamName); - - rt_pipe_internal* pipe_wdb; - BU_GET(pipe_wdb, rt_pipe_internal); - pipe_wdb->pipe_magic = RT_PIPE_INTERNAL_MAGIC; - BU_LIST_INIT(&pipe_wdb->pipe_segs_head); - BU_LIST_APPEND_LIST(&pipe_wdb->pipe_segs_head, &(it->second)); - wdb_export(wdbp, beamName.c_str(), pipe_wdb, ID_PIPE, 1); - } - - return ret; -} - - -// Local Variables: -// tab-width: 8 -// mode: C++ -// c-basic-offset: 4 -// indent-tabs-mode: t -// c-file-style: "stroustrup" -// End: -// ex: shiftwidth=4 tabstop=8 \ No newline at end of file diff --git a/src/conv/k-g/geometry.cpp b/src/conv/k-g/geometry.cpp index be567e6c06..e5b624974c 100644 --- a/src/conv/k-g/geometry.cpp +++ b/src/conv/k-g/geometry.cpp @@ -75,12 +75,10 @@ void Geometry::addArb m_arbs.addArb(arbName, point1, point2, point3, point4, point5, point6, point7, point8); } -void Geometry::addBeam -(const char* beamName, - const beamPoint point1, - const beamPoint point2) + +void Geometry::addPipePnt(const char* partName, pipePoint point) { - m_beams.addBeam(beamName, point1, point2); + m_beams.addPipePnt(partName, point); } diff --git a/src/conv/k-g/geometry.h b/src/conv/k-g/geometry.h index 464a5cd3e6..fad6b08239 100644 --- a/src/conv/k-g/geometry.h +++ b/src/conv/k-g/geometry.h @@ -29,7 +29,7 @@ #include "bot.h" #include "arbs.h" -#include "beam.h" +#include "pipe.h" class Geometry { @@ -49,9 +49,7 @@ class Geometry { const point_t& point6, const point_t& point7, const point_t& point8); - void addBeam(const char* beamName, - const beamPoint point1, - const beamPoint point2); + void addPipePnt(const char* partName, pipePoint point); const char* getBaseName(void) const; Bot& getBot(void); @@ -62,7 +60,7 @@ class Geometry { std::string name; Bot m_bot; Arbs m_arbs; - Beam m_beams; + Pipe m_beams; }; diff --git a/src/conv/k-g/k-g.cpp b/src/conv/k-g/k-g.cpp index 09995677d8..fd4c2ee0a5 100644 --- a/src/conv/k-g/k-g.cpp +++ b/src/conv/k-g/k-g.cpp @@ -33,7 +33,7 @@ #include "k_parser.h" #include "region_list.h" -#include "beam.h" +#include "pipe.h" static void AddArb(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8,KData& kData, std::string arbNumber, Geometry& geometry) { @@ -139,30 +139,35 @@ int main for (std::set::iterator itr = (it->second).elements.begin(); itr != (it->second).elements.end(); itr++) { if ((kData.elements[*itr].nodes.size() == 3)) { int x = 1; - KSectionBeam beamSection = kData.sectionsBeam[section]; - + if (section > 0) { + KSectionBeam beamSection = kData.sectionsBeam[section]; - beamPoint point1; - beamPoint point2; - + + pipePoint point1; + pipePoint point2; + + + int n1 = kData.elements[*itr].nodes[0]; + int n2 = kData.elements[*itr].nodes[1]; + int n3 = kData.elements[*itr].nodes[2]; + point1.coords[X] = kData.nodes[n1].x * factor; + point1.coords[Y] = kData.nodes[n1].y * factor; + point1.coords[Z] = kData.nodes[n1].z * factor; + point1.outerDiameter = beamSection.TS1; + point1.innerDiameter = beamSection.TT1; + + point2.coords[X] = kData.nodes[n2].x * factor; + point2.coords[Y] = kData.nodes[n2].y * factor; + point2.coords[Z] = kData.nodes[n2].z * factor; + point2.outerDiameter = beamSection.TS2; + point2.innerDiameter = beamSection.TT2; + + std::string beamNumber = std::to_string(*itr); + + geometry.addPipePnt(partName.c_str(), point1); + geometry.addPipePnt(partName.c_str(), point2); + } - int n1 = kData.elements[*itr].nodes[0]; - int n2 = kData.elements[*itr].nodes[1]; - int n3 = kData.elements[*itr].nodes[2]; - point1.coords[X] = kData.nodes[n1].x * factor; - point1.coords[Y] = kData.nodes[n1].y * factor; - point1.coords[Z] = kData.nodes[n1].z * factor; - point1.outerDiameter = beamSection.TS1; - point1.innerDiameter = beamSection.TT1; - - point2.coords[X] = kData.nodes[n2].x * factor; - point2.coords[Y] = kData.nodes[n2].y * factor; - point2.coords[Z] = kData.nodes[n2].z * factor; - point2.outerDiameter = beamSection.TS2; - point2.innerDiameter = beamSection.TT2; - - std::string beamNumber = std::to_string(*itr); - geometry.addBeam(beamNumber.c_str(), point1, point2); } else if (kData.elements[*itr].nodes.size() == 4) { diff --git a/src/conv/k-g/pipe.cpp b/src/conv/k-g/pipe.cpp new file mode 100644 index 0000000000..ddd1d4725c --- /dev/null +++ b/src/conv/k-g/pipe.cpp @@ -0,0 +1,91 @@ +/* P I P E . C P P + * BRL-CAD + * + * Copyright (c) 2024 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ + /** @file pipe.cpp + * + * LS Dyna keyword file to BRL-CAD converter: + * intermediate pipe implementation + */ + +#include "pipe.h" + + +Pipe::Pipe(void) { + BU_GET(m_pipe, rt_pipe_internal); + BU_LIST_INIT(&m_pipe->pipe_segs_head); + m_pipe->pipe_magic = RT_PIPE_INTERNAL_MAGIC; + m_pipe->pipe_segs_head.magic = RT_PIPE_INTERNAL_MAGIC; + m_pipe->pipe_count= 0; +} + + +void Pipe::setName(const char* value) +{ + name = value; +} + + +void Pipe::addPipePnt(const char* PipeName, const pipePoint& point) +{ + struct wdb_pipe_pnt* ctlPoint; + BU_ALLOC(ctlPoint, struct wdb_pipe_pnt); + ctlPoint->l.magic = WDB_PIPESEG_MAGIC; + + BU_ALLOC(ctlPoint, struct wdb_pipe_pnt); + + VMOVE(ctlPoint->pp_coord, point.coords); + ctlPoint->pp_id = point.innerDiameter; + ctlPoint->pp_od = point.outerDiameter; + ctlPoint->pp_bendradius = 2*point.outerDiameter; + + BU_LIST_PUSH(&(m_pipe->pipe_segs_head), &(ctlPoint->l)); + m_pipe->pipe_count += 1; +} + +std::vector Pipe::write +( + rt_wdb* wdbp +) { + std::vector ret; + + std::string pipeName = name; + pipeName += ".pipe"; + ret.push_back(pipeName); + + rt_pipe_internal* pipe_wdb; + BU_GET(pipe_wdb, rt_pipe_internal); + pipe_wdb->pipe_magic = RT_PIPE_INTERNAL_MAGIC; + BU_LIST_INIT(&pipe_wdb->pipe_segs_head); + BU_LIST_APPEND_LIST(&pipe_wdb->pipe_segs_head, &(m_pipe->pipe_segs_head)); + + wdb_export(wdbp, pipeName.c_str(), pipe_wdb, ID_PIPE, 1); + //wdb_export(wdbp, pipeName.c_str(), m_pipe, ID_PIPE, 1); + + return ret; +} + + +// Local Variables: +// tab-width: 8 +// mode: C++ +// c-basic-offset: 4 +// indent-tabs-mode: t +// c-file-style: "stroustrup" +// End: +// ex: shiftwidth=4 tabstop=8 \ No newline at end of file diff --git a/src/conv/k-g/beam.h b/src/conv/k-g/pipe.h similarity index 67% rename from src/conv/k-g/beam.h rename to src/conv/k-g/pipe.h index 58dcac9b96..4fff5c4fbb 100644 --- a/src/conv/k-g/beam.h +++ b/src/conv/k-g/pipe.h @@ -1,4 +1,4 @@ -/* G E O M E T R Y . H +/* P I P E . H * BRL-CAD * * Copyright (c) 2024 United States Government as represented by @@ -17,47 +17,39 @@ * License along with this file; see the file named COPYING for more * information. */ - /** @file beam.h + /** @file pipe.h * * LS Dyna keyword file to BRL-CAD converter: - * intermediate beam implementation + * intermediate pipe implementation */ -#ifndef BEAM_INCLUDED -#define BEAM_INCLUDED +#ifndef PIPE_INCLUDED +#define PIPE_INCLUDED #include "common.h" #include "wdb.h" -struct beamPoint { +struct pipePoint { point_t coords; double innerDiameter; double outerDiameter; }; -class Beam { +class Pipe { public: - Beam(void); + Pipe(void); void setName(const char* value); - void addBeam(const char* beamName, - const beamPoint& point1, - const beamPoint& point2); - - void addBeam(const char* beamName, - const beamPoint& point1, - const beamPoint& point2, - const beamPoint& point3); + void addPipePnt(const char* pipeName, const pipePoint& point); std::vector write(rt_wdb* wdbp); private: std::string name; - std::map m_list; - //rt_pipe_internal m_pipe; + rt_pipe_internal* m_pipe; }; -#endif // !BEAM_INCLUDED +#endif // !PIPE_INCLUDED // Local Variables: From 7554e0982fa4fbdcb919cae91f670be0184792b1 Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Mon, 19 Aug 2024 18:08:08 +0200 Subject: [PATCH 12/17] export error fix --- src/conv/k-g/pipe.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/conv/k-g/pipe.cpp b/src/conv/k-g/pipe.cpp index ddd1d4725c..c81444336a 100644 --- a/src/conv/k-g/pipe.cpp +++ b/src/conv/k-g/pipe.cpp @@ -28,10 +28,8 @@ Pipe::Pipe(void) { BU_GET(m_pipe, rt_pipe_internal); - BU_LIST_INIT(&m_pipe->pipe_segs_head); m_pipe->pipe_magic = RT_PIPE_INTERNAL_MAGIC; - m_pipe->pipe_segs_head.magic = RT_PIPE_INTERNAL_MAGIC; - m_pipe->pipe_count= 0; + BU_LIST_INIT(&(m_pipe->pipe_segs_head)); } @@ -68,14 +66,7 @@ std::vector Pipe::write pipeName += ".pipe"; ret.push_back(pipeName); - rt_pipe_internal* pipe_wdb; - BU_GET(pipe_wdb, rt_pipe_internal); - pipe_wdb->pipe_magic = RT_PIPE_INTERNAL_MAGIC; - BU_LIST_INIT(&pipe_wdb->pipe_segs_head); - BU_LIST_APPEND_LIST(&pipe_wdb->pipe_segs_head, &(m_pipe->pipe_segs_head)); - - wdb_export(wdbp, pipeName.c_str(), pipe_wdb, ID_PIPE, 1); - //wdb_export(wdbp, pipeName.c_str(), m_pipe, ID_PIPE, 1); + wdb_export(wdbp, pipeName.c_str(), m_pipe, ID_PIPE, 1); return ret; } From bb040907bf2214326c9a0ca46c967c04d6483cc6 Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Mon, 19 Aug 2024 22:22:14 +0200 Subject: [PATCH 13/17] Pipe clean up --- src/conv/k-g/geometry.cpp | 15 +++++++++----- src/conv/k-g/geometry.h | 5 +++-- src/conv/k-g/k-g.cpp | 41 +++++++++++++++++++-------------------- src/conv/k-g/pipe.cpp | 35 +++++++++++++++++++++++++++------ src/conv/k-g/pipe.h | 9 ++++++--- 5 files changed, 68 insertions(+), 37 deletions(-) diff --git a/src/conv/k-g/geometry.cpp b/src/conv/k-g/geometry.cpp index e5b624974c..44c7336eed 100644 --- a/src/conv/k-g/geometry.cpp +++ b/src/conv/k-g/geometry.cpp @@ -40,7 +40,7 @@ void Geometry::setBaseName m_bot.setName(name.c_str()); m_arbs.setName(name.c_str()); - m_beams.setName(name.c_str()); + m_pipe.setName(name.c_str()); } void Geometry::setThickness @@ -76,9 +76,9 @@ void Geometry::addArb } -void Geometry::addPipePnt(const char* partName, pipePoint point) +void Geometry::addPipePnt(pipePoint point) { - m_beams.addPipePnt(partName, point); + m_pipe.addPipePnt(point); } @@ -95,6 +95,11 @@ Arbs& Geometry::getArbs(void) { return m_arbs; } +Pipe& Geometry::getPipe(void) +{ + return m_pipe; +} + std::vector Geometry::write ( @@ -102,10 +107,10 @@ std::vector Geometry::write ) { std::vector ret = m_bot.write(wdbp); std::vector arbNames = m_arbs.write(wdbp); - std::vector beamNames = m_beams.write(wdbp); + std::vector pipeName = m_pipe.write(wdbp); ret.insert(ret.end(), arbNames.begin(), arbNames.end()); - ret.insert(ret.end(), beamNames.begin(), beamNames.end()); + ret.insert(ret.end(), pipeName.begin(), pipeName.end()); return ret; } diff --git a/src/conv/k-g/geometry.h b/src/conv/k-g/geometry.h index fad6b08239..99d31b6581 100644 --- a/src/conv/k-g/geometry.h +++ b/src/conv/k-g/geometry.h @@ -49,18 +49,19 @@ class Geometry { const point_t& point6, const point_t& point7, const point_t& point8); - void addPipePnt(const char* partName, pipePoint point); + void addPipePnt(pipePoint point); const char* getBaseName(void) const; Bot& getBot(void); Arbs& getArbs(void); + Pipe& getPipe(void); std::vector write(rt_wdb* wdbp); private: std::string name; Bot m_bot; Arbs m_arbs; - Pipe m_beams; + Pipe m_pipe; }; diff --git a/src/conv/k-g/k-g.cpp b/src/conv/k-g/k-g.cpp index fd4c2ee0a5..bb3f4292f9 100644 --- a/src/conv/k-g/k-g.cpp +++ b/src/conv/k-g/k-g.cpp @@ -138,36 +138,35 @@ int main for (std::set::iterator itr = (it->second).elements.begin(); itr != (it->second).elements.end(); itr++) { if ((kData.elements[*itr].nodes.size() == 3)) { - int x = 1; if (section > 0) { KSectionBeam beamSection = kData.sectionsBeam[section]; + if (beamSection.CST == 1) { + pipePoint point1; + pipePoint point2; - pipePoint point1; - pipePoint point2; + int n1 = kData.elements[*itr].nodes[0]; + int n2 = kData.elements[*itr].nodes[1]; + int n3 = kData.elements[*itr].nodes[2]; + point1.coords[X] = kData.nodes[n1].x * factor; + point1.coords[Y] = kData.nodes[n1].y * factor; + point1.coords[Z] = kData.nodes[n1].z * factor; + point1.outerDiameter = beamSection.TS1; + point1.innerDiameter = beamSection.TT1; - int n1 = kData.elements[*itr].nodes[0]; - int n2 = kData.elements[*itr].nodes[1]; - int n3 = kData.elements[*itr].nodes[2]; - point1.coords[X] = kData.nodes[n1].x * factor; - point1.coords[Y] = kData.nodes[n1].y * factor; - point1.coords[Z] = kData.nodes[n1].z * factor; - point1.outerDiameter = beamSection.TS1; - point1.innerDiameter = beamSection.TT1; + point2.coords[X] = kData.nodes[n2].x * factor; + point2.coords[Y] = kData.nodes[n2].y * factor; + point2.coords[Z] = kData.nodes[n2].z * factor; + point2.outerDiameter = beamSection.TS2; + point2.innerDiameter = beamSection.TT2; - point2.coords[X] = kData.nodes[n2].x * factor; - point2.coords[Y] = kData.nodes[n2].y * factor; - point2.coords[Z] = kData.nodes[n2].z * factor; - point2.outerDiameter = beamSection.TS2; - point2.innerDiameter = beamSection.TT2; + std::string beamNumber = std::to_string(*itr); - std::string beamNumber = std::to_string(*itr); - - geometry.addPipePnt(partName.c_str(), point1); - geometry.addPipePnt(partName.c_str(), point2); + geometry.addPipePnt(point1); + geometry.addPipePnt(point2); + } } - } else if (kData.elements[*itr].nodes.size() == 4) { diff --git a/src/conv/k-g/pipe.cpp b/src/conv/k-g/pipe.cpp index c81444336a..15fffca0a7 100644 --- a/src/conv/k-g/pipe.cpp +++ b/src/conv/k-g/pipe.cpp @@ -33,14 +33,21 @@ Pipe::Pipe(void) { } -void Pipe::setName(const char* value) -{ - name = value; +void Pipe::setName +( + const char* value +) { + if (value != nullptr) + name = value; + else + name = ""; } -void Pipe::addPipePnt(const char* PipeName, const pipePoint& point) -{ +void Pipe::addPipePnt +( + const pipePoint& point +) { struct wdb_pipe_pnt* ctlPoint; BU_ALLOC(ctlPoint, struct wdb_pipe_pnt); ctlPoint->l.magic = WDB_PIPESEG_MAGIC; @@ -56,6 +63,16 @@ void Pipe::addPipePnt(const char* PipeName, const pipePoint& point) m_pipe->pipe_count += 1; } +const char* Pipe::getName(void) const +{ + return name.c_str(); +} + +rt_pipe_internal* Pipe::getPipe(void) const +{ + return m_pipe; +} + std::vector Pipe::write ( rt_wdb* wdbp @@ -66,7 +83,13 @@ std::vector Pipe::write pipeName += ".pipe"; ret.push_back(pipeName); - wdb_export(wdbp, pipeName.c_str(), m_pipe, ID_PIPE, 1); + rt_pipe_internal* pipe_wdb; + BU_GET(pipe_wdb, rt_pipe_internal); + pipe_wdb->pipe_magic = RT_PIPE_INTERNAL_MAGIC; + BU_LIST_INIT(&pipe_wdb->pipe_segs_head); + BU_LIST_APPEND_LIST(&pipe_wdb->pipe_segs_head, &m_pipe->pipe_segs_head); + + wdb_export(wdbp, pipeName.c_str(), pipe_wdb, ID_PIPE, 1); return ret; } diff --git a/src/conv/k-g/pipe.h b/src/conv/k-g/pipe.h index 4fff5c4fbb..7372d8314a 100644 --- a/src/conv/k-g/pipe.h +++ b/src/conv/k-g/pipe.h @@ -40,11 +40,14 @@ class Pipe { void setName(const char* value); - void addPipePnt(const char* pipeName, const pipePoint& point); + void addPipePnt(const pipePoint& point); - std::vector write(rt_wdb* wdbp); + const char* getName(void) const; + rt_pipe_internal* getPipe(void) const; + + std::vector write(rt_wdb* wdbp); private: - std::string name; + std::string name; rt_pipe_internal* m_pipe; }; From ad78397a2186c12736761843ead2df7ae1d0152f Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Wed, 21 Aug 2024 20:14:34 +0200 Subject: [PATCH 14/17] new line --- src/conv/k-g/geometry.cpp | 2 +- src/conv/k-g/geometry.h | 2 +- src/conv/k-g/pipe.cpp | 2 +- src/conv/k-g/pipe.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conv/k-g/geometry.cpp b/src/conv/k-g/geometry.cpp index 44c7336eed..7fb3d0c9f1 100644 --- a/src/conv/k-g/geometry.cpp +++ b/src/conv/k-g/geometry.cpp @@ -122,4 +122,4 @@ std::vector Geometry::write // indent-tabs-mode: t // c-file-style: "stroustrup" // End: -// ex: shiftwidth=4 tabstop=8 \ No newline at end of file +// ex: shiftwidth=4 tabstop=8 diff --git a/src/conv/k-g/geometry.h b/src/conv/k-g/geometry.h index 99d31b6581..e105a7032f 100644 --- a/src/conv/k-g/geometry.h +++ b/src/conv/k-g/geometry.h @@ -75,4 +75,4 @@ class Geometry { // indent-tabs-mode: t // c-file-style: "stroustrup" // End: -// ex: shiftwidth=4 tabstop=8 \ No newline at end of file +// ex: shiftwidth=4 tabstop=8 diff --git a/src/conv/k-g/pipe.cpp b/src/conv/k-g/pipe.cpp index 15fffca0a7..c52d545b9a 100644 --- a/src/conv/k-g/pipe.cpp +++ b/src/conv/k-g/pipe.cpp @@ -102,4 +102,4 @@ std::vector Pipe::write // indent-tabs-mode: t // c-file-style: "stroustrup" // End: -// ex: shiftwidth=4 tabstop=8 \ No newline at end of file +// ex: shiftwidth=4 tabstop=8 diff --git a/src/conv/k-g/pipe.h b/src/conv/k-g/pipe.h index 7372d8314a..ca498281ae 100644 --- a/src/conv/k-g/pipe.h +++ b/src/conv/k-g/pipe.h @@ -62,4 +62,4 @@ class Pipe { // indent-tabs-mode: t // c-file-style: "stroustrup" // End: -// ex: shiftwidth=4 tabstop=8 \ No newline at end of file +// ex: shiftwidth=4 tabstop=8 From fa697b262aabd1ad173a6b7671eb83a599f3c1ed Mon Sep 17 00:00:00 2001 From: louisgoogl Date: Fri, 23 Aug 2024 11:31:51 +0200 Subject: [PATCH 15/17] third node will be used later with the other types of sections. --- src/conv/k-g/k-g.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/conv/k-g/k-g.cpp b/src/conv/k-g/k-g.cpp index bb3f4292f9..1eea58cc74 100644 --- a/src/conv/k-g/k-g.cpp +++ b/src/conv/k-g/k-g.cpp @@ -138,6 +138,7 @@ int main for (std::set::iterator itr = (it->second).elements.begin(); itr != (it->second).elements.end(); itr++) { if ((kData.elements[*itr].nodes.size() == 3)) { + //int n3 = kData.elements[*itr].nodes[2]; if (section > 0) { KSectionBeam beamSection = kData.sectionsBeam[section]; From d2f194d0a5bfe08a88f4de8ad068009c964dcc85 Mon Sep 17 00:00:00 2001 From: Ali haydar Date: Fri, 23 Aug 2024 19:43:02 +0200 Subject: [PATCH 16/17] Update k-g.cpp The third node will be used later for defining the cross-section plain for beams with asymmetric cross-section --- src/conv/k-g/k-g.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conv/k-g/k-g.cpp b/src/conv/k-g/k-g.cpp index 1eea58cc74..830b7b96e7 100644 --- a/src/conv/k-g/k-g.cpp +++ b/src/conv/k-g/k-g.cpp @@ -149,7 +149,7 @@ int main int n1 = kData.elements[*itr].nodes[0]; int n2 = kData.elements[*itr].nodes[1]; - int n3 = kData.elements[*itr].nodes[2]; + //int n3 = kData.elements[*itr].nodes[2]; point1.coords[X] = kData.nodes[n1].x * factor; point1.coords[Y] = kData.nodes[n1].y * factor; point1.coords[Z] = kData.nodes[n1].z * factor; From 179746c931a7553b0c1c262f6c781a9d67753371 Mon Sep 17 00:00:00 2001 From: Ali haydar Date: Fri, 23 Aug 2024 20:15:38 +0200 Subject: [PATCH 17/17] Update k_parser.cpp --- src/conv/k-g/k_parser.cpp | 138 +++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/src/conv/k-g/k_parser.cpp b/src/conv/k-g/k_parser.cpp index 1f0c0c2301..095ec0f02f 100644 --- a/src/conv/k-g/k_parser.cpp +++ b/src/conv/k-g/k_parser.cpp @@ -41,51 +41,51 @@ enum class KState { Element_Beam_Pulley, Element_Beam_Source, Element_Bearing, - Element_Blanking, - Element_Direct_Matrix_Input, - Element_Discrete, - Element_Discrete_Sphere, - Element_Generalized_Shell, - Element_Generalized_Solid, - Element_Inertia, - Element_Interpolation_Shell, - Element_Interpolation_Solid, - Element_Lancing, - Element_Mass, - Element_Mass_Matrix, - Element_Mass_Part, - Element_Plotel, - Element_Seatbealt, - Element_Seatbealt_Accelerometer, - Element_Seatbealt_Pretensioner, - Element_Seatbealt_Retractor, - Element_Seatbealt_Sensor, - Element_Seatbealt_Slipring, + //Element_Blanking, + //Element_Direct_Matrix_Input, + //Element_Discrete, + //Element_Discrete_Sphere, + //Element_Generalized_Shell, + //Element_Generalized_Solid, + //Element_Inertia, + //Element_Interpolation_Shell, + //Element_Interpolation_Solid, + //Element_Lancing, + //Element_Mass, + //Element_Mass_Matrix, + //Element_Mass_Part, + //Element_Plotel, + //Element_Seatbealt, + //Element_Seatbealt_Accelerometer, + //Element_Seatbealt_Pretensioner, + //Element_Seatbealt_Retractor, + //Element_Seatbealt_Sensor, + //Element_Seatbealt_Slipring, Element_Shell, - Element_Shell_Nurbs_Patch, - Element_Shell_Source_Sink, + //Element_Shell_Nurbs_Patch, + //Element_Shell_Source_Sink, Element_Solid, - Element_Solid_Nurbs_Patch, - Element_Solid_Peri, - Element_Sph, - Element_Trim, - Element_Tshell, + //Element_Solid_Nurbs_Patch, + //Element_Solid_Peri, + //Element_Sph, + //Element_Trim, + //Element_Tshell, Part, Part_Adaptive_Failure, Section_Ale1d, Section_Ale2d, Section_Beam, - Section_Beam_AISC, - Section_Discrete, - Section_Fpd, - Section_Point_Source, - Section_Point_source_Mixture, - Section_Seatbelt, + //Section_Beam_AISC, + //Section_Discrete, + //Section_Fpd, + //Section_Point_Source, + //Section_Point_source_Mixture, + //Section_Seatbelt, Section_Shell, Section_Solid, - Section_Solid_Peri, - Section_Sph, - Section_Tshell + //Section_Solid_Peri, + //Section_Sph, + //Section_Tshell }; enum class Options { @@ -239,12 +239,12 @@ bool parse_k std::string partTitle; size_t sectionLinesRead = 0; size_t elementLinesRead = 0; - size_t cardCounter = 0;// this will replace sectionLinesRead elementLinesRead, and partLinesRead + //size_t cardCounter = 0;// this will replace sectionLinesRead elementLinesRead, and partLinesRead size_t optionsCounter = 0; std::string sectionTitle; int sectionId = -1; int sectionElForm = 0; - int CST = 0; + //int CST = 0; std::string line = read_line(is); std::vector tokens; const size_t FirstNode = 2; @@ -341,140 +341,140 @@ bool parse_k } } else if ((command.size() > 1) && (command[1] == "BLANKING")) { - state = KState::Element_Blanking; + //state = KState::Element_Blanking; optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } else if ((command.size() > 3) && (command[1] == "DIRECT") && (command[2] == "MATRIX") && (command[3] == "INPUT")) { - state = KState::Element_Direct_Matrix_Input; + //state = KState::Element_Direct_Matrix_Input; optionsContainer.insert(optionsContainer.end(), command.begin() + 4, command.end()); } else if ((command.size() > 1) && (command[1] == "DISCRETE")) { if ((command.size() > 2) && (command[2] == "SPHERE")) { - state = KState::Element_Discrete_Sphere; + //state = KState::Element_Discrete_Sphere; optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else { - state = KState::Element_Discrete; + //state = KState::Element_Discrete; optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } } else if ((command.size() > 2) && (command[1] == "GENERALIZED")) { if ((command[2] == "SHELL")) { - state = KState::Element_Generalized_Shell; + //state = KState::Element_Generalized_Shell; optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else { - state = KState::Element_Generalized_Solid; + //state = KState::Element_Generalized_Solid; optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } } else if ((command.size() > 1) && (command[1] == "INERTIA")) { - state = KState::Element_Inertia; + //state = KState::Element_Inertia; optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } else if ((command.size() > 2) && (command[1] == "INTERPOLATION")) { if (command[2] == "SHELL") { - state = KState::Element_Interpolation_Shell; + //state = KState::Element_Interpolation_Shell; optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else { - state = KState::Element_Interpolation_Solid; + //state = KState::Element_Interpolation_Solid; optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } } else if ((command.size() > 1) && (command[1] == "LANCING")) { - state = KState::Element_Lancing; + //state = KState::Element_Lancing; optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } else if ((command.size() > 1) && (command[1] == "MASS")) { if ((command.size() > 2) && (command[2] == "MATRIX")) { - state = KState::Element_Mass_Matrix; + //state = KState::Element_Mass_Matrix; optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else if ((command.size() > 2) && (command[2] == "PART")) { - state = KState::Element_Mass_Part; + //state = KState::Element_Mass_Part; optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else { - state = KState::Element_Mass; + //state = KState::Element_Mass; optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } } else if ((command.size() > 1) && (command[1] == "PLOTEL")) { - state = KState::Element_Plotel; + //state = KState::Element_Plotel; optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } else if ((command.size() > 1) && (command[1] == "SEATBELT")) { if ((command.size() > 2) && (command[2] == "ACCELEROMETER")) { - state = KState::Element_Seatbealt_Accelerometer; + //state = KState::Element_Seatbealt_Accelerometer; optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else if ((command.size() > 2) && (command[2] == "PRETENSIONER")) { - state = KState::Element_Seatbealt_Pretensioner; + //state = KState::Element_Seatbealt_Pretensioner; optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else if ((command.size() > 2) && (command[2] == "RETRACTOR")) { - state = KState::Element_Seatbealt_Retractor; + //state = KState::Element_Seatbealt_Retractor; optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else if ((command.size() > 2) && (command[2] == "SENSOR")) { - state = KState::Element_Seatbealt_Sensor; + //state = KState::Element_Seatbealt_Sensor; optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else if ((command.size() > 2) && (command[2] == "SLIPRING")) { - state = KState::Element_Seatbealt_Slipring; + //state = KState::Element_Seatbealt_Slipring; optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } else { - state = KState::Element_Seatbealt; + //state = KState::Element_Seatbealt; optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } } else if ((command.size() > 1) && (command[1] == "SHELL")) { if ((command.size() > 2) && (command[2] == "NURBS")) { - state = KState::Element_Shell_Nurbs_Patch; + //state = KState::Element_Shell_Nurbs_Patch; optionsContainer.insert(optionsContainer.end(), command.begin() + 4, command.end()); } else if ((command.size() > 2) && (command[2] == "SOURCE")) { - state = KState::Element_Shell_Source_Sink; + //state = KState::Element_Shell_Source_Sink; optionsContainer.insert(optionsContainer.end(), command.begin() + 4, command.end()); } else { - state = KState::Element_Shell; + //state = KState::Element_Shell; optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } } else if ((command.size() > 1) && (command[1] == "SOLID")) { if ((command.size() > 2) && (command[2] == "NURBS")) { - state = KState::Element_Solid_Nurbs_Patch; + //state = KState::Element_Solid_Nurbs_Patch; optionsContainer.insert(optionsContainer.end(), command.begin() + 4, command.end()); } else if ((command.size() > 2) && (command[2] == "PERI")) { - state = KState::Element_Solid_Peri; + //state = KState::Element_Solid_Peri; optionsContainer.insert(optionsContainer.end(), command.begin() + 3, command.end()); } @@ -485,17 +485,17 @@ bool parse_k } } else if ((command.size() > 1) && (command[1] == "SPH")) { - state = KState::Element_Sph; + //state = KState::Element_Sph; optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } else if ((command.size() > 1) && (command[1] == "TRIM")) { - state = KState::Element_Trim; + //state = KState::Element_Trim; optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } else if ((command.size() > 1) && (command[1] == "TSHELL")) { - state = KState::Element_Tshell; + //state = KState::Element_Tshell; optionsContainer.insert(optionsContainer.end(), command.begin() + 2, command.end()); } @@ -804,8 +804,8 @@ bool parse_k if ((first7characters == "SECTION")) { sectionBeam.sectionType = tokens[0]; - for (size_t i_d = 1; i_d < 7; ++i_d) { - sectionBeam.D[i_d - 1] = stod(tokens[i_d]); + for (size_t i_d = 1; i_d < 5; ++i_d) { + sectionBeam.D.push_back(stod(tokens[i_d])); } } else { @@ -1171,7 +1171,7 @@ bool parse_k ++optionsCounter; break; } - default: + default: break; } }