Exemplo n.º 1
0
        public static void CheckModel(Model model, LoadCase lc)
        {
            model.ReIndexNodes();
            //LoadCase.DefaultLoadCase

            var fullst = MatrixAssemblerUtil.AssembleFullStiffnessMatrix(model);

            var mgr = DofMappingManager.Create(model, lc);

            var dvd = CalcUtil.GetReducedZoneDividedMatrix(fullst, mgr);

            var stiffness = dvd.ReleasedReleasedPart;


            var n = stiffness.ColumnCount;

            for (int i = 0; i < n; i++)
            {
                var t = stiffness.At(i, i);

                if (t > 0)
                {
                    continue;
                }

                var m1 = mgr.RMap2[i];
                var m2 = mgr.RMap1[m1];

                var nodeNum = m2 / 6;

                if (t == 0)
                {
                    model.Trace.Write(Common.TraceLevel.Warning, "DoF {0} of Node {1} not properly constrained", m2 % 6, nodeNum);
                }
                else//t < 0
                {
                    model.Trace.Write(Common.TraceLevel.Warning, "DoF {0} of Node {1} not member", m2 % 6, nodeNum);
                }
            }

            var k = MatrixAssemblerUtil.AssembleFullStiffnessMatrix(model);
            //CalcUtil.MakeMatrixSymetric(k);


            var kt = k.Transpose();

            Enumerable.Range(0, k.Values.Length).ToList().ForEach(i => kt.Values[i] = -kt.Values[i]);

            var sym = k.Add(kt);



            var max = sym.Values.Max(i => Math.Abs(i));
        }
Exemplo n.º 2
0
        public static void FixUnrestrainedDofs(Model model, LoadCase lc)
        {
            model.ReIndexNodes();


            var fullst = MatrixAssemblerUtil.AssembleFullStiffnessMatrix(model);

            var mgr = DofMappingManager.Create(model, lc);

            var dvd = CalcUtil.GetReducedZoneDividedMatrix(fullst, mgr);

            var stiffness = dvd.ReleasedReleasedPart;


            var n = stiffness.ColumnCount;

            for (int i = 0; i < n; i++)
            {
                var t = stiffness.At(i, i);

                if (t > 0)
                {
                    continue;
                }

                var m1 = mgr.RMap2[i];
                var m2 = mgr.RMap1[m1];

                var nodeNum = m2 / 6;

                var targetDof = (DoF)(m2 % 6);

                var nde = model.Nodes[nodeNum];

                switch (targetDof)
                {
                case DoF.Dx:
                    nde.Constraints = nde.Constraints & Constraint.FixedDX;
                    break;

                case DoF.Dy:
                    nde.Constraints = nde.Constraints & Constraint.FixedDY;
                    break;

                case DoF.Dz:
                    nde.Constraints = nde.Constraints & Constraint.FixedDZ;
                    break;

                case DoF.Rx:
                    nde.Constraints = nde.Constraints & Constraint.FixedRX;
                    break;

                case DoF.Ry:
                    nde.Constraints = nde.Constraints & Constraint.FixedRY;
                    break;

                case DoF.Rz:
                    nde.Constraints = nde.Constraints & Constraint.FixedRZ;
                    break;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds the analysis result.
        /// </summary>
        /// <param name="loadCase">The load case.</param>
        /// <remarks>if model is analyzed against specific load case, then displacements are available through <see cref="Displacements"/> property.
        /// If system is not analyses against a specific load case, then this method will analyses structure against <see cref="LoadCase"/>.
        /// While this method is using pre computed Cholesky Decomposition , its have a high performance in solving the system.
        /// </remarks>
        public static void AddAnalysisResult(this StaticLinearAnalysisResult thiis, LoadCase loadCase)
        {
            ISolver solver;

            var map = DofMappingManager.Create(thiis.Parent, loadCase);

            var n = thiis.Parent.Nodes.Count;                                        //node count
            var m = map.M;                                                           //master node count

            var pu = PermutationGenerator.GetDisplacementPermute(thiis.Parent, map); //permutation of U
            var pf = PermutationGenerator.GetForcePermute(thiis.Parent, map);        //permutation of F

            var fe = thiis.ElementForces[loadCase] = thiis.GetTotalElementsForceVector(loadCase);
            var fc = thiis.ConcentratedForces[loadCase] = thiis.GetTotalConcentratedForceVector(loadCase);


            var ft = fe.Add(fc);


            var fr  = pf.Multiply(ft);
            var ffr = thiis.GetFreePartOfReducedVector(fr, map);
            var fsr = thiis.GetFixedPartOfReducedVector(fr, map);

            var kt = MatrixAssemblerUtil.AssembleFullStiffnessMatrix(thiis.Parent);
            var kr = (CCS)((CCS)pf.Multiply(kt)).Multiply(pu);

            #region  U_s,r
            var usr = new double[map.RMap3.Length];

            {
                //should fill usr
                var ut_temp = thiis.GetTotalDispVector(loadCase, map);

                for (int i = 0; i < usr.Length; i++)
                {
                    var t1 = map.RMap3[i];
                    var t2 = map.RMap1[t1];

                    usr[i] = ut_temp[t2];
                }
            }

            #endregion

            var krd = CalcUtil.GetReducedZoneDividedMatrix(kr, map);
            thiis.AnalyseStiffnessMatrixForWarnings(krd, map, loadCase);

            {//TODO: remove
                var minAbsDiag = double.MaxValue;

                foreach (var tpl in krd.ReleasedReleasedPart.EnumerateIndexed())
                {
                    if (tpl.Item1 == tpl.Item2)
                    {
                        minAbsDiag = Math.Min(minAbsDiag, Math.Abs(tpl.Item3));
                    }
                }

                if (krd.ReleasedReleasedPart.RowCount != 0)
                {
                    //var kk = krd.ReleasedReleasedPart.ToDenseMatrix();
                }
            }

            #region  solver

            if (thiis.Solvers.ContainsKey(map.MasterMap))
            {
                solver = thiis.Solvers[map.MasterMap];
            }
            else
            {
                solver =
                    //SolverGenerator(krd.ReleasedReleasedPart);
                    thiis.SolverFactory.CreateSolver(krd.ReleasedReleasedPart);

                thiis.Solvers[map.MasterMap] = solver;
            }


            if (!solver.IsInitialized)
            {
                solver.Initialize();
            }

            #endregion

            double[] ufr = new double[map.RMap2.Length];
            //string message;

            var input = ffr.Subtract(krd.ReleasedFixedPart.Multiply(usr));


            solver.Solve(input, ufr);

            //if (res2 != SolverResult.Success)
            //    throw new BriefFiniteElementNetException(message);

            var fpsr = krd.FixedReleasedPart.Multiply(ufr).Add(krd.FixedFixedPart.Multiply(usr));

            var fsrt = fpsr.Subtract(fsr);// no needed

            var fx = thiis.SupportReactions[loadCase] = new double[6 * n];

            #region forming ft


            for (var i = 0; i < map.Fixity.Length; i++)
            {
                if (map.Fixity[i] == DofConstraint.Fixed)
                {
                    ft[i] = 0;
                }
            }

            for (var i = 0; i < fpsr.Length; i++)
            {
                var totDofNum = map.RMap1[map.RMap3[i]];

                ft[totDofNum] = fx[totDofNum] = fpsr[i];
            }


            #endregion

            #region forming ur

            var ur = new double[map.M * 6];


            for (var i = 0; i < usr.Length; i++)
            {
                ur[map.RMap3[i]] = usr[i];
            }

            for (var i = 0; i < ufr.Length; i++)
            {
                ur[map.RMap2[i]] = ufr[i];
            }

            #endregion

            var ut = pu.Multiply(ur);

            thiis.Forces[loadCase]        = ft;
            thiis.Displacements[loadCase] = ut;
        }