Beispiel #1
0
        public virtual (MicrostructureBvpNRNLAnalyzer, ProblemStructural, ElementStructuralStiffnessProvider) AnalyzeMicrostructure(Model model, ISolver solver,
                                                                                                                                    int increments, int MaxIterations, int IterationsForMatrixRebuild, Dictionary <int, Dictionary <IDofType, double> > totalPrescribedBoundaryDisplacements,
                                                                                                                                    Dictionary <int, Dictionary <IDofType, double> > initialConvergedBoundaryDisplacements, Dictionary <int, INode> boundaryNodes, Dictionary <int, IVector> uInitialFreeDOFDisplacementsPerSubdomain)
        {
            IReadOnlyDictionary <int, ILinearSystem> linearSystems = solver.LinearSystems; //V2.1

            #region Creation of nessesary analyzers for NRNLAnalyzer
            ProblemStructural provider = new ProblemStructural(model, solver);

            var subdomainUpdaters = new Dictionary <int, NonLinearSubdomainUpdaterWithInitialConditions>(1); //v2.2
            //var subdomainUpdaters = new NonLinearSubdomainUpdaterWithInitialConditions[totalSubdomains];

            foreach (Subdomain subdomain in model.Subdomains)                                                       //TODO : or else "in model.SubdomainsDictionary.Values)"
            {
                subdomainUpdaters.Add(subdomain.ID, new NonLinearSubdomainUpdaterWithInitialConditions(subdomain)); //v2.3
                //subdomainUpdaters[counter] = new NonLinearSubdomainUpdaterWithInitialConditions(subdomain);
            }

            ElementStructuralStiffnessProvider elementProvider = new ElementStructuralStiffnessProvider();

            //v2.4
            Dictionary <int, EquivalentContributionsAssebler> equivalentContributionsAssemblers = new Dictionary <int, EquivalentContributionsAssebler>();//SUNOLIKA STOIXEIA model.SubdomainsDictionary.Count oi oles tis model.subdomains ekei mallon deginontai access me ID.
            //equivalentContributionsAssemblers.Add(model.SubdomainsDictionary[1].ID, new EquivalentContributionsAssebler(model.SubdomainsDictionary[1], elementProvider));
            foreach (Subdomain subdomain in model.SubdomainsDictionary.Values)
            {
                equivalentContributionsAssemblers.Add(subdomain.ID, new EquivalentContributionsAssebler(subdomain, elementProvider)); //v2.5
            }
            #endregion

            #region Creation of Microstructure analyzer (NRNLdevelop temporarilly).
            MicrostructureBvpNRNLAnalyzer microAnalyzer = new MicrostructureBvpNRNLAnalyzer(model, solver, subdomainUpdaters,
                                                                                            provider, increments, uInitialFreeDOFDisplacementsPerSubdomain,
                                                                                            boundaryNodes, initialConvergedBoundaryDisplacements, totalPrescribedBoundaryDisplacements, equivalentContributionsAssemblers);
            microAnalyzer.SetMaxIterations = MaxIterations;
            microAnalyzer.SetIterationsForMatrixRebuild = IterationsForMatrixRebuild;
            #endregion

            #region solution and update ------------->THA MPEI ENTOS KLASHS: of free converged displacements vectors;
            MSParentAnalyzer parentAnalyzer = new MSParentAnalyzer(model, solver, provider, microAnalyzer);
            //parentAnalyzer.BuildMatrices(); //v2.6 ston neon static analyzer den xreiazetai to build matrices poia
            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();
            #endregion

            return(microAnalyzer, provider, elementProvider);
        }
Beispiel #2
0
        public static (IVector, IVector) SolveDisplLoadsExample()
        {
            #region dhmiourgia montelou
            //VectorExtensions.AssignTotalAffinityCount();
            Model model = new Model();
            model.SubdomainsDictionary.Add(1, new Subdomain(1));
            // EPILOGH MONTELOU
            int model__builder_choice;
            model__builder_choice = 1;
            if (model__builder_choice == 1) //
            {
                HexaCantileverBuilderDispControl(model, 850);
            }
            model.ConnectDataStructures();
            #endregion

            ElementStructuralStiffnessProvider elementProvider = new ElementStructuralStiffnessProvider();
            Dictionary <int, EquivalentContributionsAssebler> equivalentContributionsAssemblers = new Dictionary <int, EquivalentContributionsAssebler>();//SUNOLIKA STOIXEIA model.SubdomainsDictionary.Count oi oles tis model.subdomains ekei mallon deginontai access me ID.
            equivalentContributionsAssemblers.Add(model.SubdomainsDictionary[1].ID, new EquivalentContributionsAssebler(model.SubdomainsDictionary[1], elementProvider));
            var solverBuilder = new SkylineSolver.Builder();
            solverBuilder.DofOrderer = new DofOrderer(new NodeMajorDofOrderingStrategy(), new NullReordering());
            var solver = solverBuilder.BuildSolver(model);
            solver.OrderDofs(false);
            foreach (ILinearSystem linearSystem in solver.LinearSystems.Values)
            {
                linearSystem.Reset();
                linearSystem.Subdomain.Forces = Vector.CreateZero(linearSystem.Size);
            }
            //kai dhmiourgia twn mhdenikwn dianusmatwn forces ligo parakatw

            //DdmCalculationsGeneral.BuildModelInterconnectionData(model);
            //var ordering1=solver.DofOrderer.OrderDofs(model);
            //DdmCalculationsGeneral.UndoModelInterconnectionDataBuild(model);

            #region create boundary nodes and create displacements for 1st increment
            Dictionary <int, IVector> uInitialFreeDOFDisplacementsPerSubdomain = new Dictionary <int, IVector>();
            uInitialFreeDOFDisplacementsPerSubdomain.Add(model.SubdomainsDictionary[1].ID, Vector.CreateZero(44));//ordering1.NumGlobalFreeDofs prosoxh sto Id twn subdomain
            Dictionary <int, INode> boundaryNodes = new Dictionary <int, INode>();
            for (int k = 17; k < 21; k++)
            {
                boundaryNodes.Add(model.NodesDictionary[k].ID, model.NodesDictionary[k]);
            }
            Dictionary <int, Dictionary <IDofType, double> > initialConvergedBoundaryDisplacements = new Dictionary <int, Dictionary <IDofType, double> >();
            Dictionary <IDofType, double> initialConvergedBoundaryNodalDisplacements = new Dictionary <IDofType, double>();
            initialConvergedBoundaryNodalDisplacements.Add(StructuralDof.TranslationX, 0);
            for (int k = 17; k < 21; k++)
            {
                initialConvergedBoundaryDisplacements.Add(model.NodesDictionary[k].ID, initialConvergedBoundaryNodalDisplacements);
            }
            Dictionary <int, Dictionary <IDofType, double> > totalBoundaryDisplacements = new Dictionary <int, Dictionary <IDofType, double> >();
            double[] prescribedDisplacmentXValues = new double[4] {
                7.81614E-01, 7.07355E-01, 7.81614E-01, 7.07355E-01
            };
            for (int k = 17; k < 21; k++)
            {
                Dictionary <IDofType, double> totalBoundaryNodalDisplacements = new Dictionary <IDofType, double>();
                totalBoundaryNodalDisplacements.Add(StructuralDof.TranslationX, 0.5 * prescribedDisplacmentXValues[k - 17]);
                totalBoundaryDisplacements.Add(model.NodesDictionary[k].ID, totalBoundaryNodalDisplacements);
            }
            #endregion

            #region create nesessary structures and analyzers And Solve 1st increment
            var linearSystems          = solver.LinearSystems; // elegxos me model.subdomainsDictionary[1]
            ProblemStructural provider = new ProblemStructural(model, solver);
            var subdomainUpdaters      = new Dictionary <int, NonLinearSubdomainUpdaterWithInitialConditions>(1);
            subdomainUpdaters.Add(1, new NonLinearSubdomainUpdaterWithInitialConditions(model.Subdomains[0]));
            var increments = 1;

            var childAnalyzer = new MicrostructureBvpNRNLAnalyzer(model, solver, subdomainUpdaters, provider, increments, uInitialFreeDOFDisplacementsPerSubdomain,
                                                                  boundaryNodes, initialConvergedBoundaryDisplacements, totalBoundaryDisplacements, equivalentContributionsAssemblers);
            childAnalyzer.SetMaxIterations = 100;
            childAnalyzer.SetIterationsForMatrixRebuild = 1;

            MSParentAnalyzer parentAnalyzer = new MSParentAnalyzer(model, solver, provider, childAnalyzer);
            //TODO MS
            //foreach (ILinearSystem linearSystem in solver.LinearSystems.Values)
            //{
            //    linearSystem.Subdomain.Forces = Vector.CreateZero(linearSystem.Size); // antistoixo tou subdomain.Forces = linearSystem.CreateZeroVector();
            //}
            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();
            IVector uInitialFreeDOFs_state1 = childAnalyzer.GetConvergedSolutionVectorsOfFreeDofs()[1].Copy();
            #endregion

            #region save state and update structures and vectors for second increment
            foreach (var subdomainUpdater in subdomainUpdaters.Values)
            {
                subdomainUpdater.UpdateState();
            }
            // u (or uplusDu) initial
            uInitialFreeDOFDisplacementsPerSubdomain = childAnalyzer.GetConvergedSolutionVectorsOfFreeDofs();// ousiastika to u pou twra taftizetai me to uPlusuu

            initialConvergedBoundaryDisplacements = totalBoundaryDisplacements;

            totalBoundaryDisplacements = new Dictionary <int, Dictionary <IDofType, double> >();
            for (int k = 17; k < 21; k++)
            {
                Dictionary <IDofType, double> totalBoundaryNodalDisplacements = new Dictionary <IDofType, double>();
                totalBoundaryNodalDisplacements.Add(StructuralDof.TranslationX, 1.0 * prescribedDisplacmentXValues[k - 17]);
                totalBoundaryDisplacements.Add(model.NodesDictionary[k].ID, totalBoundaryNodalDisplacements);
            }
            #endregion

            #region Creation of nessesary analyzers and solution
            ElementStructuralStiffnessProvider elementProvider2 = new ElementStructuralStiffnessProvider();
            Dictionary <int, EquivalentContributionsAssebler> equivalentContributionsAssemblers2 = new Dictionary <int, EquivalentContributionsAssebler>();//SUNOLIKA STOIXEIA model.SubdomainsDictionary.Count oi oles tis model.subdomains ekei mallon deginontai access me ID.
            equivalentContributionsAssemblers2.Add(model.SubdomainsDictionary[1].ID, new EquivalentContributionsAssebler(model.SubdomainsDictionary[1], elementProvider2));
            var solverBuilder2 = new SkylineSolver.Builder();
            solverBuilder2.DofOrderer = new DofOrderer(new NodeMajorDofOrderingStrategy(), new NullReordering());
            ISolver solver2 = solverBuilder2.BuildSolver(model);
            solver2.OrderDofs(false);
            foreach (ILinearSystem linearSystem in solver2.LinearSystems.Values)
            {
                linearSystem.Reset();
            }
            //kalutera apotelesmata otan to parakatw den kratietai, ara pragmati resets ta subd.forces
            //solver.ResetSubdomainForcesVector();
            var linearSystems2 = solver2.LinearSystems; // elegxos me model.subdomainsDictionary[1]
            foreach (ILinearSystem linearSystem in linearSystems2.Values)
            {
                linearSystem.RhsVector = linearSystem.Subdomain.Forces; //TODO MS
            }
            ProblemStructural provider2 = new ProblemStructural(model, solver2);
            //var linearSystemsArray = new[] { linearSystems[1] };
            var subdomainUpdaters2 = new Dictionary <int, NonLinearSubdomainUpdaterWithInitialConditions>(1);
            subdomainUpdaters2.Add(1, new NonLinearSubdomainUpdaterWithInitialConditions(model.Subdomains[0]));
            //var subdomainMappers = new[] { new SubdomainGlobalMapping(model.Subdomains[0]) };
            var increments2 = 1;

            var childAnalyzer2 = new MicrostructureBvpNRNLAnalyzer(model, solver2, subdomainUpdaters2, provider2, increments2, uInitialFreeDOFDisplacementsPerSubdomain,
                                                                   boundaryNodes, initialConvergedBoundaryDisplacements, totalBoundaryDisplacements, equivalentContributionsAssemblers2);
            childAnalyzer2.SetMaxIterations = 100;
            childAnalyzer2.SetIterationsForMatrixRebuild = 1;

            MSParentAnalyzer parentAnalyzer2 = new MSParentAnalyzer(model, solver2, provider2, childAnalyzer2);
            //parentAnalyzer2.BuildMatrices();
            //DdmCalculationsGeneral.UndoModelInterconnectionDataBuild(model);
            childAnalyzer2.Initialize(); //parentAnalyzer2.Initialize();
            parentAnalyzer2.Solve();
            IVector uInitialFreeDOFs_state2 = childAnalyzer.GetConvergedSolutionVectorsOfFreeDofs()[1].Copy();
            #endregion

            return(uInitialFreeDOFs_state1, uInitialFreeDOFs_state2);
        }