public static Dictionary <int, double[][]> CalculateKpfKffinverseKfpDqSubdomains(Dictionary <int, double[][]> f2_vectorsSubdomains, Model model, IElementMatrixProvider elementProvider, IScaleTransitions scaleTransitions, Dictionary <int, INode> boundaryNodes)
        {
            Dictionary <int, double[][]> f3_vectorsSubdomains = new Dictionary <int, double[][]>();

            foreach (Subdomain subdomain in model.Subdomains)
            {
                f3_vectorsSubdomains.Add(subdomain.ID, SubdomainCalculations.CalculateKpfKffinverseKfpDq(f2_vectorsSubdomains[subdomain.ID], subdomain, elementProvider, scaleTransitions, boundaryNodes));
            }
            return(f3_vectorsSubdomains);
        }
        //int currentSubdomainID;

        public (Dictionary <int, double[][]>, Dictionary <int, double[][]>) UpdateSubdomainKffAndCalculateKfpDqAndKppDqpMultipleObje(Model model, IElementMatrixProvider elementProvider, IScaleTransitions scaleTransitions,
                                                                                                                                     Dictionary <int, INode> boundaryNodes, Dictionary <int, Dictionary <int, Element> > boundaryElements, ISolver solver)
        {
            IReadOnlyDictionary <int, ILinearSystem> linearSystems = solver.LinearSystems; //v2.3

            Dictionary <int, double[][]> KfpDqSubdomains        = new Dictionary <int, double[][]>(model.SubdomainsDictionary.Count);
            Dictionary <int, double[][]> KppDqVectorsSubdomains = new Dictionary <int, double[][]>(model.SubdomainsDictionary.Count);

            this.boundaryElements = boundaryElements;
            this.boundaryNodes    = boundaryNodes;
            this.scaleTransitions = scaleTransitions;

            KfpDqVectors = new Dictionary <int, double[][]>(model.SubdomainsDictionary.Count);
            KppDqVectors = new Dictionary <int, double[][]>(model.SubdomainsDictionary.Count);
            foreach (Subdomain subdomain in model.Subdomains)
            {
                #region Create KfpDq and KppDq vectors
                KfpDqVectors[subdomain.ID] = new double[scaleTransitions.MacroscaleVariableDimension()][];
                for (int j1 = 0; j1 < scaleTransitions.MacroscaleVariableDimension(); j1++)
                {
                    KfpDqVectors[subdomain.ID][j1] = new double[subdomain.FreeDofOrdering.NumFreeDofs]; //v2.2 subdomain.TotalDOFs];
                }

                KppDqVectors[subdomain.ID] = new double[scaleTransitions.MacroscaleVariableDimension()][];
                boundaryNodesOrder         = SubdomainCalculations.GetNodesOrderInDictionary(boundaryNodes);
                for (int j1 = 0; j1 < scaleTransitions.MacroscaleVariableDimension(); j1++)
                {
                    KppDqVectors[subdomain.ID][j1] = new double[boundaryNodesOrder.Count * scaleTransitions.PrescribedDofsPerNode()]; // h allliws subdomain.Forces.GetLength(0)
                }
                #endregion
            }

            var StiffnessProvider = new StiffnessProviderSimu(this);
            Dictionary <int, IMatrix> subdomainKs = solver.BuildGlobalMatrices(StiffnessProvider);

            foreach (Subdomain subdomain in model.Subdomains)
            {
                //dofOrdering = subdomain.FreeDofOrdering; //.1
                //FreeDofs = subdomain.FreeDofOrdering.FreeDofs;//.1 nodalDOFsDictionary = subdomain.NodalDOFsDictionary;
                //currentSubdomainID = subdomain.ID;



                //v2.4 var subdomainK= GlobalMatrixAssemblerSkyline.CalculateFreeFreeGlobalMatrix(subdomain, StiffnessProvider);

                linearSystems[subdomain.ID].Matrix = subdomainKs[subdomain.ID];
                //v2.5 linearSystems[subdomain.ID].Matrix = subdomainK;

                KfpDqSubdomains.Add(subdomain.ID, KfpDqVectors[subdomain.ID]);
                KppDqVectorsSubdomains.Add(subdomain.ID, KppDqVectors[subdomain.ID]);
            }

            return(KfpDqSubdomains, KppDqVectorsSubdomains);
        }
        public static Dictionary <int, double[]> CalculateFppReactionsVectorSubdomains(Model model, IElementMatrixProvider elementProvider,
                                                                                       IScaleTransitions scaleTransitions, Dictionary <int, INode> boundaryNodes, Dictionary <int, IVector> solution, Dictionary <int, IVector> dSolution,
                                                                                       Dictionary <int, Dictionary <IDofType, double> > initialConvergedBoundaryDisplacements, Dictionary <int, Dictionary <IDofType, double> > totalBoundaryDisplacements,
                                                                                       int nIncrement, int totalIncrements)
        {
            Dictionary <int, double[]> FppReactionVectorSubdomains = new Dictionary <int, double[]>();

            foreach (Subdomain subdomain in model.Subdomains)
            {
                FppReactionVectorSubdomains.Add(subdomain.ID, SubdomainCalculations.CalculateFppReactionsVector(subdomain, elementProvider, scaleTransitions, boundaryNodes,
                                                                                                                solution[subdomain.ID], dSolution[subdomain.ID], initialConvergedBoundaryDisplacements, totalBoundaryDisplacements, nIncrement, totalIncrements));
            }

            return(FppReactionVectorSubdomains);
        }