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.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 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); } }