public double NormaErrorW2(Function u, Function du, FEMContext FEMContext) { double norma = 0; for (int e = 0; e < FEMContext.Data.NT.GetLength(0); e++) { Point i = FEMContext.Data.CT[FEMContext.Data.NT[e].GetVertexID(0)]; Point j = FEMContext.Data.CT[FEMContext.Data.NT[e].GetVertexID(1)]; Point m = FEMContext.Data.CT[FEMContext.Data.NT[e].GetVertexID(2)]; Point point = new Point((i.X + j.X + m.X) / 3, (i.Y + j.Y + m.Y) / 3); if (TriangleOnPoint(point, i, j, m)) { double fi = CalculateArea(point, j, m) * FEMContext.X[FEMContext.Data.NT[e].GetVertexID(0)]; double fj = CalculateArea(i, point, m) * FEMContext.X[FEMContext.Data.NT[e].GetVertexID(1)]; double fm = CalculateArea(i, j, point) * FEMContext.X[FEMContext.Data.NT[e].GetVertexID(2)]; double Uh = (fi + fj + fm) / AreaTriangles[e]; double dUh = UhDerivative(e, FEMContext); norma += (Math.Abs(Math.Pow(Uh - u(point.X), 2)) + Math.Abs(Math.Pow(dUh - du(point.X), 2))) * AreaTriangles[e]; } else { MessageBox.Show("Exception - (NormaErrorW2)"); } } return(norma); }
public ErrorSolver(FEMContext fEMContext, TriangleNetHandler triangleNetHandler, List <CustomPoint> points, Equation equation) { Points = points; Equation = equation; TriangleNetHandler = triangleNetHandler; CurrentFEMContext = fEMContext; CalculateAreas(CurrentFEMContext); CalculateLength(CurrentFEMContext); }
private void CalculateAreas(FEMContext FEMContext) { this.AreaTriangles = new double[FEMContext.Data.NT.GetLength(0)]; for (int k = 0; k < FEMContext.Data.NT.GetLength(0); k++) { Point i = FEMContext.Data.CT[FEMContext.Data.NT[k].GetVertexID(0)]; Point j = FEMContext.Data.CT[FEMContext.Data.NT[k].GetVertexID(1)]; Point m = FEMContext.Data.CT[FEMContext.Data.NT[k].GetVertexID(2)]; AreaTriangles[k] = CalculateArea(i, j, m); } }
private void CalculateLength(FEMContext FEMContext) { this.LengthSegments = new double[FEMContext.Data.GT.Length][]; for (int border = 0; border < FEMContext.Data.GT.Length; border++) { LengthSegments[border] = new double[FEMContext.Data.GT[border].GetLength(0)]; for (int k = 0; k < FEMContext.Data.GT[border].GetLength(0); k++) { Point p1 = FEMContext.Data.CT[FEMContext.Data.GT[border][k, 0]]; Point p2 = FEMContext.Data.CT[FEMContext.Data.GT[border][k, 1]]; LengthSegments[border][k] = Length(p1, p2); } } }
private double UhDerivative(int numberTriangle, FEMContext FEMContext) { double UhDer; Point i = FEMContext.Data.CT[FEMContext.Data.NT[numberTriangle].GetVertexID(0)]; Point j = FEMContext.Data.CT[FEMContext.Data.NT[numberTriangle].GetVertexID(1)]; Point m = FEMContext.Data.CT[FEMContext.Data.NT[numberTriangle].GetVertexID(2)]; double bI = j.Y - m.Y; double bJ = m.Y - i.Y; double bM = i.Y - j.Y; double Ui = FEMContext.X[FEMContext.Data.NT[numberTriangle].GetVertexID(0)]; double Uj = FEMContext.X[FEMContext.Data.NT[numberTriangle].GetVertexID(1)]; double Um = FEMContext.X[FEMContext.Data.NT[numberTriangle].GetVertexID(2)]; double sigma = 2 * AreaTriangles[numberTriangle]; UhDer = (Ui * bI + Uj * bJ + Um * bM) / sigma; return(UhDer); }
public double NormaW2Exact(Function u, Function du, FEMContext FEMContext) { double norma = 0; for (int e = 0; e < FEMContext.Data.NT.GetLength(0); e++) { Point i = FEMContext.Data.CT[FEMContext.Data.NT[e].GetVertexID(0)]; Point j = FEMContext.Data.CT[FEMContext.Data.NT[e].GetVertexID(1)]; Point m = FEMContext.Data.CT[FEMContext.Data.NT[e].GetVertexID(2)]; Point point = new Point((i.X + j.X + m.X) / 3, (i.Y + j.Y + m.Y) / 3); if (TriangleOnPoint(point, i, j, m)) { norma += (Math.Pow(u(point.X), 2) + Math.Pow(du(point.X), 2)) * AreaTriangles[e]; } else { MessageBox.Show("Exception - (NormaW2_Exact)"); } } return(Math.Sqrt(norma)); }
public double NormaL2(FEMContext FEMContext) { double norma = 0; for (int e = 0; e < FEMContext.Data.NT.GetLength(0); e++) { Point i = FEMContext.Data.CT[FEMContext.Data.NT[e].GetVertexID(0)]; Point j = FEMContext.Data.CT[FEMContext.Data.NT[e].GetVertexID(1)]; Point m = FEMContext.Data.CT[FEMContext.Data.NT[e].GetVertexID(2)]; Point point = new Point((i.X + j.X + m.X) / 3, (i.Y + j.Y + m.Y) / 3); if (TriangleOnPoint(point, i, j, m)) { double fi = CalculateArea(point, j, m) * FEMContext.X[FEMContext.Data.NT[e].GetVertexID(0)]; double fj = CalculateArea(point, m, i) * FEMContext.X[FEMContext.Data.NT[e].GetVertexID(1)]; double fm = CalculateArea(point, i, j) * FEMContext.X[FEMContext.Data.NT[e].GetVertexID(2)]; norma += Math.Pow((fi + fj + fm) / AreaTriangles[e], 2) * AreaTriangles[e]; } else { MessageBox.Show("Exception - (NormaL2)"); } } return(Math.Sqrt(norma)); }