Ejemplo n.º 1
0
        internal static void TestSkylineSolver()
        {
            CantileverBeam benchmark = BuildCantileverBenchmark();

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

            RunAnalysisAndCheck(benchmark, solver);
        }
Ejemplo n.º 2
0
        internal static void TestSkylineSolverWithAmdReordering()
        {
            CantileverBeam benchmark = BuildCantileverBenchmark();

            var solverBuilder = new SkylineSolver.Builder();

            solverBuilder.DofOrderer = new DofOrderer(
                new NodeMajorDofOrderingStrategy(), AmdReordering.CreateWithCSparseAmd());
            ISolver solver = solverBuilder.BuildSolver(benchmark.Model);

            RunAnalysisAndCheck(benchmark, solver);
        }
Ejemplo n.º 3
0
        internal static void TestPcgJacobiSolver()
        {
            CantileverBeam benchmark = BuildCantileverBenchmark();

            //LibrarySettings.LinearAlgebraProviders = LinearAlgebraProviderChoice.MKL;
            var solverBuilder = new PcgSolver.Builder();
            //var pcgBuilder = new PcgAlgorithm.Builder();
            //solverBuilder.PcgAlgorithm = pcgBuilder.Build(); // default
            //solverBuilder.DofOrderer = new DofOrderer(new NodeMajorDofOrderingStrategy(), new NullReordering()); // default
            PcgSolver solver = solverBuilder.BuildSolver(benchmark.Model);

            RunAnalysisAndCheck(benchmark, solver);
        }
Ejemplo n.º 4
0
        internal static void TestSuiteSparseSolver()
        {
            Skip.IfNot(TestSettings.TestSuiteSparse, TestSettings.MessageWhenSkippingSuiteSparse);

            CantileverBeam benchmark = BuildCantileverBenchmark();

            var solverBuilder = new SuiteSparseSolver.Builder();

            solverBuilder.DofOrderer = new DofOrderer(new NodeMajorDofOrderingStrategy(), new NullReordering());
            using (SuiteSparseSolver solver = solverBuilder.BuildSolver(benchmark.Model))
            {
                RunAnalysisAndCheck(benchmark, solver);
            }
        }
Ejemplo n.º 5
0
        internal static void TestPcgJacobiSolverWithAmdReordering()
        {
            CantileverBeam benchmark = BuildCantileverBenchmark();

            var solverBuilder = new PcgSolver.Builder();

            //var pcgBuilder = new PcgAlgorithm.Builder();
            //solverBuilder.PcgAlgorithm = pcgBuilder.Build();
            solverBuilder.DofOrderer = new DofOrderer(
                new NodeMajorDofOrderingStrategy(), AmdReordering.CreateWithCSparseAmd());
            PcgSolver solver = solverBuilder.BuildSolver(benchmark.Model);

            RunAnalysisAndCheck(benchmark, solver);
        }
        private static Model CreateModel()
        {
            int numElementsX = 2, numElementsY = 4; // for the hardcoded stiffness matrices

            var cantileverBuilder = new CantileverBeam.Builder();

            cantileverBuilder.Length       = numElementsX;
            cantileverBuilder.Height       = numElementsY;
            cantileverBuilder.Width        = 1.0;
            cantileverBuilder.YoungModulus = 1.0;
            cantileverBuilder.PoissonRatio = 0.3;
            CantileverBeam cantilever = cantileverBuilder.BuildWithQuad4Elements(numElementsX, numElementsY);

            return(cantilever.Model);
        }
Ejemplo n.º 7
0
        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);
            });
        }
Ejemplo n.º 8
0
        private static void RunAnalysisAndCheck(CantileverBeam benchmark, ISolver solver)
        {
            // Structural problem provider
            var provider = new ProblemStructural(benchmark.Model, solver);

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

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

            // Check output
            double endDeflectionExpected = benchmark.CalculateEndDeflectionWithEulerBeamTheory();
            double endDeflectionComputed =
                benchmark.CalculateAverageEndDeflectionFromSolution(solver.LinearSystems.First().Value.Solution);
            var comparer = new ValueComparer(1E-2);

            Assert.True(comparer.AreEqual(endDeflectionExpected, endDeflectionComputed));
        }