//Berechnet den L2 Fehler indem die Lösung mit 2N Polynomen approximiert wird. public double computeError(double endTime) { Vector errorNodes, errorWeights; LegendrePolynomEvaluator.computeLegendreGaussNodesAndWeights(2*polynomOrder, out errorNodes, out errorWeights); LagrangeInterpolator interpolator = new LagrangeInterpolator(elements[0].nodes); double error = 0.0; double tempErr = 0.0; for (int i = 0; i < elements.Length; i++) { for (int m = 0; m < errorNodes.Length; m++) { tempErr = interpolator.evaluateLagrangeRepresentation(errorNodes[m], elements[i].GetSolution()); double trafoSpace = elements[i].MapToOriginSpace(errorNodes[m]); tempErr = (ExactSolution(trafoSpace, endTime) - tempErr) * errorWeights[m]* (ExactSolution(trafoSpace, endTime) - tempErr) * ((elements[i].rightSpaceBoundary - elements[i].leftSpaceBoundary) / 2.0); error += tempErr; } } return Math.Sqrt(error); }
private void InitializeDGElement() { LegendrePolynomEvaluator.computeGaussLobattoNodesAndWeights(N, out Nodes, out IntegrationWeights); InitializeStartSolution(); BottomBorderValues = new Matrix3D(N + 1, 1, SystemDimension); TopBorderValues = new Matrix3D(N + 1, 1, SystemDimension); LeftBorderValues = new Matrix3D(N + 1, 1, SystemDimension); RightBorderValues = new Matrix3D(N + 1, 1, SystemDimension); this.FluxF = new Matrix3D(N + 1, N + 1, SystemDimension); this.FluxG = new Matrix3D(N + 1, N + 1, SystemDimension); this.UpdateBorderValues(); S = new Matrix(N + 1, N + 1); S[0, 0] = 1.0 / IntegrationWeights[0]; S[N, N] = -1.0 / IntegrationWeights[N]; interpolator = new LagrangeInterpolator(Nodes); DifferentialMatrix = interpolator.computeLagrangePolynomeDerivativeMatrix(); DifferentialMatrixTransposed = !DifferentialMatrix; J = ((RightXBorder - LeftXBorder) * (TopYBorder - BottomYBorder)) / 4.0; }
private void InitializeDGWithGaussNodes() { fluxEvaluation = new Vector(N + 1); LegendrePolynomEvaluator.computeLegendreGaussNodesAndWeights(N, out nodes, out integrationWeights); solution = ComputeStartSolution(); interpolator = new LagrangeInterpolator(nodes); massMatrix = IntegrationToolbox.generateMassMatrix(integrationWeights); this.UpdateBorderValues(); invMassMatrix = new Matrix(N + 1, N + 1); for (int i = 0; i < N + 1; i++) invMassMatrix[i, i] = 1.0 / massMatrix[i, i]; differentialMatrix = interpolator.computeLagrangePolynomeDerivativeMatrix(); LeftBoarderInterpolation = new Vector(nodes.Length); RightBoarderInterpolation = new Vector(nodes.Length); for (int i = 0; i < nodes.Length; i++) { LeftBoarderInterpolation[i] = interpolator.evaluateLagrangePolynome(-1.0, i); RightBoarderInterpolation[i] = interpolator.evaluateLagrangePolynome(1.0, i); } B = new Matrix(N + 1, N + 1); for (int i = 0; i <= N; i++) { B[i, 0] = LeftBoarderInterpolation[i]; B[i, N] = RightBoarderInterpolation[i]; } volumeMatrix = invMassMatrix * (!differentialMatrix) * massMatrix; LeftBoarderInterpolation = invMassMatrix * LeftBoarderInterpolation; RightBoarderInterpolation = invMassMatrix * RightBoarderInterpolation; }
private void InitializeDGWithGaussLobattoNodes() { fluxEvaluation = new Vector(N + 1); LegendrePolynomEvaluator.computeGaussLobattoNodesAndWeights(N, out nodes, out integrationWeights); solution = ComputeStartSolution() ; this.UpdateBorderValues(); interpolator = new LagrangeInterpolator(nodes); massMatrix = IntegrationToolbox.generateMassMatrix(integrationWeights); invMassMatrix = new Matrix(N + 1, N+1); for (int i = 0; i < N + 1; i++) invMassMatrix[i,i] = 1.0 / massMatrix[i,i]; differentialMatrix = interpolator.computeLagrangePolynomeDerivativeMatrix(); B = new Matrix(N + 1, N + 1); B[0, 0] = -1.0; B[N, N] = 1.0; volumeMatrix = invMassMatrix*(!differentialMatrix) * massMatrix; surfaceMatrix = invMassMatrix * B; }
public void Initialize() { FluxEvaluation = new Matrix(N + 1, SystemDimension); LegendrePolynomEvaluator.computeGaussLobattoNodesAndWeights(N, out nodes, out integrationWeights); SolutionSystem = ComputeStartSolution(); LeftBoarderValue = new Vector(SystemDimension); RightBoarderValue = new Vector(SystemDimension); this.UpdateBorderValues(); interpolator = new LagrangeInterpolator(nodes); MassMatrix = IntegrationToolbox.generateMassMatrix(integrationWeights); InvMassMatrix = new Matrix(N + 1, N + 1); for (int i = 0; i < N + 1; i++) InvMassMatrix[i, i] = 1.0 / MassMatrix[i, i]; DifferentialMatrix = interpolator.computeLagrangePolynomeDerivativeMatrix(); B = new Matrix(N + 1, N + 1); B[0, 0] = -1.0; B[N, N] = 1.0; VolumeMatrix = InvMassMatrix * (!DifferentialMatrix) * MassMatrix; SurfaceMatrix = InvMassMatrix * B; }