protected override KeyedVector <NodalDegreeOfFreedom> Solve(StiffnessMatrix stiffnessMatrix, KeyedVector <NodalDegreeOfFreedom> forceVector)
        {
            KeyedSquareMatrix <NodalDegreeOfFreedom> inverse  = stiffnessMatrix.Inverse();
            KeyedVector <NodalDegreeOfFreedom>       solution = inverse.Multiply(forceVector);

            return(solution);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public KeyedSquareMatrix <DegreeOfFreedom> CalculateElementRotationMatrix()
        {
            KeyedSquareMatrix <DegreeOfFreedom> rotationMatrix = FiniteElement.CreateFromRows(this.LocalXAxis, this.LocalYAxis, this.LocalZAxis);

            rotationMatrix = rotationMatrix.NormalizeRows(2);
            return(rotationMatrix);
        }
示例#3
0
        /// <summary>
        /// Creates a new keyed matrix from keyed vectors representing the rows of the new matrix
        /// </summary>
        /// <param name="axis1">The vector representing the first row</param>
        /// <param name="axis2">The vector representing the second row</param>
        /// <param name="axis3">The vector representing the third row</param>
        /// <returns>A matrix built from the vectors</returns>
        protected static KeyedSquareMatrix <DegreeOfFreedom> CreateFromRows(KeyedVector <DegreeOfFreedom> axis1, KeyedVector <DegreeOfFreedom> axis2, KeyedVector <DegreeOfFreedom> axis3)
        {
            ////TODO this should be devolved to the KeyedMatrix class
            Guard.AgainstBadArgument(
                "axis1",
                () => { return(axis1.Count != 3); },
                "All axes should be 3D, i.e. have 3 items");
            Guard.AgainstBadArgument(
                "axis2",
                () => { return(axis2.Count != 3); },
                "All axes should be 3D, i.e. have 3 items");
            Guard.AgainstBadArgument(
                "axis3",
                () => { return(axis3.Count != 3); },
                "All axes should be 3D, i.e. have 3 items");
            Guard.AgainstBadArgument(
                "axis1",
                () => { return(axis1.SumMagnitudes().IsApproximatelyEqualTo(0.0)); },
                string.Format(
                    System.Globalization.CultureInfo.InvariantCulture,
                    "Axis should not be zero: {0}",
                    axis1));
            Guard.AgainstBadArgument(
                "axis2",
                () => { return(axis2.SumMagnitudes().IsApproximatelyEqualTo(0.0)); },
                string.Format(
                    System.Globalization.CultureInfo.InvariantCulture,
                    "Axis should not be zero: {0}",
                    axis2));
            Guard.AgainstBadArgument(
                "axis3",
                () => { return(axis3.SumMagnitudes().IsApproximatelyEqualTo(0.0)); },
                string.Format(
                    System.Globalization.CultureInfo.InvariantCulture,
                    "Axis should not be zero: {0}",
                    axis3));

            KeyedVector <DegreeOfFreedom> axis1Norm = axis1.Normalize(2);
            KeyedVector <DegreeOfFreedom> axis2Norm = axis2.Normalize(2);
            KeyedVector <DegreeOfFreedom> axis3Norm = axis3.Normalize(2);

            IList <DegreeOfFreedom> dof = new List <DegreeOfFreedom>(3)
            {
                DegreeOfFreedom.X, DegreeOfFreedom.Y, DegreeOfFreedom.Z
            };

            KeyedSquareMatrix <DegreeOfFreedom> result = new KeyedSquareMatrix <DegreeOfFreedom>(dof);

            result.At(DegreeOfFreedom.X, DegreeOfFreedom.X, axis1Norm[DegreeOfFreedom.X]);
            result.At(DegreeOfFreedom.X, DegreeOfFreedom.Y, axis1Norm[DegreeOfFreedom.Y]);
            result.At(DegreeOfFreedom.X, DegreeOfFreedom.Z, axis1Norm[DegreeOfFreedom.Z]);
            result.At(DegreeOfFreedom.Y, DegreeOfFreedom.X, axis2Norm[DegreeOfFreedom.X]);
            result.At(DegreeOfFreedom.Y, DegreeOfFreedom.Y, axis2Norm[DegreeOfFreedom.Y]);
            result.At(DegreeOfFreedom.Y, DegreeOfFreedom.Z, axis2Norm[DegreeOfFreedom.Z]);
            result.At(DegreeOfFreedom.Z, DegreeOfFreedom.X, axis3Norm[DegreeOfFreedom.X]);
            result.At(DegreeOfFreedom.Z, DegreeOfFreedom.Y, axis3Norm[DegreeOfFreedom.Y]);
            result.At(DegreeOfFreedom.Z, DegreeOfFreedom.Z, axis3Norm[DegreeOfFreedom.Z]);

            return(result);
        }
示例#4
0
        public CartesianPoint ConvertGlobalCoordinatesToLocalCoordinates(CartesianPoint globalPoint)
        {
            GeometricVector localCoordRelativeToLocalOrigin = globalPoint.Subtract(this.LocalOrigin);

            KeyedSquareMatrix <DegreeOfFreedom> rotationMatrix = CalculateElementRotationMatrix();
            CartesianPoint localCoord = new CartesianPoint(rotationMatrix.Multiply(localCoordRelativeToLocalOrigin));

            return(new CartesianPoint(localCoord));
        }
示例#5
0
        public CartesianPoint ConvertLocalCoordinatesToGlobalCoordinates(CartesianPoint localPoint)
        {
            KeyedSquareMatrix <DegreeOfFreedom> rotationMatrix = CalculateElementRotationMatrix().Transpose();
            CartesianPoint globalCoordRelativeToLocalOrigin    = new CartesianPoint(rotationMatrix.Multiply(localPoint));

            GeometricVector globalCoord = globalCoordRelativeToLocalOrigin.Add(this.LocalOrigin);

            return(new CartesianPoint(globalCoord));
        }
示例#6
0
        /// <summary>
        /// Creates a matrix which contains values from the requested sub-matrix
        /// </summary>
        /// <param name="rowsToInclude">A list of the keys of rows to include in the new matrix</param>
        /// <param name="columnsToInclude">A list of the keys of columns to include in the new matrix</param>
        /// <returns>A KeyedMatrix which contains values from the requested sub-matrix</returns>
        public KeyedSquareMatrix <TKey> SubMatrix(IList <TKey> keysToInclude)
        {
            KeyedSquareMatrix <TKey> subMatrix = new KeyedSquareMatrix <TKey>(keysToInclude);

            foreach (TKey rowKey in keysToInclude)        //rows
            {
                foreach (TKey columnKey in keysToInclude) //columns
                {
                    subMatrix.At(rowKey, columnKey, this.At(rowKey, columnKey));
                }
            }

            return(subMatrix);
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KeyedMatrix{TKey}" /> class.
 /// </summary>
 /// <param name="keysForRows">The keys which will be used to look up rows of this matrix. One unique key is expected per row.</param>
 /// <param name="keysForColumns">The keys which will be used to look up columns of this matrix. One unique key is expected per column.</param>
 /// <param name="matrix">The value to which we assign to each element of the matrix</param>
 public KeyedSquareMatrix(IList <TKey> keysForRows, IList <TKey> keysForColumns, KeyedSquareMatrix <TKey> matrix)
     : base(keysForRows, keysForColumns, matrix)
 {
     // empty
 }
示例#8
0
        public KeyedSquareMatrix <TKey> TransposeThisAndMultiply(KeyedSquareMatrix <TKey> other)
        {
            KeyedRowColumnMatrix <TKey, TKey> result = base.TransposeThisAndMultiply(other);

            return(new KeyedSquareMatrix <TKey>(result));
        }
示例#9
0
        public KeyedSquareMatrix <TKey> Add(KeyedSquareMatrix <TKey> other)
        {
            KeyedRowColumnMatrix <TKey, TKey> result = base.Add(other);

            return(new KeyedSquareMatrix <TKey>(result));
        }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KeyedMatrix{TKey}" /> class.
 /// </summary>
 /// <param name="matrix">The matrix which holds the keys and data to copy into this new matrix</param>
 public KeyedSquareMatrix(KeyedSquareMatrix <TKey> matrix)
     : base(matrix)
 {
     // empty
 }