/// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override StiffnessMatrix LocalStiffnessMatrix()
        {
            KeyedSquareMatrix <Strain> materialMatrix = this.MaterialMatrix;

            SharpFE.Maths.Integration.Gauss.GaussianIntegration2D gaussianIntegrator = new SharpFE.Maths.Integration.Gauss.GaussianIntegration2D(2);

            Matrix <double> k = gaussianIntegrator.Integrate((gaussIntegrationPointi, gaussIntegrationPointj) => {
                CartesianPoint pnt = new CartesianPoint(gaussIntegrationPointi, gaussIntegrationPointj, 0);

                KeyedRowColumnMatrix <Strain, NodalDegreeOfFreedom> strainDisplacementMatrix = this.StrainDisplacementMatrix(pnt);
                KeyedRowColumnMatrix <NodalDegreeOfFreedom, Strain> bte = strainDisplacementMatrix.TransposeThisAndMultiply <Strain>(materialMatrix);
                KeyedRowColumnMatrix <NodalDegreeOfFreedom, NodalDegreeOfFreedom> bteb = bte.Multiply <Strain, NodalDegreeOfFreedom>(strainDisplacementMatrix);

                double jacobianDeterminant = this.Jacobian(pnt).Determinant();
                bteb = bteb.Multiply(jacobianDeterminant);
                return((Matrix <double>)bteb);
            });

            double thickness = this.Element.Thickness; //TODO interpolate over element (i.e. allow varying thickness over element)

            k = k.Multiply(thickness);

            IList <NodalDegreeOfFreedom> supportedNodalDegreesOfFreedom = this.Element.SupportedLocalNodalDegreeOfFreedoms;

            return(new StiffnessMatrix(supportedNodalDegreesOfFreedom, supportedNodalDegreesOfFreedom, k));
        }
コード例 #2
0
        protected KeyedSquareMatrix<Strain> CreateMaterialMatrix(double lameConstantLambda, double lameConstantMu)
        {
            IList<Strain> keys = new List<Strain>
            {
                Strain.LinearStrainX,
                Strain.LinearStrainY,
                Strain.LinearStrainZ,
                Strain.ShearStrainXY,
                Strain.ShearStrainYZ,
                Strain.ShearStrainXZ
            };
            KeyedSquareMatrix<Strain> matrix = new KeyedSquareMatrix<Strain>(keys);

            matrix.At(Strain.LinearStrainX, Strain.LinearStrainX, lameConstantLambda + 2 * lameConstantMu);
            matrix.At(Strain.LinearStrainY, Strain.LinearStrainY, lameConstantLambda + 2 * lameConstantMu);
            matrix.At(Strain.LinearStrainZ, Strain.LinearStrainZ, lameConstantLambda + 2 * lameConstantMu);

            matrix.At(Strain.LinearStrainX, Strain.LinearStrainY, lameConstantLambda);
            matrix.At(Strain.LinearStrainX, Strain.LinearStrainZ, lameConstantLambda);
            matrix.At(Strain.LinearStrainY, Strain.LinearStrainX, lameConstantLambda);
            matrix.At(Strain.LinearStrainY, Strain.LinearStrainZ, lameConstantLambda);
            matrix.At(Strain.LinearStrainZ, Strain.LinearStrainX, lameConstantLambda);
            matrix.At(Strain.LinearStrainZ, Strain.LinearStrainY, lameConstantLambda);

            matrix.At(Strain.ShearStrainXY, Strain.ShearStrainXY, lameConstantMu);
            matrix.At(Strain.ShearStrainYZ, Strain.ShearStrainYZ, lameConstantMu);
            matrix.At(Strain.ShearStrainXZ, Strain.ShearStrainXZ, lameConstantMu);

            return matrix;
        }
コード例 #3
0
        protected KeyedSquareMatrix <Strain> CreateMaterialMatrix(double lameConstantLambda, double lameConstantMu)
        {
            IList <Strain> keys = new List <Strain>
            {
                Strain.LinearStrainX,
                Strain.LinearStrainY,
                Strain.LinearStrainZ,
                Strain.ShearStrainXY,
                Strain.ShearStrainYZ,
                Strain.ShearStrainXZ
            };
            KeyedSquareMatrix <Strain> matrix = new KeyedSquareMatrix <Strain>(keys);

            matrix.At(Strain.LinearStrainX, Strain.LinearStrainX, lameConstantLambda + 2 * lameConstantMu);
            matrix.At(Strain.LinearStrainY, Strain.LinearStrainY, lameConstantLambda + 2 * lameConstantMu);
            matrix.At(Strain.LinearStrainZ, Strain.LinearStrainZ, lameConstantLambda + 2 * lameConstantMu);

            matrix.At(Strain.LinearStrainX, Strain.LinearStrainY, lameConstantLambda);
            matrix.At(Strain.LinearStrainX, Strain.LinearStrainZ, lameConstantLambda);
            matrix.At(Strain.LinearStrainY, Strain.LinearStrainX, lameConstantLambda);
            matrix.At(Strain.LinearStrainY, Strain.LinearStrainZ, lameConstantLambda);
            matrix.At(Strain.LinearStrainZ, Strain.LinearStrainX, lameConstantLambda);
            matrix.At(Strain.LinearStrainZ, Strain.LinearStrainY, lameConstantLambda);

            matrix.At(Strain.ShearStrainXY, Strain.ShearStrainXY, lameConstantMu);
            matrix.At(Strain.ShearStrainYZ, Strain.ShearStrainYZ, lameConstantMu);
            matrix.At(Strain.ShearStrainXZ, Strain.ShearStrainXZ, lameConstantMu);

            return(matrix);
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override StiffnessMatrix LocalStiffnessMatrix()
        {
            double elementVolume = this.Element.Thickness * this.Element.Area;
            KeyedSquareMatrix <Strain> materialMatrix = this.MaterialMatrix;
            KeyedRowColumnMatrix <Strain, NodalDegreeOfFreedom> strainDisplacementMatrix           = this.StrainDisplacementMatrix(null);
            KeyedRowColumnMatrix <NodalDegreeOfFreedom, Strain> transposedStrainDisplacementMatrix = strainDisplacementMatrix.Transpose();

            KeyedRowColumnMatrix <NodalDegreeOfFreedom, Strain> bte = transposedStrainDisplacementMatrix.Multiply <Strain, Strain>(materialMatrix);

            KeyedRowColumnMatrix <NodalDegreeOfFreedom, NodalDegreeOfFreedom> bteb = bte.Multiply <Strain, NodalDegreeOfFreedom>(strainDisplacementMatrix);

            StiffnessMatrix k = new StiffnessMatrix(bteb.Multiply(elementVolume));

            return(k);
        }
コード例 #5
0
        /// <summary>
        /// Prepares and generates the stiffness matrix.
        /// It creates an entirely new matrix from the current set of nodes and the supported degrees of freedom of this element.
        /// It calls the GenerateStiffnessMatrix method which inheriting classes are expected to implement.
        /// It sets the stiffnessMatrixHasBeenGenerated flag to true.
        /// </summary>
        protected StiffnessMatrix BuildGlobalStiffnessMatrix()
        {
            StiffnessMatrix k = this.LocalStiffnessMatrix();
            KeyedSquareMatrix <NodalDegreeOfFreedom> t = this.BuildStiffnessRotationMatrixFromLocalToGlobalCoordinates();

            k = new StiffnessMatrix(t.RowKeys, t.ColumnKeys, k);                                       //pad out local stiffness matrix with zeros so that it is the same size as the rotational matrix
            Guard.AgainstInvalidState(() => { return(!k.Determinant().IsApproximatelyEqualTo(0.0)); }, ///TODO calculating the determinant is computationally intensive.  We should use another method of model verification to speed this up.
                                      "The stiffness matrix for an individual element should be singular and non-invertible. i.e. it should have a zero determinant.  This is not the case for element {0} of type {1}",
                                      this.Element,
                                      this.Element.GetType());

            ////FIXME these multiplications assume the keys of both matrices are ordered and identical
            KeyedSquareMatrix <NodalDegreeOfFreedom> kt            = k.Multiply(t);                  // K*T
            KeyedSquareMatrix <NodalDegreeOfFreedom> ttransposedkt = t.TransposeThisAndMultiply(kt); // (T^)*K*T
            StiffnessMatrix globStiffMat = new StiffnessMatrix(ttransposedkt);

            Guard.AgainstInvalidState(() => { return(!globStiffMat.Determinant().IsApproximatelyEqualTo(0.0)); }, //TODO calculating the determinant is computationally intensive.  We should use another method of model verification to speed this up.
                                      "The global stiffness matrix for an individual element should be singular and non-invertible. i.e. it should have a zero determinant.  This is not the case for element {0} of type {1}",
                                      this.Element,
                                      this.Element.GetType());

            return(globStiffMat);
        }
コード例 #6
0
        /// <summary>
        /// Builds the rotational matrix from local coordinates to global coordinates.
        /// </summary>
        /// <returns></returns>
        protected KeyedSquareMatrix <NodalDegreeOfFreedom> BuildStiffnessRotationMatrixFromLocalToGlobalCoordinates()
        {
            KeyedSquareMatrix <DegreeOfFreedom> rotationMatrix = this.Element.CalculateElementRotationMatrix();

            KeyedSquareMatrix <NodalDegreeOfFreedom> elementRotationMatrixFromLocalToGlobalCoordinates = new KeyedSquareMatrix <NodalDegreeOfFreedom>(this.Element.SupportedGlobalNodalDegreeOfFreedoms);

            foreach (IFiniteElementNode node in this.Element.Nodes)
            {
                foreach (DegreeOfFreedom dofi in this.Element.SupportedGlobalBoundaryConditionDegreeOfFreedom)
                {
                    foreach (DegreeOfFreedom dofj in this.Element.SupportedGlobalBoundaryConditionDegreeOfFreedom)
                    {
                        if (!((dofi.IsLinear() && dofj.IsLinear()) || (dofi.IsRotational() && dofj.IsRotational())))
                        {
                            continue;
                        }

                        //HACK it is used to copy the keyed matrix [x] into a larger keyed matrix of:
                        //[x 0,
                        // 0 x]
                        DegreeOfFreedom i = dofi;
                        DegreeOfFreedom j = dofj;
                        if (dofi.IsRotational() && dofj.IsRotational())
                        {
                            // shift from rotational to linear
                            i = (DegreeOfFreedom)((int)dofi - 3);
                            j = (DegreeOfFreedom)((int)dofj - 3);
                        }

                        double valueToBeCopied = rotationMatrix.At(i, j);
                        elementRotationMatrixFromLocalToGlobalCoordinates.At(new NodalDegreeOfFreedom(node, dofi), new NodalDegreeOfFreedom(node, dofj), valueToBeCopied);
                    }
                }
            }

            return(elementRotationMatrixFromLocalToGlobalCoordinates);
        }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StiffnessMatrix" /> class.
 /// </summary>
 /// <param name="matrix"></param>
 public StiffnessMatrix(KeyedSquareMatrix <NodalDegreeOfFreedom> matrix)
     : base(matrix)
 {
     // empty
 }
コード例 #8
0
        public StiffnessMatrix Add(StiffnessMatrix other)
        {
            KeyedSquareMatrix <NodalDegreeOfFreedom> result = base.Add(other);

            return(new StiffnessMatrix(result));
        }
コード例 #9
0
        public new StiffnessMatrix Multiply(double scalar)
        {
            KeyedSquareMatrix <NodalDegreeOfFreedom> result = base.Multiply(scalar);

            return(new StiffnessMatrix(result));
        }
コード例 #10
0
        protected KeyedSquareMatrix <Strain> CreateMaterialMatrix(IList <Strain> supportedStrains, double lameConstantLambda, double lameConstantMu)
        {
            KeyedSquareMatrix <Strain> matrix = CreateMaterialMatrix(lameConstantLambda, lameConstantMu);

            return(matrix.SubMatrix(supportedStrains));
        }