internal static void TestDenseSolver()
        {
            Skip.IfNot(TestSettings.TestMkl, TestSettings.MessageWhenSkippingMKL);

            // Dense solver is too slow for a ~17.000 dof linear system, without MKL
            TestSettings.RunMultiproviderTest(LinearAlgebraProviderChoice.MKL, delegate()
            {
                CantileverBeam benchmark = BuildCantileverBenchmark();

                var solverBuilder        = new DenseMatrixSolver.Builder();
                DenseMatrixSolver solver = solverBuilder.BuildSolver(benchmark.Model);
                //solverBuilder.DofOrderer = new DofOrderer(new NodeMajorDofOrderingStrategy(), new NullReordering()); // default

                RunAnalysisAndCheck(benchmark, solver);
            });
        }
Exemple #2
0
        private static IVectorView SolveModel(Model model, ComsolMeshReader2 modelReader)
        {
            //var initialTemp = Vector.CreateZero(model.Nodes.Count);
            double[] temp0       = new double[model.Nodes.Count];
            int[]    boundaryIDs = new int[] { 0 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IList <Node> nodes in modelReader.triBoundaries[boundaryID])
                {
                    foreach (Node node in nodes)
                    {
                        temp0[node.ID] = 1;
                    }
                }
            }
            boundaryIDs = new int[] { 5 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IList <Node> nodes in modelReader.triBoundaries[boundaryID])
                {
                    foreach (Node node in nodes)
                    {
                        temp0[node.ID] = 0;
                    }
                }
            }
            Vector initialTemp = Vector.CreateFromArray(temp0);
            var    builder     = new DenseMatrixSolver.Builder();

            builder.IsMatrixPositiveDefinite = false;
            var solver   = builder.BuildSolver(model);
            var provider = new ProblemConvectionDiffusion(model, solver);

            var childAnalyzer = new LinearAnalyzer(model, solver, provider);
            //var parentAnalyzer = new BDF(model, solver, provider, childAnalyzer, 1, 10, 1, initialTemp);
            var parentAnalyzer = new ConvectionDiffusionExplicitDynamicAnalyzer(model, solver, provider, childAnalyzer, 2.5e-3, 5, initialTemp);

            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();

            return(parentAnalyzer.temperature[subdomainID]);
            //return parentAnalyzer.temperature[1][subdomainID];
            //           return solver.LinearSystems[subdomainID].Solution;
        }
Exemple #3
0
        private static IVectorView SolveModel(Model model)
        {
            double[] temp0       = new double[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            Vector   initialTemp = Vector.CreateFromArray(temp0);
            var      builder     = new DenseMatrixSolver.Builder();

            builder.IsMatrixPositiveDefinite = false;
            var solver = builder.BuildSolver(model);
            //var solver = new DenseMatrixSolver.Builder().BuildSolver(model);
            //Gmres solver = (new DenseMatrixSolver.Builder()).BuildSolver(model);
            var provider = new ProblemConvectionDiffusion3(model, solver);

            var childAnalyzer  = new LinearAnalyzer(model, solver, provider);
            var parentAnalyzer = new BDF(model, solver, provider, childAnalyzer, 1, 5, 6, initialTemp);

            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();

            //return solver.LinearSystems[subdomainID].Solution;
            return(parentAnalyzer.temperature[5][subdomainID]);
        }
        public void CantileverShellBenchmark()
        {
            Model         model       = new Model();
            var           filename    = "CantileverShell";
            string        filepath    = $"..\\..\\..\\MGroup.IGA.Tests\\InputFiles\\{filename}.iga";
            IgaFileReader modelReader = new IgaFileReader(model, filepath);

            modelReader.CreateTSplineShellsModelFromFile();

            model.PatchesDictionary[0].Material = new ElasticMaterial2D(StressState2D.PlaneStress)
            {
                PoissonRatio = 0.0,
                YoungModulus = 100
            };
            model.PatchesDictionary[0].Thickness = 1;

            foreach (var controlPoint in model.ControlPointsDictionary.Values.Where(cp => cp.X < 3))
            {
                model.ControlPointsDictionary[controlPoint.ID].Constraints.Add(new Constraint()
                {
                    DOF = StructuralDof.TranslationX
                });
                model.ControlPointsDictionary[controlPoint.ID].Constraints.Add(new Constraint()
                {
                    DOF = StructuralDof.TranslationY
                });
                model.ControlPointsDictionary[controlPoint.ID].Constraints.Add(new Constraint()
                {
                    DOF = StructuralDof.TranslationZ
                });
            }

            foreach (var controlPoint in model.ControlPointsDictionary.Values.Where(cp => cp.X > 49.8))
            {
                model.Loads.Add(new Load()
                {
                    Amount = -0.5,
                    Node   = model.ControlPointsDictionary[controlPoint.ID],
                    DOF    = StructuralDof.TranslationZ
                });
            }

            var solverBuilder = new DenseMatrixSolver.Builder();

            solverBuilder.DofOrderer = new DofOrderer(
                new NodeMajorDofOrderingStrategy(), new NullReordering());
            ISolver solver = solverBuilder.BuildSolver(model);

            // Structural problem provider
            var provider = new ProblemStructural(model, solver);

            // Linear static analysis
            var childAnalyzer  = new LinearAnalyzer(model, solver, provider);
            var parentAnalyzer = new StaticAnalyzer(model, solver, provider, childAnalyzer);

            // Run the analysis
            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();

            //var paraview = new ParaviewTsplineShells(model, solver.LinearSystems[0].Solution, filename);
            //paraview.CreateParaviewFile();

            var expectedSolutionVector = Vector.CreateFromArray(new double[]
            {
                0, 0, -306.122431, 0, 0, -1552.478121, 0, 0, -3454.810388, 0, 0, -5881.924153, 0, 0, -8702.62361, 0, 0,
                -11785.71439, 0, 0, -13928.57064, 0, 0, -15000.0008, 0, 0, -306.1224369, 0, 0, -1552.47811, 0, 0,
                -3454.810407, 0, 0, -5881.924117, 0, 0, -8702.623683, 0, 0, -11785.71423, 0, 0, -13928.57093, 0, 0,
                -15000.00025, 0, 0, -306.1224493, 0, 0, -1552.478088, 0, 0, -3454.810449, 0, 0, -5881.924038, 0, 0,
                -8702.623837, 0, 0, -11785.71389, 0, 0, -13928.57157, 0, 0, -14999.99909, 0, 0, -306.1224494, 0, 0,
                -1552.478088, 0, 0, -3454.810449, 0, 0, -5881.924038, 0, 0, -8702.623837, 0, 0, -11785.71389, 0, 0,
                -13928.57157, 0, 0, -14999.99909, 0, 0, -306.1224369, 0, 0, -1552.47811, 0, 0, -3454.810407, 0, 0,
                -5881.924117, 0, 0, -8702.623683, 0, 0, -11785.71423, 0, 0, -13928.57093, 0, 0, -15000.00025, 0, 0,
                -306.122431, 0, 0, -1552.478121, 0, 0, -3454.810388, 0, 0, -5881.924154, 0, 0, -8702.62361, 0, 0,
                -11785.71439, 0, 0, -13928.57064, 0, 0, -15000.0008
            });

            for (int i = 0; i < expectedSolutionVector.Length; i++)
            {
                Assert.True(Utilities.AreValuesEqual(expectedSolutionVector[i], solver.LinearSystems[0].Solution[i],
                                                     1e-8));
            }
        }