/// <summary> /// /// </summary> public IntegrateField() : base("Integrate Field", "Integrate", "Integrates a vector field from a given point", "SpatialSlur", "Field") { IntegrationMode = IntegrationMode.Euler; }
public DGElement(IntegrationMode mode,double leftSpaceBoundary,double rightSpaceBoundary, int polynomOrder, Func<double,double> fluxFunction, Func<double, double, double> numericalFluxFunction, Func<double, double, double> inhomogenuousFunction, Func<double, double> initialFunction) { myIntegrationMode = mode; this.leftSpaceBoundary = leftSpaceBoundary; this.rightSpaceBoundary = rightSpaceBoundary; this.N = polynomOrder; this.fluxFunction = fluxFunction; this.numericalFluxFunction = numericalFluxFunction; this.inhomogenuousFunction = inhomogenuousFunction; this.initialFunction = initialFunction; Initialize(); }
public static Integrator Get(IntegrationMode integrationMode) { switch (integrationMode) { default: case IntegrationMode.Verlet: return(_verlet.Value); case IntegrationMode.VelocityVerlet: return(_velocityVerlet.Value); case IntegrationMode.Euler: return(_euler.Value); } }
public static IntegrationMode GetIntegrationMode(IIsolatedIntegrationManager isolatedIntegration, IOracleERPIntegrationManager oracleERPIntegration, ISmartERPIntegrationManager smartERPIntegration, GeneralConfig generalConfig) { IntegrationMode integrationMode = null; if (generalConfig.OrgName == IntegrationModeName.Isolated.ToString()) { integrationMode = new IsolatedImplementation(isolatedIntegration); } else if (generalConfig.OrgName == IntegrationModeName.SmartERP.ToString()) { integrationMode = new SmartERPImplementation(smartERPIntegration); } else if (generalConfig.OrgName == IntegrationModeName.OracleERP.ToString()) { integrationMode = new OracleERPImplementaion(oracleERPIntegration); } return(integrationMode); }
/// <summary> /// /// </summary> /// <param name="field"></param> /// <param name="point"></param> /// <param name="stepSize"></param> /// <param name="mode"></param> /// <returns></returns> public static IEnumerable <Vec2d> IntegrateFrom(this IField2d <Vec2d> field, Vec2d point, double stepSize, IntegrationMode mode = IntegrationMode.Euler) { return(SimulationUtil.IntegrateFrom(field, point, stepSize, mode)); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RK4Clicked(object sender, EventArgs e) { IntegrationMode = IntegrationMode.RK4; ExpireSolution(true); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EulerClicked(object sender, EventArgs e) { IntegrationMode = IntegrationMode.Euler; ExpireSolution(true); }
/// <summary> /// /// </summary> /// <param name="field"></param> /// <param name="points"></param> /// <param name="stepSize"></param> /// <param name="stepCount"></param> /// <param name="mode"></param> private PolylineCurve[] SolveInstanceImpl(IField2d <Vec2d> field, List <Point3d> points, double stepSize, int stepCount, IntegrationMode mode) { var result = new PolylineCurve[points.Count]; Parallel.For(0, points.Count, i => { Vec3d p0 = points[i]; var z = p0.Z; var pts = field.IntegrateFrom(p0, stepSize, mode).Take(stepCount).Select(p => new Point3d(p.X, p.Y, z)); result[i] = new PolylineCurve(pts); }); return(result); }
/// <summary> /// /// </summary> /// <param name="field"></param> /// <param name="points"></param> /// <param name="stepSize"></param> /// <param name="stepCount"></param> /// <param name="mode"></param> private PolylineCurve[] SolveInstanceImpl(IField3d <Vec3d> field, List <Point3d> points, double stepSize, int stepCount, IntegrationMode mode) { var result = new PolylineCurve[points.Count]; Parallel.For(0, points.Count, i => { var pts = field.IntegrateFrom(points[i], stepSize, mode).Take(stepCount).Select(p => (Point3d)p); result[i] = new PolylineCurve(pts); }); return(result); }
private Matrix computeErrorList(IntegrationMode mode) { Console.WriteLine("Start computation for Error List..."); int[] elementNumber = {2,4,8,16,32}; int[] polynomOrders = {1,3,7}; Vector CFLMapping = GetCFL(mode); Matrix errorList = new Matrix(elementNumber.Length, polynomOrders.Length); for (int i = 0; i < polynomOrders.Length; i++) { int polynomOrder = polynomOrders[i]; for (int k = 0; k < elementNumber.Length; k++) { Console.Write("N = " + polynomOrder + " - N_Q = " + elementNumber[k]); Stopwatch sw = new Stopwatch(); sw.Start(); DGController dgController = new DGController(); dgController.createDGElements(elementNumber[k], mode, polynomOrder, leftSpaceBorder, rightSpaceBorder); timeStep = dgController.ComputeTimeStep(CFLMapping[polynomOrders[i]-1]); errorList[k, i] = dgController.computeSolution(endTime, timeStep); sw.Stop(); Console.Write(" - L2 Error: " + errorList[k, i]); Console.WriteLine(" - PassedTime: " + sw.Elapsed); } } Console.WriteLine("Error Computation finished"); return errorList; }
/// <summary> /// Returns a streamline through the given vector field starting at the given point. /// </summary> /// <param name="field"></param> /// <param name="point"></param> /// <param name="stepSize"></param> /// <param name="mode"></param> /// <returns></returns> public static IEnumerable <Vector3d> IntegrateFrom(IField3d <Vector3d> field, Vector3d point, double stepSize, IntegrationMode mode = IntegrationMode.Euler) { switch (mode) { case IntegrationMode.Euler: return(IntegrateFromEuler(field, point, stepSize)); case IntegrationMode.RK2: return(IntegrateFromRK2(field, point, stepSize)); case IntegrationMode.RK4: return(IntegrateFromRK4(field, point, stepSize)); } throw new NotSupportedException(); }
public void createDGElements(int numberOfDGElements,IntegrationMode mode, int polynomOrder, double leftBoundary, double rightBoundary) { this.polynomOrder = polynomOrder; myMode= mode; spaceLengthInElements = (rightBoundary-leftBoundary)/(double)numberOfDGElements; elements = new DGElement[numberOfDGElements]; for (int i = 0; i<numberOfDGElements; i++) { double leftSpaceBorder = leftBoundary + (double)i * (rightBoundary - leftBoundary) / (double)numberOfDGElements; double rightSpaceBorder = leftBoundary + (double)(i + 1) * (rightBoundary-leftBoundary) / (double)numberOfDGElements; elements[i] = new DGElement(mode,leftSpaceBorder, rightSpaceBorder, polynomOrder, FluxFunction, NumFlux, InhomogenuousPart, InitialFunction); if (i > 0) { elements[i].LeftNeighbour = elements[i - 1]; elements[i - 1].RightNeighbour = elements[i]; } } //Periodic Boundary Condition if (numberOfDGElements > 1) { elements[0].LeftNeighbour = elements[numberOfDGElements - 1]; elements[numberOfDGElements - 1].RightNeighbour = elements[0]; } else { elements[0].LeftNeighbour = elements[0]; elements[0].RightNeighbour = elements[0]; } }
private Vector GetCFL(IntegrationMode mode) { Vector cfl; if (mode == IntegrationMode.GaussLobatto) { cfl = new Vector(new double[] { 1.36, 1.06, 0.89, 0.77, 0.68, 0.61, 0.56 }); } else { cfl = new Vector(new double[] { 3.17, 2.05, 1.63, 1.38, 1.21, 1.08, 0.98 }); } return cfl; }
private void ComputeSolutionForUnsteady(IntegrationMode mode) { Console.WriteLine("Start computation for Unsteady Solution..."); int[] elementNumber = {50}; int[] polynomOrders = { 1, 3, 7 }; Vector CFLMapping = GetCFL(mode); Matrix errorList = new Matrix(elementNumber.Length, polynomOrders.Length); for (int i = 0; i < polynomOrders.Length; i++) { int polynomOrder = polynomOrders[i]; for (int k = 0; k < elementNumber.Length; k++) { Console.WriteLine("N = " + polynomOrder + " - N_Q = " + elementNumber[k]); DGController dgController = new DGController(); dgController.createDGElements(elementNumber[k], mode, polynomOrder, leftSpaceBorder, rightSpaceBorder); timeStep = dgController.ComputeTimeStep(CFLMapping[polynomOrders[i] - 1]); errorList[k, i] = dgController.computeSolution(endTime, timeStep); Vector space = dgController.getOriginSpace(); Vector sol = dgController.getCompleteSolution(); string plotString = NSharp.Converter.MatLabConverter.ConvertToMatLabPlotStringWithAxisLabelAndTitle(space, sol, "X-Achse", "u approx", "Approximation mit NQ = " + elementNumber[k] + " N = " + polynomOrder); GeneralHelper.WriteOutputText(Directory.GetCurrentDirectory() + "\\" + mode.ToString() + "_PLOT_N =" + polynomOrder + ".txt", plotString); } } Console.WriteLine("Unsteady Solution finished"); }
/// <summary> /// /// </summary> /// <param name="field"></param> /// <param name="point"></param> /// <param name="stepSize"></param> /// <param name="mode"></param> /// <returns></returns> public static IEnumerable <Vec3d> IntegrateFrom(this IField3d <Vec3d> field, Vec3d point, double stepSize, IntegrationMode mode = IntegrationMode.Euler) { return(FieldSim.IntegrateFrom(field, point, stepSize, mode)); }
/// <summary> /// Calculates aproximation of a integral over a given variable on a given interval. /// </summary> /// <param name="variableName">Variable to integrate over.</param> /// <param name="lowerBound">Lower inclusive boundry.</param> /// <param name="upperBound">Upper exclusive boundry.</param> /// <param name="step">The step of the integration.</param> /// <param name="mode">The mode of integration.</param> /// <returns></returns> public double Integrate(string variableName, double lowerBound, double upperBound, double step, IntegrationMode mode) { if (lowerBound > upperBound) { upperBound = lowerBound; } double result = 0; EquationVariable variable = GetVariable(variableName); variable.Value = lowerBound; if (mode == IntegrationMode.Rectangle) { while (variable.Value < upperBound) { result += Calculate() * step; variable.Value += step; } } else { double val; while (variable.Value < upperBound) { val = Calculate(); variable.Value += step; result += (Calculate() + val) / 2 * step; } } return(result); }
private void computeDGLMatrices(IntegrationMode mode) { int[] elementNumber = {8,16,32,64}; int[] polynomOrders = {1,2,3,4,5,6,7}; for (int i = 0; i < polynomOrders.Length; i++) { int polynomOrder = polynomOrders[i]; for (int k = 0; k < elementNumber.Length; k++) { DGController dgController = new DGController(); dgController.createDGElements(elementNumber[k], mode, polynomOrder, leftSpaceBorder, rightSpaceBorder); Matrix A = dgController.ConstructDGLMatrix(); string matrixString = NSharp.Converter.MatLabConverter.ConvertMatrixToMatlabReadable(A); GeneralHelper.WriteOutputText(Directory.GetCurrentDirectory() + "\\" + mode.ToString() + "_NQ=" + elementNumber[k] + "_N =" + polynomOrder+".txt", matrixString); } } }