3216 unsigned int uNode = HP.
GetInt();
3218 DEBUGCOUT(
"Linked to Modal Node: " << uNode << std::endl);
3223 if (pTmpNode == 0) {
3224 silent_cerr(
"Modal(" << uLabel <<
"): "
3225 "StructuralNode(" << uNode <<
") "
3227 <<
" not defined" << std::endl);
3232 silent_cerr(
"Modal(" << uLabel <<
"): "
3234 "StructuralNode(" << uNode <<
") "
3239 pModalNode =
dynamic_cast<const ModalNode *
>(pTmpNode);
3242 if (pModalNode->
pGetRBK() != 0) {
3243 silent_cerr(
"Modal(" << uLabel
3244 <<
"): StructuralNode(" << uNode
3245 <<
") uses rigid body kinematics at line "
3259 int tmpNModes = HP.
GetInt();
3260 if (tmpNModes <= 0) {
3261 silent_cerr(
"Modal(" << uLabel <<
"): "
3262 "illegal number of modes " << tmpNModes <<
" at line "
3266 unsigned int NModes = (
unsigned int)tmpNModes;
3267 unsigned int uLargestMode(0);
3269 std::vector<unsigned int> uModeNumber(NModes);
3271 for (
unsigned int iCnt = 0; iCnt < NModes; iCnt++) {
3275 silent_cerr(
"Modal(" << uLabel <<
"): "
3276 "illegal mode number "
3277 "for mode #" << iCnt + 1
3283 std::vector<unsigned int>::const_iterator
3284 iv = std::find(uModeNumber.begin(),
3285 uModeNumber.end(), (
unsigned int)n);
3286 if (iv != uModeNumber.end()) {
3287 silent_cerr(
"Modal(" << uLabel <<
"): "
3288 "mode #" << iCnt + 1
3289 <<
" already defined "
3295 if ((
unsigned int)n > uLargestMode) {
3296 uLargestMode = (
unsigned int)n;
3299 uModeNumber[iCnt] = n;
3303 for (
unsigned int iCnt = 1; iCnt <= NModes; iCnt++) {
3304 uModeNumber[iCnt - 1] = iCnt;
3306 uLargestMode = NModes;
3309 std::vector<doublereal> InitialValues(NModes, 0.);
3310 std::vector<doublereal> InitialValuesP(NModes, 0.);
3311 bool bInitialValues(
false);
3313 bInitialValues =
true;
3321 silent_cerr(
"Modal(" << uLabel <<
"): "
3322 "illegal mode number "
3323 "for initial value #" << iCnt + 1
3329 std::vector<unsigned int>::const_iterator
3330 iv = std::find(uModeNumber.begin(),
3331 uModeNumber.end(), (
unsigned int)n);
3332 if (iv == uModeNumber.end()) {
3333 silent_cerr(
"Modal(" << uLabel <<
"): "
3334 "mode " << n <<
" not defined "
3340 unsigned iIdx = iv - uModeNumber.begin();
3341 InitialValues[iIdx] = HP.
GetReal();
3342 InitialValuesP[iIdx] = HP.
GetReal();
3348 for (
unsigned int iCnt = 0; iCnt < NModes; iCnt++) {
3349 InitialValues[0] = HP.
GetReal();
3350 InitialValuesP[0] = HP.
GetReal();
3356 unsigned int NFEMNodes = unsigned(-1);
3358 int tmpNFEMNodes = HP.
GetInt();
3359 if (tmpNFEMNodes <= 0) {
3360 silent_cerr(
"Modal(" << uLabel <<
"): "
3361 "illegal number of FEM nodes " << tmpNFEMNodes
3365 NFEMNodes = unsigned(tmpNFEMNodes);
3368 #ifdef MODAL_SCALE_DATA
3385 scaleinertia = scalemasses*(scalemodes*scalemodes);
3390 DAMPING_FROM_FILE = 0,
3394 DAMPING_SINGLE_FACTOR,
3396 } eDamp(DAMPING_FROM_FILE);
3397 const char *sDamp[] = {
3398 "damping from file",
3402 "single factor damping",
3407 doublereal damp_factor(0.), damp_coef_M(0.), damp_coef_K(0.);
3408 std::vector<doublereal> DampRatios;
3413 }
else if (HP.
IsKeyWord(
"rayleigh" "damping")) {
3414 eDamp = DAMPING_RAYLEIGH;
3416 if (damp_coef_M < 0.) {
3417 silent_cerr(
"Modal(" << uLabel <<
"): "
3418 "warning, negative mass damping coefficient for \"Rayleigh damping\" "
3422 if (damp_coef_K < 0.) {
3423 silent_cerr(
"Modal(" << uLabel <<
"): "
3424 "warning, negative stiffness damping coefficient for \"Rayleigh damping\" "
3428 }
else if (HP.
IsKeyWord(
"single" "factor" "damping")) {
3429 eDamp = DAMPING_SINGLE_FACTOR;
3431 if (damp_factor < 0.) {
3432 silent_cerr(
"Modal(" << uLabel <<
"): "
3433 "warning, negative damping factor for \"single factor damping\" "
3437 }
else if (HP.
IsKeyWord(
"proportional" "damping")) {
3438 silent_cerr(
"Modal(" << uLabel <<
"): "
3439 "warning, \"proportional damping\" is deprecated; "
3440 "use \"single factor damping\" with the desired damping factor instead "
3443 eDamp = DAMPING_SINGLE_FACTOR;
3445 if (damp_factor < 0.) {
3446 silent_cerr(
"Modal(" << uLabel <<
"): "
3447 "warning, negative damping factor for \"proportional damping\" "
3451 }
else if (HP.
IsKeyWord(
"diag" "damping")) {
3452 eDamp = DAMPING_DIAG;
3453 DampRatios.resize(NModes);
3454 fill(DampRatios.begin(), DampRatios.end(), 0.);
3457 for (
unsigned int iCnt = 0; iCnt < NModes; iCnt ++) {
3459 if (damp_factor < 0.) {
3460 silent_cerr(
"Modal(" << uLabel <<
"): "
3461 "warning, negative damping factor for \"diag damping\" "
3462 "of mode " << (iCnt + 1 ) <<
" "
3465 DampRatios[iCnt] = damp_factor;
3470 if (iDM <= 0 ||
unsigned(iDM) > NModes) {
3471 silent_cerr(
"invalid number of damped modes "
3476 std::vector<bool> gotit(NModes,
false);
3478 for (
unsigned int iCnt = 1; iCnt <= unsigned(iDM); iCnt ++) {
3480 if (iDampedMode <= 0 ||
unsigned(iDampedMode) > NModes) {
3481 silent_cerr(
"invalid index " << iDampedMode
3482 <<
" for damped mode #" << iCnt
3488 if (gotit[iDampedMode - 1]) {
3489 silent_cerr(
"damping already provided for mode " << iDampedMode
3490 <<
" (damped mode #" << iCnt
3496 gotit[iDampedMode - 1] =
true;
3498 if (damp_factor < 0.) {
3499 silent_cerr(
"Modal(" << uLabel <<
"): "
3500 "warning, negative damping factor for \"diag damping\" "
3501 "of mode " << iDampedMode <<
" "
3504 DampRatios[iDampedMode - 1] = damp_factor;
3507 }
else if (HP.
IsKeyWord(
"damping" "from" "file")) {
3508 eDamp = DAMPING_FROM_FILE;
3510 silent_cout(
"Modal(" << uLabel <<
"): "
3511 "no damping is assumed at line "
3516 DEBUGCOUT(
"Number of Modes Imported : " << NModes << std::endl);
3517 DEBUGCOUT(
"Number of FEM Nodes Imported : " << NFEMNodes << std::endl);
3518 DEBUGCOUT(
"Origin of FEM Model : " << X0 << std::endl);
3519 DEBUGCOUT(
"Orientation of FEM Model : " <<
R << std::endl);
3527 std::vector<doublereal> FEMMass;
3528 std::vector<Vec3> FEMJ;
3530 Mat3xN *pModeShapest = 0;
3531 Mat3xN *pModeShapesr = 0;
3532 Mat3xN PHIti(NModes, 0.);
3533 Mat3xN PHIri(NModes, 0.);
3534 Mat3xN *pXYZFEMNodes = 0;
3555 silent_cerr(
"Modal(" << uLabel <<
"): unable to get "
3556 "modal data file name at line " << HP.
GetLineData()
3561 std::string sFileFEM(s);
3568 dStiffnessThreshold = HP.
GetReal();
3569 if (dStiffnessThreshold < 0.) {
3570 silent_cerr(
"Modal(" << uLabel <<
"): "
3571 "invalid threshold " << dStiffnessThreshold
3576 dMassThreshold = dDampingThreshold = dStiffnessThreshold;
3578 }
else if (HP.
IsKeyWord(
"mass" "threshold")) {
3579 dMassThreshold = HP.
GetReal();
3580 if (dMassThreshold < 0.) {
3581 silent_cerr(
"Modal(" << uLabel <<
"): "
3582 "invalid mass threshold " << dMassThreshold
3588 }
else if (HP.
IsKeyWord(
"damping" "threshold")) {
3589 dDampingThreshold = HP.
GetReal();
3590 if (dDampingThreshold < 0.) {
3591 silent_cerr(
"Modal(" << uLabel <<
"): "
3592 "invalid damping threshold " << dDampingThreshold
3598 }
else if (HP.
IsKeyWord(
"stiffness" "threshold")) {
3599 dStiffnessThreshold = HP.
GetReal();
3600 if (dStiffnessThreshold < 0.) {
3601 silent_cerr(
"Modal(" << uLabel <<
"): "
3602 "invalid stiffness threshold " << dStiffnessThreshold
3614 bool bCreateBinary =
false;
3615 bool bUseBinary =
false;
3616 bool bUpdateBinary =
false;
3619 bCreateBinary =
true;
3621 }
else if (HP.
IsKeyWord(
"use" "binary")) {
3624 }
else if (HP.
IsKeyWord(
"update" "binary")) {
3625 bUpdateBinary =
true;
3632 std::string sEchoFileName;
3633 int iEchoPrecision(13);
3637 silent_cerr(
"Modal(" << uLabel <<
"): "
3638 "unable to parse echo file name at line " << HP.
GetLineData()
3645 iEchoPrecision = HP.
GetInt();
3646 if (iEchoPrecision <= 0) {
3647 silent_cerr(
"Modal(" << uLabel <<
"): "
3656 std::string sBinFileFEM;
3657 struct stat stFEM, stBIN;
3658 bool bReadFEM =
true,
3662 if (stat(sFileFEM.c_str(), &stFEM) == -1) {
3663 int save_errno = errno;
3664 char *errmsg = strerror(save_errno);
3666 silent_cerr(
"Modal(" << uLabel <<
"): "
3667 "unable to stat(\"" << sFileFEM <<
"\") "
3668 "(" << save_errno <<
": " << errmsg <<
")"
3673 if (bUseBinary || bCreateBinary || bUpdateBinary) {
3674 sBinFileFEM = sFileFEM +
".bin";
3676 if (stat(sBinFileFEM.c_str(), &stBIN) == -1) {
3677 int save_errno = errno;
3678 char *errmsg = strerror(save_errno);
3680 if (save_errno == ENOENT && (bCreateBinary || bUpdateBinary)) {
3681 silent_cerr(
"Modal(" << uLabel <<
"): "
3682 "creating binary file "
3683 "\"" << sBinFileFEM <<
"\" "
3685 "\"" << sFileFEM <<
"\""
3689 silent_cerr(
"Modal(" << uLabel <<
"): "
3690 "unable to stat(\"" << sBinFileFEM <<
"\") "
3691 "(" << save_errno <<
": " << errmsg <<
")"
3702 if (bUseBinary && bCheckBIN) {
3704 if (stBIN.st_mtime > stFEM.st_mtime) {
3709 if (bUpdateBinary) {
3712 silent_cout(
"Modal(" << uLabel <<
"): "
3713 "binary database file \"" << sBinFileFEM <<
"\" "
3714 "older than text database file \"" << sFileFEM <<
"\"; "
3719 silent_cerr(
"Modal(" << uLabel <<
"): "
3720 "warning, binary database file \"" << sBinFileFEM <<
"\" "
3721 "older than text database file \"" << sFileFEM <<
"\"; "
3722 "using text database file "
3723 "(enable \"update binary\" to refresh binary database file)"
3728 }
else if (bCreateBinary || bUpdateBinary) {
3745 std::vector<std::string> IdFEMNodes;
3746 std::vector<bool> bActiveModes;
3749 MODAL_VERSION_UNKNOWN = 0,
3751 MODAL_VERSION_1 = 1,
3752 MODAL_VERSION_2 = 2,
3753 MODAL_VERSION_3 = 3,
3754 MODAL_VERSION_4 = 4,
3760 const char magic[5] =
"bmod";
3761 const uint32_t BinVersion = MODAL_VERSION_4;
3763 uint32_t currBinVersion = MODAL_VERSION_UNKNOWN;
3765 uint32_t NFEMNodesFEM = 0, NModesFEM = 0;
3767 bool bBuildInvariants =
false;
3780 MODAL_RECORD_10 = 10,
3781 MODAL_RECORD_11 = 11,
3782 MODAL_RECORD_12 = 12,
3783 MODAL_RECORD_13 = 13,
3789 MODAL_END_OF_FILE = char(-1)
3793 bool bRecordGroup[MODAL_LAST_RECORD] = {
false };
3812 std::ifstream fdat(sFileFEM.c_str());
3814 silent_cerr(
"Modal(" << uLabel <<
"): "
3815 "unable to open file \"" << sFileFEM <<
"\""
3825 fbin.open(sBinFileFEM.c_str(), std::ios::binary | std::ios::trunc);
3827 silent_cerr(
"Modal(" << uLabel <<
"): "
3828 "unable to open file \"" << sBinFileFEM <<
"\""
3833 fbin.write(&magic[0],
sizeof(4));
3834 currBinVersion = BinVersion;
3835 fbin.write((
const char *)&currBinVersion,
sizeof(currBinVersion));
3843 unsigned int NRejModes = 0;
3846 while (fdat && !fdat.eof()) {
3847 fdat.getline(str,
sizeof(str));
3849 if (strncmp(
"** END OF FILE", str,
STRLENOF(
"** END OF FILE")) == 0) {
3854 if (strncmp(
"** RECORD GROUP ", str,
3855 STRLENOF(
"** RECORD GROUP ")) != 0) {
3860 long rg = std::strtol(&str[
STRLENOF(
"** RECORD GROUP ")], &next, 10);
3861 if (next == &str[
STRLENOF(
"** RECORD GROUP ")]) {
3862 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
3863 "unable to parse \"RECORD GROUP\" number <" << &str[
STRLENOF(
"** RECORD GROUP ")] <<
">"
3868 if (!bRecordGroup[MODAL_RECORD_1] && rg != MODAL_RECORD_1) {
3869 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
3870 "\"RECORD GROUP 1\" not parsed yet; cannot parse \"RECORD GROUP " << rg <<
"\""
3876 case MODAL_RECORD_1: {
3877 if (bRecordGroup[MODAL_RECORD_1]) {
3878 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
3879 "\"RECORD GROUP 1\" already parsed"
3884 fdat.getline(str,
sizeof(str));
3890 fdat >> NFEMNodesFEM;
3903 NModesFEM -= NRejModes;
3906 if (NFEMNodes ==
unsigned(-1)) {
3907 NFEMNodes = NFEMNodesFEM;
3909 }
else if (NFEMNodes != NFEMNodesFEM) {
3910 silent_cerr(
"Modal(" << uLabel <<
"), "
3911 "file \"" << sFileFEM <<
"\": "
3912 "FEM nodes number " << NFEMNodes
3913 <<
" does not match node number "
3919 if (NModes > NModesFEM) {
3920 silent_cerr(
"Modal(" << uLabel <<
"), "
3921 "file '" << sFileFEM <<
"': "
3922 "number of requested modes "
3923 "(" << NModes <<
") "
3924 "exceeds number of available "
3925 "modes (" << NModesFEM <<
")"
3931 if (NModes < NModesFEM) {
3932 silent_cout(
"Modal(" << uLabel <<
"), "
3933 "file '" << sFileFEM <<
"': "
3935 <<
" of " << NModesFEM
3936 <<
" available modes"
3940 if (uLargestMode > NModesFEM) {
3941 silent_cerr(
"Modal(" << uLabel <<
"), "
3942 "file '" << sFileFEM <<
"': "
3943 "largest requested mode "
3944 "(" << uLargestMode <<
") "
3945 "exceeds available modes "
3946 "(" << NModesFEM <<
")"
3951 if (!bActiveModes.empty()) {
3955 IdFEMNodes.resize(NFEMNodes);
3961 bActiveModes.resize(NModesFEM + 1,
false);
3963 for (
unsigned int iCnt = 0; iCnt < NModes; iCnt++) {
3964 if (uModeNumber[iCnt] > NModesFEM) {
3965 silent_cerr(
"Modal(" << uLabel <<
"): "
3966 "mode " << uModeNumber[iCnt]
3967 <<
" is not available (max = "
3972 bActiveModes[uModeNumber[iCnt]] =
true;
3976 checkPoint = MODAL_RECORD_1;
3977 fbin.write(&checkPoint,
sizeof(checkPoint));
3978 fbin.write((
const char *)&NFEMNodesFEM,
sizeof(NFEMNodesFEM));
3979 fbin.write((
const char *)&NModesFEM,
sizeof(NModesFEM));
3982 bRecordGroup[MODAL_RECORD_1] =
true;
3985 case MODAL_RECORD_2: {
3987 if (bRecordGroup[MODAL_RECORD_2]) {
3988 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
3989 "\"RECORD GROUP 2\" already parsed"
3994 for (
unsigned int iNode = 0; iNode < NFEMNodes; iNode++) {
3997 fdat >> IdFEMNodes[iNode];
4001 checkPoint = MODAL_RECORD_2;
4002 fbin.write(&checkPoint,
sizeof(checkPoint));
4003 for (
unsigned int iNode = 0; iNode < NFEMNodes; iNode++) {
4004 uint32_t len = IdFEMNodes[iNode].size();
4005 fbin.write((
const char *)&len,
sizeof(len));
4006 fbin.write((
const char *)IdFEMNodes[iNode].c_str(), len);
4010 bRecordGroup[2] =
true;
4013 case MODAL_RECORD_3: {
4015 if (bRecordGroup[MODAL_RECORD_3]) {
4016 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
4017 "\"RECORD GROUP 3\" already parsed"
4022 unsigned int iCnt = 1;
4024 if (bActiveModes.empty()) {
4025 silent_cerr(
"Modal(" << uLabel <<
"): "
4026 "input file \"" << sFileFEM <<
"\" "
4027 "is bogus (RECORD GROUP 3)"
4033 checkPoint = MODAL_RECORD_3;
4034 fbin.write(&checkPoint,
sizeof(checkPoint));
4037 for (
unsigned int jMode = 1; jMode <= NModesFEM; jMode++) {
4041 fbin.write((
const char *)&d,
sizeof(d));
4044 if (!bActiveModes[jMode]) {
4051 bRecordGroup[MODAL_RECORD_3] =
true;
4054 case MODAL_RECORD_4: {
4056 if (bRecordGroup[MODAL_RECORD_4]) {
4057 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
4058 "\"RECORD GROUP 4\" already parsed"
4063 unsigned int iCnt = 1;
4065 if (bActiveModes.empty()) {
4066 silent_cerr(
"Modal(" << uLabel <<
"): "
4067 "input file \"" << sFileFEM <<
"\" "
4068 "is bogus (RECORD GROUP 4)"
4074 checkPoint = MODAL_RECORD_4;
4075 fbin.write(&checkPoint,
sizeof(checkPoint));
4078 for (
unsigned int jMode = 1; jMode <= NModesFEM; jMode++) {
4082 fbin.write((
const char *)&d,
sizeof(d));
4085 if (!bActiveModes[jMode]) {
4092 bRecordGroup[MODAL_RECORD_4] =
true;
4095 case MODAL_RECORD_5: {
4097 if (bRecordGroup[MODAL_RECORD_5]) {
4098 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
4099 "\"RECORD GROUP 5\" already parsed"
4105 checkPoint = MODAL_RECORD_5;
4106 fbin.write(&checkPoint,
sizeof(checkPoint));
4109 for (
unsigned int iNode = 1; iNode <= NFEMNodes; iNode++) {
4113 fbin.write((
const char *)&d,
sizeof(d));
4116 #ifdef MODAL_SCALE_DATA
4119 pXYZFEMNodes->
Put(1, iNode, d);
4122 bRecordGroup[MODAL_RECORD_5] =
true;
4125 case MODAL_RECORD_6: {
4127 if (bRecordGroup[MODAL_RECORD_6]) {
4128 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
4129 "\"RECORD GROUP 6\" already parsed"
4135 checkPoint = MODAL_RECORD_6;
4136 fbin.write(&checkPoint,
sizeof(checkPoint));
4139 for (
unsigned int iNode = 1; iNode <= NFEMNodes; iNode++) {
4143 fbin.write((
const char *)&d,
sizeof(d));
4146 #ifdef MODAL_SCALE_DATA
4149 pXYZFEMNodes->
Put(2, iNode, d);
4152 bRecordGroup[MODAL_RECORD_6] =
true;
4155 case MODAL_RECORD_7: {
4157 if (bRecordGroup[MODAL_RECORD_7]) {
4158 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
4159 "\"RECORD GROUP 7\" already parsed"
4165 checkPoint = MODAL_RECORD_7;
4166 fbin.write(&checkPoint,
sizeof(checkPoint));
4169 for (
unsigned int iNode = 1; iNode <= NFEMNodes; iNode++) {
4173 fbin.write((
const char *)&d,
sizeof(d));
4176 #ifdef MODAL_SCALE_DATA
4179 pXYZFEMNodes->
Put(3, iNode, d);
4182 bRecordGroup[MODAL_RECORD_7] =
true;
4185 case MODAL_RECORD_8: {
4187 if (bRecordGroup[MODAL_RECORD_8]) {
4188 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
4189 "\"RECORD GROUP 8\" already parsed"
4195 checkPoint = MODAL_RECORD_8;
4196 fbin.write(&checkPoint,
sizeof(checkPoint));
4200 for (
unsigned int jMode = 1; jMode <= NRejModes; jMode++) {
4202 fdat.getline(str,
sizeof(str));
4204 silent_cout(
"Modal(" << uLabel <<
"): rejecting mode #" << jMode
4205 <<
" (" << str <<
")" << std::endl);
4208 for (
unsigned int iNode = 1; iNode <= NFEMNodes; iNode++) {
4211 fdat >> n[0] >> n[1] >> n[2]
4212 >> n[3] >> n[4] >> n[5];
4217 fdat.getline(str,
sizeof(str));
4220 if (bActiveModes.empty()) {
4221 silent_cerr(
"Modal(" << uLabel <<
"): "
4222 "input file \"" << sFileFEM <<
"\" "
4223 "is bogus (RECORD GROUP 8)"
4228 unsigned int iCnt = 1;
4229 for (
unsigned int jMode = 1; jMode <= NModesFEM; jMode++) {
4230 fdat.getline(str,
sizeof(str));
4231 if (str[0] !=
'\0' && strncmp(
"**", str,
STRLENOF(
"**")) != 0)
4234 silent_cerr(
"Modal(" << uLabel <<
"): "
4235 "input file \"" << sFileFEM <<
"\""
4236 "is bogus (\"**\" expected before mode #" << jMode
4237 <<
" of " << NModesFEM <<
"; "
4238 "#" << jMode + NRejModes
4239 <<
" of " << NModesFEM + NRejModes
4240 <<
" including rejected)"
4243 silent_cerr(
"Modal(" << uLabel <<
"): "
4244 "input file \"" << sFileFEM <<
"\""
4245 "is bogus (\"**\" expected before mode #" << jMode
4246 <<
" of " << NModesFEM <<
")"
4252 for (
unsigned int iNode = 1; iNode <= NFEMNodes; iNode++) {
4255 fdat >> n[0] >> n[1] >> n[2]
4256 >> n[3] >> n[4] >> n[5];
4259 fbin.write((
const char *)n,
sizeof(n));
4262 if (!bActiveModes[jMode]) {
4266 #ifdef MODAL_SCALE_DATA
4271 pModeShapest->
PutVec((iCnt - 1)*NFEMNodes + iNode,
Vec3(&n[0]));
4272 pModeShapesr->
PutVec((iCnt - 1)*NFEMNodes + iNode,
Vec3(&n[3]));
4275 if (bActiveModes[jMode]) {
4278 fdat.getline(str,
sizeof(str));
4281 bRecordGroup[MODAL_RECORD_8] =
true;
4284 case MODAL_RECORD_9: {
4286 if (bRecordGroup[MODAL_RECORD_9]) {
4287 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
4288 "\"RECORD GROUP 9\" already parsed"
4293 if (bActiveModes.empty()) {
4294 silent_cerr(
"Modal(" << uLabel <<
"): "
4295 "input file \"" << sFileFEM <<
"\" "
4296 "is bogus (RECORD GROUP 9)"
4302 checkPoint = MODAL_RECORD_9;
4303 fbin.write(&checkPoint,
sizeof(checkPoint));
4306 unsigned int iCnt = 1;
4307 for (
unsigned int jMode = 1; jMode <= NModesFEM; jMode++) {
4308 unsigned int jCnt = 1;
4310 for (
unsigned int kMode = 1; kMode <= NModesFEM; kMode++) {
4313 if (dMassThreshold > 0.0 &&
fabs(d) < dMassThreshold) {
4318 fbin.write((
const char *)&d,
sizeof(d));
4321 if (!bActiveModes[jMode] || !bActiveModes[kMode]) {
4324 pGenMass->
Put(iCnt, jCnt, d);
4328 if (bActiveModes[jMode]) {
4333 bRecordGroup[MODAL_RECORD_9] =
true;
4336 case MODAL_RECORD_10: {
4338 if (bRecordGroup[MODAL_RECORD_10]) {
4339 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
4340 "\"RECORD GROUP 10\" already parsed"
4345 if (bActiveModes.empty()) {
4346 silent_cerr(
"Modal(" << uLabel <<
"): "
4347 "input file \"" << sFileFEM <<
"\" "
4348 "is bogus (RECORD GROUP 10)"
4354 checkPoint = MODAL_RECORD_10;
4355 fbin.write(&checkPoint,
sizeof(checkPoint));
4358 unsigned int iCnt = 1;
4359 for (
unsigned int jMode = 1; jMode <= NModesFEM; jMode++) {
4360 unsigned int jCnt = 1;
4362 for (
unsigned int kMode = 1; kMode <= NModesFEM; kMode++) {
4365 if (dStiffnessThreshold > 0.0 &&
fabs(d) < dStiffnessThreshold) {
4370 fbin.write((
const char *)&d,
sizeof(d));
4373 if (!bActiveModes[jMode] || !bActiveModes[kMode]) {
4376 pGenStiff->
Put(iCnt, jCnt, d);
4380 if (bActiveModes[jMode]) {
4385 bRecordGroup[MODAL_RECORD_10] =
true;
4388 case MODAL_RECORD_11: {
4390 if (bRecordGroup[MODAL_RECORD_11]) {
4391 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
4392 "\"RECORD GROUP 11\" already parsed"
4398 checkPoint = MODAL_RECORD_11;
4399 fbin.write(&checkPoint,
sizeof(checkPoint));
4402 FEMMass.resize(NFEMNodes);
4403 FEMJ.resize(NFEMNodes);
4405 for (
unsigned int iNode = 1; iNode <= NFEMNodes; iNode++) {
4407 for (
unsigned int jCnt = 1; jCnt <= 6; jCnt++) {
4411 fbin.write((
const char *)&d,
sizeof(d));
4417 #ifdef MODAL_SCALE_DATA
4420 FEMMass[iNode - 1] = d;
4426 silent_cout(
"Warning: component(" << jCnt <<
") "
4427 "of FEM node(" << iNode <<
") mass "
4428 "differs from component(1)=" << tmpmass << std::endl);
4435 #ifdef MODAL_SCALE_DATA
4438 FEMJ[iNode - 1](jCnt - 3) = d;
4444 bBuildInvariants =
true;
4446 bRecordGroup[MODAL_RECORD_11] =
true;
4449 case MODAL_RECORD_12: {
4451 if (bRecordGroup[MODAL_RECORD_12]) {
4452 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
4453 "\"RECORD GROUP 12\" already parsed"
4459 checkPoint = MODAL_RECORD_12;
4460 fbin.write(&checkPoint,
sizeof(checkPoint));
4466 fbin.write((
const char *)&d,
sizeof(d));
4473 for (
int iRow = 1; iRow <= 3; iRow++) {
4477 fbin.write((
const char *)&d,
sizeof(d));
4484 for (
int iRow = 1; iRow <= 3; iRow++) {
4485 for (
int iCol = 1; iCol <= 3; iCol++) {
4489 fbin.write((
const char *)&d,
sizeof(d));
4492 JTmpIn(iRow, iCol) = d;
4496 bRecordGroup[MODAL_RECORD_12] =
true;
4499 case MODAL_RECORD_13: {
4501 if (bRecordGroup[MODAL_RECORD_13]) {
4502 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
4503 "\"RECORD GROUP 13\" already parsed"
4508 if (bActiveModes.empty()) {
4509 silent_cerr(
"Modal(" << uLabel <<
"): "
4510 "input file \"" << sFileFEM <<
"\" "
4511 "is bogus (RECORD GROUP 13)"
4517 checkPoint = MODAL_RECORD_13;
4518 fbin.write(&checkPoint,
sizeof(checkPoint));
4521 unsigned int iCnt = 1;
4522 for (
unsigned int jMode = 1; jMode <= NModesFEM; jMode++) {
4523 unsigned int jCnt = 1;
4525 for (
unsigned int kMode = 1; kMode <= NModesFEM; kMode++) {
4528 if (dDampingThreshold > 0.0 &&
fabs(d) < dDampingThreshold) {
4533 fbin.write((
const char *)&d,
sizeof(d));
4536 if (!bActiveModes[jMode] || !bActiveModes[kMode]) {
4540 if (eDamp == DAMPING_FROM_FILE) {
4541 pGenDamp->
Put(iCnt, jCnt, d);
4547 if (bActiveModes[jMode]) {
4552 bRecordGroup[MODAL_RECORD_13] =
true;
4556 silent_cerr(
"file=\"" << sFileFEM <<
"\": "
4557 "\"RECORD GROUP " << rg <<
"\" unhandled"
4565 checkPoint = MODAL_END_OF_FILE;
4566 fbin.write(&checkPoint,
sizeof(checkPoint));
4575 (void)unlink(sBinFileFEM.c_str());
4583 std::ifstream fbin(sBinFileFEM.c_str(), std::ios::binary);
4585 silent_cerr(
"Modal(" << uLabel <<
"): "
4586 "unable to open file \"" << sBinFileFEM <<
"\""
4590 silent_cout(
"Modal(" << uLabel <<
"): "
4591 "reading flexible body data from file "
4592 "\"" << sBinFileFEM <<
"\"" << std::endl);
4617 char currMagic[5] = { 0 };
4618 fbin.read((
char *)&currMagic,
sizeof(4));
4619 if (memcmp(magic, currMagic, 4) != 0) {
4620 silent_cerr(
"Modal(" << uLabel <<
"): "
4621 "file \"" << sBinFileFEM <<
"\" "
4622 "unexpected signature" << std::endl);
4626 fbin.read((
char *)&currBinVersion,
sizeof(currBinVersion));
4627 if (currBinVersion > BinVersion) {
4628 silent_cerr(
"Modal(" << uLabel <<
"): "
4629 "file \"" << sBinFileFEM <<
"\" "
4630 "version " << currBinVersion <<
" unsupported" << std::endl);
4633 }
else if (currBinVersion < BinVersion) {
4634 silent_cout(
"Modal(" << uLabel <<
"): "
4635 "file \"" << sBinFileFEM <<
"\" "
4636 "version " << currBinVersion <<
" is outdated; "
4637 "trying to read anyway..." << std::endl);
4640 pedantic_cout(
"Modal(" << uLabel <<
"): "
4641 "binary version " << currBinVersion << std::endl);
4649 fbin.read(&checkPoint,
sizeof(checkPoint));
4650 if (checkPoint != MODAL_RECORD_1) {
4651 silent_cerr(
"Modal(" << uLabel <<
"): "
4652 "file \"" << sBinFileFEM <<
"\" "
4653 "looks broken (expecting checkpoint 1)"
4658 pedantic_cout(
"Modal(" << uLabel <<
"): "
4659 "reading block " <<
unsigned(checkPoint) << std::endl);
4661 fbin.read((
char *)&NFEMNodesFEM,
sizeof(NFEMNodesFEM));
4662 fbin.read((
char *)&NModesFEM,
sizeof(NModesFEM));
4665 if (NFEMNodes ==
unsigned(-1)) {
4666 NFEMNodes = NFEMNodesFEM;
4668 }
else if (NFEMNodes != NFEMNodesFEM) {
4669 silent_cerr(
"Modal(" << uLabel <<
"), "
4670 "file \"" << sFileFEM <<
"\": "
4671 "FEM nodes number " << NFEMNodes
4672 <<
" does not match node number "
4678 if (NModes != NModesFEM) {
4679 silent_cout(
"Modal(" << uLabel
4680 <<
"), file '" << sFileFEM
4681 <<
"': using " << NModes
4682 <<
" of " << NModesFEM
4683 <<
" modes" << std::endl);
4686 if (!bActiveModes.empty()) {
4690 IdFEMNodes.resize(NFEMNodes);
4696 bActiveModes.resize(NModesFEM + 1,
false);
4698 for (
unsigned int iCnt = 0; iCnt < NModes; iCnt++) {
4699 if (uModeNumber[iCnt] > NModesFEM) {
4700 silent_cerr(
"Modal(" << uLabel <<
"): "
4701 "mode " << uModeNumber[iCnt]
4702 <<
" is not available (max = "
4707 bActiveModes[uModeNumber[iCnt]] =
true;
4710 bRecordGroup[1] =
true;
4713 fbin.read(&checkPoint,
sizeof(checkPoint));
4715 if (checkPoint == MODAL_END_OF_FILE) {
4716 pedantic_cout(
"Modal(" << uLabel <<
"): "
4717 "end of binary file \"" << sBinFileFEM <<
"\""
4723 if (checkPoint < MODAL_RECORD_1 || checkPoint >= MODAL_LAST_RECORD) {
4724 silent_cerr(
"Modal(" << uLabel <<
"): "
4725 "file \"" << sBinFileFEM <<
"\" "
4726 "looks broken (unknown block " <<
unsigned(checkPoint) <<
")"
4731 if (bRecordGroup[
unsigned(checkPoint)]) {
4732 silent_cerr(
"Modal(" << uLabel <<
"): "
4733 "file \"" << sBinFileFEM <<
"\" "
4734 "looks broken (block " <<
unsigned(checkPoint) <<
" already parsed)"
4739 pedantic_cout(
"Modal(" << uLabel <<
"): "
4740 "reading block " <<
unsigned(checkPoint)
4741 <<
" from file \"" << sBinFileFEM <<
"\"" << std::endl);
4743 switch (checkPoint) {
4744 case MODAL_RECORD_2:
4746 for (
unsigned int iNode = 0; iNode < NFEMNodes; iNode++) {
4748 fbin.read((
char *)&len,
sizeof(len));
4750 IdFEMNodes[iNode].resize(len);
4751 fbin.read((
char *)IdFEMNodes[iNode].c_str(), len);
4755 case MODAL_RECORD_3:
4757 for (
unsigned int iCnt = 1, jMode = 1; jMode <= NModesFEM; jMode++) {
4760 fbin.read((
char *)&d,
sizeof(d));
4762 if (!bActiveModes[jMode]) {
4771 case MODAL_RECORD_4:
4773 for (
unsigned int iCnt = 1, jMode = 1; jMode <= NModesFEM; jMode++) {
4776 fbin.read((
char *)&d,
sizeof(d));
4778 if (!bActiveModes[jMode]) {
4787 case MODAL_RECORD_5:
4789 for (
unsigned int iNode = 1; iNode <= NFEMNodes; iNode++) {
4792 fbin.read((
char *)&d,
sizeof(d));
4794 #ifdef MODAL_SCALE_DATA
4798 pXYZFEMNodes->
Put(1, iNode, d);
4802 case MODAL_RECORD_6:
4804 for (
unsigned int iNode = 1; iNode <= NFEMNodes; iNode++) {
4807 fbin.read((
char *)&d,
sizeof(d));
4809 #ifdef MODAL_SCALE_DATA
4813 pXYZFEMNodes->
Put(2, iNode, d);
4817 case MODAL_RECORD_7:
4819 for (
unsigned int iNode = 1; iNode <= NFEMNodes; iNode++) {
4822 fbin.read((
char *)&d,
sizeof(d));
4824 #ifdef MODAL_SCALE_DATA
4828 pXYZFEMNodes->
Put(3, iNode, d);
4832 case MODAL_RECORD_8:
4834 for (
unsigned int iCnt = 1, jMode = 1; jMode <= NModesFEM; jMode++) {
4835 for (
unsigned int iNode = 1; iNode <= NFEMNodes; iNode++) {
4838 fbin.read((
char *)n,
sizeof(n));
4840 if (!bActiveModes[jMode]) {
4844 #ifdef MODAL_SCALE_DATA
4849 pModeShapest->
PutVec((iCnt - 1)*NFEMNodes + iNode,
Vec3(&n[0]));
4850 pModeShapesr->
PutVec((iCnt - 1)*NFEMNodes + iNode,
Vec3(&n[3]));
4853 if (bActiveModes[jMode]) {
4859 case MODAL_RECORD_9:
4861 for (
unsigned int iCnt = 1, jMode = 1; jMode <= NModesFEM; jMode++) {
4862 unsigned int jCnt = 1;
4864 for (
unsigned int kMode = 1; kMode <= NModesFEM; kMode++) {
4867 fbin.read((
char *)&d,
sizeof(d));
4869 if (!bActiveModes[jMode] || !bActiveModes[kMode]) {
4872 pGenMass->
Put(iCnt, jCnt, d);
4876 if (bActiveModes[jMode]) {
4882 case MODAL_RECORD_10:
4884 for (
unsigned int iCnt = 1, jMode = 1; jMode <= NModesFEM; jMode++) {
4885 unsigned int jCnt = 1;
4887 for (
unsigned int kMode = 1; kMode <= NModesFEM; kMode++) {
4890 fbin.read((
char *)&d,
sizeof(d));
4892 if (!bActiveModes[jMode] || !bActiveModes[kMode]) {
4895 pGenStiff->
Put(iCnt, jCnt, d);
4899 if (bActiveModes[jMode]) {
4905 case MODAL_RECORD_11:
4907 FEMMass.resize(NFEMNodes);
4908 FEMJ.resize(NFEMNodes);
4910 for (
unsigned int iNode = 1; iNode <= NFEMNodes; iNode++) {
4911 for (
unsigned int jCnt = 1; jCnt <= 6; jCnt++) {
4914 fbin.read((
char *)&d,
sizeof(d));
4918 #ifdef MODAL_SCALE_DATA
4921 FEMMass[iNode - 1] = d;
4927 #ifdef MODAL_SCALE_DATA
4930 FEMJ[iNode - 1](jCnt - 3) = d;
4936 bBuildInvariants =
true;
4939 case MODAL_RECORD_12: {
4941 fbin.read((
char *)&d,
sizeof(d));
4946 for (
int iRow = 1; iRow <= 3; iRow++) {
4947 fbin.read((
char *)&d,
sizeof(d));
4953 for (
int iRow = 1; iRow <= 3; iRow++) {
4954 for (
int iCol = 1; iCol <= 3; iCol++) {
4955 fbin.read((
char *)&d,
sizeof(d));
4957 JTmpIn(iRow, iCol) = d;
4962 case MODAL_RECORD_13:
4963 for (
unsigned int iCnt = 1, jMode = 1; jMode <= NModesFEM; jMode++) {
4964 unsigned int jCnt = 1;
4966 for (
unsigned int kMode = 1; kMode <= NModesFEM; kMode++) {
4969 fbin.read((
char *)&d,
sizeof(d));
4971 if (!bActiveModes[jMode] || !bActiveModes[kMode]) {
4975 if (eDamp == DAMPING_FROM_FILE) {
4976 pGenDamp->
Put(iCnt, jCnt, d);
4982 if (bActiveModes[jMode]) {
4989 silent_cerr(
"Modal(" << uLabel <<
"): "
4990 "file \"" << sBinFileFEM <<
"\" "
4991 "looks broken (unknown block " <<
unsigned(checkPoint) <<
")"
4996 bRecordGroup[unsigned(checkPoint)] =
true;
4999 fname = sBinFileFEM;
5002 unsigned reqMR[] = {
5013 bool bBailOut(
false);
5014 for (
unsigned iCnt = 0; iCnt <
sizeof(reqMR)/
sizeof(
unsigned); iCnt++) {
5015 if (!bRecordGroup[reqMR[iCnt]]) {
5016 silent_cerr(
"Modal(" << uLabel <<
"): "
5017 "incomplete input file \"" << fname <<
"\", "
5018 "record group " << reqMR[iCnt] <<
" missing "
5031 if (!sEchoFileName.empty()) {
5032 std::ofstream fecho(sEchoFileName.c_str());
5034 fecho.setf(std::ios::scientific);
5035 fecho.precision(iEchoPrecision);
5041 <<
"** echo of file \"" << fname <<
"\" generated " << ctime(&t)
5042 <<
"** RECORD GROUP 1, HEADER" << std::endl
5043 <<
"** REVISION. NODES. NORMAL, ATTACHMENT, CONSTRAINT, REJECTED MODES." << std::endl
5044 <<
"VER" << currBinVersion <<
" " << NFEMNodes <<
" " << NModes <<
" 0 0 0" << std::endl
5045 <<
"**" << std::endl
5046 <<
"** RECORD GROUP 2, FINITE ELEMENT NODE LIST" << std::endl;
5047 for (
unsigned r = 0; r <= (IdFEMNodes.size() - 1)/6; r++) {
5048 for (
unsigned c = 0;
c < std::min(6U,
unsigned(IdFEMNodes.size() - 6*r));
c++) {
5049 fecho << IdFEMNodes[6*r +
c] <<
" ";
5055 <<
"**" << std::endl
5056 <<
"** RECORD GROUP 3, INITIAL MODAL DISPLACEMENTS"<< std::endl;
5058 fecho << (*a)(r) << std::endl;
5062 <<
"**" << std::endl
5063 <<
"** RECORD GROUP 4, INITIAL MODAL VELOCITIES"<< std::endl;
5065 fecho << (*aP)(r) << std::endl;
5069 <<
"**" << std::endl
5070 <<
"** RECORD GROUP 5, NODAL X COORDINATES" << std::endl;
5071 for (
int r = 1; r <= pXYZFEMNodes->
iGetNumCols(); r++) {
5072 fecho << (*pXYZFEMNodes)(1, r) << std::endl;
5076 <<
"**" << std::endl
5077 <<
"** RECORD GROUP 6, NODAL Y COORDINATES" << std::endl;
5078 for (
int r = 1; r <= pXYZFEMNodes->
iGetNumCols(); r++) {
5079 fecho << (*pXYZFEMNodes)(2, r) << std::endl;
5083 <<
"**" << std::endl
5084 <<
"** RECORD GROUP 7, NODAL Z COORDINATES" << std::endl;
5085 for (
int r = 1; r <= pXYZFEMNodes->
iGetNumCols(); r++) {
5086 fecho << (*pXYZFEMNodes)(3, r) << std::endl;
5090 <<
"**" << std::endl
5091 <<
"** RECORD GROUP 8, NON-ORTHOGONALIZED MODE SHAPES" << std::endl;
5092 for (
unsigned m = 0; m < NModes; m++) {
5094 <<
"** NORMAL MODE SHAPE # " << uModeNumber[m] << std::endl;
5095 for (
unsigned n = 1; n <= NFEMNodes; n++) {
5097 << (*pModeShapest)(1, m*NFEMNodes + n) <<
" "
5098 << (*pModeShapest)(2, m*NFEMNodes + n) <<
" "
5099 << (*pModeShapest)(3, m*NFEMNodes + n) <<
" "
5100 << (*pModeShapesr)(1, m*NFEMNodes + n) <<
" "
5101 << (*pModeShapesr)(2, m*NFEMNodes + n) <<
" "
5102 << (*pModeShapesr)(3, m*NFEMNodes + n) << std::endl;
5107 <<
"**" << std::endl
5108 <<
"** RECORD GROUP 9, MODAL MASS MATRIX. COLUMN-MAJOR FORM" << std::endl;
5109 for (
unsigned r = 1; r <= NModes; r++) {
5110 for (
unsigned c = 1;
c <= NModes;
c++) {
5111 fecho << (*pGenMass)(r,
c) <<
" ";
5117 <<
"**" << std::endl
5118 <<
"** RECORD GROUP 10, MODAL STIFFNESS MATRIX. COLUMN-MAJOR FORM" << std::endl;
5119 for (
unsigned r = 1; r <= NModes; r++) {
5120 for (
unsigned c = 1;
c <= NModes;
c++) {
5121 fecho << (*pGenStiff)(r,
c) <<
" ";
5126 if (bBuildInvariants) {
5128 <<
"**" << std::endl
5129 <<
"** RECORD GROUP 11, DIAGONAL OF LUMPED MASS MATRIX" << std::endl;
5130 for (
unsigned r = 0; r < FEMMass.size(); r++) {
5132 << FEMMass[r] <<
" " << FEMMass[r] <<
" " << FEMMass[r] <<
" "
5133 << FEMJ[r] << std::endl;
5137 if (bRecordGroup[MODAL_RECORD_12]) {
5139 <<
"**" << std::endl
5140 <<
"** RECORD GROUP 12, GLOBAL INERTIA" << std::endl
5141 << dMass << std::endl
5142 << XTmpIn << std::endl,
5143 JTmpIn.Write(fecho,
" ",
"\n") << std::endl;
5146 if (bRecordGroup[MODAL_RECORD_13]) {
5148 <<
"**" << std::endl
5149 <<
"** RECORD GROUP 13, MODAL DAMPING MATRIX. COLUMN-MAJOR FORM" << std::endl;
5150 for (
unsigned r = 1; r <= NModes; r++) {
5151 for (
unsigned c = 1;
c <= NModes;
c++) {
5152 fecho << (*pGenDamp)(r,
c) <<
" ";
5166 Mat3xN* pPHItStrNode = 0;
5167 Mat3xN* pPHIrStrNode = 0;
5171 bool bOrigin(
false);
5175 std::string FEMOriginNode;
5180 pedantic_cerr(
"Modal(" << uLabel <<
"): "
5181 "origin node expected as string with delimiters"
5187 for (iNode = 0; iNode < NFEMNodes; iNode++) {
5188 if (FEMOriginNode == IdFEMNodes[iNode]) {
5193 if (iNode == NFEMNodes) {
5194 silent_cerr(
"Modal(" << uLabel <<
"): "
5195 "FEM node \"" << FEMOriginNode <<
"\""
5197 <<
" not defined " << std::endl);
5202 Origin = pXYZFEMNodes->
GetVec(iNode);
5204 pedantic_cout(
"Modal(" << uLabel <<
"): origin x={" << Origin <<
"}" << std::endl);
5207 }
else if (HP.
IsKeyWord(
"origin" "position")) {
5213 for (
unsigned int iStrNode = 1; iStrNode <= NFEMNodes; iStrNode++) {
5214 pXYZFEMNodes->
SubVec(iStrNode, Origin);
5217 if (!bBuildInvariants) {
5224 unsigned int NStrNodes = HP.
GetInt();
5225 DEBUGCOUT(
"Number of Interface Nodes : " << NStrNodes << std::endl);
5228 Mat3xN(NStrNodes*NModes, 0.));
5230 Mat3xN(NStrNodes*NModes, 0.));
5232 std::vector<Modal::StrNodeData> SND(NStrNodes);
5239 for (
unsigned int iStrNode = 1; iStrNode <= NStrNodes; iStrNode++) {
5246 if (Node1.find(
' ') != std::string::npos ) {
5247 silent_cout(
"Modal(" << uLabel <<
"): "
5248 "FEM node \"" << Node1 <<
"\""
5250 <<
" contains a blank" << std::endl);
5253 DEBUGCOUT(
"Linked to FEM Node " << Node1 << std::endl);
5257 for (iNode = 0; iNode < NFEMNodes; iNode++) {
5258 if (Node1 == IdFEMNodes[iNode]) {
5263 if (iNode == NFEMNodes) {
5264 silent_cerr(
"Modal(" << uLabel <<
"): "
5265 "FEM node \"" << Node1 <<
"\""
5267 <<
" not defined " << std::endl);
5273 int iNodeCurr = iNode;
5282 SND[iStrNode-1].OffsetFEM = pXYZFEMNodes->
GetVec(iNodeCurr);
5286 for (
unsigned int jMode = 0; jMode < NModes; jMode++) {
5287 pPHItStrNode->
PutVec(jMode*NStrNodes + iStrNode,
5288 pModeShapest->GetVec(jMode*NFEMNodes + iNodeCurr));
5289 pPHIrStrNode->
PutVec(jMode*NStrNodes + iStrNode,
5290 pModeShapesr->
GetVec(jMode*NFEMNodes + iNodeCurr));
5294 unsigned int uNode2 = (
unsigned int)HP.
GetInt();
5295 DEBUGCOUT(
"Linked to Multi-Body Node " << uNode2 << std::endl);
5299 if (SND[iStrNode - 1].pNode == 0) {
5300 silent_cerr(
"Modal(" << uLabel <<
"): "
5301 "StructuralNode(" << uNode2 <<
") "
5303 <<
" not defined" << std::endl);
5315 SND[iStrNode - 1].OffsetMB = d2;
5316 SND[iStrNode - 1].RotMB = R2;
5318 DEBUGCOUT(
"Multibody Node reference frame d2: " << std::endl
5319 << d2 << std::endl);
5323 SND[iStrNode - 1].FEMNode = Node1;
5329 const Vec3& xMB(SND[iStrNode - 1].pNode->GetXCurr());
5330 pedantic_cout(
"Interface node " << iStrNode <<
":" << std::endl
5331 <<
" MB node " << uNode2 <<
" x={" << xMB <<
"}" << std::endl);
5332 Vec3 xFEMRel(pXYZFEMNodes->
GetVec(iNodeCurr));
5333 Vec3 xFEM(X0 +
R*xFEMRel);
5334 pedantic_cout(
" FEM node \"" << Node1 <<
"\" x={" << xFEM <<
"} "
5335 "xrel={" << xFEMRel <<
"}" << std::endl);
5336 pedantic_cout(
" offset={" << xFEM - xMB <<
"}" << std::endl);
5340 std::vector<Modal::StrNodeData>::iterator i = SND.begin();
5341 std::vector<Modal::StrNodeData>::iterator end = SND.end();
5342 for (; i != end; ++i) {
5356 if (bBuildInvariants) {
5361 MatNxN GenMass(NModes, 0.);
5377 if (HP.
IsKeyWord(
"use" "invariant" "9")) {
5386 for (
unsigned int iNode = 1; iNode <= NFEMNodes; iNode++) {
5398 JiNodeTmp(1, 1) = FEMJ[iNode - 1](1);
5399 JiNodeTmp(2, 2) = FEMJ[iNode - 1](2);
5400 JiNodeTmp(3, 3) = FEMJ[iNode - 1](3);
5406 for (
unsigned int jMode = 1; jMode <= NModes; jMode++) {
5407 unsigned int iOffset = (jMode - 1)*NFEMNodes + iNode;
5409 PHIti.PutVec(jMode, pModeShapest->GetVec(iOffset));
5410 PHIri.PutVec(jMode, pModeShapesr->
GetVec(iOffset));
5415 Mat3xN Inv3Tmp(NModes, 0.);
5416 Mat3xN Inv4Tmp(NModes, 0.);
5417 Mat3xN Inv4JTmp(NModes, 0.);
5418 Inv3Tmp.Copy(PHIti);
5424 Inv4Tmp.LeftMult(uiWedge*mi, PHIti);
5425 Inv4JTmp.LeftMult(JiNodeTmp, PHIri);
5426 Inv4Tmp += Inv4JTmp;
5429 *pInv11 += Inv4JTmp;
5432 for (
unsigned int jMode = 1; jMode <= NModes; jMode++) {
5433 Vec3 PHItij = PHIti.GetVec(jMode);
5434 Vec3 PHIrij = PHIri.GetVec(jMode);
5437 Mat3xN Inv5jTmp(NModes, 0);
5441 Inv5jTmp.LeftMult(PHItijvett_mi, PHIti);
5442 for (
unsigned int kMode = 1; kMode <= NModes; kMode++) {
5443 pInv5->
AddVec((jMode - 1)*NModes + kMode,
5444 Inv5jTmp.GetVec(kMode));
5449 GenMass(jMode, kMode) += (PHItij*PHIti.GetVec(kMode))*mi
5450 + PHIrij*(JiNodeTmp*PHIri.GetVec(kMode));
5455 Mat3x3 Inv8jTmp = -uiWedge*PHItijvett_mi;
5456 pInv8->
AddMat3x3((jMode - 1)*3 + 1, Inv8jTmp);
5461 for (
unsigned int kMode = 1; kMode <= NModes; kMode++) {
5463 Mat3x3 Inv9jkTmp = PHItijvett_mi*PHItikvett;
5465 pInv9->
AddMat3x3((jMode - 1)*3*NModes + (kMode - 1)*3 + 1, Inv9jkTmp);
5472 pInv10->
AddMat3x3((jMode - 1)*3 + 1, Inv10jTmp);
5476 if (bRecordGroup[12]) {
5477 Mat3x3 DJ = JTmp - JTmpInv;
5478 pedantic_cerr(
" Rigid-body mass: "
5479 "input - computed" << std::endl
5480 <<
" " << dMass - dMassInv << std::endl);
5481 pedantic_cerr(
" Rigid-body CM location: "
5482 "input - computed" << std::endl
5483 <<
" " << XTmpIn - STmpInv/dMassInv << std::endl);
5484 pedantic_cerr(
" Rigid-body inertia: "
5485 "input - computed" << std::endl
5486 <<
" " << DJ.
GetVec(1) << std::endl
5487 <<
" " << DJ.
GetVec(2) << std::endl
5488 <<
" " << DJ.
GetVec(3) << std::endl);
5494 pedantic_cerr(
" Generalized mass: input - computed" << std:: endl);
5495 for (
unsigned int jMode = 1; jMode <= NModes; jMode++) {
5497 for (
unsigned int kMode = 1; kMode <= NModes; kMode++) {
5498 pedantic_cerr(
" " << pGenMass->
dGet(jMode, kMode) - GenMass(jMode, kMode));
5500 pedantic_cerr(std::endl);
5505 if (!bRecordGroup[12]) {
5513 if (bRecordGroup[12]) {
5515 STmp = XTmpIn*dMass;
5523 bool bIsMSym =
true;
5524 bool bIsMDiag =
true;
5525 for (
unsigned iRow = 2; iRow <= NModes; iRow++) {
5526 for (
unsigned iCol = 1; iCol < iRow; iCol++) {
5531 silent_cerr(
"Modal(" << uLabel <<
"): mass matrix is not symmetric: (at least) "
5532 "M(" << iRow <<
", " << iCol <<
")=" << mrc <<
" "
5534 "M(" << iCol <<
", " << iRow <<
")=" << mcr <<
" "
5540 if (mrc != 0. || mcr != 0.) {
5542 silent_cerr(
"Modal(" << uLabel <<
"): mass matrix is not diagonal: (at least) "
5543 "M(" << iRow <<
", " << iCol <<
")=" << mrc <<
" "
5545 "M(" << iCol <<
", " << iRow <<
")=" << mcr <<
" "
5554 bool bIsKSym =
true;
5555 bool bIsKDiag =
true;
5556 for (
unsigned iRow = 2; iRow <= NModes; iRow++) {
5557 for (
unsigned iCol = 1; iCol < iRow; iCol++) {
5562 silent_cerr(
"Modal(" << uLabel <<
"): stiffness matrix is not symmetric: (at least) "
5563 "K(" << iRow <<
", " << iCol <<
")=" << mrc <<
" "
5565 "K(" << iCol <<
", " << iRow <<
")=" << mcr <<
" "
5571 if (mrc != 0. || mcr != 0.) {
5573 silent_cerr(
"Modal(" << uLabel <<
"): stiffness matrix is not diagonal: (at least) "
5574 "K(" << iRow <<
", " << iCol <<
")=" << mrc <<
" "
5576 "K(" << iCol <<
", " << iRow <<
")=" << mcr <<
" "
5585 if (eDamp == DAMPING_FROM_FILE) {
5586 bool bIsCSym =
true;
5587 bool bIsCDiag =
true;
5588 for (
unsigned iRow = 2; iRow <= NModes; iRow++) {
5589 for (
unsigned iCol = 1; iCol < iRow; iCol++) {
5594 silent_cerr(
"Modal(" << uLabel <<
"): damping matrix is not symmetric: (at least) "
5595 "C(" << iRow <<
", " << iCol <<
") "
5597 "C(" << iCol <<
", " << iRow <<
") "
5603 if (mrc != 0. || mcr != 0.) {
5605 silent_cerr(
"Modal(" << uLabel <<
"): damping matrix is not diagonal: (at least) "
5606 "C(" << iRow <<
", " << iCol <<
") "
5608 "C(" << iCol <<
", " << iRow <<
") "
5626 case DAMPING_SINGLE_FACTOR:
5627 if (!bIsMDiag || !bIsKDiag) {
5628 silent_cerr(
"Modal(" << uLabel <<
"): "
5629 "warning, " << sDamp[eDamp]
5630 <<
" with non-diagonal mass and/or stiffness matrix" << std::endl);
5633 for (
unsigned int iCnt = 1; iCnt <= NModes; iCnt++) {
5638 if (eDamp == DAMPING_DIAG) {
5639 pGenDamp->
Put(iCnt, iCnt, 2.*DampRatios[iCnt - 1]*d);
5641 }
else if (eDamp == DAMPING_SINGLE_FACTOR) {
5642 pGenDamp->
Put(iCnt, iCnt, 2.*damp_factor*d);
5647 case DAMPING_RAYLEIGH:
5648 for (
unsigned int iRow = 1; iRow <= NModes; iRow++) {
5649 for (
unsigned int iCol = 1; iCol <= NModes; iCol++) {
5652 pGenDamp->
Put(iRow, iCol, damp_coef_M*m + damp_coef_K*k);
5664 if (pedantic_output) {
5665 std::ostream &out = std::cout;
5667 out <<
" Total Mass: " << dMass << std::endl;
5668 out <<
" Inertia Matrix (referred to modal node): " << std::endl
5669 <<
" " << JTmp << std::endl;
5670 out <<
" Static Moment Vector: " << STmp << std::endl;
5672 out <<
" Generalized Stiffness: " << std::endl;
5673 for (
unsigned int iCnt = 1; iCnt <= NModes; iCnt++) {
5675 for (
unsigned int jCnt = 1; jCnt <= NModes; jCnt++) {
5676 out <<
" " << pGenStiff->
dGet(iCnt, jCnt);
5681 out <<
" Generalized Mass: " << std::endl;
5682 for (
unsigned int iCnt = 1; iCnt <= NModes; iCnt++) {
5684 for (
unsigned int jCnt = 1; jCnt <= NModes; jCnt++) {
5685 out <<
" " << pGenMass->
dGet(iCnt, jCnt);
5690 out <<
" Generalized Damping: " << std::endl;
5691 for (
unsigned int iCnt = 1; iCnt <= NModes; iCnt++) {
5693 for (
unsigned int jCnt = 1; jCnt <= NModes; jCnt++) {
5694 out <<
" " << pGenDamp->
dGet(iCnt, jCnt);
5700 out <<
" Inv3: " << std::endl;
5701 for (
unsigned int iCnt = 1; iCnt <= 3; iCnt++) {
5703 for (
unsigned int jCnt = 1; jCnt <= NModes; jCnt++) {
5704 out <<
" " << pInv3->
dGet(iCnt, jCnt);
5709 out <<
" Inv3: unused" << std::endl;
5713 out <<
" Inv4: " << std::endl;
5714 for (
unsigned int iCnt = 1; iCnt <= 3; iCnt++) {
5716 for (
unsigned int jCnt = 1; jCnt <= NModes; jCnt++) {
5717 out <<
" " << pInv4->
dGet(iCnt, jCnt);
5722 out <<
" Inv4: unused" << std::endl;
5726 for (
unsigned int jMode = 1; jMode <= NModes; jMode++) {
5727 out <<
" Inv5j(j=" << jMode <<
"): " << std::endl;
5728 for (
unsigned int iCnt = 1; iCnt <= 3; iCnt++) {
5730 for (
unsigned int kMode = 1; kMode <= NModes; kMode++) {
5731 out <<
" " << pInv5->
dGet(iCnt, (jMode - 1)*NModes + kMode);
5737 out <<
" Inv5: unused" << std::endl;
5741 for (
unsigned int jMode = 1; jMode <= NModes; jMode++) {
5742 out <<
" Inv8j(j=" << jMode <<
"): " << std::endl;
5743 for (
unsigned int iCnt = 1; iCnt <= 3; iCnt++) {
5745 for (
unsigned int jCnt = 1; jCnt <= 3; jCnt++) {
5746 out <<
" " << pInv8->
dGet(iCnt, (jMode - 1)*3 + jCnt);
5752 out <<
" Inv8: unused" << std::endl;
5756 for (
unsigned int jMode = 1; jMode <= NModes; jMode++) {
5757 for (
unsigned int kMode = 1; kMode <= NModes; kMode++) {
5758 out <<
" Inv9jk(j=" << jMode <<
",k=" << kMode <<
"): " << std::endl;
5759 for (
unsigned int iCnt = 1; iCnt <= 3; iCnt++) {
5761 for (
unsigned int jCnt = 1; jCnt <= 3; jCnt++) {
5762 out <<
" " << pInv9->
dGet(iCnt, (jMode - 1)*3*NModes + (kMode - 1)*3 + jCnt);
5769 out <<
" Inv9: unused" << std::endl;
5776 silent_cout(
"Modal(" << uLabel <<
"): warning, the syntax changed "
5777 "since 1.2.7; the output now occurs to a common \".mod\" file, "
5778 "the per-element file \"" << sTmp <<
"\" is no longer required, "
5779 "and will actually be ignored." << std::endl);
5783 if (bInitialValues) {
5784 for (
unsigned int iCnt = 0; iCnt < NModes; iCnt++) {
5785 a->
Put(iCnt + 1, InitialValues[iCnt]);
5786 aP->
Put(iCnt + 1, InitialValuesP[iCnt]);
5835 os <<
"modal: " << pEl->
GetLabel() <<
" "
5836 <<
static_cast<integer>(pModalNode ? pModalNode->
GetLabel() : -1) <<
" "
5838 << STmp / dMass <<
" "
5839 << JTmp << std::endl;
flag fReadOutput(MBDynParser &HP, const T &t) const
Mat3x3 GetRotRel(const ReferenceFrame &rf)
const Vec3 Zero3(0., 0., 0.)
Vec3 Cross(const Vec3 &v) const
void Put(integer i, integer j, const doublereal &d)
void Put(int i, integer j, const doublereal &d)
#define MBDYN_EXCEPT_ARGS
virtual integer GetInt(integer iDefval=0)
const MatCross_Manip MatCross
virtual const Mat3x3 & GetRCurr(void) const
Mat3x3 GetRotAbs(const ReferenceFrame &rf)
const Mat3x3 Eye3(1., 0., 0., 0., 1., 0., 0., 0., 1.)
virtual const char * GetFileName(enum Delims Del=DEFAULTDELIM)
const doublereal & dGet(integer i, integer j) const
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
Vec3 GetVec(unsigned short int i) const
virtual bool GetYesNoOrBool(bool bDefval=false)
const Mat3x3 Zero3x3(0., 0., 0., 0., 0., 0., 0., 0., 0.)
Vec3 GetVec(integer iCol) const
const ReferenceFrame AbsRefFrame(0, Vec3(0., 0., 0), Mat3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.), Vec3(0., 0., 0), Vec3(0., 0., 0), EULER_123)
void Put(integer i, const doublereal &d)
virtual StructNode::Type GetStructNodeType(void) const =0
Vec3 GetPosRel(const ReferenceFrame &rf)
virtual bool IsKeyWord(const char *sKeyWord)
integer iGetNumRows(void) const
Vec3 GetPosAbs(const ReferenceFrame &rf)
virtual const char * GetStringWithDelims(enum Delims Del=DEFAULTDELIM, bool escape=true)
void SubVec(integer iCol, const Vec3 &v)
integer iGetNumCols(void) const
#define ASSERT(expression)
const RigidBodyKinematics * pGetRBK(void) const
GradientExpression< UnaryExpr< FuncSqrt, Expr > > sqrt(const GradientExpression< Expr > &u)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
const doublereal & dGet(int i, integer j) const
virtual const Vec3 & GetXCurr(void) const
void AddVec(integer iCol, const Vec3 &v)
static std::stack< cleanup * > c
virtual std::string GetString(const std::string &sDefVal)
const MatCrossCross_Manip MatCrossCross
virtual bool IsStringWithDelims(enum Delims Del=DEFAULTDELIM)
std::ostream & GetLogFile(void) const
void PutVec(integer iCol, const Vec3 &v)
static const doublereal a
void OutputOpen(const OutputHandler::OutFiles out)
void AddMat3x3(integer iCol, const Mat3x3 &m)
virtual HighParser::ErrOut GetLineData(void) const
unsigned int GetLabel(void) const
Node * pFindNode(Node::Type Typ, unsigned int uNode) const
virtual doublereal GetReal(const doublereal &dDefval=0.0)