private double Project(double ksi1Initial)
        {
            int    maxIterations = 1000;
            double tol           = Math.Pow(10.0, -6.0);
            double deltaKsi      = 0.0;
            double ksi           = ksi1Initial;

            double[] xUpdated = NodalXUpdated();
            for (int i = 1; i <= maxIterations; i++)
            {
                Tuple <double[, ], double[, ], double[, ]> aMatrices = CalculatePositionMatrix(ksi);
                //double[] slavePositionVector = new double[] { xUpdated[6], xUpdated[7] };
                double[] masterSlaveRelativeVector = VectorOperations.MatrixVectorProduct(aMatrices.Item1, xUpdated);
                double[] surfaceVector             = VectorOperations.VectorScalarProduct(VectorOperations.MatrixVectorProduct(aMatrices.Item2, xUpdated), -1);
                double[] surfaceVectorDerivative   = VectorOperations.VectorScalarProduct(VectorOperations.MatrixVectorProduct(aMatrices.Item3, xUpdated), -1);

                deltaKsi = CalculateDeltaKsi(masterSlaveRelativeVector, surfaceVector, surfaceVectorDerivative);
                ksi     += deltaKsi;
                if (Math.Abs(deltaKsi) <= tol)
                {
                    break;
                }
            }
            if (Math.Abs(deltaKsi) > tol)
            {
                throw new Exception("CPP not found in current iterations");
            }
            else
            {
                return(ksi);
            }
        }
Exemple #2
0
        private Tuple <double[], double, double[], double[], double> MasterSegmentGeometry(double[,] daMatrix, double[,] da2Matrix)
        {
            double[] xupd                    = VectorOperations.VectorScalarProduct(NodalXUpdated(), -1);
            double[] surfaceVector           = VectorOperations.MatrixVectorProduct(daMatrix, xupd);
            double[] surfaceVectorDerivative = VectorOperations.MatrixVectorProduct(da2Matrix, xupd);

            double detm = VectorOperations.VectorDotProduct(surfaceVector, surfaceVector);
            double m11  = 1.0 / detm;

            double[] vector      = new double[2];
            double   scalarCoef  = new double();
            double   scalarCoef2 = Math.Pow(m11, 2.0);

            double[] tangentVector   = new double[2];
            double   curvatureTensor = new double();

            if (Properties.MasterSegmentPolynomialDegree == 1)
            {
                double Xm1 = Nodes[1].XCoordinate + DisplacementVector[0];
                double Ym1 = Nodes[1].YCoordinate + DisplacementVector[1];
                double Xm2 = Nodes[2].XCoordinate + DisplacementVector[2];
                double Ym2 = Nodes[2].YCoordinate + DisplacementVector[3];
                vector[0]  = Ym2 - Ym1;
                vector[1]  = Xm1 - Xm2;
                scalarCoef = -1.0 / (2.0 * Math.Sqrt(detm));
            }
            else
            {
                vector[0]     = -surfaceVector[1];
                vector[1]     = surfaceVector[0];
                scalarCoef    = 1.0 / (Math.Sqrt(detm));
                tangentVector = VectorOperations.VectorScalarProductNew(surfaceVector, scalarCoef);
            }
            double[] normalUnitVec = VectorOperations.VectorScalarProductNew(vector, scalarCoef);
            curvatureTensor = scalarCoef2 * VectorOperations.VectorDotProduct(surfaceVectorDerivative, normalUnitVec);
            return(new Tuple <double[], double, double[], double[], double>(surfaceVector, m11, normalUnitVec, tangentVector, curvatureTensor));
        }
Exemple #3
0
        private double Project(double ksi1Initial, double ksi2)
        {
            if (Properties.MasterSegmentPolynomialDegree == 1)
            {
                double[,] aMatrix = CalculatePositionMatrix(ksi1Initial, ksi2).Item1;
                int m = Properties.SlaveSegmentPolynomialDegree + 1;
                double[,] slaveNMatrix = new double[2, 2 * m];
                double[]      xUpdated = NodalXUpdated();
                List <double> list     = new List <double>();
                for (int i = 4; i < list.Count; i++)
                {
                    list.Add(xUpdated[i]);
                }
                double[] x = list.ToArray();
                for (int i = 0; i <= 1; i++)
                {
                    if (i == 0)
                    {
                        int countCols = 0;
                        for (int j = 4; j < aMatrix.GetLength(1) - 1; j += 2)
                        {
                            slaveNMatrix[i, countCols] = aMatrix[i, j];
                            countCols += 2;
                        }
                    }
                    else
                    {
                        int countCols = 1;
                        for (int j = 5; j < aMatrix.GetLength(1); j += 2)
                        {
                            slaveNMatrix[i, countCols] = aMatrix[i, j];
                            countCols += 2;
                        }
                    }
                }
                double[] slavePositionVector = VectorOperations.MatrixVectorProduct(slaveNMatrix, x);
                double   xM1 = xUpdated[0];
                double   yM1 = xUpdated[1];
                double   xM2 = xUpdated[2];
                double   yM2 = xUpdated[3];
                double   xS  = slavePositionVector[0];
                double   yS  = slavePositionVector[1];
                double   ksi = (2 * (xS * (xM2 - xM1) + yS * (yM2 - yM1)) - Math.Pow(xM2, 2) - Math.Pow(yM2, 2) + Math.Pow(xM1, 2) + Math.Pow(yM1, 2)) / (Math.Pow(xM2 - xM1, 2) + Math.Pow(yM2 - yM1, 2));
                return(ksi);
            }
            else
            {
                int      maxIterations = 1000;
                double   tol           = Math.Pow(10.0, -6.0);
                double   deltaKsi      = 0.0;
                double   ksi           = ksi1Initial;
                double[] xUpdated      = NodalXUpdated();
                for (int i = 1; i <= maxIterations; i++)
                {
                    Tuple <double[, ], double[, ], double[, ], double[, ], double[, ]> aMatrices = CalculatePositionMatrix(ksi, ksi2);
                    double[] masterSlaveRelativeVector = VectorOperations.MatrixVectorProduct(aMatrices.Item1, xUpdated);
                    double[] surfaceVector             = VectorOperations.VectorScalarProduct(VectorOperations.MatrixVectorProduct(aMatrices.Item2, xUpdated), -1);
                    double[] surfaceVectorDerivative   = VectorOperations.VectorScalarProduct(VectorOperations.MatrixVectorProduct(aMatrices.Item3, xUpdated), -1);

                    deltaKsi = CalculateDeltaKsi(masterSlaveRelativeVector, surfaceVector, surfaceVectorDerivative);
                    ksi     += deltaKsi;
                    if (Math.Abs(deltaKsi) <= tol)
                    {
                        break;
                    }
                }
                if (Math.Abs(deltaKsi) > tol)
                {
                    throw new Exception("CPP not found in current iterations");
                }
                else
                {
                    return(ksi);
                }
            }
        }