public void SolveTest()
        {
            Rectangle body = new Rectangle(1, 1);

            Material material = Material.Aluminium();
            Model    model    = new Model(material, body);

            model.BoundaryConditions[body.Edges[0]].Type = BoundaryConditionsType.Static;

            double load = 1000;

            model.BoundaryConditions[body.Edges[1]].Type     = BoundaryConditionsType.Kinematic;
            model.BoundaryConditions[body.Edges[1]].Value[2] = load;

            Mesh mesh = new RectangularMesh(body, 2, 2);

            double error         = 0.001;
            int    maxIterations = 20;
            Solver solver        = new StationaryNonlinear2DSolver(model, mesh, error, maxIterations);

            IResult actual   = solver.Solve(1).FirstOrDefault();
            IResult expected = new AnaliticalResultRectangleWithOneSideFixed(model);

            IEnumerable <Point> points = mesh.GetPointsForResult();

            Assert.IsTrue(ResultHelper.IsResultsEqual(points, expected, actual, 0, error));
        }
Example #2
0
        //
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        internal virtual Mesh CreateMesh()
        {
            // TODO: Instantiate an appropriate concrete class.
            Rectangle body = new Rectangle(1, 2, 4, 6);
            Mesh      mesh = new RectangularMesh(body, 3, 3);

            return(mesh);
        }
Example #3
0
        public void Solve()
        {
            Rectangle rectangle = solidMechanicsModel.Model.Shape as Rectangle;

            if (rectangle != null)
            {
                SolidMechanicsModel2D smm = solidMechanicsModel as SolidMechanicsModel2D;
                if (smm != null)
                {
                    RectangularMesh mesh = new RectangularMesh(rectangle, smm.VerticalElements, smm.HorizontalElements);
                    pointsForGrid = mesh.GetPointsForResult();
                    IEnumerable <INumericalResult> results = null;
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    Task taskSolver = Task.Factory.StartNew(() =>
                    {
                        //Solver solver = new FreeVibrationsLinearSolver(solidMechanicsModel.Model, mesh, error, solidMechanicsModel.MaxAmplitude);

                        Solver solver = new FreeVibrationsLinearSolver(smm.Model, mesh, error, smm.MaxAmplitude);

                        /*Solver initSolver = new FreeVibrationsLinearSolver(_solidMechanicsModel.Model, mesh, _error);
                         * IEnumerable<INumericalResult> initResults = initSolver.Solve(1);
                         * EigenValuesNumericalResult res = initResults.First() as EigenValuesNumericalResult;*/

                        //Solver solver = new FreeVibrationsNonLinearSolver2(_solidMechanicsModel.Model, mesh, _error, res.U, 2, 50);

                        //Solver solver = new NewmarkVibrationNonLinearSolver(_solidMechanicsModel.Model, mesh, _error, res.U, 5, 50);

                        //Solver solver = new StationaryNonlinear2DSolver(_solidMechanicsModel.Model, mesh, _error, 20);

                        //IResult analiticalResult = new AnaliticalResultRectangleWithOneSideFixed(_solidMechanicsModel.Model);

                        results = solver.Solve(maxResults);
                    });
                    sw.Stop();
                    TimeElapsed = sw.Elapsed;
                    Task.WaitAll(taskSolver);
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        Results.Clear();
                        foreach (INumericalResult result in results)
                        {
                            Results.Add(result);
                        }
                    }));
                }
            }
        }
Example #4
0
        public void SolveTest()
        {
            double    error     = 0.001;
            Rectangle rectangle = new Rectangle(0.1, 1);
            Model     model     = new Model(Material.Aluminium(), rectangle); // TODO: Initialize to an appropriate value

            model.PointConditions[rectangle.Points[2]].Type = BoundaryConditionsType.Static;
            model.PointConditions[rectangle.Points[3]].Type = BoundaryConditionsType.Static;
            Mesh mesh = new RectangularMesh(rectangle, 10, 4);                                      // TODO: Initialize to an appropriate value
            FreeVibrationsLinearSolver solver = new FreeVibrationsLinearSolver(model, mesh, error); // TODO: Initialize to an appropriate value
            IResult expected = null;                                                                // TODO: Initialize to an appropriate value
            IResult actual   = null;

            actual = solver.Solve(1).FirstOrDefault();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Example #5
0
        public void SolveSimpleTest()
        {
            double    error     = 0.001;
            Rectangle rectangle = new Rectangle(1, 1);
            Model     model     = new Model(Material.Aluminium(), rectangle);

            model.PointConditions[rectangle.Points[2]].Type = BoundaryConditionsType.Static;
            model.PointConditions[rectangle.Points[3]].Type = BoundaryConditionsType.Static;
            //model.BoundaryConditions[rectangle.Edges[0]].Type = BoundaryConditionsType.Static;
            //model.BoundaryConditions[rectangle.Edges[2]].Type = BoundaryConditionsType.Static;
            Mesh mesh = new RectangularMesh(rectangle, 2, 2);
            FreeVibrationsLinearSolver solver = new FreeVibrationsLinearSolver(model, mesh, error);
            IResult expected = null; // TODO: Initialize to an appropriate value
            IResult actual   = solver.Solve(1).FirstOrDefault();

            IEnumerable <Point> points = mesh.GetPointsForResult();

            ResultHelper.IsResultsEqual(points, expected, actual, 0, error);

            Assert.AreEqual(true, false);
        }
        private void FillResultPicture()
        {
            Rectangle rectangle = solidMechanicsModel.Model.Shape as Rectangle;

            if (rectangle != null)
            {
                RectangularMesh mesh   = new RectangularMesh(rectangle, VerticalElements, HorizontalElements);
                List <Shape>    shapes = new List <Shape>();
                foreach (FiniteElementRectangle fe in mesh.Elements)
                {
                    shapes.Add(ConvertFiniteElementToShape(fe));
                }
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    Figures.Clear();
                    foreach (Shape shape in shapes)
                    {
                        Figures.Add(shape);
                    }
                }));
            }
        }