コード例 #1
0
        private NewmarkDynamicAnalyzer(IStructuralModel model, ISolver solver, IImplicitIntegrationProvider provider,
                                       IChildAnalyzer childAnalyzer, double timeStep, double totalTime, double alpha, double delta)
        {
            this.model         = model;
            this.linearSystems = solver.LinearSystems;
            this.solver        = solver;
            this.provider      = provider;
            this.ChildAnalyzer = childAnalyzer;
            this.beta          = alpha;
            this.gamma         = delta;
            this.timeStep      = timeStep;
            this.totalTime     = totalTime;
            this.ChildAnalyzer.ParentAnalyzer = this;

            // Initialize coefficients. It would make sense for them to be initialized in a different function, if they could
            // change during the analysis
            a0 = 1 / (alpha * timeStep * timeStep);
            a1 = delta / (alpha * timeStep);
            a2 = 1 / (alpha * timeStep);
            a3 = 1 / (2 * alpha) - 1;
            a4 = delta / alpha - 1;
            a5 = timeStep * 0.5 * (delta / alpha - 2);
            a6 = timeStep * (1 - delta);
            a7 = delta * timeStep;
        }
コード例 #2
0
        public void SolveTimestep(int i)
        {
            Debug.WriteLine("Newmark step: {0}", i);

            if (CreateNewModel != null)
            {
                CreateNewModel(uu, uc, v, modelsForReplacement, solversForReplacement, providersForReplacement, childAnalyzersForReplacement);
                model         = modelsForReplacement[0];
                solver        = solversForReplacement[0];
                linearSystems = solver.LinearSystems;
                provider      = providersForReplacement[0];
                ChildAnalyzer = childAnalyzersForReplacement[0];
                ChildAnalyzer.ParentAnalyzer = this;

                InitializeInternal(true);
            }
            IDictionary <int, IVector> rhsVectors = provider.GetRhsFromHistoryLoad(i);

            foreach (var l in linearSystems.Values)
            {
                l.RhsVector = rhsVectors[l.Subdomain.ID];
            }
            InitializeRhs();
            CalculateRhsImplicit();

            DateTime start = DateTime.Now;

            ChildAnalyzer.Solve();
            DateTime end = DateTime.Now;

            UpdateVelocityAndAcceleration(i);
            UpdateResultStorages(start, end);
            // Print output results in *.txt file
            string path0 = Path.Combine(Directory.GetCurrentDirectory(), "MsolveOutput");
            var    path2 = Path.Combine(path0, $"MSolveHyperelasticDynamicsImplicitResults.txt");

            using (var fileName = new StreamWriter(path2, true))
            {
                double currentTime      = ((i + 1) * timeStep);
                string strTimeStep      = currentTime.ToString();
                var    totalSolution    = ChildAnalyzer.Responses[0][1];
                string strTotalSolution = totalSolution.ToString();
                fileName.WriteLine(strTimeStep + ", " + strTotalSolution);
            }
            //if (CreateNewModel != null)
            //{
            //    CreateNewModel(uu, uc, v, modelsForReplacement, solversForReplacement, providersForReplacement, childAnalyzersForReplacement);
            //    model = modelsForReplacement[0];
            //    solver = solversForReplacement[0];
            //    linearSystems = solver.LinearSystems;
            //    provider = providersForReplacement[0];
            //    ChildAnalyzer = childAnalyzersForReplacement[0];
            //    ChildAnalyzer.ParentAnalyzer = this;

            //    InitializeInternal(true);
            //}
        }
コード例 #3
0
            private double beta = 0.25, gamma = 0.5; // constant acceleration is the default

            public Builder(IStructuralModel model, ISolver solver, IImplicitIntegrationProvider provider,
                           IChildAnalyzer childAnalyzer, double timeStep, double totalTime)
            {
                this.model         = model;
                this.solver        = solver;
                this.provider      = provider;
                this.childAnalyzer = childAnalyzer;

                this.timeStep  = timeStep;
                this.totalTime = totalTime;
            }
コード例 #4
0
 public NewmarkDynamicAnalyzer(IImplicitIntegrationProvider provider, IAnalyzer embeddedAnalyzer, IDictionary <int, ISolverSubdomain> subdomains,
                               double alpha, double delta, double timeStep, double totalTime)
 {
     this.provider      = provider;
     this.childAnalyzer = embeddedAnalyzer;
     this.subdomains    = subdomains;
     this.alpha         = alpha;
     this.delta         = delta;
     this.timeStep      = timeStep;
     this.totalTime     = totalTime;
     this.childAnalyzer.ParentAnalyzer = this;
 }
コード例 #5
0
 /// <summary>
 /// Creates an instance that uses a specific problem type and an appropriate child analyzer for the construction of the system of equations arising from the actual physical problem
 /// </summary>
 /// <param name="model">Instance of the model to be solved</param>
 /// <param name="solver">Instance of the solver that will handle the solution of the system of equations</param>
 /// <param name="provider">Instance of the problem type to be solver</param>
 /// <param name="childAnalyzer">Instance of the child analyzer that will handle the solution of the system of equations</param>
 /// <param name="beta">Instance of parameter "beta" of the method that will be initialized</param>
 /// <param name="timeStep">Instance of the time step of the method that will be initialized</param>
 /// <param name="totalTime">Instance of the total time of the method that will be initialized</param>
 public ThermalDynamicAnalyzer(IModel model, ISolver solver, IImplicitIntegrationProvider provider,
                               IChildAnalyzer childAnalyzer, double beta, double timeStep, double totalTime)
 {
     this.model         = model;
     this.linearSystems = solver.LinearSystems;
     this.solver        = solver;
     this.provider      = provider;
     this.ChildAnalyzer = childAnalyzer;
     this.beta          = beta;
     this.timeStep      = timeStep;
     this.totalTime     = totalTime;
     this.ChildAnalyzer.ParentAnalyzer = this;
 }
コード例 #6
0
 public ODEDynamicAnalyzer(IStructuralModel model, ISolver solver, IImplicitIntegrationProvider provider,
                           IChildAnalyzer childAnalyzer, double beta, double timeStep, double totalTime, IVector initialValue = null)
 {
     this.model         = model;
     this.linearSystems = solver.LinearSystems;
     this.solver        = solver;
     //solver.PreventFromOverwrittingSystemMatrices(); //TODO: If the scheme is purely implicit we can overwrite the matrix.
     this.provider      = provider;
     this.ChildAnalyzer = childAnalyzer;
     this.beta          = beta;
     this.timeStep      = timeStep;
     this.totalTime     = totalTime;
     this.ChildAnalyzer.ParentAnalyzer = this;
 }
        private static IVectorView[] SolveModels(Model[] models)
        {
            SkylineSolver[] solvers = new SkylineSolver[models.Length];
            IImplicitIntegrationProvider[] providers = new IImplicitIntegrationProvider[models.Length];
            IChildAnalyzer[] childAnalyzers          = new IChildAnalyzer[models.Length];
            for (int i = 0; i < models.Length; i++)
            {
                //var builder = new DenseMatrixSolver.Builder();
                solvers[i]        = builder.BuildSolver(models[i]);
                providers[i]      = new ProblemStructural(models[i], solvers[i]);
                childAnalyzers[i] = new LinearAnalyzer(models[i], solvers[i], providers[i]);
            }

            var parentAnalyzer = new NewmarkDynamicAnalyzerMultiModel(UpdateModels, models, solvers, providers, childAnalyzers, 0.28, 3.36, .25, .5);

            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();

            return(solvers.Select(x => x.LinearSystems[subdomainID].Solution).ToArray());
        }
コード例 #8
0
        public void SolveTimestep(int i)
        {
            Debug.WriteLine("Newmark step: {0}", i);

            if (CreateNewModel != null)
            {
                CreateNewModel(uu, uc, v, modelsForReplacement, solversForReplacement, providersForReplacement, childAnalyzersForReplacement);
                model         = modelsForReplacement[0];
                solver        = solversForReplacement[0];
                linearSystems = solver.LinearSystems;
                provider      = providersForReplacement[0];
                ChildAnalyzer = childAnalyzersForReplacement[0];
                ChildAnalyzer.ParentAnalyzer = this;

                InitializeInternal(true);
            }
            IDictionary <int, IVector> rhsVectors = provider.GetRhsFromHistoryLoad(i);

            foreach (var l in linearSystems.Values)
            {
                l.RhsVector = rhsVectors[l.Subdomain.ID];
            }
            InitializeRhs();
            CalculateRhsImplicit();

            DateTime start = DateTime.Now;

            ChildAnalyzer.Solve();
            DateTime end = DateTime.Now;

            UpdateVelocityAndAcceleration(i);
            UpdateResultStorages(start, end);
            // Print output results in *.txt file
            if (i == 0)
            {
                using (var fileName = new StreamWriter(path))
                {
                    double currentTime   = ((i + 1) * timeStep);
                    string strTimeStep   = currentTime.ToString();
                    var    totalSolution = ChildAnalyzer.Responses[0][62]; //mesh446elem
                    //var totalSolution = ChildAnalyzer.Responses[0][1]; //meshXXCoarse254elem
                    //var totalSolution = ChildAnalyzer.Responses[0][57]; //meshXXCoarse
                    //var totalSolution = ChildAnalyzer.Responses[0][0]; //106TetCube100m
                    //var totalSolution = ChildAnalyzer.Responses[0][19]; //261TetCube100m
                    //var totalSolution = ChildAnalyzer.Responses[0][1]; //125HexaHyperelasticCube100m
                    //var totalSolution = ChildAnalyzer.Responses[0][13]; //4HexaHyperelasticCube100m
                    //var totalSolution = ChildAnalyzer.Responses[0][0]; //1Hexa
                    string strTotalSolution = totalSolution.ToString();
                    fileName.WriteLine(strTimeStep + " " + strTotalSolution);
                }
            }
            else
            {
                using (var fileName = new StreamWriter(path, true))
                {
                    double currentTime   = ((i + 1) * timeStep);
                    string strTimeStep   = currentTime.ToString();
                    var    totalSolution = ChildAnalyzer.Responses[0][62]; //mesh446elem
                    //var totalSolution = ChildAnalyzer.Responses[0][1]; //meshXXCoarse254elem
                    //var totalSolution = ChildAnalyzer.Responses[0][57]; //meshXXCoarse
                    //var totalSolution = ChildAnalyzer.Responses[0][0]; //106TetCube100m
                    //var totalSolution = ChildAnalyzer.Responses[0][19]; //261TetCube100m
                    //var totalSolution = ChildAnalyzer.Responses[0][1]; //125HexaHyperelasticCube100m
                    //var totalSolution = ChildAnalyzer.Responses[0][13]; //4HexaHyperelasticCube100m
                    //var totalSolution = ChildAnalyzer.Responses[0][0]; //1Hexa
                    string strTotalSolution = totalSolution.ToString();
                    fileName.WriteLine(strTimeStep + " " + strTotalSolution);
                }
            }
        }