示例#1
0
        private void SetBoundaryConditions(TypeOfFixation type, IBoundaryCondition conditions)
        {
            foreach (var item in conditions.FixedNodes)
            {
                switch (type)
                {
                case TypeOfFixation.RIGID:
                    MathOps.SetZerosRow(ref globalMatrix, item.Key * DEGREES_OF_FREEDOM);
                    globalMatrix[item.Key * DEGREES_OF_FREEDOM, item.Key *DEGREES_OF_FREEDOM] = 1.0;
                    MathOps.SetZerosRow(ref globalMatrix, item.Key * DEGREES_OF_FREEDOM + 1);
                    globalMatrix[item.Key * DEGREES_OF_FREEDOM + 1, item.Key *DEGREES_OF_FREEDOM + 1] = 1.0;
                    MathOps.SetZerosRow(ref globalMatrix, item.Key * DEGREES_OF_FREEDOM + 2);
                    globalMatrix[item.Key * DEGREES_OF_FREEDOM + 2, item.Key *DEGREES_OF_FREEDOM + 2] = 1.0;

                    loads[item.Key * DEGREES_OF_FREEDOM]     = 0.0;
                    loads[item.Key * DEGREES_OF_FREEDOM + 1] = 0.0;
                    loads[item.Key * DEGREES_OF_FREEDOM + 2] = 0.0;
                    break;

                case TypeOfFixation.ARTICULATION_YZ: throw new NotImplementedException();

                case TypeOfFixation.ARTICULATION_XZ: throw new NotImplementedException();

                case TypeOfFixation.ARTICULATION_XY: throw new NotImplementedException();

                default: throw new ArgumentException("Wrong type of the fixation");
                }
            }
        }
示例#2
0
        private void SetBoundaryConditions(MemoryMappedViewAccessor accessor, TypeOfFixation type, IBoundaryCondition conditions)
        {
            foreach (var item in conditions.FixedNodes)
            {
                int ind = item.Key * DEGREES_OF_FREEDOM;
                switch (type)
                {
                case TypeOfFixation.RIGID:
                    MathOps.SetZerosRow(accessor, lengthMatrix, ind);
                    MappedMatrix.SetDoubleValue(accessor, ind, ind, lengthMatrix, 1.0);
                    MathOps.SetZerosRow(accessor, lengthMatrix, ind + 1);
                    MappedMatrix.SetDoubleValue(accessor, ind + 1, ind + 1, lengthMatrix, 1.0);
                    MathOps.SetZerosRow(accessor, lengthMatrix, ind + 2);
                    MappedMatrix.SetDoubleValue(accessor, ind + 2, ind + 2, lengthMatrix, 1.0);

                    loads[ind]     = 0.0;
                    loads[ind + 1] = 0.0;
                    loads[ind + 2] = 0.0;
                    break;

                case TypeOfFixation.ARTICULATION_YZ: throw new NotImplementedException();

                case TypeOfFixation.ARTICULATION_XZ: throw new NotImplementedException();

                case TypeOfFixation.ARTICULATION_XY: throw new NotImplementedException();

                default: throw new ArgumentException("Wrong type of the fixation");
                }
            }
        }
示例#3
0
        private void SetBoundaryConditions(TypeOfFixation type, IBoundaryCondition conditions)
        {
            foreach (var node in conditions.FixedNodes)
            {
                switch (type)
                {
                case TypeOfFixation.RIGID:
                    globalMatrix.ClearRow(node.Key * DEGREES_OF_FREEDOM);
                    //globalMatrix.ClearColumn(node.Key * DEGREES_OF_FREEDOM);
                    globalMatrix[node.Key * DEGREES_OF_FREEDOM, node.Key *DEGREES_OF_FREEDOM] = 1.0;

                    globalMatrix.ClearRow(node.Key * DEGREES_OF_FREEDOM + 1);
                    //globalMatrix.ClearColumn(node.Key * DEGREES_OF_FREEDOM + 1);
                    globalMatrix[node.Key * DEGREES_OF_FREEDOM + 1, node.Key *DEGREES_OF_FREEDOM + 1] = 1.0;

                    globalMatrix.ClearRow(node.Key * DEGREES_OF_FREEDOM + 2);
                    //globalMatrix.ClearColumn(node.Key * DEGREES_OF_FREEDOM + 2);
                    globalMatrix[node.Key * DEGREES_OF_FREEDOM + 2, node.Key *DEGREES_OF_FREEDOM + 2] = 1.0;

                    loads[node.Key * DEGREES_OF_FREEDOM]     = 0.0;
                    loads[node.Key * DEGREES_OF_FREEDOM + 1] = 0.0;
                    loads[node.Key * DEGREES_OF_FREEDOM + 2] = 0.0;
                    break;

                case TypeOfFixation.ARTICULATION_YZ: throw new NotImplementedException();

                case TypeOfFixation.ARTICULATION_XZ: throw new NotImplementedException();

                case TypeOfFixation.ARTICULATION_XY: throw new NotImplementedException();

                default: throw new ArgumentException("Wrong type of the fixation");
                }
            }
        }
示例#4
0
        public void Solve(TypeOfFixation type, IBoundaryCondition conditions, ILoad load)
        {
            globalMatrix = solver.GlobalMatrix;
            results      = new double[length];

            SetLoads(load);
            SetBoundaryConditions(type, conditions);

            //List<double> nonZeroRows = globalMatrix.Storage.EnumerateNonZero().ToList();

            var iterationCountStopCriterion = new IterationCountStopCriterion <double>(length >> 1);
            var residualStopCriterion       = new ResidualStopCriterion <double>(ACCURACY);

            var monitor = new Iterator <double>(iterationCountStopCriterion, residualStopCriterion);

            var solverM = new TFQMR();

            //Vector<double> vectorResults = globalMatrix.LU().Solve(Vector.Build.DenseOfArray(loads));
            Vector <double> vectorResults = globalMatrix
                                            .SolveIterative(Vector.Build.DenseOfArray(loads), solverM, monitor);

            results = vectorResults.ToArray();
            for (int i = 0; i < results.Length; i++)
            {
                if (globalMatrix[i, i] == 1.0)
                {
                    results[i] = 0.0;
                }
            }
        }
        public void Solve(TypeOfFixation type, IBoundaryCondition conditions, ILoad load)
        {
            globalMatrix = solver.GlobalMatrix;
            results      = new double[length];


            SetLoads(load);
            SetBoundaryConditions(type, conditions, globalMatrix);

            var           storage     = globalMatrix.Storage as SparseCompressedRowMatrixStorage <double>;
            List <double> nonZeroRows = globalMatrix.Storage.EnumerateNonZero().ToList();

            //CudaSolveSparse sp = new CudaSolveSparse();
            //CudaSparseMatrixDescriptor matrixDescriptor = new CudaSparseMatrixDescriptor();
            //        sp.CsrlsvluHost(globalMatrix.RowCount, nonZeroRows.Count, matrixDescriptor, nonZeroRows.ToArray(),
            //storage.RowPointers, storage.ColumnIndices, loads, ACCURACY, 0, results);

            for (int i = 0; i < results.Length; i++)
            {
                if (globalMatrix[i, i] == 1.0)
                {
                    results[i] = 0.0;
                }
            }
        }
        /// <summary>
        /// Solves the problem of stress-strain state
        /// </summary>
        /// <param name="type">Type of fixation</param>
        /// <param name="conditions">Boundary conditions</param>
        /// <returns>Result vector</returns>
        public void Solve(TypeOfFixation type, IBoundaryCondition conditions, ILoad load)
        {
            globalMatrix = solver.GlobalMatrix;
            results      = new double[globalMatrix.Count];

            SetLoads(load);
            SetBoundaryConditions(type, conditions);

            results = MathOps.MethodOfGauss(ref globalMatrix, loads);
        }
示例#7
0
        /// <summary>
        /// Solves the problem of stress-strain state
        /// </summary>
        /// <param name="type">Type of fixation</param>
        /// <param name="conditions">Boundary conditions</param>
        /// <returns>Result vector</returns>
        public void Solve(TypeOfFixation type, IBoundaryCondition conditions, ILoad load)
        {
            globalMatrix = solver.GlobalMatrix;
            results      = new double[globalMatrix.GetLength(1)];

            SetLoads(load);
            SetBoundaryConditions(type, conditions);

            results = MathOps.GausSlau(globalMatrix, loads);
        }
示例#8
0
        /// <summary>
        /// Solves the problem of stress-strain state
        /// </summary>
        /// <param name="type">Type of fixation</param>
        /// <param name="conditions">Boundary conditions</param>
        /// <returns>Result vector</returns>
        public void Solve(TypeOfFixation type, IBoundaryCondition conditions, ILoad load)
        {
            results = new double[solver.GlobalMatrix.Length];

            SetLoads(load);
            SetBoundaryConditions(type, conditions);

            results = MathOps.MethodOfGauss(DIRECTORY_PATH, globalMatrix, loads);
            //results = MathOps.CGMethod(DIRECTORY_PATH, globalMatrix, loads, EPSILON);
        }
示例#9
0
        /// <summary>
        /// Solves the problem of stress-strain state
        /// </summary>
        /// <param name="type">Type of fixation</param>
        /// <param name="conditions">Boundary conditions</param>
        /// <returns>Result vector</returns>
        public void Solve(TypeOfFixation type, IBoundaryCondition conditions, ILoad load)
        {
            //globalMatrix = solver.GlobalMatrix;
            results = new double[lengthMatrix];

            using (globalMatrix = MappedMatrix.Open("global.matrix", "globalMatrix"))
            {
                using (var accessor = globalMatrix.CreateViewAccessor())
                {
                    SetLoads(load);
                    SetBoundaryConditions(accessor, type, conditions);

                    results = MathOps.MethodOfGauss(accessor, loads);
                }
            }
        }
示例#10
0
        public void Solve(TypeOfFixation type, IBoundaryCondition conditions, ILoad load)
        {
            globalMatrix = solver.GlobalMatrix;
            results      = new double[length];

            //MathOps.IncompleteCholeskyFactorization(ref globalMatrix);
            //DictionaryMatrix C = MathOps.Multiply(ref globalMatrix);

            AddZeros();
            SetLoads(load);
            //SetBoundaryConditions(type, conditions, C);
            SetBoundaryConditions(type, conditions, globalMatrix);

            results = MathOps.MethodOfGauss(globalMatrix, loads);
            //results = MathOps.CGMethod(globalMatrix, loads, EPSILON);
            //results = MathOps.CGMethod(C, loads, EPSILON);
        }
示例#11
0
        private void SetBoundaryConditions(TypeOfFixation type, IBoundaryCondition conditions, DictionaryMatrix dictionaryMatrix)
        {
            int processCount = conditions.FixedNodes.Count;

            using (ManualResetEvent resetEvent = new ManualResetEvent(false))
            {
                foreach (var item in conditions.FixedNodes)
                {
                    ThreadPool.QueueUserWorkItem(thrItem =>
                    {
                        KeyValuePair <int, Node> node = (KeyValuePair <int, Node>)thrItem;

                        switch (type)
                        {
                        case TypeOfFixation.RIGID:
                            MathOps.SetZerosRowColumn(ref dictionaryMatrix, node.Key * DEGREES_OF_FREEDOM, length);
                            dictionaryMatrix.SetValue(node.Key * DEGREES_OF_FREEDOM, node.Key * DEGREES_OF_FREEDOM, 1.0);
                            MathOps.SetZerosRowColumn(ref dictionaryMatrix, node.Key * DEGREES_OF_FREEDOM + 1, length);
                            dictionaryMatrix.SetValue(node.Key * DEGREES_OF_FREEDOM + 1, node.Key * DEGREES_OF_FREEDOM + 1, 1.0);
                            MathOps.SetZerosRowColumn(ref dictionaryMatrix, node.Key * DEGREES_OF_FREEDOM + 2, length);
                            dictionaryMatrix.SetValue(node.Key * DEGREES_OF_FREEDOM + 2, node.Key * DEGREES_OF_FREEDOM + 2, 1.0);

                            loads[node.Key * DEGREES_OF_FREEDOM]     = 0.0;
                            loads[node.Key * DEGREES_OF_FREEDOM + 1] = 0.0;
                            loads[node.Key * DEGREES_OF_FREEDOM + 2] = 0.0;
                            break;

                        case TypeOfFixation.ARTICULATION_YZ: throw new NotImplementedException();

                        case TypeOfFixation.ARTICULATION_XZ: throw new NotImplementedException();

                        case TypeOfFixation.ARTICULATION_XY: throw new NotImplementedException();

                        default: throw new ArgumentException("Wrong type of the fixation");
                        }
                        if (Interlocked.Decrement(ref processCount) == 0)
                        {
                            resetEvent.Set();
                        }
                    }, item);
                }
                resetEvent.WaitOne();
            }
        }