feapproblem.java

来自「平面三角形有限元程序」· Java 代码 · 共 114 行

JAVA
114
字号
/* * FeapProblem.java * * Created on 12. Oktober 2002, 20:01 *//** * @author Christian Uhde */import java.util.*;import java.io.*;import javax.swing.*;import java.awt.*;public class FeapProblem{    String name;                      // I guess it's the name!    String comment;                // so what do you think?    int numnp = 0;                        // number of nodal points    int numel = 0;                         // number of elements    int nummat = 0;                      // number of materials    int ndm = 0;                            // space dimensions of mesh    int ndf = 0;                             // maximum number of unknowns per node    int nen = 0;                             // maximum number of unknowns per element    Vector materials;                //  materials objekts used in current problem        String coordinateString;    String elementString;    String forceString;    String boundsString;        /** Creates a new instance of FeapProblem */    public FeapProblem(String name) {        this.name = name;        comment = "";         coordinateString = new String();         elementString = new String();         forceString = new String();         boundsString = new String();        materials = new Vector();    }        /** Add material to problem */    public void addMaterial(Object obj, JPanel p) {        GridBagConstraints gbc = new GridBagConstraints();        gbc.insets = new Insets(3, 5, 3, 5);        gbc.gridx = 0;        gbc.gridy = materials.size();                if(obj instanceof FeapMatTruss) {            FeapMatTruss truss = (FeapMatTruss)obj;            p.add(truss, gbc);            materials.addElement(truss);        } else if(obj instanceof FeapMatFrame) {            FeapMatFrame frame = (FeapMatFrame)obj;            p.add(frame, gbc);            materials.addElement(frame);        } else if(obj instanceof FeapMatSolidElasticIso) {            FeapMatSolidElasticIso solid = (FeapMatSolidElasticIso)obj;            p.add(solid, gbc);            materials.addElement(solid);        }        p.updateUI();            }    /** Writes a Feap inputfile to file "filename" */    public void writeFeapFile(String filename) {        FileWriter outputfile;                try {                outputfile = new FileWriter(filename);                // print name, comment, numnp, numel, ndm, ndf, nen                outputfile.write("feap " + name + ", " + comment + "  \n");                outputfile.write("" + numnp + " " + numel + " " + nummat + " " + ndm + " " + ndf + " " + nen+ "\n\n");                // print materials                for(int k = 0; k < materials.size(); k++) {                    outputfile.write("MATErial " + (k+1) + "\n");                    FeapMaterial fm = (FeapMaterial) materials.elementAt(k);                    outputfile.write("" + fm.writeFeapFile());                }                // print nodes                outputfile.write("COORdinate\n");                outputfile.write(coordinateString);                outputfile.write("\n");                // print elements                outputfile.write("ELEMent\n");                outputfile.write(elementString);                outputfile.write("\n");                // print boundaries                outputfile.write("BOUNdary\n");                outputfile.write(boundsString);                outputfile.write("\n");                // print forces                outputfile.write("FORCe\n");                outputfile.write(forceString);                outputfile.write("\n");                // print batch entries//                outputfile.write("BATCh\n");//                outputfile.write("tang,,1\ndisp all\nstress all\n");                outputfile.write("END\n\n");                outputfile.write("INTEractive\n\n");                outputfile.write("STOP\n\n");                // close outputfile                outputfile.close();        } catch(IOException e) {            System.out.println("Could not write file \"" + filename + "\"");        }            }    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?