private static IVectorView[] SolveModelsWithNewmark(Model[] models, IModelReader[] modelReaders) { Vector[] initialValues = new Vector[models.Length]; var value0 = new Dictionary <int, double[]>(); for (int i = 0; i < models.Length; i++) { double[] v0 = new double[models[i].Nodes.Count]; value0.Add(i, v0); } foreach (Node node in models[0].Nodes) { value0[0][node.ID] = 1; } DenseMatrixSolver[] solvers = new DenseMatrixSolver[models.Length]; IConvectionDiffusionIntegrationProvider[] providers = new IConvectionDiffusionIntegrationProvider[models.Length]; IChildAnalyzer[] childAnalyzers = new IChildAnalyzer[models.Length]; for (int i = 0; i < models.Length; i++) { initialValues[i] = Vector.CreateFromArray(value0[i]); //var builder = new DenseMatrixSolver.Builder(); builder.IsMatrixPositiveDefinite = false; solvers[i] = builder.BuildSolver(models[i]); providers[i] = new ProblemConvectionDiffusion2(models[i], solvers[i]); childAnalyzers[i] = new LinearAnalyzer(models[i], solvers[i], providers[i]); } const double timestep = .1; const double time = 3; var parentAnalyzer = new ConvectionDiffusionImplicitDynamicAnalyzerMultiModel(UpdateModels, models, solvers, providers, childAnalyzers, timestep, time, initialTemperature: initialValues); parentAnalyzer.Initialize(); var structuralModel = CreateStructuralModel(3e4, 0, new DynamicMaterial(.001, 0, 0, true), 0, new double[] { 1000, 0, 0 }, 1).Item1; // new Model(); var structuralSolver = structuralBuilder.BuildSolver(structuralModel); var structuralProvider = new ProblemStructural(structuralModel, structuralSolver); //var structuralChildAnalyzer = new LinearAnalyzer(structuralModel, structuralSolver, structuralProvider); var increments = 2; var structuralChildAnalyzerBuilder = new LoadControlAnalyzer.Builder(structuralModel, structuralSolver, structuralProvider, increments); structuralChildAnalyzerBuilder.ResidualTolerance = 1E-6; structuralChildAnalyzerBuilder.MaxIterationsPerIncrement = 50; structuralChildAnalyzerBuilder.NumIterationsForMatrixRebuild = 1; //childAnalyzerBuilder.SubdomainUpdaters = new[] { new NonLinearSubdomainUpdater(model.SubdomainsDictionary[subdomainID]) }; // This is the default LoadControlAnalyzer structuralChildAnalyzer = structuralChildAnalyzerBuilder.Build(); var structuralParentAnalyzer = new NewmarkDynamicAnalyzer(UpdateNewmarkModel, structuralModel, structuralSolver, structuralProvider, structuralChildAnalyzer, timestep, time, 0.25, .5); structuralParentAnalyzer.Initialize(); for (int i = 0; i < time / timestep; i++) { parentAnalyzer.SolveTimestep(i); structuralParentAnalyzer.SolveTimestep(i); } return(solvers.Select(x => x.LinearSystems[subdomainID].Solution).ToArray()); }
private static IVectorView SolveModel(Model model, IModelReader modelReader) { var builder = new SkylineSolver.Builder(); //builder.IsMatrixPositiveDefinite = false; var solver = builder.BuildSolver(model); const double timestep = 1; const double time = 100; var provider = new ProblemStructural(model, solver); var increments = 2; var childAnalyzerBuilder = new LoadControlAnalyzer.Builder(model, solver, provider, increments); childAnalyzerBuilder.ResidualTolerance = 1E-6; childAnalyzerBuilder.MaxIterationsPerIncrement = 50; childAnalyzerBuilder.NumIterationsForMatrixRebuild = 1; LoadControlAnalyzer childAnalyzer = childAnalyzerBuilder.Build(); //var parentAnalyzerBuilder = new NewmarkDynamicAnalyzer.Builder(model, solver, provider, childAnalyzer, timestep, time); //parentAnalyzerBuilder.SetNewmarkParametersForConstantAcceleration(); //NewmarkDynamicAnalyzer parentAnalyzer = parentAnalyzerBuilder.Build(); var parentAnalyzer = new NewmarkDynamicAnalyzer(UpdateNewmarkModel, model, solver, provider, childAnalyzer, timestep, time, .25, .5); parentAnalyzer.Initialize(); for (int i = 0; i < time / timestep; i++) { //lambdag = .01 * i + 1; parentAnalyzer.SolveTimestep(i); } return(solver.LinearSystems[subdomainID].Solution); }