Example #1
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");
                }
            }
        }
Example #2
0
 private void SetRowConditions(int index)
 {
     using (var mappedFile = MappedMatrix.Open($"{DIRECTORY_PATH}{globalMatrix[index]}.matrix", globalMatrix[index]))
     {
         using (var accessor = mappedFile.CreateViewAccessor())
         {
             MathOps.SetZerosRow(accessor, globalMatrix.Length);
             MappedMatrix.SetDoubleValue(accessor, index, 1.0);
         }
     }
 }
Example #3
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);
                }
            }
        }
        private void GenerateGlobalMatrix()
        {
            int length = nodes.Count * DEGREES_OF_FREEDOM;

            foreach (var element in tetrahedrons)
            {
                double[,] k = GenerateLocalK(element);

                for (int si = 0; si < element.Nodes.Count; si++)
                {
                    for (int sj = 0; sj < element.Nodes.Count; sj++)
                    {
                        for (int ki = 0; ki < DEGREES_OF_FREEDOM; ki++)
                        {
                            for (int kj = 0; kj < DEGREES_OF_FREEDOM; kj++)
                            {
                                int gSi  = element.Nodes[si].GlobalIndex;
                                int gSj  = element.Nodes[sj].GlobalIndex;
                                int gI   = gSi * DEGREES_OF_FREEDOM + ki;
                                int gJ   = gSj * DEGREES_OF_FREEDOM + kj;
                                int locI = si * DEGREES_OF_FREEDOM + ki;
                                int locJ = sj * DEGREES_OF_FREEDOM + kj;

                                using (var mappedFile = MappedMatrix.OpenOrCreate($"{DIRECTORY_PATH}{GlobalMatrix[gI]}.matrix", GlobalMatrix[gI], GlobalMatrix.Length))
                                {
                                    using (var accessor = mappedFile.CreateViewAccessor())
                                    {
                                        double tmp = MappedMatrix.GetDoubleValue(accessor, gJ);
                                        MappedMatrix.SetDoubleValue(accessor, gJ, tmp + k[locI, locJ]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #5
0
        private void GenerateGlobalMatrix()
        {
            int lenght = nodes.Count * DEGREES_OF_FREEDOM;

            using (globalMatrix = MappedMatrix.Init("global.matrix", "globalMatrix", lenght))
            {
                using (var accessor = globalMatrix.CreateViewAccessor())
                {
                    foreach (var element in tetrahedrons)
                    {
                        double[,] k = GenerateLocalK(element);

                        for (int si = 0; si < element.Nodes.Count; si++)
                        {
                            for (int sj = 0; sj < element.Nodes.Count; sj++)
                            {
                                for (int ki = 0; ki < DEGREES_OF_FREEDOM; ki++)
                                {
                                    for (int kj = 0; kj < DEGREES_OF_FREEDOM; kj++)
                                    {
                                        int gSi  = element.Nodes[si].GlobalIndex;
                                        int gSj  = element.Nodes[sj].GlobalIndex;
                                        int gI   = gSi * DEGREES_OF_FREEDOM + ki;
                                        int gJ   = gSj * DEGREES_OF_FREEDOM + kj;
                                        int locI = si * DEGREES_OF_FREEDOM + ki;
                                        int locJ = sj * DEGREES_OF_FREEDOM + kj;

                                        double tmp = MappedMatrix.GetDoubleValue(accessor, gI, gJ, lenght);
                                        MappedMatrix.SetDoubleValue(accessor, gI, gJ, lenght, tmp + k[locI, locJ]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }