protected virtual void AddFirstBoundary(IMatrix A, double[] b, FirstBoundaryEdge edge) { double[,] M = info.BoundaryBasis.MassMatrix; Func <double, double, double, double> ugtime = edge.F; Func <double, double, double> ug = (double x, double y) => ugtime(x, y, 0); double x0 = info.Mesh.Points[edge[0]].X; double y0 = info.Mesh.Points[edge[0]].Y; double x1 = info.Mesh.Points[edge[edge.NodeCount - 1]].X; double y1 = info.Mesh.Points[edge[edge.NodeCount - 1]].Y; double[] q = BasisHelpers.ExpandInBasis((double ksi) => ug(x0 + ksi * (x1 - x0), y0 + ksi * (y1 - y0)), info.BoundaryBasis); for (int i = 0; i < edge.NodeCount; i++) { A.DI[edge[i]] = 1.0e+50; b[edge[i]] = 1.0e+50 * q[i]; } }
static Mesh LoadMesh( string pointsFile, string elementsFile, string firstBoundaryFile, string secondBoundaryFile, string thirdBoundaryFile, ProblemInfo info, IMeshBuilder builder) { // Points Parsing -------------------------------------------------------- string[] lines = File.ReadAllLines(pointsFile); int pointCount = int.Parse(lines[0]); Point[] points = new Point[pointCount]; for (int i = 0; i < pointCount; i++) { points[i] = Point.Parse(lines[i + 1]); } // ----------------------------------------------------------------------- // Elements Parsing ------------------------------------------------------ lines = File.ReadAllLines(elementsFile); int elementsCount = int.Parse(lines[0]); List <FiniteElement> elements = new List <FiniteElement>(); for (int i = 0; i < elementsCount; i++) { FiniteElement e = new FiniteElement(info.Basis.Size); string[] tokens = lines[i + 1].Split(' '); e.Vertices[0] = int.Parse(tokens[0]) - 1; e.Vertices[1] = int.Parse(tokens[1]) - 1; e.Vertices[2] = int.Parse(tokens[2]) - 1; e.Material = info.MaterialDictionary[int.Parse(tokens[3])]; elements.Add(e); } // ----------------------------------------------------------------------- // First Boundary Parsing ------------------------------------------------ lines = File.ReadAllLines(firstBoundaryFile); int firstBoundaryCount = int.Parse(lines[0]); List <FirstBoundaryEdge> firstBondary = new List <FirstBoundaryEdge>(); for (int i = 0; i < firstBoundaryCount; i++) { FirstBoundaryEdge e = new FirstBoundaryEdge(info.BoundaryBasis.Size); string[] tokens = lines[i + 1].Split(' '); e.Vertices[0] = int.Parse(tokens[0]) - 1; e.Vertices[info.BoundaryBasis.Size - 1] = int.Parse(tokens[1]) - 1; e.F = info.FirstBoundaryDictionary[int.Parse(tokens[2])]; firstBondary.Add(e); } // ----------------------------------------------------------------------- // Second Boundary Parsing ----------------------------------------------- lines = File.ReadAllLines(secondBoundaryFile); int secondBoundaryCount = int.Parse(lines[0]); List <SecondBoundaryEdge> secondBondary = new List <SecondBoundaryEdge>(); for (int i = 0; i < secondBoundaryCount; i++) { SecondBoundaryEdge e = new SecondBoundaryEdge(info.BoundaryBasis.Size); string[] tokens = lines[i + 1].Split(' '); e.Vertices[0] = int.Parse(tokens[0]) - 1; e.Vertices[info.BoundaryBasis.Size - 1] = int.Parse(tokens[1]) - 1; e.Theta = info.SecondBoundaryDictionary[int.Parse(tokens[2])]; secondBondary.Add(e); } // ----------------------------------------------------------------------- // Third Boundary Parsing ------------------------------------------------ lines = File.ReadAllLines(thirdBoundaryFile); int thirdBoundaryCount = int.Parse(lines[0]); List <ThirdBoundaryEdge> thirdBondary = new List <ThirdBoundaryEdge>(); for (int i = 0; i < thirdBoundaryCount; i++) { ThirdBoundaryEdge e = new ThirdBoundaryEdge(info.BoundaryBasis.Size); string[] tokens = lines[i + 1].Split(' '); e.Vertices[0] = int.Parse(tokens[0]) - 1; e.Vertices[info.BoundaryBasis.Size - 1] = int.Parse(tokens[1]) - 1; int boundaryNo = int.Parse(tokens[2]); e.UBeta = info.ThirdBoundaryDictionary[boundaryNo].ubeta; e.Beta = info.ThirdBoundaryDictionary[boundaryNo].beta; thirdBondary.Add(e); } // ----------------------------------------------------------------------- builder.AddPoints(points); builder.AddElements(elements); builder.AddFirstBoundary(firstBondary); builder.AddSecondBoundary(secondBondary); builder.AddThirdBoundary(thirdBondary); return(builder.Build()); }