Exemple #1
0
        public static void SuiteSparseMemoryConsumptionDebugging()
        {
            for (int rep = 0; rep < 10; ++rep)
            {
                var benchmarkBuilder = new CantileverBeam.Builder();
                //benchmarkBuilder.Length = 5.0;
                CantileverBeam benchmark = benchmarkBuilder.BuildWithQuad4Elements(2000, 100);

                // Solver
                var solverBuilder = new SuiteSparseSolver.Builder();
                using (SuiteSparseSolver solver = solverBuilder.BuildSolver(benchmark.Model))
                {
                    // 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();
                }
            }
        }
        public static void EmbeddedEBEinMatrix_NewtonRaphson()
        {
            // Model creation
            var model = new Model();

            // Subdomains
            //model.SubdomainsDictionary.Add(subdomainID, new Subdomain() { ID = 1 });
            model.SubdomainsDictionary.Add(subdomainID, new Subdomain(subdomainID));

            // Variables
            int      monitorNode = 41;
            IDofType monitorDof  = StructuralDof.TranslationZ;

            // Choose model
            EmbeddedEBEModelBuilder.EmbeddedExampleBuilder(model);

            //-----------------------------------------------------------------------------------------------------------
            // Model

            // Choose linear equation system solver
            //var solverBuilder = new SkylineSolver.Builder();
            //SkylineSolver solver = solverBuilder.BuildSolver(model);
            var solverBuilder        = new SuiteSparseSolver.Builder();
            SuiteSparseSolver solver = solverBuilder.BuildSolver(model);

            // Choose the provider of the problem -> here a structural problem
            var provider = new ProblemStructural(model, solver);

            // Choose child analyzer -> Child: NewtonRaphsonNonLinearAnalyzer
            int increments           = 100;
            var childAnalyzerBuilder = new LoadControlAnalyzer.Builder(model, solver, provider, increments)
            {
                ResidualTolerance = 1E-03, MaxIterationsPerIncrement = 10
            };
            LoadControlAnalyzer childAnalyzer = childAnalyzerBuilder.Build();

            // Choose parent analyzer -> Parent: Static
            var parentAnalyzer = new StaticAnalyzer(model, solver, provider, childAnalyzer);

            // Request output
            string outputFile = outputDirectory + "\\CNT-Embedded-3D_Results.txt";
            var    logger     = new TotalLoadsDisplacementsPerIncrementLog(model.SubdomainsDictionary[subdomainID], increments,
                                                                           model.NodesDictionary[monitorNode], monitorDof, outputFile);

            childAnalyzer.IncrementalLogs.Add(subdomainID, logger);

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

            // Create Paraview File
            var paraview = new ParaviewEmbedded3D(model, solver.LinearSystems[0].Solution, "test");

            paraview.CreateParaviewFile();
        }
        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);
            }
        }
        public static void EmbeddedEBEinMatrix_DisplacementControl()
        {
            // Model creation
            var model = new Model();

            // Subdomains
            //model.SubdomainsDictionary.Add(subdomainID, new Subdomain() { ID = 1 });
            model.SubdomainsDictionary.Add(subdomainID, new Subdomain(subdomainID));

            // Variables
            int      monitorNode = 161;
            IDofType monitorDof  = StructuralDof.TranslationZ;

            // Choose model
            EmbeddedEBEModelBuilder.EmbeddedExampleBuilder(model);

            //-----------------------------------------------------------------------------------------------------------
            // Model

            // Choose linear equation system solver
            //var solverBuilder = new SkylineSolver.Builder();
            //SkylineSolver solver = solverBuilder.BuildSolver(model);
            var solverBuilder        = new SuiteSparseSolver.Builder();
            SuiteSparseSolver solver = solverBuilder.BuildSolver(model);

            // Choose the provider of the problem -> here a structural problem
            var provider = new ProblemStructural(model, solver);

            // Choose child analyzer -> Child: DisplacementControl
            var subdomainUpdaters    = new[] { new NonLinearSubdomainUpdater(model.SubdomainsDictionary[subdomainID]) };
            int increments           = 100;
            var childAnalyzerBuilder = new DisplacementControlAnalyzer.Builder(model, solver, provider, increments);
            DisplacementControlAnalyzer childAnalyzer = childAnalyzerBuilder.Build();

            // Choose parent analyzer -> Parent: Static
            var parentAnalyzer = new StaticAnalyzer(model, solver, provider, childAnalyzer);

            // Request output
            string outputFile = outputDirectory + "\\CNT-Embedded-3D_Results.txt";
            var    logger     = new TotalLoadsDisplacementsPerIncrementLog(model.SubdomainsDictionary[subdomainID], increments,
                                                                           model.NodesDictionary[monitorNode], monitorDof, outputFile);

            childAnalyzer.IncrementalLogs.Add(subdomainID, logger);

            // Run the analysis
            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();
        }
        public static void EmbeddedCNTinMatrix_NewtonRaphson()
        {
            // No. of increments
            int increments = 1000;

            // Model creation
            var model = new Model();

            // Subdomains
            //model.SubdomainsDictionary.Add(subdomainID, new Subdomain() { ID = 1 });
            model.SubdomainsDictionary.Add(subdomainID, new Subdomain(subdomainID));

            // Variables
            int      monitorNode = 10001;
            IDofType monitorDof  = StructuralDof.TranslationZ;

            // Choose model
            EmbeddedModelBuilder.EmbeddedExample(model);

            // Boundary Conditions - Left End [End-1]
            for (int iNode = 1; iNode <= 100; iNode++)
            {
                model.NodesDictionary[iNode].Constraints.Add(new Constraint {
                    DOF = StructuralDof.TranslationZ
                });
            }

            // Boundary Conditions - Bottom End [End-3]
            for (int iNode = 1; iNode <= 10001; iNode += 100)
            {
                for (int j = 0; j < 10; j++)
                {
                    model.NodesDictionary[iNode + j].Constraints.Add(new Constraint {
                        DOF = StructuralDof.TranslationY
                    });
                }
            }

            // Boundary Conditions - Right End [End-5]
            for (int iNode = 1; iNode <= 10091; iNode += 10)
            {
                model.NodesDictionary[iNode].Constraints.Add(new Constraint {
                    DOF = StructuralDof.TranslationX
                });
            }

            //// Boundary Conditions - Left End [End-6]
            //for (int iNode = 10; iNode <= 10100; iNode += 10)
            //{
            //    model.NodesDictionary[iNode].Constraints.Add(new Constraint { DOF = DOFType.X });
            //}

            //Compression Loading
            double nodalLoad = -1.0;                         //0.40;

            for (int iNode = 10001; iNode <= 10100; iNode++) //[End-4]
            {
                model.Loads.Add(new Load()
                {
                    Amount = nodalLoad, Node = model.NodesDictionary[iNode], DOF = StructuralDof.TranslationZ
                });
            }

            // Choose linear equation system solver
            //var solverBuilder = new SkylineSolver.Builder();
            //SkylineSolver solver = solverBuilder.BuildSolver(model);
            var solverBuilder        = new SuiteSparseSolver.Builder();
            SuiteSparseSolver solver = solverBuilder.BuildSolver(model);

            // Choose the provider of the problem -> here a structural problem
            var provider = new ProblemStructural(model, solver);

            // Choose child analyzer -> Child: NewtonRaphsonNonLinearAnalyzer
            var childAnalyzerBuilder = new LoadControlAnalyzer.Builder(model, solver, provider, increments)
            {
                ResidualTolerance = 1E-03
            };
            LoadControlAnalyzer childAnalyzer = childAnalyzerBuilder.Build();

            // Choose parent analyzer -> Parent: Static
            var parentAnalyzer = new StaticAnalyzer(model, solver, provider, childAnalyzer);

            // Request output
            string outputFile = outputDirectory + "\\CNT-Embedded-3D_Results.txt";
            var    logger     = new TotalLoadsDisplacementsPerIncrementLog(model.SubdomainsDictionary[subdomainID], increments,
                                                                           model.NodesDictionary[monitorNode], monitorDof, outputFile);

            childAnalyzer.IncrementalLogs.Add(subdomainID, logger);

            // Run the analysis
            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();
        }
        public static void EmbeddedCNT_20_20_inMatrix_NewtonRaphson()
        {
            // No. of increments
            int increments = 100;

            // Model creation
            var model = new Model();

            // Subdomains
            //model.SubdomainsDictionary.Add(subdomainID, new Subdomain() { ID = 1 });
            model.SubdomainsDictionary.Add(subdomainID, new Subdomain(subdomainID));

            // Variables
            int      monitorNode = 1800;
            IDofType monitorDof  = StructuralDof.TranslationZ;

            // Choose model
            EmbeddedModelBuilder.EmbeddedExample(model);

            // Boundary Conditions - Left End [End-1]
            for (int iNode = 1; iNode <= 400; iNode++)
            {
                //model.NodesDictionary[iNode].Constraints.Add(new Constraint { DOF = DOFType.X });
                //model.NodesDictionary[iNode].Constraints.Add(new Constraint { DOF = DOFType.Y });
                model.NodesDictionary[iNode].Constraints.Add(new Constraint {
                    DOF = StructuralDof.TranslationZ
                });
            }

            // Boundary Conditions - Bottom End [End-3] (y = -10)
            for (int iNode = 1; iNode <= 17601; iNode = iNode + 400)
            {
                for (int jj = 0; jj <= 19; jj++)
                {
                    model.NodesDictionary[iNode + jj].Constraints.Add(new Constraint {
                        DOF = StructuralDof.TranslationY
                    });
                }
            }

            // Boundary Conditions - Bottom End [End-5] (x = -10)
            for (int iNode = 1; iNode <= 17981; iNode = iNode + 20)
            {
                model.NodesDictionary[iNode].Constraints.Add(new Constraint {
                    DOF = StructuralDof.TranslationX
                });
            }

            // Compressive Loading - [End-4]
            double nodalLoad = -0.5; //-2.0; //

            for (int iNode = 17601; iNode <= 18000; iNode++)
            {
                model.Loads.Add(new Load()
                {
                    Amount = nodalLoad, Node = model.NodesDictionary[iNode], DOF = StructuralDof.TranslationZ
                });
            }

            // Choose linear equation system solver
            //var solverBuilder = new SkylineSolver.Builder();
            //SkylineSolver solver = solverBuilder.BuildSolver(model);
            var solverBuilder        = new SuiteSparseSolver.Builder();
            SuiteSparseSolver solver = solverBuilder.BuildSolver(model);

            // Choose the provider of the problem -> here a structural problem
            var provider = new ProblemStructural(model, solver);

            // Choose child analyzer -> Child: NewtonRaphsonNonLinearAnalyzer
            var childAnalyzerBuilder = new LoadControlAnalyzer.Builder(model, solver, provider, increments)
            {
                MaxIterationsPerIncrement     = 100,
                NumIterationsForMatrixRebuild = 1,
                ResidualTolerance             = 5E-3
            };
            LoadControlAnalyzer childAnalyzer = childAnalyzerBuilder.Build();

            // Choose parent analyzer -> Parent: Static
            var parentAnalyzer = new StaticAnalyzer(model, solver, provider, childAnalyzer);

            // Request output
            string outputFile = outputDirectory + "\\CNT-Embedded-3D_Results_NewtonRaphson.txt";
            var    logger     = new TotalLoadsDisplacementsPerIncrementLog(model.SubdomainsDictionary[subdomainID], increments,
                                                                           model.NodesDictionary[monitorNode], monitorDof, outputFile);

            childAnalyzer.IncrementalLogs.Add(subdomainID, logger);

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

            // Create Paraview File
            var paraview = new ParaviewEmbedded3D(model, solver.LinearSystems[0].Solution, "test");

            paraview.CreateParaviewFile();
        }