Esempio n. 1
0
        public writemesh()
        {
            String modelName = CSMGEN.RD.next();
            String fileName  = CSMGEN.RD.next();

            CSMGEN.PR.Write("WriteMesh: {0}    {1}\n", modelName, fileName);

            StreamWriter WR = new FePrintWriter().getPrinter(fileName);

            if (CSMGEN.blocks.ContainsKey(modelName))
            {
                m = (FeModel)CSMGEN.blocks[modelName];
            }
            else
            {
                UTIL.errorMsg("No such mesh block: " + modelName);
            }

            WR.Write("# Model name: {0}\n", modelName);
            WR.Write("nNod = {0,5}\n", m.nNod);
            WR.Write("nEl = {0,5}\n", m.nEl);
            WR.Write("nDim = {0,5}\n", m.nDim);

            WR.Write("nodCoord\n");
            for (int i = 0; i < m.nNod; i++)
            {
                for (int j = 0; j < m.nDim; j++)
                {
                    WR.Write("{0,20:0.000000000}", m.getNodeCoord(i, j));
                }
                WR.WriteLine("");
            }

            WR.Write("\nelCon");
            for (int iel = 0; iel < m.nEl; iel++)
            {
                WR.Write("\n{0} {1,6}", m.elems[iel].name, m.elems[iel].matName);
                if (m.elems[iel].name.Equals("quad4") || m.elems[iel].name.Equals("quad8r")) //|| m.elems[iel].name.Equals("genquad4") || m.elems[iel].name.Equals("genquad8"))
                {
                    WR.Write("{0,6}", m.elems[iel].t);
                }
                if (m.elems[iel].name.Equals("truss22") || m.elems[iel].name.Equals("truss32"))//|| m.elems[iel].name.Equals("genquad4") || m.elems[iel].name.Equals("genquad8"))
                {
                    WR.Write("{0,12}", m.elems[iel].A);
                }
                int nind = m.elems[iel].ind.Length;
                for (int i = 0; i < nind; i++)
                {
                    WR.Write("{0,12}", m.elems[iel].ind[i]);
                }
            }
            WR.Write("\n\nend\n");
            WR.Close();
            CSMGEN.PR.Write("Mesh " + modelName + ": nEl = {0}  nNod = {1}\n", m.nEl, m.nNod);
        }
        // Write results to a file.
        public void writeResults()
        {
            String       fileResult = fea.CSFEM.fileOut + "." + FeLoad.loadStepName;
            StreamWriter PR         = new FePrintWriter().getPrinter(fileResult);

            PR.WriteLine("Displacements" + Environment.NewLine);
            if (fem.nDim == 2)
            {
                PR.WriteLine(" Node             ux             uy");
            }
            else
            {
                PR.WriteLine(" Node             ux             uy             uz");
            }
            for (int i = 0; i < fem.nNod; i++)
            {
                PR.Write("{0,5}", i + 1);
                for (int j = 0; j < fem.nDim; j++)
                {
                    PR.Write("{0,15:E6}", FeLoad.sDispl[fem.nDim * i + j]);
                    //Console.Write("{0,15:E6}", FeLoad.sDispl[fem.nDim * i + j]);
                }
                PR.WriteLine();
            }

            PR.WriteLine(Environment.NewLine + Environment.NewLine + "Stresses");
            for (int iel = 0; iel < fem.nEl; iel++)
            {
                if (fem.nDim == 2)
                {
                    PR.Write(Environment.NewLine + "El {0,4}     sxx            syy            sxy            szz            epi", iel + 1);
                }
                else
                {
                    PR.Write(Environment.NewLine + "El {0,4}     sxx            syy            szz            sxy            syz            szx            epi", iel + 1);
                }

                foreach (StressContainer aStr in fem.elems[iel].str)
                {
                    PR.Write(Environment.NewLine);
                    for (int i = 0; i < 2 * fem.nDim; i++)
                    {
                        PR.Write("{0,20:0.00000000}", aStr.sStress[i]);
                        //PR.Write("{0,15:0.00000000}", aStr.sStress[i]);
                    }
                    PR.Write("{0,20:0.00000000}", aStr.sEpi);
                }
            }
            PR.Close();
        }