//================== // constructor //================== public Codend(List <Panel> PanelList, double EntranceRadius) { this.PanelList = PanelList; PanelCount = PanelList.Count; this.EntranceRadius = EntranceRadius; MeshSettings = new MeshSettings(); }
private void GetAlongAndAcross(MeshSettings meshSettings) { if (meshSettings.meshingMethod.Equals("ByMesh", StringComparison.InvariantCulture)) { nAlong = (int)Math.Ceiling(LengthInMeshes / meshSettings.MeshPerElemAlong); nAcross = (int)Math.Ceiling(WidthInMeshes / meshSettings.MeshPerElemAcross); } else { nAlong = meshSettings.ElemAlongPanel; nAcross = meshSettings.ElemAcrossPanel; } }
//public void StructuredMesh(int nSouth, int nEast, int nNorth, int nWest, double MaxLength, double MaxWidth, QualityOptions quality) //{ // Length = MaxLength; // Width = MaxWidth; // var poly = new Polygon(); // poly.Add(new Contour(new Vertex[4] // Add the outer box contour with boundary marker ID. // { // new Vertex(0.0, 0.0, 1), // new Vertex(WidthInMeshes, 0.0, 1), // new Vertex(WidthInMeshes, LengthInMeshes, 1), // new Vertex(0.0, LengthInMeshes, 1) // }, 1)); // for (int i = 1; i < nSouth; i++) // { // poly.Add(new Vertex(i * WidthInMeshes / nSouth, 0, 1)); // //Console.WriteLine("{0,10:F3}{1,10:F3}", i * Geom.WidthInMeshes / nSouth, 0); // } // for (int i = 1; i < nEast; i++) // { // poly.Add(new Vertex(WidthInMeshes, i * LengthInMeshes / nEast, 1)); // //Console.WriteLine("{0,10:F3}{1,10:F3}", Geom.WidthInMeshes, i * Geom.LengthInMeshes / nEast); // } // for (int i = 1; i < nNorth; i++) // { // poly.Add(new Vertex(WidthInMeshes * (1 - i / (double)nNorth), LengthInMeshes, 1)); // //Console.WriteLine("{0,10:F3}{1,10:F3}", Geom.WidthInMeshes * (1 - i / (double)nNorth), Geom.LengthInMeshes); // } // for (int i = 1; i < nWest; i++) // { // poly.Add(new Vertex(0, LengthInMeshes * (1 - i / (double)nWest), 1)); // //Console.WriteLine("{0,10:F3}{1,10:F3}", 0, Geom.LengthInMeshes * (1 - i / (double)nWest)); // } // var options = new ConstraintOptions() // { // ConformingDelaunay = true, // SegmentSplitting = 1, // }; // var mesh = (Mesh)poly.Triangulate(options, quality); // var smoother = new SimpleSmoother(); // Smooth mesh and re-apply quality options. // smoother.Smooth(mesh, 100); // mesh.Refine(quality); // mesh.Renumber(); // //==================================================== // //==================================================== // // Calculate mesh quality // var statistic = new QualityMeasure(); // statistic.Update(mesh); // // Use the minimum triangle area for region refinement // double area = 3 * statistic.AreaMinimum; // foreach (var t in mesh.Triangles) // { // t.Area = area; // } // // Use per triangle area constraint for next refinement // quality.VariableArea = true; // // Refine mesh to meet area constraint. // mesh.Refine(quality); // // Smooth once again. // smoother.Smooth(mesh); // //==================================================== // //==================================================== // foreach (var v in mesh.Vertices) // { // NodeList.Add(new Node(v.ID, // MaxWidth * v.X / WidthInMeshes, // MaxLength * v.Y / LengthInMeshes, // 0)); // } // foreach (var t in mesh.Triangles) // { // TriangleList.Add(new DiamondNetTriangle(t.ID, // NodeList[t.GetVertexID(0)], NodeList[t.GetVertexID(1)], NodeList[t.GetVertexID(2)], // new double[] { t.GetVertex(0).X, t.GetVertex(1).X, t.GetVertex(2).X }, // new double[] { t.GetVertex(0).Y, t.GetVertex(1).Y, t.GetVertex(2).Y } // ) { Label = ID, Material = Material }); // } //} public void CreateUnitMesh(MeshSettings meshSettings) { InitializeFemLists(); GetAlongAndAcross(meshSettings); // rectangular grid for (int i = 0; i < nAlong + 1; i++) // { for (int j = 0; j < nAcross + 1; j++) { NodeList.Add(new Node(i * (nAcross + 1) + j, j / (double)nAcross, i / (double)nAlong, 0)); // label for last ring of points (for BC) if (i == nAlong) { NodeList.Last().Label = 1; } // label for first ring of points (for BC) if (i == 0) { NodeList.Last().Label = 0; } } LeftSelvedgeNodes.Add(NodeList[i * (nAcross + 1) + 0]); RightSelvedgeNodes.Add(NodeList[i * (nAcross + 1) + nAcross]); } int gridSize = NodeList.Count; int nextrowIdx, thisrowIdx; double xMid, yMid; // create midpoints in the square cells and define triangles for (int i = 0; i < nAlong; i++) { for (int j = 0; j < nAcross; j++) { thisrowIdx = i * (nAcross + 1) + j; nextrowIdx = (i + 1) * (nAcross + 1) + j; // add mid node to a square cell xMid = (NodeList[thisrowIdx].X + NodeList[thisrowIdx + 1].X + NodeList[nextrowIdx].X + NodeList[nextrowIdx + 1].X) / 4; yMid = (NodeList[thisrowIdx].Y + NodeList[thisrowIdx + 1].Y + NodeList[nextrowIdx].Y + NodeList[nextrowIdx + 1].Y) / 4; NodeList.Add(new Node(gridSize + i * nAcross + j, xMid, yMid, 0)); // label for pre-last ring of points (for initial shape) if (i == nAlong - 1) { NodeList.Last().Label = 2; } //south trinagle in this row TriangleList.Add(new DiamondNetTriangle(i * 4 * nAcross + 4 * j + 0, NodeList[gridSize + i * nAcross + j], NodeList[thisrowIdx], NodeList[thisrowIdx + 1], TriangleuCoord(NodeList, gridSize + i * nAcross + j, thisrowIdx, thisrowIdx + 1), TrianglevCoord(NodeList, gridSize + i * nAcross + j, thisrowIdx, thisrowIdx + 1)) { Material = Material, orientation = Orientation }); // east trinagle in this row TriangleList.Add(new DiamondNetTriangle(i * 4 * nAcross + 4 * j + 1, NodeList[gridSize + i * nAcross + j], NodeList[thisrowIdx + 1], NodeList[nextrowIdx + 1], TriangleuCoord(NodeList, gridSize + i * nAcross + j, thisrowIdx + 1, nextrowIdx + 1), TrianglevCoord(NodeList, gridSize + i * nAcross + j, thisrowIdx + 1, nextrowIdx + 1)) { Material = Material, orientation = Orientation }); // north trinagle in this row TriangleList.Add(new DiamondNetTriangle(i * 4 * nAcross + 4 * j + 2, NodeList[gridSize + i * nAcross + j], NodeList[nextrowIdx + 1], NodeList[nextrowIdx], TriangleuCoord(NodeList, gridSize + i * nAcross + j, nextrowIdx + 1, nextrowIdx), TrianglevCoord(NodeList, gridSize + i * nAcross + j, nextrowIdx + 1, nextrowIdx)) { Material = Material, orientation = Orientation }); // west trinagle in this row TriangleList.Add(new DiamondNetTriangle(i * 4 * nAcross + 4 * j + 3, NodeList[gridSize + i * nAcross + j], NodeList[nextrowIdx], NodeList[thisrowIdx], TriangleuCoord(NodeList, gridSize + i * nAcross + j, nextrowIdx, thisrowIdx), TrianglevCoord(NodeList, gridSize + i * nAcross + j, nextrowIdx, thisrowIdx)) { Material = Material, orientation = Orientation }); } } }