From c866cbd4b39244a2d9ab0d90f550181c956e83ae Mon Sep 17 00:00:00 2001 From: Knut Morten Okstad Date: Thu, 24 Oct 2024 14:42:37 +0200 Subject: [PATCH] Fix issue openfedem/fedem-gui#7: Support MPC Nastran bulk entries by conversion to WAVGM elements. Replace some static functions in FFlNastranProcessor.C file scope by lambdas. --- .../FFlIOAdaptors/FFlNastranProcessor.C | 165 ++++++++---- src/FFlLib/FFlIOAdaptors/FFlNastranReader.C | 5 + src/FFlLib/FFlIOAdaptors/FFlNastranReader.H | 4 + src/FFlLib/FFlTests/models/MPC-test.nas | 17 ++ src/FFlLib/FFlTests/models/MPC_RGD_Test.nas | 252 ++++++++++++++++++ src/FFlLib/FFlTests/testParser.C | 23 +- 6 files changed, 414 insertions(+), 52 deletions(-) create mode 100644 src/FFlLib/FFlTests/models/MPC-test.nas create mode 100644 src/FFlLib/FFlTests/models/MPC_RGD_Test.nas diff --git a/src/FFlLib/FFlIOAdaptors/FFlNastranProcessor.C b/src/FFlLib/FFlIOAdaptors/FFlNastranProcessor.C index 4252274..9c6d63d 100644 --- a/src/FFlLib/FFlIOAdaptors/FFlNastranProcessor.C +++ b/src/FFlLib/FFlIOAdaptors/FFlNastranProcessor.C @@ -179,6 +179,7 @@ bool FFlNastranReader::processThisEntry (const std::string& name, if (name == "RBE2") return process_RBE2 (entry); if (name == "RBE3") return process_RBE3 (entry); if (name == "RBAR") return process_RBAR (entry); + if (name == "MPC") return process_MPC (entry); if (name == "CWELD") return process_CWELD (entry); if (name == "CBEAM") return process_CBEAM (entry); if (name == "CBAR") return process_CBAR (entry); @@ -255,6 +256,7 @@ bool FFlNastranReader::processThisEntry (const std::string& name, return true; } + //////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// ASET /// //////////////////////////////////////////////////////////////////////////////// @@ -2449,6 +2451,7 @@ bool FFlNastranReader::process_MAT9 (std::vector& entry) return true; } + //////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// PCOMP // //////////////////////////////////////////////////////////////////////////////// @@ -2506,6 +2509,7 @@ bool FFlNastranReader::process_PCOMP (std::vector& entry) return true; } + //////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// MOMENT / //////////////////////////////////////////////////////////////////////////////// @@ -2547,6 +2551,75 @@ bool FFlNastranReader::process_MOMENT (std::vector& entry) } +//////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// MPC //// +//////////////////////////////////////////////////////////////////////////////// + +bool FFlNastranReader::process_MPC (std::vector& entry) +{ + START_TIMER("process_MPC") + + if (entry.size() < 7) entry.resize(7,""); + + int SID = 0; + size_t nMst = 1 + (entry.size()-6)/4; + std::vector G(1+nMst,0), C(1+nMst,0); + std::vector A(1+nMst,0.0); + + CONVERT_ENTRY ("MPC", + fieldValue(entry[0],SID) && + fieldValue(entry[1],G[0]) && + fieldValue(entry[2],C[0]) && + fieldValue(entry[3],A[0]) && + fieldValue(entry[4],G[1]) && + fieldValue(entry[5],C[1]) && + fieldValue(entry[6],A[1])); + + size_t i = 8; + for (size_t j = 2; i+2 < entry.size(); j++) + { + CONVERT_ENTRY ("MPC", + fieldValue(entry[i+1],G[j]) && + fieldValue(entry[i+2],C[j]) && + (i+3 >= entry.size() || fieldValue(entry[i+3],A[j]))); + i += j%2 ? 5 : 3; + } + +#ifdef FFL_DEBUG + std::cout <<"Multi-point constraint, SID = "<< SID <<": "; + for (i = 0; i < G.size(); i++) + { + if (i == 0) + std::cout << A.front(); + else if (A[i] < 0.0) + std::cout <<" - "<< -A[i]; + else if (A[i] > 0.0) + std::cout <<" + "<< A[i]; + else + continue; + std::cout <<"*("<< G[i] <<","<< C[i] <<")"; + } + std::cout <<" = 0"<< std::endl; +#endif + + if (fabs(A.front()) < 1.0e-12) + { + ListUI <<"\n *** Error: A1 ("<< A.front() <<") must be non-zero" + <<" for MPC "<< SID <<".\n"; + STOPP_TIMER("process_MPC") + return false; + } + + FFl::DepDOFs& masters = myMPCs[G.front()][C.front()]; + masters.reserve(G.size()-1); + for (i = 1; i < G.size(); i++) + masters.push_back(FFl::DepDOF(G[i],C[i],-A[i]/A.front())); + + STOPP_TIMER("process_MPC") + return true; +} + + //////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// PBAR /// //////////////////////////////////////////////////////////////////////////////// @@ -3341,14 +3414,13 @@ bool FFlNastranReader::process_PSOLID (std::vector& entry) { START_TIMER("process_PSOLID") - int PID = 0, MID = 0, CORDM = 0; + int PID = 0, MID = 0; - if (entry.size() < 7) entry.resize(7,""); + if (entry.size() < 2) entry.resize(2,""); CONVERT_ENTRY ("PSOLID", fieldValue(entry[0],PID) && - fieldValue(entry[1],MID) && - fieldValue(entry[2],CORDM)); + fieldValue(entry[1],MID)); #ifdef FFL_DEBUG std::cout <<"Solid property, ID = "<< PID <<" --> material ID = "<< MID @@ -3579,59 +3651,57 @@ bool FFlNastranReader::process_RBE2 (std::vector& entry) /////////////////////////////////////////////////////////////////////// RBE3 /// //////////////////////////////////////////////////////////////////////////////// -// Some auxilliary functions for processing of component numbers in process_RBE3 - -static bool isDigitIn (int target, const int digit) +bool FFlNastranReader::process_RBE3 (std::vector& entry) { - while (target > 0) + // Lambda function checking if given target integer contains given digit + auto&& isDigitIn = [](int target, const int digit) { - if (target%10 == digit) return true; - target /= 10; - } - return false; -} + while (target > 0) + if (target%10 == digit) + return true; + else + target /= 10; + return false; + }; -static bool isSubset (int target, int value) -{ - while (value > 0) + // Lambda function checking if given target integer contains a set of digits. + auto&& isSubset = [&isDigitIn](int target, int value) { - if (!isDigitIn(target,value%10)) return false; - value /= 10; - } - return true; -} - -static bool setMinusIfSubset (int& target, int value) -{ - if (!isSubset(target,value)) return false; + while (value > 0) + if (!isDigitIn(target,value%10)) + return false; + else + value /= 10; + return true; + }; - int digit, result = 0, expon = 1; - while (target > 0) + // Lambda function removong a set of digits from given target integer. + auto&& setMinusIfSubset = [&isSubset,&isDigitIn](int& target, int value) { - digit = target%10; - if (!isDigitIn(value,digit)) result += digit*expon; - expon *= 10; - target /= 10; - } - target = result; - return true; -} - + if (!isSubset(target,value)) + return false; -/*! - \brief Group of independent nodes with common weight and component numbers. -*/ + int digit, result = 0, expon = 1; + while (target > 0) + { + digit = target%10; + if (!isDigitIn(value,digit)) + result += digit*expon; + expon *= 10; + target /= 10; + } -struct NodeGroup -{ - double WT = 0.0; //!< Common weighting factor - int C = 0; //!< Component numbers - std::vector G; //!< List of node numbers -}; + target = result; + return true; + }; + struct NodeGroup + { + double WT = 0.0; + int C = 0; + std::vector G; + }; -bool FFlNastranReader::process_RBE3 (std::vector& entry) -{ START_TIMER("process_RBE3") int n, EID, REFC = 0; @@ -3773,7 +3843,6 @@ bool FFlNastranReader::process_RBE3 (std::vector& entry) //////////////////////////////////////////////////////////////////////// SPC /// //////////////////////////////////////////////////////////////////////////////// - FFlNastranReader::IntMap::iterator FFlNastranReader::setDofFlag (int n, int flg) { IntMap::iterator it = nodeStat.find(n); diff --git a/src/FFlLib/FFlIOAdaptors/FFlNastranReader.C b/src/FFlLib/FFlIOAdaptors/FFlNastranReader.C index c2bb823..f351ebe 100644 --- a/src/FFlLib/FFlIOAdaptors/FFlNastranReader.C +++ b/src/FFlLib/FFlIOAdaptors/FFlNastranReader.C @@ -400,6 +400,11 @@ bool FFlNastranReader::resolve (bool stillOK) std::cout <<"FFlNastranReader: resolving loads ..."<< std::endl; #endif if (stillOK) stillOK = this->resolveLoads(); +#ifdef FFL_DEBUG + std::cout <<"FFlNastranReader: resolving MPCs ..."<< std::endl; +#endif + if (stillOK) stillOK = FFl::convertMPCsToWAVGM(myLink,myMPCs); + myMPCs.clear(); #ifdef FFL_DEBUG std::cout <<"FFlNastranReader: resolve done."<< std::endl; #endif diff --git a/src/FFlLib/FFlIOAdaptors/FFlNastranReader.H b/src/FFlLib/FFlIOAdaptors/FFlNastranReader.H index 4a77b8e..fc5d1bb 100644 --- a/src/FFlLib/FFlIOAdaptors/FFlNastranReader.H +++ b/src/FFlLib/FFlIOAdaptors/FFlNastranReader.H @@ -9,6 +9,7 @@ #define FFL_NASTRAN_READER_H #include "FFlReaderBase.H" +#include "FFlLib/FFlUtils.H" #include "FFaLib/FFaAlgebra/FFaMat34.H" #include "FFaLib/FFaAlgebra/FFaVec3.H" #include @@ -127,6 +128,8 @@ private: LoadFaceMap loadFace; // Pressure load --> element face nodes std::map loadCID; // Load --> coord. system ID for direction + FFl::MPCMap myMPCs; + static int nWarnings, nNotes; // Accumulates the number of warnings and notes mutable std::pair lastComment; @@ -251,6 +254,7 @@ protected: DEF_PROCESSOR( MAT8 ) // Material properties DEF_PROCESSOR( MAT9 ) // Material properties DEF_PROCESSOR( MOMENT ) // Concentrated moment at grid point + DEF_PROCESSOR( MPC ) // Multi-point constraints DEF_PROCESSOR( PBAR ) // Properties for CBAR DEF_PROCESSOR( PBARL ) // Properties for CBAR with cross section dimensions DEF_PROCESSOR( PBEAM ) // Properties for CBEAM diff --git a/src/FFlLib/FFlTests/models/MPC-test.nas b/src/FFlLib/FFlTests/models/MPC-test.nas new file mode 100644 index 0000000..b4ff9ba --- /dev/null +++ b/src/FFlLib/FFlTests/models/MPC-test.nas @@ -0,0 +1,17 @@ +BEGIN BULK +GRID,1,0,0.0 +GRID,2,0,1.0 +GRID,3,0,2.0 +GRID,4,0,3.0 +GRID,5,0,4.0 +GRID,6,0,5.0 +CTETRA,1,1,1,4,5,6 +PSOLID,1,1 +MAT1,1,1.0,1.0,0.3,1.0 +MPC,1,2,1,1.,1,1,-1.,,,1,6,.5 +MPC,1,3,1,1.,1,1,-1.,,,1,6,-.5 +MPC,1,3,6,1.,1,6,-1. +MPC,1,2,6,1.,1,6,-1. +MPC,1,2,2,1.,1,2,-1. +MPC,1,3,2,1.,1,2,-1 +ENDDATA diff --git a/src/FFlLib/FFlTests/models/MPC_RGD_Test.nas b/src/FFlLib/FFlTests/models/MPC_RGD_Test.nas new file mode 100644 index 0000000..856cb3a --- /dev/null +++ b/src/FFlLib/FFlTests/models/MPC_RGD_Test.nas @@ -0,0 +1,252 @@ +ASSIGN dbc='01_MPC_Test_coarse.xdb', +unit=40 unformated delete +SOL 101 +TIME 10000 +CEND + TITLE = C:\00_Work\02_Prosjekter\00_Demo\03_Bugmodels\02_MPC_Test\02_ANSYS\01_MPC_Test_coarse.nas + ECHO = NONE + DISPLACEMENT(PLOT) = ALL + STRESS(PLOT) = ALL + SPC = 1 +BEGIN BULK +PARAM, WTMASS,1.000000 +PARAM, POST, 0 +$ CORD SYS ------------------------------ +CORD2R 12 0 0.0000000.0000000.0000000.0000000.0000001.000000 + 1.0000000.0000000.000000 +$ Materials ------------------------------ +MAT1 1 2.000+11 0.3000007850.0001.200-0522.00000 +MAT1 2 2.000+11 0.3000007850.0001.200-0522.00000 +$ Properties ------------------------------ +PSHELL 1 1 0.0100001 1 0.000000 +PSHELL 2 2 0.0050002 2 0.000000 +$ RBE2s (Rigid) ------------------------------ +RBE2 70 65 123456 8 7 3 4 +RBE2 75 67 123456 57 64 43 45 +$ NODES ------------------------------ +GRID 1 0 0.050000-0.050001.9000000 +GRID 2 0 -0.05000-0.050001.9000000 +GRID 3 0 -0.05000-0.050000.0000000 +GRID 4 0 0.050000-0.050000.0000000 +GRID 5 0 0.0500000.0500001.9000000 +GRID 6 0 -0.050000.0500001.9000000 +GRID 7 0 -0.050000.0500000.0000000 +GRID 8 0 0.0500000.0500000.0000000 +GRID 9 0 0.050000-0.050001.5833550 +GRID 10 0 0.050000-0.050001.2666840 +GRID 11 0 0.050000-0.050000.9500130 +GRID 12 0 0.050000-0.050000.6333420 +GRID 13 0 0.050000-0.050000.3166710 +GRID 14 0 0.0500000.0500001.5833640 +GRID 15 0 0.0500000.0500001.2666910 +GRID 16 0 0.0500000.0500000.9500180 +GRID 17 0 0.0500000.0500000.6333450 +GRID 18 0 0.0500000.0500000.3166730 +GRID 19 0 -0.050000.0500001.5833330 +GRID 20 0 -0.050000.0500001.2666670 +GRID 21 0 -0.050000.0500000.9500000 +GRID 22 0 -0.050000.0500000.6333330 +GRID 23 0 -0.050000.0500000.3166670 +GRID 24 0 -0.05000-0.050001.5833640 +GRID 25 0 -0.05000-0.050001.2666910 +GRID 26 0 -0.05000-0.050000.9500180 +GRID 27 0 -0.05000-0.050000.6333450 +GRID 28 0 -0.05000-0.050000.3166730 +GRID 29 0 -0.05000-0.050002.0000000 +GRID 30 0 -0.050000.0500002.0000000 +GRID 31 0 -0.050000.0000002.0000000 +GRID 32 0 0.050000-0.050002.0000000 +GRID 33 0 0.000000-0.050002.0000000 +GRID 34 0 0.0500000.0500002.0000000 +GRID 35 0 0.0000000.0500002.0000000 +GRID 36 0 0.0500000.0000002.0000000 +GRID 37 0 0.0500000.1500002.0000000 +GRID 38 0 -0.133330.1500002.0000000 +GRID 39 0 -0.316670.1500002.0000000 +GRID 40 0 -0.500000.1500002.0000000 +GRID 41 0 -0.683330.1500002.0000000 +GRID 42 0 -0.866670.1500002.0000000 +GRID 43 0 -1.050000.1500002.0000000 +GRID 44 0 0.0500000.1500001.9000000 +GRID 45 0 -1.050000.1500001.9000000 +GRID 46 0 -0.133330.1500001.9000000 +GRID 47 0 -0.316670.1500001.9000000 +GRID 48 0 -0.500000.1500001.9000000 +GRID 49 0 -0.683330.1500001.9000000 +GRID 50 0 -0.866670.1500001.9000000 +GRID 51 0 0.0500000.0500001.9000000 +GRID 52 0 -0.133330.0500001.9000000 +GRID 53 0 -0.316670.0500001.9000000 +GRID 54 0 -0.500000.0500001.9000000 +GRID 55 0 -0.683330.0500001.9000000 +GRID 56 0 -0.866670.0500001.9000000 +GRID 57 0 -1.050000.0500001.9000000 +GRID 58 0 0.0500000.0500002.0000000 +GRID 59 0 -0.133330.0500002.0000000 +GRID 60 0 -0.316670.0500002.0000000 +GRID 61 0 -0.500000.0500002.0000000 +GRID 62 0 -0.683330.0500002.0000000 +GRID 63 0 -0.866670.0500002.0000000 +GRID 64 0 -1.050000.0500002.0000000 +GRID 65 0 0.0000000.0000000.0000000 +GRID 67 0 -1.050000.1000001.9500000 +$ ELEMENTS ------------------------------ +$ ANSYS: Combin14 (longitudinal) +$ ANSYS: Combin14 (coincident) +$ ANSYS: Combin250 +$ ANSYS: Link180 +$ ANSYS: Beam188 +$ ANSYS: Shell 181 +CTRIA3 1 1 35 34 5 +CQUAD4 2 1 6 30 35 5 +CTRIA3 3 1 36 32 1 +CQUAD4 4 1 5 34 36 1 +CTRIA3 5 1 31 30 6 +CQUAD4 6 1 2 29 31 6 +CQUAD4 7 1 18 13 4 8 +CQUAD4 8 1 17 12 13 18 +CQUAD4 9 1 16 11 12 17 +CQUAD4 10 1 15 10 11 16 +CQUAD4 11 1 14 9 10 15 +CQUAD4 12 1 5 1 9 14 +CTRIA3 13 1 33 29 2 +CQUAD4 14 1 1 32 33 2 +CQUAD4 15 1 4 13 28 3 +CQUAD4 16 1 13 12 27 28 +CQUAD4 17 1 12 11 26 27 +CQUAD4 18 1 11 10 25 26 +CQUAD4 19 1 10 9 24 25 +CQUAD4 20 1 9 1 2 24 +CQUAD4 21 1 19 24 2 6 +CQUAD4 22 1 20 25 24 19 +CQUAD4 23 1 21 26 25 20 +CQUAD4 24 1 22 27 26 21 +CQUAD4 25 1 23 28 27 22 +CQUAD4 26 1 7 3 28 23 +CQUAD4 27 1 14 19 6 5 +CQUAD4 28 1 15 20 19 14 +CQUAD4 29 1 16 21 20 15 +CQUAD4 30 1 17 22 21 16 +CQUAD4 31 1 18 23 22 17 +CQUAD4 32 1 8 7 23 18 +CQUAD4 33 2 40 61 62 41 +CQUAD4 34 2 39 60 61 40 +CQUAD4 35 2 63 42 41 62 +CQUAD4 36 2 38 59 60 39 +CQUAD4 37 2 37 58 59 38 +CQUAD4 38 2 64 43 42 63 +CQUAD4 39 2 48 40 41 49 +CQUAD4 40 2 47 39 40 48 +CQUAD4 41 2 42 50 49 41 +CQUAD4 42 2 46 38 39 47 +CQUAD4 43 2 43 45 50 42 +CQUAD4 44 2 44 37 38 46 +CQUAD4 45 2 54 61 60 53 +CQUAD4 46 2 55 62 61 54 +CQUAD4 47 2 59 52 53 60 +CQUAD4 48 2 56 63 62 55 +CQUAD4 49 2 58 51 52 59 +CQUAD4 50 2 57 64 63 56 +CQUAD4 51 2 48 54 53 47 +CQUAD4 52 2 49 55 54 48 +CQUAD4 53 2 52 46 47 53 +CQUAD4 54 2 50 56 55 49 +CQUAD4 55 2 51 44 46 52 +CQUAD4 56 2 45 57 56 50 +$ ANSYS: Shell 281 +$ ANSYS: Solid 185 +$ ANSYS: Solid 186 +$ ANSYS: Solid 187 +$ ANSYS: Mass 21 +$ MPCs +MPC 1 34 4 1.00000058 4 -1.00000 + +MPC 2 34 5 1.00000058 5 -1.00000 + +MPC 3 34 6 1.00000058 6 -1.00000 + +MPC 4 34 1 1.00000058 1 -1.00000 + +MPC 5 34 2 1.00000058 2 -1.00000 + +MPC 6 34 3 1.00000058 3 -1.00000 + +MPC 7 35 1 1.00000059 1 -0.30732 + 58 1 -0.3073252 1 -0.19268 + 51 1 -0.1926858 3 0.105096 + 51 3 0.10509659 3 -0.10510 + 52 3 -0.10510 +MPC 8 35 2 1.00000058 2 -0.61364 + 59 2 -0.3863652 2 0.113636 + 51 2 -0.11364 +MPC 9 35 3 1.00000058 3 -0.33758 + 51 3 -0.3375859 3 -0.16242 + 52 3 -0.1624259 1 0.047771 + 58 1 0.04777152 1 -0.04777 + 51 1 -0.04777 +MPC 10 35 4 1.00000059 2 5.000000 + 58 2 5.00000052 2 -5.00000 + 51 2 -5.00000 +MPC 11 35 5 1.00000058 3 2.101911 + 51 3 2.10191159 3 -2.10191 + 52 3 -2.1019152 1 1.146497 + 51 1 1.14649759 1 -1.14650 + 58 1 -1.14650 +MPC 12 35 6 1.00000059 2 2.727273 + 52 2 2.72727358 2 -2.72727 + 51 2 -2.72727 +MPC 13 5 4 1.00000051 4 -1.00000 +MPC 14 5 5 1.00000051 5 -1.00000 +MPC 15 5 6 1.00000051 6 -1.00000 +MPC 16 5 1 1.00000051 1 -1.00000 +MPC 17 5 2 1.00000051 2 -1.00000 +MPC 18 5 3 1.00000051 3 -1.00000 +MPC 19 30 1 1.00000059 1 -0.30732 + 58 1 -0.3073252 1 -0.19268 + 51 1 -0.1926858 3 0.105096 + 51 3 0.10509659 3 -0.10510 + 52 3 -0.10510 +MPC 20 30 2 1.00000059 2 -0.52273 + 58 2 -0.4772751 2 0.022727 + 52 2 -0.02273 +MPC 21 30 3 1.00000059 3 -0.26752 + 52 3 -0.2675258 3 -0.23248 + 51 3 -0.2324852 1 0.009554 + 51 1 0.00955459 1 -0.00955 + 58 1 -0.00955 +MPC 22 30 4 1.00000059 2 5.000000 + 58 2 5.00000052 2 -5.00000 + 51 2 -5.00000 +MPC 23 30 5 1.00000058 3 2.101911 + 51 3 2.10191159 3 -2.10191 + 52 3 -2.1019152 1 1.146497 + 51 1 1.14649759 1 -1.14650 + 58 1 -1.14650 +MPC 24 30 6 1.00000059 2 2.727273 + 52 2 2.72727358 2 -2.72727 + 51 2 -2.72727 +MPC 25 6 1 1.00000052 1 -0.30732 + 51 1 -0.3073259 1 -0.19268 + 58 1 -0.1926859 3 0.105096 + 52 3 0.10509658 3 -0.10510 + 51 3 -0.10510 +MPC 26 6 2 1.00000052 2 -0.52273 + 51 2 -0.4772758 2 0.022727 + 59 2 -0.02273 +MPC 27 6 3 1.00000059 3 -0.26752 + 52 3 -0.2675258 3 -0.23248 + 51 3 -0.2324852 1 0.009554 + 51 1 0.00955459 1 -0.00955 + 58 1 -0.00955 +MPC 28 6 4 1.00000059 2 5.000000 + 58 2 5.00000052 2 -5.00000 + 51 2 -5.00000 +MPC 29 6 5 1.00000058 3 2.101911 + 51 3 2.10191159 3 -2.10191 + 52 3 -2.1019152 1 1.146497 + 51 1 1.14649759 1 -1.14650 + 58 1 -1.14650 +MPC 30 6 6 1.00000059 2 2.727273 + 52 2 2.72727358 2 -2.72727 + 51 2 -2.72727 +ENDDATA diff --git a/src/FFlLib/FFlTests/testParser.C b/src/FFlLib/FFlTests/testParser.C index 1639e16..32b151b 100644 --- a/src/FFlLib/FFlTests/testParser.C +++ b/src/FFlLib/FFlTests/testParser.C @@ -22,6 +22,8 @@ #include "FFaLib/FFaAlgebra/FFaVec3.H" #include "FFaLib/FFaOS/FFaFortran.H" +using DoubleVec = std::vector; + static std::string inpdir; //!< Full path of the input file directory @@ -111,8 +113,6 @@ TEST(TestFFl,NastranParser) TEST(TestFFl,TaperedBeams) { - using DoubleVec = std::vector; - FFlLinkHandler part; ASSERT_GT(FFlReaders::instance()->read(inpdir+"PBEAM-test.nas",&part),0); std::cout <<"Successfully read "<< inpdir <<"PBEAM-test.nas"<< std::endl; @@ -141,10 +141,9 @@ TEST(TestFFl,TaperedBeams) TEST(TestFFl,BeamCrossSections) { - using DoubleVec = std::vector; - FFlLinkHandler part, partB; ASSERT_GT(FFlReaders::instance()->read(inpdir+"RectangularBeam.nas",&partB),0); + std::cout <<"Successfully read "<< inpdir <<"RectangularBeam.nas"<< std::endl; ASSERT_GT(FFlReaders::instance()->read(inpdir+"PBEAML-test.nas",&part),0); std::cout <<"Successfully read "<< inpdir <<"PBEAML-test.nas"<< std::endl; for (const AttributeMap::value_type& att : partB.getAttributes("PBEAMSECTION")) @@ -164,6 +163,22 @@ TEST(TestFFl,BeamCrossSections) } +/*! + \brief Creates a unit test for parsing Nastran MPC entries. +*/ + +TEST(TestFFl,MPC) +{ + FFlLinkHandler partA, partB; + ASSERT_GT(FFlReaders::instance()->read(inpdir+"MPC-test.nas",&partA),0); + std::cout <<"Successfully read "<< inpdir <<"MPC-test.nas"<< std::endl; + ASSERT_GT(FFlReaders::instance()->read(inpdir+"MPC_RGD_Test.nas",&partB),0); + std::cout <<"Successfully read "<< inpdir <<"MPC_RGD_Test.nas"<< std::endl; + EXPECT_EQ(partA.getElementCount("WAVGM"),2); + EXPECT_EQ(partB.getElementCount("WAVGM"),5); +} + + void ffl_setLink(FFlLinkHandler* part); SUBROUTINE(ffl_getcoor,FFL_GETCOOR) (double* X, double* Y, double* Z, const int& iel, int& ierr);