private void button1_Click(object sender, EventArgs e) { PreprocessingModelling.getGaussianCoordinates(comboBox1.SelectedIndex); int NumbersOfNodes = PreprocessingModelling.getElementNodesNumber(); int DegreeOfFreedom = 3; PreprocessingModelling.removeExcessEtopol(); int NumbersOfElements = PreprocessingModelling.getNumberOfElements(); double[,] NodalCoordinates = Analysis.getNodalCoordinates(); int GaussianNumber = MainInterface.XGaussianCoordinates.GetLength(0); double[,] ShapeFunctionDerivatives = Analysis.getShapeFunctionDerivatives(MainInterface.XGaussianCoordinates, MainInterface.YGaussianCoordinates, MainInterface.ZGaussianCoordinates); double[,] GlobalStiffnessMatrix = new double[MainInterface.Nodes.Count() * DegreeOfFreedom, MainInterface.Nodes.Count() * DegreeOfFreedom]; // for (int i = 0; i < NumbersOfElements; i++) { double[,] StiffnessMatrix = new double[NumbersOfNodes * DegreeOfFreedom, NumbersOfNodes *DegreeOfFreedom]; double[,] ElementNodalCoordinates = Analysis.getElementNodalCoordinates(i, NodalCoordinates); double[,] Jacobian = Analysis.getJacobian(ElementNodalCoordinates); for (int j = 0; j < GaussianNumber; j++) { double[,] GaussianJacobian = Analysis.getGaussianJacobian(j, Jacobian); double JacobianDeterminant = Accord.Math.Matrix.Determinant(GaussianJacobian); double[,] GaussianShapeFunctionDerivative = Analysis.getGaussianShapeFunctionDerivatives(j, ShapeFunctionDerivatives); double[,] ShapeFunctionDerivativeWRTCoordinates = Accord.Math.Matrix.Solve(GaussianJacobian, GaussianShapeFunctionDerivative); double[,] StrainDisplacementMatrix = Analysis.getStrainDisplacementMatrix(ShapeFunctionDerivativeWRTCoordinates); double[,] ConstitutiveMatrix = Analysis.getConstitutiveMatrix(i); StiffnessMatrix = Analysis.addStiffnessMatrix(StiffnessMatrix, StrainDisplacementMatrix, ConstitutiveMatrix, JacobianDeterminant, j); } GlobalStiffnessMatrix = Analysis.addGlobalStiffnessMatrix(i, GlobalStiffnessMatrix, StiffnessMatrix); } Analysis.calculateDisplacement(GlobalStiffnessMatrix); this.Close(); }
public ElementCreation(int element_Type) { Nodes_Added = 0; NumberOfNodes = PreprocessingModelling.getElementNodesNumber(element_Type); PreprocessingModelling.removeExcessEtopol(element_Type); InitializeComponent(); dataGridView1.DataSource = MainInterface.Nodes.Select(vector => new { X = vector.X, Y = vector.Y, Z = vector.Z }).ToList(); this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; }
private void button1_Click(object sender, EventArgs e) { if (Mode == 0) { PreprocessingModelling.addMaterials(textBox1.Text, Convert.ToSingle(textBox2.Text), Convert.ToSingle(textBox3.Text), Convert.ToSingle(textBox4.Text)); } else { PreprocessingModelling.editMaterials(Selection, textBox1.Text, Convert.ToSingle(textBox2.Text), Convert.ToSingle(textBox3.Text), Convert.ToSingle(textBox4.Text)); } this.Close(); }
public static double[,] getNodalCoordinates() { int NumbersOfNodes = PreprocessingModelling.getElementNodesNumber(); int NumbersOfElements = PreprocessingModelling.getNumberOfElements(); double[,] NodalCoordinates = new double[NumbersOfElements * NumbersOfNodes, 3]; for (int i = 0; i < NumbersOfElements * NumbersOfNodes; i++) { NodalCoordinates[i, 0] = MainInterface.Nodes[MainInterface.Etopol[i]].X; NodalCoordinates[i, 1] = MainInterface.Nodes[MainInterface.Etopol[i]].Y; NodalCoordinates[i, 2] = MainInterface.Nodes[MainInterface.Etopol[i]].Z; } return(NodalCoordinates); }
public static double[,] getElementNodalCoordinates(int elementBeingCalculated, double[,] nodalCoordinates) { int NumbersOfNodes = PreprocessingModelling.getElementNodesNumber(); double[,] ElementNodalCoordinates = new double[NumbersOfNodes, 3]; int j = 0; for (int i = elementBeingCalculated * NumbersOfNodes; i < (elementBeingCalculated + 1) * NumbersOfNodes; i++) { ElementNodalCoordinates[j, 0] = nodalCoordinates[i, 0]; ElementNodalCoordinates[j, 1] = nodalCoordinates[i, 1]; ElementNodalCoordinates[j, 2] = nodalCoordinates[i, 2]; j += 1; } return(ElementNodalCoordinates); }
private void loadAnalysisToolStripMenuItem_Click(object sender, EventArgs e) { PreprocessingModelling.addNodes(0, 0, 0); PreprocessingModelling.addNodes(0.5, 0, 0); PreprocessingModelling.addNodes(1, 0, 0); PreprocessingModelling.addNodes(0, 1, 0); PreprocessingModelling.addNodes(0.5, 1, 0); PreprocessingModelling.addNodes(1, 1, 0); PreprocessingModelling.addNodes(0, 0, 1); PreprocessingModelling.addNodes(0.5, 0, 1); PreprocessingModelling.addNodes(1, 0, 1); PreprocessingModelling.addNodes(0, 1, 1); PreprocessingModelling.addNodes(0.5, 1, 1); PreprocessingModelling.addNodes(1, 1, 1); MainInterface.Etopol.Add(0); MainInterface.Etopol.Add(6); MainInterface.Etopol.Add(7); MainInterface.Etopol.Add(1); MainInterface.Etopol.Add(3); MainInterface.Etopol.Add(9); MainInterface.Etopol.Add(10); MainInterface.Etopol.Add(4); MainInterface.Etopol.Add(1); MainInterface.Etopol.Add(7); MainInterface.Etopol.Add(8); MainInterface.Etopol.Add(2); MainInterface.Etopol.Add(4); MainInterface.Etopol.Add(10); MainInterface.Etopol.Add(11); MainInterface.Etopol.Add(5); MainInterface.Etopol_Material.Add(0); MainInterface.Etopol_Material.Add(0); PreprocessingModelling.addNodesLoading(2, 1000, 0, 0); PreprocessingModelling.addNodesLoading(5, 1000, 0, 0); PreprocessingModelling.addNodesLoading(8, 1000, 0, 0); PreprocessingModelling.addNodesLoading(11, 1000, 0, 0); PreprocessingModelling.addNodesBoundaryCondition(0, 1, 1, 1); PreprocessingModelling.addNodesBoundaryCondition(3, 1, 1, 1); PreprocessingModelling.addNodesBoundaryCondition(6, 1, 1, 1); PreprocessingModelling.addNodesBoundaryCondition(9, 1, 1, 1); PreprocessingModelling.addNodesDefinedDisplacement(6, 0, 0, -0.25); PreprocessingModelling.addMaterials(1.ToString(), 70000000, 0.33, 0); }
public static double[,] addGlobalStiffnessMatrix(int elementBeingCalculated, double[,] existingGlobalStiffnessMatrix, double[,] stiffnessMatrix) { int NumbersOfNodes = PreprocessingModelling.getElementNodesNumber(); int LocalStiffnessMatrixSize = stiffnessMatrix.GetLength(0); int[] GlobalStiffnessMatrixLocation = new int[LocalStiffnessMatrixSize]; for (int i = 0; i < NumbersOfNodes; i++) { GlobalStiffnessMatrixLocation[i * 3] = MainInterface.Etopol[(NumbersOfNodes * elementBeingCalculated) + i] * 3; GlobalStiffnessMatrixLocation[(i * 3) + 1] = GlobalStiffnessMatrixLocation[i * 3] + 1; GlobalStiffnessMatrixLocation[(i * 3) + 2] = GlobalStiffnessMatrixLocation[i * 3] + 2; } for (int i = 0; i < LocalStiffnessMatrixSize; i++) { for (int j = 0; j < LocalStiffnessMatrixSize; j++) { existingGlobalStiffnessMatrix[GlobalStiffnessMatrixLocation[i], GlobalStiffnessMatrixLocation[j]] += stiffnessMatrix[i, j]; } } return(existingGlobalStiffnessMatrix); }
public static double[,] getStrainDisplacementMatrix(double[,] shapeFunctionDerivativeWRTCoordinates) { int NumbersOfNodes = PreprocessingModelling.getElementNodesNumber(); int DegreeOfFreedom = 3; double[,] StrainDisplacementMatrix = new double[6, NumbersOfNodes *DegreeOfFreedom]; //TODO: Account for 9 rows situations and other cases too. for (int i = 0; i < NumbersOfNodes; i++) { int j = (3 * (i + 1)) - 3; StrainDisplacementMatrix[0, j] = shapeFunctionDerivativeWRTCoordinates[0, i]; StrainDisplacementMatrix[1, j + 1] = shapeFunctionDerivativeWRTCoordinates[1, i]; StrainDisplacementMatrix[2, j + 2] = shapeFunctionDerivativeWRTCoordinates[2, i]; StrainDisplacementMatrix[3, j] = shapeFunctionDerivativeWRTCoordinates[1, i]; StrainDisplacementMatrix[3, j + 1] = shapeFunctionDerivativeWRTCoordinates[0, i]; StrainDisplacementMatrix[4, j + 1] = shapeFunctionDerivativeWRTCoordinates[2, i]; StrainDisplacementMatrix[4, j + 2] = shapeFunctionDerivativeWRTCoordinates[1, i]; StrainDisplacementMatrix[5, j] = shapeFunctionDerivativeWRTCoordinates[2, i]; StrainDisplacementMatrix[5, j + 2] = shapeFunctionDerivativeWRTCoordinates[0, i]; } return(StrainDisplacementMatrix); }
public static double[,] getShapeFunctionDerivatives(int element_Type, double[,] xsi, double[,] eta, double[,] zet) { int NumberofNodes = PreprocessingModelling.getElementNodesNumber(element_Type); int GaussianNumber = xsi.GetLength(0); double[,] ShapeFunctionDerivatives = new double[3 * NumberofNodes, GaussianNumber]; if (NumberofNodes == 8) { for (int i = 0; i < NumberofNodes; i++) { for (int j = 0; j < GaussianNumber; j++) { ShapeFunctionDerivatives[(3 * (j + 1)) - 3, i] = (Math.Sign(xsi[i, 0]) * (1 + Math.Sign(eta[i, 0]) * eta[j, 0]) * (1 + Math.Sign(zet[i, 0]) * zet[j, 0])) / 8; ShapeFunctionDerivatives[(3 * (j + 1)) - 2, i] = (Math.Sign(eta[i, 0]) * (1 + Math.Sign(xsi[i, 0]) * xsi[j, 0]) * (1 + Math.Sign(zet[i, 0]) * zet[j, 0])) / 8; ShapeFunctionDerivatives[(3 * (j + 1)) - 1, i] = (Math.Sign(zet[i, 0]) * (1 + Math.Sign(xsi[i, 0]) * xsi[j, 0]) * (1 + Math.Sign(eta[i, 0]) * eta[j, 0])) / 8; } } } // TODO: Fill in the other Shape Function Derivatives. return(ShapeFunctionDerivatives); }
public static double[,] getShapeFunction(double[,] xsi, double[,] eta, double[,] zet) { int NumberofNodes = PreprocessingModelling.getElementNodesNumber(); int GaussianNumber = xsi.GetLength(0); double[,] ShapeFunction = new double[GaussianNumber, NumberofNodes]; if (GaussianNumber == 8) { for (int i = 0; i < GaussianNumber; i++) { ShapeFunction[i, 0] = 0.125 * (1 - xsi[i, 0]) * (1 - eta[i, 0]) * (1 - zet[i, 0]); ShapeFunction[i, 1] = 0.125 * (1 - xsi[i, 0]) * (1 - eta[i, 0]) * (1 + zet[i, 0]); ShapeFunction[i, 2] = 0.125 * (1 + xsi[i, 0]) * (1 - eta[i, 0]) * (1 + zet[i, 0]); ShapeFunction[i, 3] = 0.125 * (1 + xsi[i, 0]) * (1 - eta[i, 0]) * (1 - zet[i, 0]); ShapeFunction[i, 4] = 0.125 * (1 - xsi[i, 0]) * (1 + eta[i, 0]) * (1 - zet[i, 0]); ShapeFunction[i, 5] = 0.125 * (1 - xsi[i, 0]) * (1 + eta[i, 0]) * (1 + zet[i, 0]); ShapeFunction[i, 6] = 0.125 * (1 + xsi[i, 0]) * (1 + eta[i, 0]) * (1 + zet[i, 0]); ShapeFunction[i, 7] = 0.125 * (1 + xsi[i, 0]) * (1 + eta[i, 0]) * (1 - zet[i, 0]); } } // TODO: Fill in the other Shape Functions. return(ShapeFunction); }
private void button1_Click(object sender, EventArgs e) { PreprocessingModelling.addNodesLoading(Selection, Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text), Convert.ToDouble(textBox3.Text)); this.Close(); }
public void button1_Click(object sender, EventArgs e) { PreprocessingModelling.addNodes(Convert.ToDouble(xCoordinate.Text), Convert.ToDouble(yCoordinate.Text), Convert.ToDouble(zCoordinate.Text)); this.Close(); }
private void button1_Click(object sender, EventArgs e) { PreprocessingModelling.addNodesBoundaryCondition(Selection, Int32.Parse(textBox1.Text), Int32.Parse(textBox2.Text), Int32.Parse(textBox3.Text)); PreprocessingModelling.addNodesDefinedDisplacement(Selection, Int32.Parse(textBox4.Text), Int32.Parse(textBox5.Text), Int32.Parse(textBox6.Text)); this.Close(); }
public static double[,] calculateDisplacement(double[,] globalStiffnessMatrix) { int TotalDegreeOfFreedom = MainInterface.Nodes.Count() * 3; double[,] ExternalForce = new double[TotalDegreeOfFreedom, 1]; int[] FreeDegreeOfFreedom = new int[TotalDegreeOfFreedom]; int LockedDegreeOfFreedom = 0; for (int i = 0; i < TotalDegreeOfFreedom; i += 3) { if (MainInterface.Nodes[Convert.ToInt32(Math.Floor(Convert.ToDouble(i) / 3))].XBoundaryCondition == 1) { FreeDegreeOfFreedom[i] = 1; LockedDegreeOfFreedom += 1; } if (MainInterface.Nodes[Convert.ToInt32(Math.Floor(Convert.ToDouble(i) / 3))].YBoundaryCondition == 1) { FreeDegreeOfFreedom[i + 1] = 1; LockedDegreeOfFreedom += 1; } if (MainInterface.Nodes[Convert.ToInt32(Math.Floor(Convert.ToDouble(i) / 3))].ZBoundaryCondition == 1) { FreeDegreeOfFreedom[i + 2] = 1; LockedDegreeOfFreedom += 1; } ExternalForce[i, 0] = MainInterface.Nodes[Convert.ToInt32(Math.Floor(Convert.ToDouble(i) / 3))].XLoading; ExternalForce[i + 1, 0] = MainInterface.Nodes[Convert.ToInt32(Math.Floor(Convert.ToDouble(i) / 3))].YLoading; ExternalForce[i + 2, 0] = MainInterface.Nodes[Convert.ToInt32(Math.Floor(Convert.ToDouble(i) / 3))].ZLoading; } double[,] FilteredExternalForce = new double[TotalDegreeOfFreedom - LockedDegreeOfFreedom, 1]; double[,] FilteredBoundaryConditionDisplacement = new double[LockedDegreeOfFreedom, 1]; int k = 0; for (int i = 0; i < TotalDegreeOfFreedom; i += 3) { int NodesLocator = Convert.ToInt32(Math.Floor(Convert.ToDouble(i) / 3)); if (MainInterface.Nodes[NodesLocator].XBoundaryCondition == 1) { FilteredBoundaryConditionDisplacement[k, 0] = MainInterface.Nodes[NodesLocator].XDefinedDisplacement; k += 1; } if (MainInterface.Nodes[NodesLocator].YBoundaryCondition == 1) { FilteredBoundaryConditionDisplacement[k, 0] = MainInterface.Nodes[NodesLocator].YDefinedDisplacement; k += 1; } if (MainInterface.Nodes[NodesLocator].ZBoundaryCondition == 1) { FilteredBoundaryConditionDisplacement[k, 0] = MainInterface.Nodes[NodesLocator].ZDefinedDisplacement; k += 1; } } k = 0; for (int i = 0; i < TotalDegreeOfFreedom; i++) { if (FreeDegreeOfFreedom[i] != 1) { FilteredExternalForce[k, 0] = ExternalForce[i, 0]; k += 1; } } double[,] FilteredStiffnessMatrix = new double[TotalDegreeOfFreedom - LockedDegreeOfFreedom, TotalDegreeOfFreedom - LockedDegreeOfFreedom]; double[,] StiffnessMatrixCorrectionForExternalForce = new double[TotalDegreeOfFreedom - LockedDegreeOfFreedom, LockedDegreeOfFreedom]; k = 0; for (int i = 0; i < TotalDegreeOfFreedom; i++) { int l = 0; int m = 0; if (FreeDegreeOfFreedom[i] != 1) { for (int j = 0; j < TotalDegreeOfFreedom; j++) { if (FreeDegreeOfFreedom[j] != 1) { FilteredStiffnessMatrix[k, l] = globalStiffnessMatrix[i, j]; l += 1; } else { StiffnessMatrixCorrectionForExternalForce[k, m] = globalStiffnessMatrix[i, j]; m += 1; } } FilteredExternalForce[k, 0] = ExternalForce[i, 0]; k += 1; } } double[,] FilteredExternalForceCorrection = Accord.Math.Matrix.Dot(StiffnessMatrixCorrectionForExternalForce, FilteredBoundaryConditionDisplacement); double[,] CorrectedFilteredExternalForce = new double[TotalDegreeOfFreedom - LockedDegreeOfFreedom, 1]; for (int i = 0; i < TotalDegreeOfFreedom - LockedDegreeOfFreedom; i++) { CorrectedFilteredExternalForce[i, 0] = FilteredExternalForce[i, 0] - FilteredExternalForceCorrection[i, 0]; } double[,] FilteredDisplacement = Accord.Math.Matrix.Solve(FilteredStiffnessMatrix, CorrectedFilteredExternalForce); double[,] Displacement = new double[TotalDegreeOfFreedom, 1]; k = 0; int n = 0; for (int i = 0; i < TotalDegreeOfFreedom; i++) { if (FreeDegreeOfFreedom[i] != 1) { Displacement[i, 0] = FilteredDisplacement[k, 0]; k += 1; } else { Displacement[i, 0] = FilteredBoundaryConditionDisplacement[n, 0]; n += 1; } } for (int i = 0; i < TotalDegreeOfFreedom; i += 3) { PreprocessingModelling.addNodesDisplacement(Convert.ToInt32(Math.Floor(Convert.ToDouble(i) / 3)), Displacement[i, 0], Displacement[i + 1, 0], Displacement[i + 2, 0]); } return(Displacement); }