SYMPTOM/PROBLEM --------------- How to output the stiffness matrix and/or the mass matrix from I-deas Model Solution? SOLUTION/WORKAROUND ------------------- Storing and Accessing Elemental Stiffness and Mass Matrices In the past this has been difficult, as the only option was to modify a program file to use a different setup method and then do a hypermatrix write to a universal file. Begining with I-deas 8 and in all subsequent releases of I-deas and I-deas NX Series, there is a delivered program file nbbstf.prg which can be copied locally and made to be a user defined program file in either a linear statics or normal mode analysis. The program file will be found in the $SDRC_INSTL/ideas/stb directory. The selection to specify a user defined program file is chosen under the Options when creating a Solution Set. Running with this program file will not perform a "solve" but just generate the matrices and write them to the files modelfile.stf and modelfile.mas. These files will be written to the directory I-deas is started in. Rather than give a specification of the file format, shown below are Fortran and C sample programs which read these files and print out the contents. These programs can be used to read both the modelfile.stf file and the modelfile.mas file. A programmer could also alter the code to specify any desired format. Fortran version: C SAMPLE PROGRAM FOR READING THE ELEMENT MATRICES GENERATED C IN MODEL SOLUTION C INTEGER IUNIT PARAMETER (IUNIT=1) C INTEGER I, I1, I2, IELE, IFED, IROW, NELF, NTERM DOUBLE PRECISION DMAT(3600), DSYMAT(1830) CHARACTER*80 FILNAM C C*** GET THE FILE NAME C WRITE(6,100) READ(5,110)FILNAM C C*** OPEN THE FILE C OPEN (IUNIT, FILE=FILNAM, STATUS='OLD', FORM='UNFORMATTED') C C*** READ THE ELEMENT DATA C 10 READ(IUNIT,END=999) IELE, IFED, NELF WRITE(6,120) IELE, IFED, NELF NTERM = (NELF*(NELF+1))/2 READ(IUNIT) (DSYMAT(I),I=1,NTERM) CALL EXPAND (DSYMAT, NELF, DMAT) C C*** WRITE MATRIX TO TERMINAL C I2 = 0 DO 20 IROW=1,NELF WRITE(6,130)IROW I1 = I2 + 1 I2 = I2 + NELF WRITE(6,140)(DMAT(I),I=I1,I2) 20 CONTINUE GO TO 10 C 100 FORMAT(' ENTER NAME OF FILE') 110 FORMAT(A80) 120 FORMAT(/' ELEMENT =',I5,' TYPE =',I4,' NUMBER OF FREEDOMS ='I4) 130 FORMAT(/'ROW',I3) 140 FORMAT(1P6E13.5) C 999 CLOSE(IUNIT) END C SUBROUTINE EXPAND (DMAT1, N, DMAT2) C C EXPAND UPPER TRIANGULAR MATRIX TO FULL C INTEGER I, J, K, N DOUBLE PRECISION DMAT1(*), DMAT2(N,N) C K = 0 DO 10 J=1,N DO 10 I=1,J K = K + 1 DMAT2(I,J) = DMAT1(K) DMAT2(J,I) = DMAT1(K) 10 CONTINUE RETURN END C version: /* Sample progrm for reading the element matrices generated in Model Solution */ #include void expand (double [], int, double[]); main() { int i, i1, i2, iBuf[5], iDum, iEle, iFed, iRet, iRow; int iNelf, iNread, iNterm, n; double dMat[3600], dSymat[1830]; char cFilnam[80]; FILE *cfPtr; /* Get the filename */ Prompt: printf("Enter name of file\n"); scanf("%s", cFilnam); /* Open the file */ cfPtr = fopen(cFilnam, "r"); if (cfPtr == NULL) goto Prompt; /* Read the element data */ NextElem: iNread = fread (iBuf, sizeof(int), 5, cfPtr); if (iNread ==5) { iEle = iBuf[1]; iFed = iBuf[2]; iNelf = iBuf[3]; printf("\nElement = %d Type = %d Number of freedoms %d\n", iEle, iFed, iNelf); iNterm = (iNelf*(iNelf+1))/2; iNread = fread (&iDum, sizeof(int), 1, cfPtr); iNread = fread (dSymat, sizeof(double), iNterm, cfPtr); iNread = fread (&iDum, sizeof(int), 1, cfPtr); expand (dSymat, iNelf, dMat); /* Write the matrix */ i2 = -1; for (iRow=0;iRow