public PointViewModel(int index, Point point, BoundaryCondition condition) { Index = index; Point = point; Condition = condition; Types = new ObservableCollection <BoundaryConditionsType>(getTypesOfBoundaryConditions()); }
protected Grain GetTopRight(Cell[,] grid, int i, int j, BoundaryCondition boundary) { if (i != grid.GetLength(0) - 1 && j != 0) { return(grid[i + 1, j - 1].Grain); } else if (boundary == BoundaryCondition.Periodic) { if (i == grid.GetLength(0) - 1 && j == 0) { return(grid[0, grid.GetLength(1) - 1].Grain); } else if (i == grid.GetLength(0) - 1) { return(grid[0, j - 1].Grain); } else { return(grid[i + 1, grid.GetLength(1) - 1].Grain); } } else { return(Grain.EmptyGrain); } }
protected Grain GetBottomLeft(Cell[,] grid, int i, int j, BoundaryCondition boundary) { if (i != 0 && j != grid.GetLength(1) - 1) { return(grid[i - 1, j + 1].Grain); } else if (boundary == BoundaryCondition.Periodic) { if (i == 0 && j == grid.GetLength(1) - 1) { return(grid[grid.GetLength(0) - 1, 0].Grain); } else if (i == 0) { return(grid[grid.GetLength(0) - 1, j + 1].Grain); } else { return(grid[i - 1, 0].Grain); } } else { return(Grain.EmptyGrain); } }
private void BC_Button_Click(object sender, RoutedEventArgs e) { // Clear current Box PropertyBox.Children.Clear(); // Create new BC, add to Database and Viewport BoundaryCondition NewBC; if (DB.BCLib.Count != 0) { NewBC = new BoundaryCondition("New Boundary Condition", "SPC", DB.BCLib.Last().Value.ID + 1); } else { NewBC = new BoundaryCondition("New Boundary Condition", "SPC", 1); } NewBC.Initialize(); DB.BCLib.Add(NewBC.ID, NewBC); // Add new BC to GUI Fun.AddBC2GUI(NewBC, iRen, Tree, true); // Add Property Card BOX_BC NewBox = new BOX_BC(NewBC, DB, Tree, iRen, BC_Arrow_scale, ResControl.Step); PropertyBox.Children.Add(NewBox); }
static void Main() { Foo foo = Foo.First; if (foo == Foo.Second) { throw new Exception("Enum values should be different"); } // Check that Foo_Max enum element was ignored. int numFooEnumElements = Enum.GetValues(typeof(Foo)).Length; if (numFooEnumElements != 2) { throw new Exception(String.Format("Enum should have 2 elements, not {0}", numFooEnumElements)); } BoundaryCondition bc = BoundaryCondition.MaxMax; if ((int)bc != 2) { throw new Exception("Wrong enum value"); } Colour c = Colour.red; if (c == Colour.blue) { throw new Exception("Enum values should be different"); } }
public EdgeViewModel(int index, Edge edge, BoundaryCondition condition) { Index = index; Edge = edge; Condition = condition; Types = new ObservableCollection <BoundaryConditionsType>(getTypesOfBoundaryConditions()); }
/// <summary>Initializes a new instance of the <see cref="NaturalCubicSplineBoundaryCondition"/> class. /// </summary> internal NaturalCubicSplineBoundaryCondition() : base(CurveResource.AnnotationBoundaryCubicSplineNatural) { m_BoundaryCondition = new BoundaryCondition(); m_Name = new IdentifierString("Natural"); m_LongName = new IdentifierString(CurveResource.LongNameBoundaryNaturalCubicSpline); }
public BoundaryCharacteristic(double delta, double beta, double uC, double u0) { this.delta = delta; this.beta = beta; this.uC = uC; this.u0 = u0; condition = BoundaryCondition.First; }
public BoundaryCharacteristic() { delta = 1; beta = 1; uC = 0; u0 = 0; condition = BoundaryCondition.First; }
public SmallTransverseStringVibrations(double tMax, int nT, double[] elements, BoundaryCondition condition, double ro, double t0) : base(tMax, nT, elements) { Ro = ro; T0 = t0; Condition = condition; U0 = partEnd(Elements.ToArray(), 1).Select(Condition.U0).ToArray(); V0 = partEnd(Elements.ToArray(), 1).Select(Condition.V0).ToArray(); }
/// <summary> /// Constructor /// </summary> /// <param name="config"></param> /// <param name="speciesMap"></param> /// <param name="boundaryCondition"></param> /// <param name="fluxFunction"></param> public BoundaryConditionSourceFromINonlinear2ndOrderForm( CNSControl config, ISpeciesMap speciesMap, BoundaryCondition boundaryCondition, INonlinear2ndOrderForm fluxFunction) : base(config, speciesMap, boundaryCondition) { this.fluxFunction = fluxFunction; if (boundaryCondition is AdiabaticWall) { adiaWall = true; } }
public void Solve(string name, TData data, IScheme1D scheme, double[] initialValues, BoundaryCondition leftBoundaryCondition, BoundaryCondition rightBoundaryCondition, params IContinue[] continues) { var bundle = (SequenceBundle)CreateBundle(name, data); try { bundle.BeginEdit(); bundle.Save(); double t = 0; int number = 0; var grid = bundle.GetGrid(); double dt = bundle.dt(); // Начальные условия. string layerName = GetLayerName(bundle, number); bundle.AddArray(layerName, number, initialValues); while (continues.All(c => c.Continue(bundle))) { number++; t += dt; var matrix = new TriDiagMatrix(grid.N); // На левой границе. SetLeftBoundaryCondition(matrix, leftBoundaryCondition, t); // Построение матрицы. scheme.FillMatrix(matrix, bundle, grid, t, dt); // На правой границе. SetRightBoundaryCondition(matrix, rightBoundaryCondition, t); // Решение СЛАУ методом прогонки. var newLayer = matrix.Solve(); // Добавления нового слоя в результат. layerName = GetLayerName(bundle, number); bundle.AddArray(layerName, number, newLayer); } OnSolved(bundle, true); } catch (Exception exception) { OnSolved(bundle, false, exception); } }
public HB.Aperture ToHoneybee() { return(new HB.Aperture( Identifier, Geometry?.ToHoneybee(), BoundaryCondition.ToHoneybeeAnyOf(), Properties, DisplayName, null, // user data IsOperable, IndoorShades, OutdoorShades )); }
public HB.Door ToHoneybee() { return(new HB.Door( Identifier, Geometry.ToHoneybee(), BoundaryCondition.ToHoneybeeAnyOf(), Properties, DisplayName, null, // user data IsGlass, IndoorShades, OutdoorShades )); }
protected Grain GetBottom(Cell[,] grid, int i, int j, BoundaryCondition boundary) { if (j != grid.GetLength(1) - 1) { return(grid[i, j + 1].Grain); } else if (boundary == BoundaryCondition.Periodic) { return(grid[i, 0].Grain); } else { return(Grain.EmptyGrain); } }
protected Grain GetLeft(Cell[,] grid, int i, int j, BoundaryCondition boundary) { if (i != 0) { return(grid[i - 1, j].Grain); } else if (boundary == BoundaryCondition.Periodic) { return(grid[grid.GetLength(0) - 1, j].Grain); } else { return(Grain.EmptyGrain); } }
public override Grain GetLivingNeighbors(Cell[,] grid, int i, int j, BoundaryCondition boundary) { List <Grain> list = new List <Grain>(); list.Add(GetRight(grid, i, j, boundary)); list.Add(GetBottomRight(grid, i, j, boundary)); list.Add(GetBottom(grid, i, j, boundary)); list.Add(GetBottomLeft(grid, i, j, boundary)); list.Add(GetLeft(grid, i, j, boundary)); list.Add(GetTopLeft(grid, i, j, boundary)); list.Add(GetTop(grid, i, j, boundary)); list.Add(GetTopRight(grid, i, j, boundary)); return(TrancisionRule.GetWinningGrain(list)); }
//static == fixed protected ICollection <int> getIndeciesWithStaticBoundaryConditions() { List <int> indecies = new List <int>(); foreach (Edge edge in _model.Shape.Edges) { BoundaryCondition boundaryCondition = _model.BoundaryConditions[edge]; if (boundaryCondition.Type == BoundaryConditionsType.Static) { IEnumerable <FiniteElementNode> nodes = _mesh.GetNodesOnEdge(edge); foreach (FiniteElementNode node in nodes) { for (int i = 0; i < 6; i++) { if (!indecies.Contains(6 * node.Index + i)) { indecies.Add(6 * node.Index + i); } } } } } foreach (Point point in _model.Shape.Points) { BoundaryCondition pointCondition = _model.PointConditions[point]; if (pointCondition.Type == BoundaryConditionsType.Static) { FiniteElementNode node = _mesh.GetNodeOnPoint(point); if (node != null) { if (node.Point.Y > point.Y) { indecies.Add(6 * node.Index + 1); indecies.Add(6 * node.Index + 4); } else { indecies.Add(6 * node.Index); indecies.Add(6 * node.Index + 3); } } } } return(indecies); }
int Step; // Current selected analysis Step public BOX_BC(BoundaryCondition bc, Database db, TreeView tree, RenderInterface iren, double arrowScale, int step) { InitializeComponent(); VerticalAlignment = VerticalAlignment.Stretch; HorizontalAlignment = HorizontalAlignment.Stretch; BC = bc; DB = db; iRen = iren; ArrowScale = arrowScale; Step = step; // Define BC TreeView item TreeBC = (TreeViewItem)tree.Items[2]; if (TreeBC.Items != null) { foreach (TreeViewItem i in TreeBC.Items) { if (i.Header.ToString().Contains("BC ID " + BC.ID + ":")) { TreeItem = i; break; } } } // Load data Name.Text = BC.Name; Color_Box.SelectedIndex = BC.ColorID; if (BC.Type == "SPC") { Type_Box.SelectedIndex = 0; } if (BC.Type == "PointLoad") { Type_Box.SelectedIndex = 1; } Table.Items.Clear(); foreach (KeyValuePair <int, MatrixST> i in BC.NodalValues) { Table.Items.Add(new SPC_Row { NID = i.Key, X = i.Value.GetFast(0, 0), Y = i.Value.GetFast(1, 0), Z = i.Value.GetFast(2, 0) }); } }
private List <int> getIndeciesWithStaticBoundaryConditions() { List <int> indecies = new List <int>(); foreach (Edge edge in _model.Shape.Edges) { BoundaryCondition boundaryCondition = _model.BoundaryConditions[edge]; if (boundaryCondition.Type == BoundaryConditionsType.Static) { IEnumerable <FiniteElementNode> nodes = _mesh.GetNodesOnEdge(edge); foreach (FiniteElementNode node in nodes) { if (!indecies.Contains(2 * node.Index)) { indecies.Add(2 * node.Index); } if (!indecies.Contains(2 * node.Index + 1)) { indecies.Add(2 * node.Index + 1); } } } } foreach (Point point in _model.Shape.Points) { BoundaryCondition pointCondition = _model.PointConditions[point]; if (pointCondition.Type == BoundaryConditionsType.Static) { FiniteElementNode node = _mesh.GetNodeOnPoint(point); if (node != null) { if (!indecies.Contains(2 * node.Index)) { indecies.Add(2 * node.Index); } if (!indecies.Contains(2 * node.Index + 1)) { indecies.Add(2 * node.Index + 1); } } } } return(indecies); }
private static BoundaryCondition MapBoundaryCondition(XElement Xsegment, int numberOfCollocationPoints) { var XboundaryCondition = Xsegment.Element(BoundaryConditionElementName); BoundaryConditionType boundaryConditionType; BoundaryConditionValueType boundaryConditionValueType; TimeIntervalBoundaryConditionHelper timeIntervalValueBoundaryConditionHelper = null; RobinBoundaryConditionHelper robinBoundaryConditionHelper = null; if (XboundaryCondition.Attribute(BoundaryConditionTypeAttributeName).Value == "q") { boundaryConditionType = BoundaryConditionType.HeatFlux; } else { boundaryConditionType = BoundaryConditionType.Temperature; } var boundaryConditionExpression = String.Empty; var valueBoundaryConditionXElement = XboundaryCondition.Elements(valueBoundaryConditionElementName); var timeIntervalBoundaryConditionXElement = XboundaryCondition.Elements(timeIntervalBoundaryConditionElementName); var robinBoundaryConditionXElement = XboundaryCondition.Elements(robinBoundaryConditionElementName); if (robinBoundaryConditionXElement.Count() > 0) { robinBoundaryConditionHelper = MapRobinBoundaryCondition(robinBoundaryConditionXElement.First()); boundaryConditionValueType = BoundaryConditionValueType.ConvectionRadiation; } else if (timeIntervalBoundaryConditionXElement.Count() > 0) { timeIntervalValueBoundaryConditionHelper = MapTimeIntervalValueBoundaryCondition(timeIntervalBoundaryConditionXElement); boundaryConditionValueType = BoundaryConditionValueType.TimeIntervalValue; } else if (valueBoundaryConditionXElement.Count() > 0) { boundaryConditionExpression = valueBoundaryConditionXElement.First().Value.Replace(".", ","); boundaryConditionValueType = BoundaryConditionValueType.Value; } else { throw new AggregateException("Wrong boundary condition"); } var boundaryCondition = new BoundaryCondition(boundaryConditionType, numberOfCollocationPoints, boundaryConditionExpression, boundaryConditionValueType, timeIntervalValueBoundaryConditionHelper, robinBoundaryConditionHelper); return(boundaryCondition); }
public override bool IsBorder(Cell[,] grid, int i, int j, BoundaryCondition boundary) { var activeGrain = grid[i, j].Grain; var neighbors = new List <Grain>() { GetRight(grid, i, j, boundary), GetBottomRight(grid, i, j, boundary), GetBottom(grid, i, j, boundary), GetBottomLeft(grid, i, j, boundary), GetLeft(grid, i, j, boundary), GetTopLeft(grid, i, j, boundary), GetTop(grid, i, j, boundary), GetTopRight(grid, i, j, boundary), }; return(neighbors.Any(x => x != activeGrain && !x.IsInclusion())); }
/// <summary> /// Perform cubic splines given the knots /// </summary> /// <param name="knots">knots(channel,counts)</param> /// <param name="boundary">Boundary condtion for the first and last knot, /// Clamped (f'(0)=f'(n)=0) or Natural (f''(0)=f''(n)=0) </param> /// <returns>The array of spline coefficients</returns> private double[] FitContinuum(Tuple <int, double>[] knots, BoundaryCondition boundary) { int n = knots.Length; //initilize the right-hand side double[] d = new double[n]; //initilize the left-hand side coefficients double[,] A = new double[n, n]; //build the system of equations for (int i = 1; i < n - 1; i++) { //create simplification variables double h0 = knots[i].Item1 - knots[i - 1].Item1; double h1 = knots[i + 1].Item1 - knots[i].Item1; double h2 = knots[i + 1].Item1 - knots[i - 1].Item1; //fill the matrix A[i, i - 1] = h0 / h2; A[i, i] = 2; A[i, i + 1] = h1 / h2; //second divided difference d[i] = 6 * ((knots[i + 1].Item2 - knots[i].Item2) / h1 - (knots[i].Item2 - knots[i - 1].Item2) / h0) / h2; } //do the boundry equations (first and Last) if (boundary == BoundaryCondition.Natural) { A[0, 0] = 1; A[0, 1] = 0; d[0] = 0; A[n - 1, n - 2] = 0; A[n - 1, n - 1] = 1; d[n - 1] = 0; } else { A[0, 0] = 2; A[0, 1] = 1; d[0] = ((knots[1].Item2 - knots[0].Item2) / (knots[1].Item1 - knots[0].Item1)) / (knots[1].Item1 - knots[0].Item1); A[n - 1, n - 2] = 1; A[n - 1, n - 1] = 2; d[n - 1] = (0 - (knots[n].Item2 - knots[n - 1].Item2) / (knots[n].Item1 - knots[n - 1].Item1)) / (knots[n].Item1 - knots[n - 1].Item1); } return(Matrix.Tridiagonal(A, d)); }
/// <summary> /// Добавить парабоидальное граничное условие /// </summary> /// <param name="x1"> x координата левого верхнего угла </param> /// <param name="y1"> y координата левого верхнего угла </param> /// <param name="x2"> x координата правого нижнего угла </param> /// <param name="y2"> y координата правого нижнего угла </param> /// <param name="condition"> Тип граничного условия </param> /// <param name="maxVelocity"> Пиковое значение входной скорости </param> public void AddBoundary(int x1, int y1, int x2, int y2, BoundaryCondition condition, int maxVelocity) { _boundaries.Add(x1); _boundaries.Add(y1); _boundaries.Add(x2); _boundaries.Add(y2); _boundaries.Add((int)condition); for (var i = x1; i <= x2; i++) { for (var j = y1; j <= y2; j++) { VelocityX[i, j] = x1 == x2 ? (-4 * maxVelocity * j * j) / ((y2 - y1) * (y2 - y1)) + (4 * maxVelocity * j) / ((y2 - y1)) : 0; VelocityY[i, j] = y1 == y2 ? (-4 * maxVelocity * i * i) / ((x2 - x1) * (x2 - x1)) + (4 * maxVelocity * i) / ((x2 - x1)) : 0; } } }
//static == fixed private void AsumeStaticBoundaryConditions(Matrix stiffnessMatrix, Vector totalVector) { foreach (Edge edge in _model.Shape.Edges) { BoundaryCondition boundaryCondition = _model.BoundaryConditions[edge]; if (boundaryCondition.Type == BoundaryConditionsType.Static) { IEnumerable <FiniteElementNode> nodes = _mesh.GetNodesOnEdge(edge); foreach (FiniteElementNode node in nodes) { stiffnessMatrix[2 * node.Index, 2 * node.Index] *= 1000000000000; stiffnessMatrix[2 * node.Index + 1, 2 * node.Index + 1] *= 1000000000000; } } else { IEnumerable <FiniteElementRectangleEdge> segments = _mesh.GetSegmentsOnEdge(edge); foreach (FiniteElementRectangleEdge FiniteElementRectangleEdge in segments) { Vector localVector = GetLocalTotalVector(FiniteElementRectangleEdge, boundaryCondition.Value); for (int i = 0; i < FiniteElementRectangleEdge.Count; i++) { totalVector[2 * FiniteElementRectangleEdge[i].Index] += localVector[2 * i]; totalVector[2 * FiniteElementRectangleEdge[i].Index + 1] += localVector[2 * i + 1]; } } } } foreach (Point point in _model.Shape.Points) { BoundaryCondition pointCondition = _model.PointConditions[point]; if (pointCondition.Type == BoundaryConditionsType.Static) { FiniteElementNode node = _mesh.GetNodeOnPoint(point); if (node != null) { stiffnessMatrix[2 * node.Index, 2 * node.Index] *= 1000000000000; stiffnessMatrix[2 * node.Index + 1, 2 * node.Index + 1] *= 1000000000000; } } } }
public DiffusionConvectionReaction( double[] elements, BoundaryCondition condition, Func <double, double> f, Func <double, double> mu, Func <double, double> beta, Func <double, double> sigma, double alpha ) : base(elements) { N_prev = elements.Length - 1; Condition = condition; F = f; Mu = mu; Beta = beta; Sigma = sigma; Alpha = alpha; nIntegrals = N - 1; }
/// <summary> /// Constructs a new flux builder where the boundary conditions are /// evaluated using the convective fluxes defined by /// <paramref name="convectiveBuilder"/>. /// </summary> /// <param name="control"></param> /// <param name="boundaryMap"></param> /// <param name="speciesMap"></param> /// <param name="convectiveBuilder"></param> /// <param name="diffusiveBuilder"></param> public BoundaryConditionSourceFluxBuilder( IBMControl control, BoundaryConditionMap boundaryMap, ISpeciesMap speciesMap, FluxBuilder convectiveBuilder, FluxBuilder diffusiveBuilder) : base(control, boundaryMap, speciesMap) { standardOperator = new Operator(control); if (convectiveBuilder != null) { convectiveBuilder.BuildFluxes(standardOperator); } if (diffusiveBuilder != null) { diffusiveBuilder.BuildFluxes(standardOperator); } string levelSetBoundaryType = control.LevelSetBoundaryTag; boundaryCondition = boundaryMap.GetBoundaryCondition(levelSetBoundaryType); }
public void AddBC2GUI(BoundaryCondition BC, RenderInterface iRen, TreeView Tree, bool Selected) { // Define BC TreeView item TreeViewItem TreeBC = (TreeViewItem)Tree.Items[2]; // Add BC actor to Viewport iRen.AddActor(BC.GetActor()[0]); iRen.AddActor(BC.GetActor()[1]); iRen.AddActor(BC.GetActor()[2]); BC.HideActor(); // Add BC to TreeView TreeViewItem item = new TreeViewItem() { Header = "BC ID " + BC.ID.ToString() + ": " + BC.Name, IsSelected = Selected }; TreeBC.Items.Add(item); TreeBC.IsExpanded = true; }
/// <summary> /// Добавить простое граничное условие /// </summary> /// <param name="x1"> x координата левого верхнего угла </param> /// <param name="y1"> y координата левого верхнего угла </param> /// <param name="x2"> x координата правого нижнего угла </param> /// <param name="y2"> y координата правого нижнего угла </param> /// <param name="condition"> Тип граничного условия </param> public void AddBoundary(int x1, int y1, int x2, int y2, BoundaryCondition condition) { _boundaries.Add(x1); _boundaries.Add(y1); _boundaries.Add(x2); _boundaries.Add(y2); _boundaries.Add((int)condition); if (condition != BoundaryCondition.SolidWall) { return; } for (var i = x1; i <= x2; i++) { for (var j = y1; j <= y2; j++) { VelocityX[i, j] = 0; VelocityY[i, j] = 0; } } }
/// <summary> /// Create a new ComputationalDomain object and load the information from the specified file /// </summary> /// <param name="navigator"></param> /// <returns></returns> public GEMSComputationalDomain(XPathNavigator navigator, GEMSProject parent) { this.parent = parent; minVector3 = new Vector3WithUnit(); maxVector3 = new Vector3WithUnit(); navigator.MoveToChild("X0", string.Empty); minVector3.X = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty)); conditionXmin = (BoundaryCondition)Enum.Parse(typeof(BoundaryCondition), navigator.GetAttribute("condition", string.Empty)); navigator.MoveToParent(); navigator.MoveToChild("X1", string.Empty); maxVector3.X = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty)); conditionXmax = (BoundaryCondition)Enum.Parse(typeof(BoundaryCondition), navigator.GetAttribute("condition", string.Empty)); navigator.MoveToParent(); navigator.MoveToChild("Y0", string.Empty); minVector3.Y = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty)); conditionYmin = (BoundaryCondition)Enum.Parse(typeof(BoundaryCondition), navigator.GetAttribute("condition", string.Empty)); navigator.MoveToParent(); navigator.MoveToChild("Y1", string.Empty); maxVector3.Y = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty)); conditionYmax = (BoundaryCondition)Enum.Parse(typeof(BoundaryCondition), navigator.GetAttribute("condition", string.Empty)); navigator.MoveToParent(); navigator.MoveToChild("Z0", string.Empty); minVector3.Z = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty)); conditionZmin = (BoundaryCondition)Enum.Parse(typeof(BoundaryCondition), navigator.GetAttribute("condition", string.Empty)); navigator.MoveToParent(); navigator.MoveToChild("Z1", string.Empty); maxVector3.Z = new Length(navigator.GetAttribute("value", string.Empty), navigator.GetAttribute("unit", string.Empty)); conditionZmax = (BoundaryCondition)Enum.Parse(typeof(BoundaryCondition), navigator.GetAttribute("condition", string.Empty)); navigator.MoveToParent(); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BoundaryCondition obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }