Beispiel #1
0
 public StaticMechanicDictSolution(ISolve <DictionaryMatrix> solver, IScene scene)
 {
     this.solver  = solver;
     globalMatrix = solver.GlobalMatrix;
     length       = scene.Nodes.Count * DEGREES_OF_FREEDOM;
     loads        = new double[length];
     results      = new double[length];
 }
Beispiel #2
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);
        }
Beispiel #3
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();
            }
        }