private static void GenerateGroundSpring(ModelSetting sett, SingleRingResult result) { double r = sett.outerRadius - sett.thickness / 2; // radius of the model double pi = Math.PI; int count = result.elements[1].Count; int ground_radius_ID = 2; int ground_tangential_ID = 3; if (!result.elements.ContainsKey(ground_radius_ID)) result.elements[ground_radius_ID] = new List<Element>(); if (!result.elements.ContainsKey(ground_tangential_ID)) result.elements[ground_tangential_ID] = new List<Element>(); for (int i = 0; i < sett.num_node_ring; i++) { count++; ElementLink spring = new ElementLink(count, ground_radius_ID, i + 1, i + 1 + sett.num_node_ring); result.elements[ground_radius_ID].Add(spring); count++; spring = new ElementLink(count, ground_tangential_ID, i + 1, i + 1 + 2 * sett.num_node_ring); result.elements[ground_tangential_ID].Add(spring); } }
//you don't need to assign modelSetting.num_longit as it will calculated by axis public static void BuildCurveModel(ModelSetting modelSetting, Model model, string path) { //get the coordinary of each ring double length = Math.Abs(modelSetting.axis.AxisPoints.First().Mileage - modelSetting.axis.AxisPoints.Last().Mileage); modelSetting.num_ring = (int)(length / modelSetting.width); List<RingInfo> ringInfos = GetRingInfo(modelSetting); //get single ring result SingleRingResult ringResult = new SingleRingResult(); GenerateNodes.GenerateSingleRingNode(modelSetting, ringResult); GenerateElements.GenerateSingleRingElement(modelSetting, ringResult); //initial 3D result List<ShieldTunnel3DResult> results = new List<ShieldTunnel3DResult>(); for (int i = 0; i < ringInfos.Count - 1; i++) //for (int i = 0; i < 10; i++) { ShieldTunnel3DResult result = new ShieldTunnel3DResult(); ChangeLocal(ringInfos[i], result); GetNodes(i, modelSetting, ringResult, result); GetShellElements(i, modelSetting, ringResult, result); RotateNode(i, modelSetting, result); results.Add(result); } Output(model, results, path); }
private static void GenerateSingleRingShell(ModelSetting sett, SingleRingResult result) { double r = sett.outerRadius - sett.thickness / 2; // radius of the model int count = 0; int shellID = 1; if (!result.elements.ContainsKey(shellID)) result.elements[shellID] = new List<Element>(); //generate the shell elements of a ring for (int i = 0; i < sett.num_longit; i++) { // element from 0 degree to pos_joint.first degree for(int j = 0; j < sett.num_segment_element[0]; j++) { count++; ElementShell shell = new ElementShell(count, shellID, j + 1 + i * sett.num_node_face, j + 2 + i * sett.num_node_face, j + 2 + sett.num_node_face * (i + 1), j + 1 + sett.num_node_face * (i + 1)); result.elements[shellID].Add(shell); } //element from pos_joint.first degree to pos_joint.last degree for(int j = 0; j < sett.pos_joint.Count - 1; j++) { count++; ElementShell shell = new ElementShell(count, shellID, sett.num_circum + j + 1 + i * sett.num_node_face, sett.num_segment_element[j] + 2 + i * sett.num_node_face, sett.num_segment_element[j] + 2 + (i + 1) * sett.num_node_face, sett.num_circum + j + 1 + (i + 1) * sett.num_node_face); result.elements[shellID].Add(shell); for (int k = sett.num_segment_element[j] + 2; k <= sett.num_segment_element[j + 1]; k++) { count++; ElementShell shell_tmp = new ElementShell(count, shellID, k + i * sett.num_node_face, k + 1 + i * sett.num_node_face, k + 1 + (i + 1) * sett.num_node_face, k + (i + 1) * sett.num_node_face); result.elements[shellID].Add(shell_tmp); } } //element from pos_joint.last degree to 360 degree count++; ElementShell shell1 = new ElementShell(count, shellID, sett.num_circum + sett.pos_joint.Count + i * sett.num_node_face, sett.num_segment_element.Last() + 2 + i * sett.num_node_face, sett.num_segment_element.Last() + 2 + (i + 1) * sett.num_node_face, sett.num_circum + sett.pos_joint.Count + (i + 1) * sett.num_node_face); result.elements[shellID].Add(shell1); for (int j = sett.num_segment_element.Last() + 2; j < sett.num_circum; j++) { count++; ElementShell shell2 = new ElementShell(count, shellID, j + i * sett.num_node_face, j + 1 + i * sett.num_node_face, j + 1 + (i + 1) * sett.num_node_face, j + (i + 1) * sett.num_node_face); result.elements[shellID].Add(shell2); } count++; ElementShell shell3 = new ElementShell(count, shellID, sett.num_circum + i * sett.num_node_face, 1 + i * sett.num_node_face, 1 + (i + 1) * sett.num_node_face, sett.num_circum + (i + 1) * sett.num_node_face); result.elements[shellID].Add(shell3); } }
public static void GenerateSingleRingElement(ModelSetting sett, SingleRingResult result) { GenerateSingleRingShell(sett, result); GenerateGroundSpring(sett,result); }
public static void GenerateSingleRingNode(ModelSetting sett, SingleRingResult result) { double r = sett.outerRadius - sett.thickness / 2; // radius of the model double pi = Math.PI; //generate the nodes of front border //first segment for (int i = 0; i < sett.num_segment_element[0]; i++ ) { double detal = sett.pos_joint[0] * 1.0 / sett.num_segment_element[0]; double angle = pi / 180 * i * detal; Node node = new Node(i + 1, 0, Math.Sin(angle) * r, Math.Cos(angle) * r); result.nodes.Add(node); } //middle segment for (int i = 1; i < sett.pos_joint.Count; i++ ) { for (int j = 0; j < (sett.num_segment_element[i] - sett.num_segment_element[i - 1]); j++) { double detal = (sett.pos_joint[i] - sett.pos_joint[i - 1]) * 1.0 / (sett.num_segment_element[i] - sett.num_segment_element[i - 1]); double angle = (sett.pos_joint[i - 1] + j * detal) * pi / 180; Node node = new Node(sett.num_segment_element[i - 1] + j + 1, 0, Math.Sin(angle) * r, Math.Cos(angle) * r); result.nodes.Add(node); } } //last segment for (int i = 0; i < sett.num_segment_element[0]; i++) { double detal = sett.pos_joint[0] * 1.0 / sett.num_segment_element[0]; double angle = (sett.pos_joint.Last() + i * detal) * pi / 180; Node node = new Node(sett.num_segment_element.Last() + i + 1, 0, Math.Sin(angle) * r, Math.Cos(angle) * r); result.nodes.Add(node); } //joint node for(int i = 0; i < sett.pos_joint.Count; i++) { double angle = pi / 180 * sett.pos_joint[i]; Node node = new Node(sett.num_circum + i + 1, 0, Math.Sin(angle) * r, Math.Cos(angle) * r); result.nodes.Add(node); } //generate the nodes of lining in longitudinal direction double width = sett.width * 0.97; double delta = width / sett.num_longit; for(int j = 0; j < sett.num_longit; j++) { for (int i = 0; i < sett.num_node_face; i++) { Node tmp = result.nodes[i]; Node node = new Node(tmp.nid + (j + 1) * sett.num_node_face, delta * (j + 1), tmp.y, tmp.z); result.nodes.Add(node); } } //generate the radial ground node for(int i = 0; i < sett.num_node_ring; i++) { Node slNode = result.nodes[i]; Node node = new Node(slNode.nid + sett.num_node_ring, slNode.x, slNode.y * (1 + 1 / r), slNode.z * (1 + 1 / r)); result.nodes.Add(node); } //gegerate the tangential ground node for (int i = 0; i < sett.num_node_ring; i++) { Node slNode = result.nodes[i]; Node node = new Node(slNode.nid + sett.num_node_ring * 2, slNode.x, slNode.y + slNode.z / r, slNode.z - slNode.y / r); result.nodes.Add(node); } }
//you don't need to assign modelSetting.axis as it won't be used public static void BuildStraightModel(ModelSetting modelSetting, Model model) { SingleRingResult ringResult = new SingleRingResult(); GenerateNodes.GenerateSingleRingNode(modelSetting, ringResult); GenerateElements.GenerateSingleRingElement(modelSetting, ringResult); //generate all nodes for(int i = 0; i < modelSetting.num_ring; i++) { for(int j = 0; j < modelSetting.num_node_all; j++) { Node node = ringResult.nodes[j]; Node newNode = new Node(node.nid + i * modelSetting.num_node_all, node.x, node.y, node.z + modelSetting.width * i); model.AddNode(newNode); } } int elemenCount = 0; //generate all shells for (int i = 0; i < modelSetting.num_ring; i++) { foreach (Element element in ringResult.elements[1]) { elemenCount++; ElementShell shell = element as ElementShell; ElementShell newShell = new ElementShell(elemenCount, shell.pid, shell.n1 + modelSetting.num_node_all * i, shell.n2 + modelSetting.num_node_all * i, shell.n3 + modelSetting.num_node_all * i, shell.n4 + modelSetting.num_node_all * i); model.AddElement(newShell); } } //generate radial ground spring for (int i = 0; i < modelSetting.num_ring; i++) { foreach (Element element in ringResult.elements[2]) { elemenCount++; ElementLink link = element as ElementLink; ElementLink newLink = new ElementLink(elemenCount, link.pid, link.n1 + modelSetting.num_node_all * i, link.n2 + modelSetting.num_node_all * i); model.AddElement(newLink); } } //generate tangential ground spring for (int i = 0; i < modelSetting.num_ring; i++) { foreach (Element element in ringResult.elements[3]) { elemenCount++; ElementLink link = element as ElementLink; ElementLink newLink = new ElementLink(elemenCount, link.pid, link.n1 + modelSetting.num_node_all * i, link.n2 + modelSetting.num_node_all * i); model.AddElement(newLink); } } //generate the longitudinal joint spring for (int i = 0; i < modelSetting.num_ring; i++) { for (int j = 0; j <= modelSetting.num_longit; j++) { for (int k = 0; k < modelSetting.pos_joint.Count; k++) { elemenCount++; ElementCombin combinZ = new ElementCombin(elemenCount, 5, modelSetting.pos_joint[k] + 1 + j * modelSetting.num_node_face + i * modelSetting.num_node_all, k + 1 + modelSetting.num_circum + j * modelSetting.num_node_face + i * modelSetting.num_node_all); model.AddElement(combinZ); } } } //generate circumferential joint spring for (int i = 1; i < modelSetting.num_ring; i++) { for (int j = 0; j < modelSetting.num_node_face; j++ ) { elemenCount++; ElementCombin combinCircumZ = new ElementCombin(elemenCount, 4, j + 1 + (i - 1) * modelSetting.num_node_all + modelSetting.num_node_face * modelSetting.num_longit, j + 1 + i * modelSetting.num_node_all); elemenCount++; ElementCombin combinCircumX = new ElementCombin(elemenCount, 6, j + 1 + (i - 1) * modelSetting.num_node_all + modelSetting.num_node_face * modelSetting.num_longit, j + 1 + i * modelSetting.num_node_all); elemenCount++; ElementCombin combinCircumY = new ElementCombin(elemenCount, 7, j + 1 + (i - 1) * modelSetting.num_node_all + modelSetting.num_node_face * modelSetting.num_longit, j + 1 + i * modelSetting.num_node_all); model.AddElement(combinCircumZ); model.AddElement(combinCircumX); model.AddElement(combinCircumY); } } //add longitudinal joint nodes couple-constrain for (int i = 0; i < modelSetting.num_ring; i++) { for (int j = 0; j <= modelSetting.num_longit; j++) { for (int k = 0; k < modelSetting.pos_joint.Count; k++) { ConstrainedNodes constrain = new ConstrainedNodes(); constrain.nodes.Add(model.nodes[modelSetting.pos_joint[k] + 1 + j * modelSetting.num_node_face + i * modelSetting.num_node_all]); constrain.nodes.Add(model.nodes[k + 1 + modelSetting.num_circum + j * modelSetting.num_node_face + i * modelSetting.num_node_all]); constrain.ux = 1; constrain.uy = 1; model.AddConstrained(constrain); } } } //add boundary for (int i = 0; i < modelSetting.num_node_face; i++) { BoundaryNode boundary = new BoundaryNode(); boundary.node = model.nodes[i + 1]; boundary.ux = 1; boundary.uy = 1; boundary.uz = 1; boundary.rx = 1; boundary.ry = 1; boundary.rz = 1; model.AddBoundary(boundary); } for (int i = 0; i < modelSetting.num_node_face; i++) { BoundaryNode boundary = new BoundaryNode(); boundary.node = model.nodes[i + 1 + modelSetting.num_node_all * (modelSetting.num_ring - 1) + modelSetting.num_longit * modelSetting.num_node_face]; boundary.ux = 1; boundary.uy = 1; boundary.uz = 1; boundary.rx = 1; boundary.ry = 1; boundary.rz = 1; model.AddBoundary(boundary); } //apply load }
private static void GetShellElements(int ringNo, ModelSetting modelSetting, SingleRingResult ringResult, ShieldTunnel3DResult result) { if (!result.PreElements.ContainsKey(1)) result.PreElements[1] = new List<Element>(); foreach (Element element in ringResult.elements[1]) { ElementShell shell = element as ElementShell; ElementShell newShell = new ElementShell(1, shell.pid, shell.n1 + modelSetting.num_node_all * ringNo, shell.n2 + modelSetting.num_node_all * ringNo, shell.n3 + modelSetting.num_node_all * ringNo, shell.n4 + modelSetting.num_node_all * ringNo); result.PreElements[1].Add(newShell); } }
private static void GetNodes(int ringNo, ModelSetting modelSetting, SingleRingResult ringResult, ShieldTunnel3DResult result) { for (int j = 0; j < modelSetting.num_node_all; j++) { Node node = ringResult.nodes[j]; Node newNode = new Node(node.nid + ringNo * modelSetting.num_node_all, node.x, node.y, node.z); result.nodes.Add(newNode); } }
private static void GetGroundElements(int ringNo, ModelSetting modelSetting, SingleRingResult ringResult, ShieldTunnel3DResult result) { if (!result.PreElements.ContainsKey(2)) result.PreElements[2] = new List<Element>(); //generate radial ground spring foreach (Element element in ringResult.elements[2]) { ElementLink link = element as ElementLink; ElementLink newLink = new ElementLink(1, link.pid, link.n1 + modelSetting.num_node_all * ringNo, link.n2 + modelSetting.num_node_all * ringNo); result.PreElements[2].Add(newLink); } if (!result.PreElements.ContainsKey(3)) result.PreElements[3] = new List<Element>(); //generate tangential ground spring foreach (Element element in ringResult.elements[3]) { ElementLink link = element as ElementLink; ElementLink newLink = new ElementLink(1, link.pid, link.n1 + modelSetting.num_node_all * ringNo, link.n2 + modelSetting.num_node_all * ringNo); result.PreElements[3].Add(newLink); } }