Login  Register

Re: Help in Java (netbeans & eclipse)

Posted by tamb20 on May 29, 2015; 1:15am
URL: https://forum.jogamp.org/Help-in-Java-netbeans-eclipse-tp4034513p4034539.html

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

public class DataProcessor extends JFrame {

        private Map<Integer, Integer> idMappings = new HashMap<Integer, Integer>();
        private int pointInConcern;
        private double interval = 5;
        private int intervalCount = 100;
        private List<TetraHedron> allTetrahedrons = new ArrayList<>();
        private List<TetraHedron> tetrahedrons = new ArrayList<>();
        private double youngsModulus; // Represented by E
        private double poissonRatio; // Represented by v
        private int selectedPointId = 0;
        private double volume = 0.0;
        private double[] force = new double[3];
        private double[] newPoint = new double[3];

        double[][][] newF = new double[intervalCount + 1][tetrahedrons.size() * 12][1];

        private int temppp;

        private double[][] elasticityMatrix; // Represented by D

        private double[][] AG;

        List<double[][]> allK = new ArrayList<double[][]>();

        /**
         * @param args
         */
        public static void main(String[] args) {
                DataProcessor dataProcessor = new DataProcessor();
                dataProcessor.process();

        }

        public void process() {

                selectedPointId = 0;
                double row = 1;
                double lambda = calculateLambda(youngsModulus, poissonRatio);
                double mue = calculateMue(youngsModulus, poissonRatio);
                elasticityMatrix = calculateElasticityMatrix(lambda, mue);

                double[][] Ksum = new double[tetrahedrons.size() * 12][tetrahedrons
                                .size() * 12];
                for (int i = 0; i < 3 * tetrahedrons.size(); i++) {
                        for (int j = 0; j < 3 * tetrahedrons.size(); j++) {
                                Ksum[i][j] = 0.0;
                        }
                }

                for (TetraHedron t : tetrahedrons) {
                        double[][] s = getStiffnessMatrix(t, false);
                        assemble(Ksum, s, t.getPoints()[0].getId(),
                                        t.getPoints()[1].getId(), t.getPoints()[2].getId(),
                                        t.getPoints()[3].getId());
                        allK.add(s);
                }

                double[] F = new double[tetrahedrons.size() * 12];
                for (int i = 0; i < F.length;) {
                        F[i++] = force[0];
                        F[i++] = force[1];
                        F[i++] = force[2];
                }

                double[] U = solve(Ksum, F);

                int m = 0;
                for (TetraHedron t : tetrahedrons) {
                        Point[] points = new Point[4];
                        points[0] = new Point(U[(m * 3) + 0], U[(m * 3) + 1],
                                        U[(m * 3) + 2], t.getPoints()[0].getId());
                        m++;
                        points[1] = new Point(U[(m * 3) + 0], U[(m * 3) + 1],
                                        U[(m * 3) + 2], t.getPoints()[1].getId());
                        m++;
                        points[2] = new Point(U[(m * 3) + 0], U[(m * 3) + 1],
                                        U[(m * 3) + 2], t.getPoints()[2].getId());
                        m++;
                        points[3] = new Point(U[(m * 3) + 0], U[(m * 3) + 1],
                                        U[(m * 3) + 2], t.getPoints()[3].getId());
                        m++;

                        t.setPoints(0, points);
                }

                double[][] UTransformed = new double[U.length][1];

                for (int i = 0; i < U.length; i++) {

                        UTransformed[i][0] = U[i];
                }

                double[][] Fall = new double[tetrahedrons.size()][12];
                for (int i = 0; i < tetrahedrons.size(); i++) {
                        for (int j = 0; j < 12; j++) {
                                Fall[i][j] = 0.0;
                        }
                }

                double[][] Udash = new double[tetrahedrons.size() * 12][1];
                double[][] Fdash = new double[tetrahedrons.size() * 12][1];

                for (int i = 0; i < tetrahedrons.size() * 12; i++) {
                        Udash[i][0] = U[i];
                        Fdash[i][0] = F[i];
                }

                for (int i = 0; i < tetrahedrons.size(); i++) {

                        double[][] USelected = new double[12][1];
                        USelected[0][0] = UTransformed[((tetrahedrons.get(i).getPoints()[0]
                                        .getId()) * 3) + 0][0];
                        USelected[1][0] = UTransformed[((tetrahedrons.get(i).getPoints()[0]
                                        .getId()) * 3) + 1][0];
                        USelected[2][0] = UTransformed[((tetrahedrons.get(i).getPoints()[0]
                                        .getId()) * 3) + 2][0];
                        USelected[3][0] = UTransformed[((tetrahedrons.get(i).getPoints()[1]
                                        .getId()) * 3) + 0][0];
                        USelected[4][0] = UTransformed[((tetrahedrons.get(i).getPoints()[1]
                                        .getId()) * 3) + 1][0];
                        USelected[5][0] = UTransformed[((tetrahedrons.get(i).getPoints()[1]
                                        .getId()) * 3) + 2][0];
                        USelected[6][0] = UTransformed[((tetrahedrons.get(i).getPoints()[2]
                                        .getId()) * 3) + 0][0];
                        USelected[7][0] = UTransformed[((tetrahedrons.get(i).getPoints()[2]
                                        .getId()) * 3) + 1][0];
                        USelected[9][0] = UTransformed[((tetrahedrons.get(i).getPoints()[2]
                                        .getId()) * 3) + 2][0];
                        USelected[9][0] = UTransformed[((tetrahedrons.get(i).getPoints()[3]
                                        .getId()) * 3) + 0][0];
                        USelected[10][0] = UTransformed[((tetrahedrons.get(i).getPoints()[3]
                                        .getId()) * 3) + 1][0];
                        USelected[11][0] = UTransformed[((tetrahedrons.get(i).getPoints()[3]
                                        .getId()) * 3) + 2][0];

                        double[][] temp = multiply(allK.get(i), USelected);
                        for (int j = 0; j < 12; j++) {
                                Fall[i][j] = temp[j][0];
                        }
                }

                newF[0] = Fall;

                double[][] M = new double[tetrahedrons.size() * 12][tetrahedrons.size() * 12];
                for (int i = 0; i < M.length; i++) {
                        for (int j = 0; j < M.length; j++) {
                                M[i][j] = 0.0;
                        }
                }

                M[0][0] = 2.0;

                for (int j = 1; j < M.length; j++) {
                        if (j % 3 == 0) {
                                M[0][j] = 1.0;
                        }
                }

                for (int i = 1; i < M.length; i++) {
                        for (int j = 1; j < M.length; j++) {
                                M[i][j] = M[i - 1][j - 1];
                        }
                        M[i][0] = M[i - 1][M.length - 1];
                }

                M = multiply(M, (row * volume / 20));

                double cK = 1.0;
                double cM = 1.0;

                double[][] C = sum(multiply(Ksum, cK), multiply(M, cM));

                for (TetraHedron t : tetrahedrons) {
                        t.getStrain().put(0, getStiffnessMatrix(t, true));
                        t.getStress().put(0,
                                        multiply(elasticityMatrix, t.getStrain().get(0)));
                }

                double[][] velocity = new double[tetrahedrons.size() * 12][1];
                double[][] acceleration = new double[tetrahedrons.size() * 12][1];

                for (int t = 1; t <= intervalCount; t++) {

                        temppp = t;

                        double delta = 0.05;
                        double alpha = 0.25 * (0.5 + delta) * (0.5 + delta);
                        double a0 = 1 / (alpha * ((t + 1) * interval) * ((t + 1) * interval));
                        double a1 = delta / (alpha * ((t + 1) * interval));
                        double a2 = 1 / (alpha * ((t + 1) * interval));
                        double a3 = (1 / (2 * alpha)) - 1;
                        double a4 = (delta / alpha) - 1;
                        double a5 = ((t + 1) * interval / 2) * ((delta / alpha) - 2);
                        double a6 = ((t + 1) * interval) * (1 - delta);
                        double a7 = (t + 1) * interval * delta;

                        double[][] effectiveStiffnessMatrix = sum(Ksum,
                                        sum(multiply(M, a0), multiply(C, a1)));

                        double[][] term1 = multiply(
                                        M,
                                        sum(sum(multiply(Udash, a0), multiply(velocity, a2)),
                                                        multiply(acceleration, a3)));
                        double[][] term2 = multiply(
                                        C,
                                        sum(sum(multiply(Udash, a1), multiply(velocity, a4)),
                                                        multiply(acceleration, a5)));

                        double[][] R = sum(sum(Fdash, term1), term2);

                        newF[t] = R;

                        double[] Rdash = new double[R.length];

                        for (int i = 0; i < Rdash.length; i++) {
                                Rdash[i] = R[i][0];
                        }

                        double[] newU = solve(effectiveStiffnessMatrix, Rdash);
                        double[][] newUdash = new double[tetrahedrons.size() * 12][1];
                        for (int i = 0; i < tetrahedrons.size() * 12; i++) {
                                newUdash[i][0] = newU[i];
                        }

                        m = 0;
                        for (TetraHedron eachT : tetrahedrons) {
                                Point[] points = new Point[4];
                                points[0] = new Point(newU[(m * 3) + 0], newU[(m * 3) + 1],
                                                newU[(m * 3) + 2], eachT.getPoints()[0].getId());
                                m++;
                                points[1] = new Point(newU[(m * 3) + 0], newU[(m * 3) + 1],
                                                newU[(m * 3) + 2], eachT.getPoints()[1].getId());
                                m++;
                                points[2] = new Point(newU[(m * 3) + 0], newU[(m * 3) + 1],
                                                newU[(m * 3) + 2], eachT.getPoints()[2].getId());
                                m++;
                                points[3] = new Point(newU[(m * 3) + 0], newU[(m * 3) + 1],
                                                newU[(m * 3) + 2], eachT.getPoints()[3].getId());
                                m++;

                                eachT.setPoints(t, points);
                        }

                        double[][] newAcceleration = sum(
                                        sum(multiply(sum(multiply(Udash, -1.0), newUdash), a0),
                                                        multiply(velocity, -1.0 * a2)),
                                        multiply(acceleration, -1.0 * a3));
                        double[][] newVelocity = sum(
                                        sum(velocity, multiply(acceleration, a6)),
                                        multiply(newAcceleration, a7));

                        velocity = newVelocity;
                        acceleration = newAcceleration;

                        for (TetraHedron eachT : tetrahedrons) {
                                eachT.getStrain().put(t, getStiffnessMatrix(eachT, true));
                                eachT.getStress()
                                                .put(t,
                                                                sum(eachT.getStress().get(t - 1),
                                                                                multiply(
                                                                                                elasticityMatrix,
                                                                                                sum(eachT.getStrain().get(t),
                                                                                                                multiply(eachT
                                                                                                                                .getStrain()
                                                                                                                                .get(t - 1),
                                                                                                                                -1.0)))));
                        }

                }

                System.out.println("Strain");
                for (Integer t : tetrahedrons.get(0).getStrain().keySet()) {
                        System.out.println("\t"
                                        + tetrahedrons.get(0).getStrain().get(t)[0][0] + "\t"
                                        + tetrahedrons.get(0).getStrain().get(t)[1][0] + "\t"
                                        + tetrahedrons.get(0).getStrain().get(t)[2][0] + "\t"
                                        + tetrahedrons.get(0).getStrain().get(t)[3][0] + "\t"
                                        + tetrahedrons.get(0).getStrain().get(t)[4][0] + "\t"
                                        + tetrahedrons.get(0).getStrain().get(t)[5][0]);

                }

                System.out.println("Stress");

                for (Integer t : tetrahedrons.get(0).getStress().keySet()) {
                        System.out.println("\t"
                                        + tetrahedrons.get(0).getStress().get(t)[0][0] + "\t"
                                        + tetrahedrons.get(0).getStress().get(t)[1][0] + "\t"
                                        + tetrahedrons.get(0).getStress().get(t)[2][0] + "\t"
                                        + tetrahedrons.get(0).getStress().get(t)[3][0] + "\t"
                                        + tetrahedrons.get(0).getStress().get(t)[4][0] + "\t"
                                        + tetrahedrons.get(0).getStress().get(t)[5][0]);

                }

        }

        /**
         * @return
         */
        private XYDataset[] createDataset() {

                final XYSeries series1 = new XYSeries("Stress vs Strain");
                final XYSeries series2 = new XYSeries("Force vs Displacement");
                final XYSeries series3 = new XYSeries("Force vs Time");
                for (Integer t : tetrahedrons.get(0).getStrain().keySet()) {
                        series1.add(tetrahedrons.get(0).getStrain().get(t)[0][0],
                                        tetrahedrons.get(0).getStress().get(t)[0][0]);
                        series3.add(1.0 * t, newF[t][0][0]);
                        series2.add(tetrahedrons.get(0)
                                        .getHistoricalPositions().get(t)[0].getX(),newF[t][0][0]);
                }

                final XYSeriesCollection dataset1 = new XYSeriesCollection();
                final XYSeriesCollection dataset2 = new XYSeriesCollection();
                final XYSeriesCollection dataset3 = new XYSeriesCollection();
                dataset1.addSeries(series1);
                dataset2.addSeries(series2);
                dataset3.addSeries(series3);

                return new XYDataset[] { dataset1, dataset2, dataset3 };

        }

        /**
         * @param dataset
         * @return
         */
        private JFreeChart createChart(final XYDataset dataset) {

                final JFreeChart chart = ChartFactory.createXYLineChart("Title",
                                "X Axis", "Y Axis", dataset);
                final XYPlot plot = chart.getXYPlot();
                return chart;

        }

        /**
         * @param ad
         * @param ad1
         * @return
         */
        public double[] solve(double ad[][], double ad1[]) {
                if (ad == null || ad1 == null || ad.length != ad1.length
                                || ad[0].length != ad1.length)
                        return null;
                double ad2[][] = (double[][]) ad.clone();
                double ad3[] = (double[]) ad1.clone();
                int i = ad3.length;
                double ad4[] = new double[i];
                for (int j = 0; j < i - 1; j++)
                        if (ad2[j][j] != 0.0D) {
                                for (int l = j + 1; l < i; l++) {
                                        double d = ad2[l][j] / ad2[j][j];
                                        for (int j1 = j; j1 < i; j1++)
                                                ad2[l][j1] = ad2[l][j1] - ad2[j][j1] * d;

                                        ad3[l] = ad3[l] - ad3[j] * d;
                                }

                        }

                for (int k = i - 1; k >= 0; k--) {
                        ad4[k] = 0.0D;
                        for (int i1 = k + 1; i1 < i; i1++)
                                ad4[k] = ad4[k] - ad2[k][i1] * ad4[i1];

                        if (ad2[k][k] == 0.0D)
                                ad2[k][k] = 0.10000000000000001D;
                        ad4[k] = (ad4[k] + ad3[k]) / ad2[k][k];
                }

                return ad4;

        }

        private double[][] getStiffnessMatrix(TetraHedron t, boolean justStrain) {

                double[][] displacementDifferentiationMatrix; // Represented by B
                double[][] shapefunctionIdentityMatrix; // Represented by N
                double[][] displacementIdentityMatrix; // Represented by T
                double[][] relativeDisplacementMatrix; // Represented by G
                double[][] nonLinearDisplacementMatrix; // Represented by A
                double[][] linearDifferentialOperator; // Represented by S

                TetrahedronShapeFunction shapeFunctionCalculator = new TetrahedronShapeFunction();
                Point originalPoint = tetrahedrons.get(0).getPoints()[selectedPointId];
                double[] shapeFunctions = shapeFunctionCalculator.getShapeFunction(
                                tetrahedrons.get(0), originalPoint);

                linearDifferentialOperator = multiply(
                                new double[][] {
                                                { shapeFunctionCalculator.getBetas()[selectedPointId],
                                                                0, 0 },
                                                {
                                                                0,
                                                                shapeFunctionCalculator.getGammas()[selectedPointId],
                                                                0 },
                                                {
                                                                0,
                                                                0,
                                                                shapeFunctionCalculator.getDeltas()[selectedPointId] },
                                                {
                                                                shapeFunctionCalculator.getGammas()[selectedPointId],
                                                                shapeFunctionCalculator.getBetas()[selectedPointId],
                                                                0 },
                                                {
                                                                0,
                                                                shapeFunctionCalculator.getDeltas()[selectedPointId],
                                                                shapeFunctionCalculator.getGammas()[selectedPointId] },
                                                {
                                                                shapeFunctionCalculator.getDeltas()[selectedPointId],
                                                                0,
                                                                shapeFunctionCalculator.getBetas()[selectedPointId] } },
                                (1.0 / (6.0 * shapeFunctionCalculator.getVolume())));

// double[][] Su = multiply(linearDifferentialOperator, new double[][] {
// { t.getPoints()[selectedPointId].getX() },
// { t.getPoints()[selectedPointId].getY() },
// { t.getPoints()[selectedPointId].getZ() } });

                double[][] Su = multiply(linearDifferentialOperator, new double[][] {
                                { newPoint[0] },
                                { newPoint[1] },
                                { newPoint[2] } });

                displacementDifferentiationMatrix = multiply(
                                calculateDisplacementDifferentiationMatrix(shapeFunctionCalculator),
                                1.0 / (6 * shapeFunctionCalculator.getVolume()));
                shapefunctionIdentityMatrix = calculateShapeFunctionIdentityMatrix(shapeFunctions);

                double[][] elementDisplacement = multiply(shapefunctionIdentityMatrix,
                                new double[][] { { t.getPoints()[0].getX() },
                                                { t.getPoints()[0].getY() },
                                                { t.getPoints()[0].getZ() },
                                                { t.getPoints()[1].getX() },
                                                { t.getPoints()[1].getY() },
                                                { t.getPoints()[1].getZ() },
                                                { t.getPoints()[2].getX() },
                                                { t.getPoints()[2].getY() },
                                                { t.getPoints()[2].getZ() },
                                                { t.getPoints()[3].getX() },
                                                { t.getPoints()[3].getY() },
                                                { t.getPoints()[3].getZ() } }); // should be 3x1 ...
                                                                                                                // small u

                displacementIdentityMatrix = calculateDisplacementIdentityMatrix(shapeFunctionCalculator);
                relativeDisplacementMatrix = multiply(displacementIdentityMatrix,
                                shapefunctionIdentityMatrix);

                nonLinearDisplacementMatrix = generateNonLinearDisplacementMatrix(shapeFunctionCalculator);

                AG = multiply(nonLinearDisplacementMatrix, relativeDisplacementMatrix);

                double[][] theta = multiply(displacementIdentityMatrix,
                                multiply(elementDisplacement, (1.1 * temppp)));

                double[][] ATheta = multiply(nonLinearDisplacementMatrix, theta);

                double[][] strain = sum(multiply(Su, 1), multiply(ATheta, 0.5));
                if (justStrain) {
                        return strain;
                }

                double[][] elementStiffness1 = multiply(
                                multiply(
                                                multiply(transpose(displacementDifferentiationMatrix),
                                                                elasticityMatrix),
                                                displacementDifferentiationMatrix),
                                shapeFunctionCalculator.getVolume());
                double[][] elementStiffness2 = multiply(
                                multiply(transpose(displacementDifferentiationMatrix), AG),
                                0.5 * shapeFunctionCalculator.getVolume());
                double[][] elementStiffness = sum(elementStiffness1, elementStiffness2);

                volume = volume + shapeFunctionCalculator.getVolume();

                return elementStiffness;
        }

        /**
         * @return
         */
        private double[][] generateNonLinearDisplacementMatrix(
                        TetrahedronShapeFunction shapeFunctionCalculator) {
                double[][] returnValue = new double[6][9];
                for (int i = 0; i < 6; i++) {
                        for (int j = 0; j < 9; j++) {
                                returnValue[i][j] = 0.0;
                        }
                }

                int[] indices = new int[3];
                int j = 0;
                for (int i = 0; i < 4; i++) {
                        if (i != selectedPointId) {
                                indices[j] = i;
                                j++;
                        }
                }

                returnValue[0][0] = shapeFunctionCalculator.getBetas()[indices[0]];
                returnValue[1][4] = shapeFunctionCalculator.getGammas()[indices[1]];
                returnValue[2][8] = shapeFunctionCalculator.getDeltas()[indices[2]];
                returnValue[3][1] = shapeFunctionCalculator.getGammas()[indices[0]];
                returnValue[3][3] = shapeFunctionCalculator.getBetas()[indices[1]];
                returnValue[4][5] = shapeFunctionCalculator.getDeltas()[indices[1]];
                returnValue[4][7] = shapeFunctionCalculator.getGammas()[indices[2]];
                returnValue[5][2] = shapeFunctionCalculator.getDeltas()[indices[0]];
                returnValue[5][6] = shapeFunctionCalculator.getBetas()[indices[2]];

                return returnValue;
        }

        /**
         * @return
         */
        private double[][] calculateDisplacementIdentityMatrix(
                        TetrahedronShapeFunction shapeFunctionCalculator) {
                double[][] returnValue = new double[9][3];
                for (int i = 0; i < 9; i++) {
                        for (int j = 0; j < 3; j++) {
                                returnValue[i][j] = 0.0;
                        }
                }

                returnValue[0][0] = shapeFunctionCalculator.getBetas()[selectedPointId];
                returnValue[1][1] = shapeFunctionCalculator.getBetas()[selectedPointId];
                returnValue[2][2] = shapeFunctionCalculator.getBetas()[selectedPointId];

                returnValue[3][0] = shapeFunctionCalculator.getGammas()[selectedPointId];
                returnValue[4][1] = shapeFunctionCalculator.getGammas()[selectedPointId];
                returnValue[5][2] = shapeFunctionCalculator.getGammas()[selectedPointId];

                returnValue[6][0] = shapeFunctionCalculator.getDeltas()[selectedPointId];
                returnValue[7][1] = shapeFunctionCalculator.getDeltas()[selectedPointId];
                returnValue[8][2] = shapeFunctionCalculator.getDeltas()[selectedPointId];

                return multiply(returnValue,
                                (1.0 / (6 * shapeFunctionCalculator.getVolume())));
        }

        /**
         * @return
         */
        private double[][] calculateShapeFunctionIdentityMatrix(
                        double[] shapeFunctions) {

                double[][] returnValue = new double[3][12];
                for (int i = 0; i < 3; i++) {
                        for (int j = 0; j < 12; j++) {
                                returnValue[i][j] = 0.0;
                        }
                }

                returnValue[0][0] = shapeFunctions[0];
                returnValue[1][1] = shapeFunctions[0];
                returnValue[2][2] = shapeFunctions[0];

                returnValue[0][3] = shapeFunctions[1];
                returnValue[1][4] = shapeFunctions[1];
                returnValue[2][5] = shapeFunctions[1];

                returnValue[0][6] = shapeFunctions[2];
                returnValue[1][7] = shapeFunctions[2];
                returnValue[2][8] = shapeFunctions[2];

                returnValue[0][9] = shapeFunctions[3];
                returnValue[1][10] = shapeFunctions[3];
                returnValue[2][11] = shapeFunctions[3];

                return returnValue;
        }

        private double[][] calculateDisplacementDifferentiationMatrix(
                        TetrahedronShapeFunction shapeFunctionCalculator) {

                double[][] returnValue = new double[6][12];
                for (int i = 0; i < 6; i++) {
                        for (int j = 0; j < 12; j++) {
                                returnValue[i][j] = 0.0;
                        }
                }

                for (int i = 0; i < 4; i++) {
                        returnValue[0][(i * 3) + 0] = shapeFunctionCalculator.getBetas()[i];
                        returnValue[1][(i * 3) + 1] = shapeFunctionCalculator.getGammas()[i];
                        returnValue[2][(i * 3) + 2] = shapeFunctionCalculator.getDeltas()[i];
                        returnValue[3][(i * 3) + 0] = shapeFunctionCalculator.getGammas()[i];
                        returnValue[3][(i * 3) + 1] = shapeFunctionCalculator.getBetas()[i];
                        returnValue[4][(i * 3) + 1] = shapeFunctionCalculator.getDeltas()[i];
                        returnValue[4][(i * 3) + 2] = shapeFunctionCalculator.getGammas()[i];
                        returnValue[5][(i * 3) + 0] = shapeFunctionCalculator.getDeltas()[i];
                        returnValue[5][(i * 3) + 2] = shapeFunctionCalculator.getBetas()[i];
                }

                return returnValue;
        }

        /**
         * @param lambda
         * @param mue
         * @return
         */
        private double[][] calculateElasticityMatrix(double lambda, double mue) {
                double[][] returnValue = new double[6][6];
                for (int i = 0; i < 6; i++) {
                        for (int j = 0; j < 6; j++) {
                                returnValue[i][j] = 0.0;
                        }
                }

                double term = lambda + (2 * mue);
                returnValue[0][0] = term;
                returnValue[1][1] = term;
                returnValue[2][2] = term;

                returnValue[0][1] = lambda;
                returnValue[0][2] = lambda;
                returnValue[1][0] = lambda;
                returnValue[1][2] = lambda;
                returnValue[2][0] = lambda;
                returnValue[2][1] = lambda;

                returnValue[3][3] = mue;
                returnValue[4][4] = mue;
                returnValue[5][5] = mue;

                return returnValue;
        }

        private double calculateLambda(double E, double v) {

                return (E * v) / ((1 + v) * (1 - (2 * v)));
        }

        private double calculateMue(double E, double v) {
                return (E) / ((2) * (1 + (2 * v)));
        }

        private Vector getAppliedForce() {
                return new Vector(1, 0, 0);
        }

        private Vector getBoundaryConditions() {
                return new Vector(1, 0, 0);
        }

        public void loadData(TetraHedronVolumeDataPopulator meshData,
                        int pointInConcern, double[] newPosition, double[] Force, double y,
                        double p) {

                this.youngsModulus = y;
                this.poissonRatio = p;
                this.force = Force;
                this.newPoint = newPosition;

                this.pointInConcern = pointInConcern;
                int s1 = meshData.getTriangleNum();
                int[][] s2 = meshData.getTriangleData();
                int s3 = meshData.getVertexNum();
                double[][] s4 = meshData.getVertex();
                int id = 0;

                List<Point> allPoints = new ArrayList<>();
                for (int i = 0; i < s3; i++) {
                        allPoints.add(new Point(s4[i][0], s4[i][1], s4[i][2], i));
                }

                for (int i = 0; i < s1; i++) {
                        TetraHedron t = new TetraHedron(allPoints.get(s2[i][0]),
                                        allPoints.get(s2[i][1]), allPoints.get(s2[i][2]),
                                        allPoints.get(s2[i][3]));
                        allTetrahedrons.add(t);

                        if (s2[i][0] == pointInConcern || s2[i][1] == pointInConcern
                                        || s2[i][2] == pointInConcern || s2[i][3] == pointInConcern) {

                                for (int j = 0; j < 4; j++) {
                                        if (!idMappings.containsKey(t.getPoints()[j].getId())) {
                                                idMappings.put(t.getPoints()[j].getId(), id++);
                                        }
                                }

                                Point point0 = new Point(t.getPoints()[0].getX(),
                                                t.getPoints()[0].getY(), t.getPoints()[0].getZ(),
                                                idMappings.get(t.getPoints()[0].getId()));
                                Point point1 = new Point(t.getPoints()[1].getX(),
                                                t.getPoints()[1].getY(), t.getPoints()[1].getZ(),
                                                idMappings.get(t.getPoints()[1].getId()));
                                Point point2 = new Point(t.getPoints()[2].getX(),
                                                t.getPoints()[2].getY(), t.getPoints()[2].getZ(),
                                                idMappings.get(t.getPoints()[2].getId()));
                                Point point3 = new Point(t.getPoints()[3].getX(),
                                                t.getPoints()[3].getY(), t.getPoints()[3].getZ(),
                                                idMappings.get(t.getPoints()[3].getId()));

                                tetrahedrons
                                                .add(new TetraHedron(point0, point1, point2, point3));
                        }
                }
        }

        private void loadTestData() {
                Point p0 = new Point(-4.286024570, 7.582150460, -2.571624280, 0);
                Point p1 = new Point(-5.561186790, 6.248299120, -3.544672010, 1);
                Point p2 = new Point(-4.923605440, 6.915225030, -3.058148150, 2);
                Point p3 = new Point(-5.596092700, 7.658648970, -1.979978200, 3);
                Point p4 = new Point(-5.578639980, 6.953474040, -2.762325050, 4);
                Point p5 = new Point(-6.699521540, 6.046098710, -3.274888280, 5);
                Point p6 = new Point(-6.147807120, 6.852373600, -2.627433300, 6);
                Point p7 = new Point(-4.471798900, 6.164323810, -3.749437090, 7);
                Point p8 = new Point(-3.678542850, 8.107747080, -1.605524780, 8);
                Point p9 = new Point(-4.637318130, 7.883197780, -1.792751550, 9);
                Point p10 = new Point(-6.516149040, 4.549613000, -4.341012950, 10);
                Point p11 = new Point(-6.038668160, 5.398956300, -3.942842480, 11);
                Point p12 = new Point(-7.392597200, 6.445587640, -2.368927480, 12);
                Point p13 = new Point(-6.494345190, 7.052118300, -2.174452780, 13);
                Point p14 = new Point(-3.316689970, 7.464766030, -2.778481250, 14);
                Point p15 = new Point(-5.556344990, 4.681081300, -4.552515980, 15);

                TetraHedron t1 = new TetraHedron(p0, p1, p2, p3);
                TetraHedron t2 = new TetraHedron(p4, p5, p6, p7);
                TetraHedron t3 = new TetraHedron(p8, p9, p10, p11);
                TetraHedron t4 = new TetraHedron(p12, p13, p14, p15);

                tetrahedrons.add(t1);
                tetrahedrons.add(t2);
                tetrahedrons.add(t3);
                tetrahedrons.add(t4);
        }

        public double[][] multiply(double[][] A, double[][] B) {
                int mA = A.length;
                int nA = A[0].length;
                int mB = B.length;
                int nB = B[0].length;
                if (nA != mB)
                        throw new RuntimeException("Illegal matrix dimensions.");
                double[][] C = new double[mA][nB];
                for (int i = 0; i < mA; i++)
                        for (int j = 0; j < nB; j++)
                                for (int k = 0; k < nA; k++)
                                        C[i][j] += (A[i][k] * B[k][j]);
                return C;
        }

        public double[][] multiply(double[][] A, double factor) {
                int mA = A.length;
                int nA = A[0].length;
                double[][] result = new double[mA][nA];
                for (int i = 0; i < mA; i++) {
                        for (int j = 0; j < nA; j++) {
                                result[i][j] = A[i][j] * factor;
                        }
                }
                return result;
        }

        public double[][] sum(double[][] A, double[][] B) {
                int mA = A.length;
                int nA = A[0].length;
                int mB = B.length;
                int nB = B[0].length;
                if (mA != mB || nA != nB) {
                        throw new RuntimeException("Matrix dimensions do not match.");
                }

                double[][] result = new double[mA][nA];
                for (int i = 0; i < mA; i++) {
                        for (int j = 0; j < nA; j++) {
                                result[i][j] = A[i][j] + B[i][j];
                        }
                }
                return result;
        }

        public double[][] transpose(double[][] A) {
                int m = A.length;
                int n = A[0].length;
                double[][] C = new double[n][m];
                for (int i = 0; i < m; i++)
                        for (int j = 0; j < n; j++)
                                C[j][i] = A[i][j];
                return C;
        }

        private void assemble(double[][] K, double[][] k, int i, int j, int m, int n) {

                i++;
                j++;
                m++;
                n++;

                K[(3 * i) - 2 - 1][(3 * i) - 2 - 1] = K[(3 * i) - 2 - 1][(3 * i) - 2 - 1]
                                + k[1 - 1][1 - 1];
                K[3 * i - 2 - 1][3 * i - 1 - 1] = K[3 * i - 2 - 1][3 * i - 1 - 1]
                                + k[1 - 1][2 - 1];
                K[3 * i - 2 - 1][3 * i - 1] = K[3 * i - 2 - 1][3 * i - 1]
                                + k[1 - 1][3 - 1];
                K[3 * i - 2 - 1][3 * j - 2 - 1] = K[3 * i - 2 - 1][3 * j - 2 - 1]
                                + k[1 - 1][4 - 1];
                K[3 * i - 2 - 1][3 * j - 1 - 1] = K[3 * i - 2 - 1][3 * j - 1 - 1]
                                + k[1 - 1][5 - 1];
                K[3 * i - 2 - 1][3 * j - 1] = K[3 * i - 2 - 1][3 * j - 1]
                                + k[1 - 1][6 - 1];
                K[3 * i - 2 - 1][3 * m - 2 - 1] = K[3 * i - 2 - 1][3 * m - 2 - 1]
                                + k[1 - 1][7 - 1];
                K[3 * i - 2 - 1][3 * m - 1 - 1] = K[3 * i - 2 - 1][3 * m - 1 - 1]
                                + k[1 - 1][8 - 1];
                K[3 * i - 2 - 1][3 * m - 1] = K[3 * i - 2 - 1][3 * m - 1]
                                + k[1 - 1][9 - 1];
                K[3 * i - 2 - 1][3 * n - 2 - 1] = K[3 * i - 2 - 1][3 * n - 2 - 1]
                                + k[1 - 1][10 - 1];
                K[3 * i - 2 - 1][3 * n - 1 - 1] = K[3 * i - 2 - 1][3 * n - 1 - 1]
                                + k[1 - 1][11 - 1];
                K[3 * i - 2 - 1][3 * n - 1] = K[3 * i - 2 - 1][3 * n - 1]
                                + k[1 - 1][12 - 1];
                K[3 * i - 1 - 1][3 * i - 2 - 1] = K[3 * i - 1 - 1][3 * i - 2 - 1]
                                + k[2 - 1][1 - 1];
                K[3 * i - 1 - 1][3 * i - 1 - 1] = K[3 * i - 1 - 1][3 * i - 1 - 1]
                                + k[2 - 1][2 - 1];
                K[3 * i - 1 - 1][3 * i - 1] = K[3 * i - 1 - 1][3 * i - 1]
                                + k[2 - 1][3 - 1];
                K[3 * i - 1 - 1][3 * j - 2 - 1] = K[3 * i - 1 - 1][3 * j - 2 - 1]
                                + k[2 - 1][4 - 1];
                K[3 * i - 1 - 1][3 * j - 1 - 1] = K[3 * i - 1 - 1][3 * j - 1 - 1]
                                + k[2 - 1][5 - 1];
                K[3 * i - 1 - 1][3 * j - 1] = K[3 * i - 1 - 1][3 * j - 1]
                                + k[2 - 1][6 - 1];
                K[3 * i - 1 - 1][3 * m - 2 - 1] = K[3 * i - 1 - 1][3 * m - 2 - 1]
                                + k[2 - 1][7 - 1];
                K[3 * i - 1 - 1][3 * m - 1 - 1] = K[3 * i - 1 - 1][3 * m - 1 - 1]
                                + k[2 - 1][8 - 1];
                K[3 * i - 1 - 1][3 * m - 1] = K[3 * i - 1 - 1][3 * m - 1]
                                + k[2 - 1][9 - 1];
                K[3 * i - 1 - 1][3 * n - 2 - 1] = K[3 * i - 1 - 1][3 * n - 2 - 1]
                                + k[2 - 1][10 - 1];
                K[3 * i - 1 - 1][3 * n - 1 - 1] = K[3 * i - 1 - 1][3 * n - 1 - 1]
                                + k[2 - 1][11 - 1];
                K[3 * i - 1 - 1][3 * n - 1] = K[3 * i - 1 - 1][3 * n - 1]
                                + k[2 - 1][12 - 1];
                K[3 * i - 1][3 * i - 2 - 1] = K[3 * i - 1][3 * i - 2 - 1]
                                + k[3 - 1][1 - 1];
                K[3 * i - 1][3 * i - 1 - 1] = K[3 * i - 1][3 * i - 1 - 1]
                                + k[3 - 1][2 - 1];
                K[3 * i - 1][3 * i - 1] = K[3 * i - 1][3 * i - 1] + k[3 - 1][3 - 1];
                K[3 * i - 1][3 * j - 2 - 1] = K[3 * i - 1][3 * j - 2 - 1]
                                + k[3 - 1][4 - 1];
                K[3 * i - 1][3 * j - 1 - 1] = K[3 * i - 1][3 * j - 1 - 1]
                                + k[3 - 1][5 - 1];
                K[3 * i - 1][3 * j - 1] = K[3 * i - 1][3 * j - 1] + k[3 - 1][6 - 1];
                K[3 * i - 1][3 * m - 2 - 1] = K[3 * i - 1][3 * m - 2 - 1]
                                + k[3 - 1][7 - 1];
                K[3 * i - 1][3 * m - 1 - 1] = K[3 * i - 1][3 * m - 1 - 1]
                                + k[3 - 1][8 - 1];
                K[3 * i - 1][3 * m - 1] = K[3 * i - 1][3 * m - 1] + k[3 - 1][9 - 1];
                K[3 * i - 1][3 * n - 2 - 1] = K[3 * i - 1][3 * n - 2 - 1]
                                + k[3 - 1][10 - 1];
                K[3 * i - 1][3 * n - 1 - 1] = K[3 * i - 1][3 * n - 1 - 1]
                                + k[3 - 1][11 - 1];
                K[3 * i - 1][3 * n - 1] = K[3 * i - 1][3 * n - 1] + k[3 - 1][12 - 1];
                K[3 * j - 2 - 1][3 * i - 2 - 1] = K[3 * j - 2 - 1][3 * i - 2 - 1]
                                + k[4 - 1][1 - 1];
                K[3 * j - 2 - 1][3 * i - 1 - 1] = K[3 * j - 2 - 1][3 * i - 1 - 1]
                                + k[4 - 1][2 - 1];
                K[3 * j - 2 - 1][3 * i - 1] = K[3 * j - 2 - 1][3 * i - 1]
                                + k[4 - 1][3 - 1];
                K[3 * j - 2 - 1][3 * j - 2 - 1] = K[3 * j - 2 - 1][3 * j - 2 - 1]
                                + k[4 - 1][4 - 1];
                K[3 * j - 2 - 1][3 * j - 1 - 1] = K[3 * j - 2 - 1][3 * j - 1 - 1]
                                + k[4 - 1][5 - 1];
                K[3 * j - 2 - 1][3 * j - 1] = K[3 * j - 2 - 1][3 * j - 1]
                                + k[4 - 1][6 - 1];
                K[3 * j - 2 - 1][3 * m - 2 - 1] = K[3 * j - 2 - 1][3 * m - 2 - 1]
                                + k[4 - 1][7 - 1];
                K[3 * j - 2 - 1][3 * m - 1 - 1] = K[3 * j - 2 - 1][3 * m - 1 - 1]
                                + k[4 - 1][8 - 1];
                K[3 * j - 2 - 1][3 * m - 1] = K[3 * j - 2 - 1][3 * m - 1]
                                + k[4 - 1][9 - 1];
                K[3 * j - 2 - 1][3 * n - 2 - 1] = K[3 * j - 2 - 1][3 * n - 2 - 1]
                                + k[4 - 1][10 - 1];
                K[3 * j - 2 - 1][3 * n - 1 - 1] = K[3 * j - 2 - 1][3 * n - 1 - 1]
                                + k[4 - 1][11 - 1];
                K[3 * j - 2 - 1][3 * n - 1] = K[3 * j - 2 - 1][3 * n - 1]
                                + k[4 - 1][12 - 1];
                K[3 * j - 1 - 1][3 * i - 2 - 1] = K[3 * j - 1 - 1][3 * i - 2 - 1]
                                + k[5 - 1][1 - 1];
                K[3 * j - 1 - 1][3 * i - 1 - 1] = K[3 * j - 1 - 1][3 * i - 1 - 1]
                                + k[5 - 1][2 - 1];
                K[3 * j - 1 - 1][3 * i - 1] = K[3 * j - 1 - 1][3 * i - 1]
                                + k[5 - 1][3 - 1];
                K[3 * j - 1 - 1][3 * j - 2 - 1] = K[3 * j - 1 - 1][3 * j - 2 - 1]
                                + k[5 - 1][4 - 1];
                K[3 * j - 1 - 1][3 * j - 1 - 1] = K[3 * j - 1 - 1][3 * j - 1 - 1]
                                + k[5 - 1][5 - 1];
                K[3 * j - 1 - 1][3 * j - 1] = K[3 * j - 1 - 1][3 * j - 1]
                                + k[5 - 1][6 - 1];
                K[3 * j - 1 - 1][3 * m - 2 - 1] = K[3 * j - 1 - 1][3 * m - 2 - 1]
                                + k[5 - 1][7 - 1];
                K[3 * j - 1 - 1][3 * m - 1 - 1] = K[3 * j - 1 - 1][3 * m - 1 - 1]
                                + k[5 - 1][8 - 1];
                K[3 * j - 1 - 1][3 * m - 1] = K[3 * j - 1 - 1][3 * m - 1]
                                + k[5 - 1][9 - 1];
                K[3 * j - 1 - 1][3 * n - 2 - 1] = K[3 * j - 1 - 1][3 * n - 2 - 1]
                                + k[5 - 1][10 - 1];
                K[3 * j - 1 - 1][3 * n - 1 - 1] = K[3 * j - 1 - 1][3 * n - 1 - 1]
                                + k[5 - 1][11 - 1];
                K[3 * j - 1 - 1][3 * n - 1] = K[3 * j - 1 - 1][3 * n - 1]
                                + k[5 - 1][12 - 1];
                K[3 * j - 1][3 * i - 2 - 1] = K[3 * j - 1][3 * i - 2 - 1]
                                + k[6 - 1][1 - 1];
                K[3 * j - 1][3 * i - 1 - 1] = K[3 * j - 1][3 * i - 1 - 1]
                                + k[6 - 1][2 - 1];
                K[3 * j - 1][3 * i - 1] = K[3 * j - 1][3 * i - 1] + k[6 - 1][3 - 1];
                K[3 * j - 1][3 * j - 2 - 1] = K[3 * j - 1][3 * j - 2 - 1]
                                + k[6 - 1][4 - 1];
                K[3 * j - 1][3 * j - 1 - 1] = K[3 * j - 1][3 * j - 1 - 1]
                                + k[6 - 1][5 - 1];
                K[3 * j - 1][3 * j - 1] = K[3 * j - 1][3 * j - 1] + k[6 - 1][6 - 1];
                K[3 * j - 1][3 * m - 2 - 1] = K[3 * j - 1][3 * m - 2 - 1]
                                + k[6 - 1][7 - 1];
                K[3 * j - 1][3 * m - 1 - 1] = K[3 * j - 1][3 * m - 1 - 1]
                                + k[6 - 1][8 - 1];
                K[3 * j - 1][3 * m - 1] = K[3 * j - 1][3 * m - 1] + k[6 - 1][9 - 1];
                K[3 * j - 1][3 * n - 2 - 1] = K[3 * j - 1][3 * n - 2 - 1]
                                + k[6 - 1][10 - 1];
                K[3 * j - 1][3 * n - 1 - 1] = K[3 * j - 1][3 * n - 1 - 1]
                                + k[6 - 1][11 - 1];
                K[3 * j - 1][3 * n - 1] = K[3 * j - 1][3 * n - 1] + k[6 - 1][12 - 1];
                K[3 * m - 2 - 1][3 * i - 2 - 1] = K[3 * m - 2 - 1][3 * i - 2 - 1]
                                + k[7 - 1][1 - 1];
                K[3 * m - 2 - 1][3 * i - 1 - 1] = K[3 * m - 2 - 1][3 * i - 1 - 1]
                                + k[7 - 1][2 - 1];
                K[3 * m - 2 - 1][3 * i - 1] = K[3 * m - 2 - 1][3 * i - 1]
                                + k[7 - 1][3 - 1];
                K[3 * m - 2 - 1][3 * j - 2 - 1] = K[3 * m - 2 - 1][3 * j - 2 - 1]
                                + k[7 - 1][4 - 1];
                K[3 * m - 2 - 1][3 * j - 1 - 1] = K[3 * m - 2 - 1][3 * j - 1 - 1]
                                + k[7 - 1][5 - 1];
                K[3 * m - 2 - 1][3 * j - 1] = K[3 * m - 2 - 1][3 * j - 1]
                                + k[7 - 1][6 - 1];
                K[3 * m - 2 - 1][3 * m - 2 - 1] = K[3 * m - 2 - 1][3 * m - 2 - 1]
                                + k[7 - 1][7 - 1];
                K[3 * m - 2 - 1][3 * m - 1 - 1] = K[3 * m - 2 - 1][3 * m - 1 - 1]
                                + k[7 - 1][8 - 1];
                K[3 * m - 2 - 1][3 * m - 1] = K[3 * m - 2 - 1][3 * m - 1]
                                + k[7 - 1][9 - 1];
                K[3 * m - 2 - 1][3 * n - 2 - 1] = K[3 * m - 2 - 1][3 * n - 2 - 1]
                                + k[7 - 1][10 - 1];
                K[3 * m - 2 - 1][3 * n - 1 - 1] = K[3 * m - 2 - 1][3 * n - 1 - 1]
                                + k[7 - 1][11 - 1];
                K[3 * m - 2 - 1][3 * n - 1] = K[3 * m - 2 - 1][3 * n - 1]
                                + k[7 - 1][12 - 1];
                K[3 * m - 1 - 1][3 * i - 2 - 1] = K[3 * m - 1 - 1][3 * i - 2 - 1]
                                + k[8 - 1][1 - 1];
                K[3 * m - 1 - 1][3 * i - 1 - 1] = K[3 * m - 1 - 1][3 * i - 1 - 1]
                                + k[8 - 1][2 - 1];
                K[3 * m - 1 - 1][3 * i - 1] = K[3 * m - 1 - 1][3 * i - 1]
                                + k[8 - 1][3 - 1];
                K[3 * m - 1 - 1][3 * j - 2 - 1] = K[3 * m - 1 - 1][3 * j - 2 - 1]
                                + k[8 - 1][4 - 1];
                K[3 * m - 1 - 1][3 * j - 1 - 1] = K[3 * m - 1 - 1][3 * j - 1 - 1]
                                + k[8 - 1][5 - 1];
                K[3 * m - 1 - 1][3 * j - 1] = K[3 * m - 1 - 1][3 * j - 1]
                                + k[8 - 1][6 - 1];
                K[3 * m - 1 - 1][3 * m - 2 - 1] = K[3 * m - 1 - 1][3 * m - 2 - 1]
                                + k[8 - 1][7 - 1];
                K[3 * m - 1 - 1][3 * m - 1 - 1] = K[3 * m - 1 - 1][3 * m - 1 - 1]
                                + k[8 - 1][8 - 1];
                K[3 * m - 1 - 1][3 * m - 1] = K[3 * m - 1 - 1][3 * m - 1]
                                + k[8 - 1][9 - 1];
                K[3 * m - 1 - 1][3 * n - 2 - 1] = K[3 * m - 1 - 1][3 * n - 2 - 1]
                                + k[8 - 1][10 - 1];
                K[3 * m - 1 - 1][3 * n - 1 - 1] = K[3 * m - 1 - 1][3 * n - 1 - 1]
                                + k[8 - 1][11 - 1];
                K[3 * m - 1 - 1][3 * n - 1] = K[3 * m - 1 - 1][3 * n - 1]
                                + k[8 - 1][12 - 1];
                K[3 * m - 1][3 * i - 2 - 1] = K[3 * m - 1][3 * i - 2 - 1]
                                + k[9 - 1][1 - 1];
                K[3 * m - 1][3 * i - 1 - 1] = K[3 * m - 1][3 * i - 1 - 1]
                                + k[9 - 1][2 - 1];
                K[3 * m - 1][3 * i - 1] = K[3 * m - 1][3 * i - 1] + k[9 - 1][3 - 1];
                K[3 * m - 1][3 * j - 2 - 1] = K[3 * m - 1][3 * j - 2 - 1]
                                + k[9 - 1][4 - 1];
                K[3 * m - 1][3 * j - 1 - 1] = K[3 * m - 1][3 * j - 1 - 1]
                                + k[9 - 1][5 - 1];
                K[3 * m - 1][3 * j - 1] = K[3 * m - 1][3 * j - 1] + k[9 - 1][6 - 1];
                K[3 * m - 1][3 * m - 2 - 1] = K[3 * m - 1][3 * m - 2 - 1]
                                + k[9 - 1][7 - 1];
                K[3 * m - 1][3 * m - 1 - 1] = K[3 * m - 1][3 * m - 1 - 1]
                                + k[9 - 1][8 - 1];
                K[3 * m - 1][3 * m - 1] = K[3 * m - 1][3 * m - 1] + k[9 - 1][9 - 1];
                K[3 * m - 1][3 * n - 2 - 1] = K[3 * m - 1][3 * n - 2 - 1]
                                + k[9 - 1][10 - 1];
                K[3 * m - 1][3 * n - 1 - 1] = K[3 * m - 1][3 * n - 1 - 1]
                                + k[9 - 1][11 - 1];
                K[3 * m - 1][3 * n - 1] = K[3 * m - 1][3 * n - 1] + k[9 - 1][12 - 1];
                K[3 * n - 2 - 1][3 * i - 2 - 1] = K[3 * n - 2 - 1][3 * i - 2 - 1]
                                + k[10 - 1][1 - 1];
                K[3 * n - 2 - 1][3 * i - 1 - 1] = K[3 * n - 2 - 1][3 * i - 1 - 1]
                                + k[10 - 1][2 - 1];
                K[3 * n - 2 - 1][3 * i - 1] = K[3 * n - 2 - 1][3 * i - 1]
                                + k[10 - 1][3 - 1];
                K[3 * n - 2 - 1][3 * j - 2 - 1] = K[3 * n - 2 - 1][3 * j - 2 - 1]
                                + k[10 - 1][4 - 1];
                K[3 * n - 2 - 1][3 * j - 1 - 1] = K[3 * n - 2 - 1][3 * j - 1 - 1]
                                + k[10 - 1][5 - 1];
                K[3 * n - 2 - 1][3 * j - 1] = K[3 * n - 2 - 1][3 * j - 1]
                                + k[10 - 1][6 - 1];
                K[3 * n - 2 - 1][3 * m - 2 - 1] = K[3 * n - 2 - 1][3 * m - 2 - 1]
                                + k[10 - 1][7 - 1];
                K[3 * n - 2 - 1][3 * m - 1 - 1] = K[3 * n - 2 - 1][3 * m - 1 - 1]
                                + k[10 - 1][8 - 1];
                K[3 * n - 2 - 1][3 * m - 1] = K[3 * n - 2 - 1][3 * m - 1]
                                + k[10 - 1][9 - 1];
                K[3 * n - 2 - 1][3 * n - 2 - 1] = K[3 * n - 2 - 1][3 * n - 2 - 1]
                                + k[10 - 1][10 - 1];
                K[3 * n - 2 - 1][3 * n - 1 - 1] = K[3 * n - 2 - 1][3 * n - 1 - 1]
                                + k[10 - 1][11 - 1];
                K[3 * n - 2 - 1][3 * n - 1] = K[3 * n - 2 - 1][3 * n - 1]
                                + k[10 - 1][12 - 1];
                K[3 * n - 1 - 1][3 * i - 2 - 1] = K[3 * n - 1 - 1][3 * i - 2 - 1]
                                + k[11 - 1][1 - 1];
                K[3 * n - 1 - 1][3 * i - 1 - 1] = K[3 * n - 1 - 1][3 * i - 1 - 1]
                                + k[11 - 1][2 - 1];
                K[3 * n - 1 - 1][3 * i - 1] = K[3 * n - 1 - 1][3 * i - 1]
                                + k[11 - 1][3 - 1];
                K[3 * n - 1 - 1][3 * j - 2 - 1] = K[3 * n - 1 - 1][3 * j - 2 - 1]
                                + k[11 - 1][4 - 1];
                K[3 * n - 1 - 1][3 * j - 1 - 1] = K[3 * n - 1 - 1][3 * j - 1 - 1]
                                + k[11 - 1][5 - 1];
                K[3 * n - 1 - 1][3 * j - 1] = K[3 * n - 1 - 1][3 * j - 1]
                                + k[11 - 1][6 - 1];
                K[3 * n - 1 - 1][3 * m - 2 - 1] = K[3 * n - 1 - 1][3 * m - 2 - 1]
                                + k[11 - 1][7 - 1];
                K[3 * n - 1 - 1][3 * m - 1 - 1] = K[3 * n - 1 - 1][3 * m - 1 - 1]
                                + k[11 - 1][8 - 1];
                K[3 * n - 1 - 1][3 * m - 1] = K[3 * n - 1 - 1][3 * m - 1]
                                + k[11 - 1][9 - 1];
                K[3 * n - 1 - 1][3 * n - 2 - 1] = K[3 * n - 1 - 1][3 * n - 2 - 1]
                                + k[11 - 1][10 - 1];
                K[3 * n - 1 - 1][3 * n - 1 - 1] = K[3 * n - 1 - 1][3 * n - 1 - 1]
                                + k[11 - 1][11 - 1];
                K[3 * n - 1 - 1][3 * n - 1] = K[3 * n - 1 - 1][3 * n - 1]
                                + k[11 - 1][12 - 1];
                K[3 * n - 1][3 * i - 2 - 1] = K[3 * n - 1][3 * i - 2 - 1]
                                + k[12 - 1][1 - 1];
                K[3 * n - 1][3 * i - 1 - 1] = K[3 * n - 1][3 * i - 1 - 1]
                                + k[12 - 1][2 - 1];
                K[3 * n - 1][3 * i - 1] = K[3 * n - 1][3 * i - 1] + k[12 - 1][3 - 1];
                K[3 * n - 1][3 * j - 2 - 1] = K[3 * n - 1][3 * j - 2 - 1]
                                + k[12 - 1][4 - 1];
                K[3 * n - 1][3 * j - 1 - 1] = K[3 * n - 1][3 * j - 1 - 1]
                                + k[12 - 1][5 - 1];
                K[3 * n - 1][3 * j - 1] = K[3 * n - 1][3 * j - 1] + k[12 - 1][6 - 1];
                K[3 * n - 1][3 * m - 2 - 1] = K[3 * n - 1][3 * m - 2 - 1]
                                + k[12 - 1][7 - 1];
                K[3 * n - 1][3 * m - 1 - 1] = K[3 * n - 1][3 * m - 1 - 1]
                                + k[12 - 1][8 - 1];
                K[3 * n - 1][3 * m - 1] = K[3 * n - 1][3 * m - 1] + k[12 - 1][9 - 1];
                K[3 * n - 1][3 * n - 2 - 1] = K[3 * n - 1][3 * n - 2 - 1]
                                + k[12 - 1][10 - 1];
                K[3 * n - 1][3 * n - 1 - 1] = K[3 * n - 1][3 * n - 1 - 1]
                                + k[12 - 1][11 - 1];
                K[3 * n - 1][3 * n - 1] = K[3 * n - 1][3 * n - 1] + k[12 - 1][12 - 1];
        }

        public void display() {
                XYDataset[] datasets = createDataset();
                JFreeChart[] charts = new JFreeChart[] { createChart(datasets[0]),
                                createChart(datasets[1]), createChart(datasets[2]) };

                System.out.println("___________________-");

                JPanel panel = new JPanel();
                JTabbedPane tab = new JTabbedPane();

                ChartPanel chartPanel1 = new ChartPanel(charts[0]);
                chartPanel1.setPreferredSize(new java.awt.Dimension(1000, 300));

                ChartPanel chartPanel2 = new ChartPanel(charts[1]);
                chartPanel2.setPreferredSize(new java.awt.Dimension(1000, 300));

                ChartPanel chartPanel3 = new ChartPanel(charts[2]);
                chartPanel3.setPreferredSize(new java.awt.Dimension(1000, 300));

                JPanel testPanel1 = new JPanel();
                testPanel1.add(chartPanel1);

                JPanel testPanel2 = new JPanel();
                testPanel2.add(chartPanel2);

                JPanel testPanel3 = new JPanel();
                testPanel3.add(chartPanel3);

                tab.add(testPanel1, "Stress vs Strain");
                tab.add(testPanel2, "Force vs Displacement");
                tab.add(testPanel3, "Force vs Time");

                panel.add(tab);

                setContentPane(panel);

                pack();
                setVisible(true);

        }

}