public QuasiStaticCrackPropagationAnalyzer(XModel model, ISolver solver, /*IStaticProvider problem,*/ ICrackDescription crack, double fractureToughness, int maxIterations) { this.model = model; this.solver = solver; this.linearSystems = solver.LinearSystems; //this.problem = problem; this.crack = crack; this.fractureToughness = fractureToughness; this.maxIterations = maxIterations; //TODO: Refactor problem structural and remove the next problem = new ElementStructuralStiffnessProvider(); loadsAssembler = new DirichletEquivalentLoadsStructural(problem);; }
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); }
private void BuildKs() { ks = new Dictionary <int, IMatrix2D <double> >(model.SubdomainsDictionary.Count); //ks.Add(1, new SkylineMatrix2D<double>(new double[,] { { 6, -2 }, { -2, 4 } })); ElementStructuralStiffnessProvider s = new ElementStructuralStiffnessProvider(); //foreach (Subdomain subdomain in model.SubdomainsDictionary.Values) // ks.Add(subdomain.ID, GlobalMatrixAssemblerSkyline.CalculateGlobalMatrix(subdomain, s)); //var kks = new Dictionary<int, IMatrix2D<double>>(model.SubdomainsDictionary.Count); int procs = VectorExtensions.AffinityCount; var k = model.SubdomainsDictionary.Keys.Select(x => x).ToArray <int>(); var internalKs = new Dictionary <int, IMatrix2D <double> > [procs]; Parallel.ForEach(k.PartitionLimits(procs), limit => { if (limit.Item3 - limit.Item2 > 0) { internalKs[limit.Item1] = new Dictionary <int, IMatrix2D <double> >(limit.Item3 - limit.Item2); for (int i = limit.Item2; i < limit.Item3; i++) { internalKs[limit.Item1].Add(k[i], GlobalMatrixAssemblerSkyline.CalculateGlobalMatrix(model.SubdomainsDictionary[k[i]], s)); } } else { internalKs[limit.Item1] = new Dictionary <int, IMatrix2D <double> >(); } }); for (int i = 0; i < procs; i++) { foreach (int key in internalKs[i].Keys) { ks.Add(key, internalKs[i][key]); } } }
public void CalculateOriginalConstitutiveMatrixWithoutNLAnalysis() { ISolver solver; if (matrices_not_initialized) { this.InitializeMatrices(); this.InitializeData(); solver = createSolver(model); solver.OrderDofs(false); foreach (ILinearSystem linearSystem in solver.LinearSystems.Values) { linearSystem.Reset(); //TODO find out if new structures cause any problems linearSystem.Subdomain.Forces = Vector.CreateZero(linearSystem.Size); } this.InitializeFreeAndPrescribedDofsInitialDisplacementVectors(); } else { solver = createSolver(model); solver.OrderDofs(false); //v2.1. TODO: Is this needed in this case? foreach (ILinearSystem linearSystem in solver.LinearSystems.Values) { linearSystem.Reset(); } //solver.ResetSubdomainForcesVector(); } var elementProvider = new ElementStructuralStiffnessProvider(); #region INTEGRATION constitutive Matrix var integrationSimultaneous = new SubdomainCalculationsAndAssembly(); (Dictionary <int, double[][]> KfpDqSubdomains, Dictionary <int, double[][]> KppDqVectorsSubdomains) = integrationSimultaneous.UpdateSubdomainKffAndCalculateKfpDqAndKppDqpMultipleObje(model, elementProvider, scaleTransitions, boundaryNodes, boundaryElements, solver); Dictionary <int, double[][]> f2_vectorsSubdomains = SubdomainCalculationsMultiple.CalculateKffinverseKfpDqSubdomains(KfpDqSubdomains, model, elementProvider, scaleTransitions, boundaryNodes, solver); Dictionary <int, double[][]> f3_vectorsSubdomains = SubdomainCalculationsMultiple.CalculateKpfKffinverseKfpDqSubdomains(f2_vectorsSubdomains, model, elementProvider, scaleTransitions, boundaryNodes); double[][] f3_vectors = SubdomainCalculationsMultiple.CombineMultipleSubdomainsIntegrationVectorsIntoTotal(f3_vectorsSubdomains, scaleTransitions); double[][] KppDqVectors = SubdomainCalculationsMultiple.CombineMultipleSubdomainsIntegrationVectorsIntoTotal(KppDqVectorsSubdomains, scaleTransitions); double[][] f4_vectors = SubdomainCalculations.SubtractConsecutiveVectors(KppDqVectors, f3_vectors); double[,] DqCondDq = SubdomainCalculations.CalculateDqCondDq(f4_vectors, scaleTransitions, boundaryNodes); double[,] d2W_dfdf = new double[DqCondDq.GetLength(0), DqCondDq.GetLength(1)]; for (int i1 = 0; i1 < DqCondDq.GetLength(0); i1++) { for (int i2 = 0; i2 < DqCondDq.GetLength(1); i2++) { d2W_dfdf[i1, i2] = (1 / volume) * DqCondDq[i1, i2]; } } #endregion #region constitutive tensors transformation methods double[,] d2W_dFtrdFtr = Reorder_d2Wdfdf_to_d2W_dFtrdFtr(d2W_dfdf); double[,] SPK_mat = new double[3, 3] { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; double[,] DefGradMat = new double[3, 3] { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; double[,] Cinpk = Transform_d2WdFtrdFtr_to_Cijrs(d2W_dFtrdFtr, SPK_mat, DefGradMat); // to onomazoume Cinpk epeidh einai to 9x9 kai to diakrinoume etsi apo to Cijrs 6x6 double[,] Cijrs = CombineCinpkTensorTermsIntoMatrix(Cinpk); constitutiveMatrix = Matrix.CreateFromArray(Cijrs); #endregion //PrintMethodsForDebug(KfpDq, f2_vectors, f3_vectors, KppDqVectors, f4_vectors, DqCondDq, d2W_dfdf, Cijrs); this.modified = CheckIfConstitutiveMatrixChanged(); if (EstimateOnlyLinearResponse) { model = null; boundaryElements = null; boundaryNodes = null; rveBuilder = null; uInitialFreeDOFDisplacementsPerSubdomain = null; initialConvergedBoundaryDisplacements = null; Cijrs_prev = null; } }
public void CalculateOriginalConstitutiveMatrixWithoutNLAnalysis() { ISolver solver; if (matrices_not_initialized) { this.InitializeMatrices(); this.InitializeData(); solver = createSolver(model); solver.OrderDofs(false); //model.GlobalDofOrdering = solver.DofOrderer.OrderDofs(model); //TODO find out if new structures cause any problems foreach (ILinearSystem linearSystem in solver.LinearSystems.Values) { linearSystem.Reset(); linearSystem.Subdomain.Forces = Vector.CreateZero(linearSystem.Size); } this.InitializeFreeAndPrescribedDofsInitialDisplacementVectors(); } else { solver = createSolver(model); solver.OrderDofs(false); //v2.1. TODO: Is this needed in this case? foreach (ILinearSystem linearSystem in solver.LinearSystems.Values) { linearSystem.Reset(); } //solver.ResetSubdomainForcesVector(); } trueStressVec = new double[3]; var elementProvider = new ElementStructuralStiffnessProvider(); #region INTEGRATION constitutive Matrix var integrationSimultaneous = new SubdomainCalculationsAndAssembly(); (Dictionary <int, double[][]> KfpDqSubdomains, Dictionary <int, double[][]> KppDqVectorsSubdomains) = integrationSimultaneous.UpdateSubdomainKffAndCalculateKfpDqAndKppDqpMultipleObje(model, elementProvider, scaleTransitions, boundaryNodes, boundaryElements, solver); Dictionary <int, double[][]> f2_vectorsSubdomains = SubdomainCalculationsMultiple.CalculateKffinverseKfpDqSubdomains(KfpDqSubdomains, model, elementProvider, scaleTransitions, boundaryNodes, solver); Dictionary <int, double[][]> f3_vectorsSubdomains = SubdomainCalculationsMultiple.CalculateKpfKffinverseKfpDqSubdomains(f2_vectorsSubdomains, model, elementProvider, scaleTransitions, boundaryNodes); double[][] f3_vectors = SubdomainCalculationsMultiple.CombineMultipleSubdomainsIntegrationVectorsIntoTotal(f3_vectorsSubdomains, scaleTransitions); double[][] KppDqVectors = SubdomainCalculationsMultiple.CombineMultipleSubdomainsIntegrationVectorsIntoTotal(KppDqVectorsSubdomains, scaleTransitions); double[][] f4_vectors = SubdomainCalculations.SubtractConsecutiveVectors(KppDqVectors, f3_vectors); double[,] DqCondDq = SubdomainCalculations.CalculateDqCondDq(f4_vectors, scaleTransitions, boundaryNodes); double[,] constitutiveMat = new double[DqCondDq.GetLength(0), DqCondDq.GetLength(1)]; for (int i1 = 0; i1 < DqCondDq.GetLength(0); i1++) { for (int i2 = 0; i2 < DqCondDq.GetLength(1); i2++) { constitutiveMat[i1, i2] = (1 / volume) * DqCondDq[i1, i2]; } } #endregion #region constitutive tensors transformation methods // transformation gia to shell (var transformedTrueStressVec, var transformedConstitutiveMat) = StressesAndConstitutiveMatrixTransformation(trueStressVec, constitutiveMat); this.constitutiveMatrix = Matrix.CreateFromArray(transformedConstitutiveMat); trueStressVec = transformedTrueStressVec; #endregion //PrintMethodsForDebug(KfpDq, f2_vectors, f3_vectors, KppDqVectors, f4_vectors, DqCondDq, d2W_dfdf, Cijrs); this.modified = CheckIfConstitutiveMatrixChanged(); if (EstimateOnlyLinearResponse) { model = null; boundaryElements = null; boundaryNodes = null; NormalVectorV3 = null; TangentVectorV1 = null; TangentVectorV2 = null; rveBuilder = null; uInitialFreeDOFDisplacementsPerSubdomain = null; initialConvergedBoundaryDisplacements = null; trueStressVec = null; transformationMatrix = null; Cijrs_prev = null; } }
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); }