コード例 #1
0
ファイル: EulerBeam2D.cs プロジェクト: mgroupntua/FEM
        ////[ 140*c^2+156*s^2,         -16*c*s,         -22*s*L,   70*c^2+54*s^2,          16*c*s,          13*s*L]
        ////[         -16*c*s, 140*s^2+156*c^2,          22*c*L,          16*c*s,   70*s^2+54*c^2,         -13*c*L]
        ////[         -22*s*L,          22*c*L,           4*L^2,         -13*s*L,          13*c*L,          -3*L^2]
        ////[   70*c^2+54*s^2,          16*c*s,         -13*s*L, 140*c^2+156*s^2,         -16*c*s,          22*s*L]
        ////[          16*c*s,   70*s^2+54*c^2,          13*c*L,         -16*c*s, 140*s^2+156*c^2,         -22*c*L]
        ////[          13*s*L,         -13*c*L,          -3*L^2,          22*s*L,         -22*c*L,           4*L^2]

        //public IMatrix2D<double> MassMatrix(Element element)
        //{
        //    double x2 = Math.Pow(element.Nodes[1].X - element.Nodes[0].X, 2);
        //    double y2 = Math.Pow(element.Nodes[1].Y - element.Nodes[0].Y, 2);
        //    double L = Math.Sqrt(x2 + y2);
        //    double L2 = L * L;
        //    double c = (element.Nodes[1].X - element.Nodes[0].X) / L;
        //    double c2 = c * c;
        //    double s = (element.Nodes[1].Y - element.Nodes[0].Y) / L;
        //    double s2 = s * s;
        //    double dAL420 = Density * SectionArea * L / 420;
        //    return new SymmetricMatrix2D<double>(new double[] { dAL420*(140*c2+156*s2), -16*dAL420*c*s, -22*dAL420*s*L, dAL420*(70*c2+54*s2), 16*dAL420*c*s, 13*dAL420*s*L,
        //        dAL420*(140*s2+156*c2), 22*dAL420*c*L, 16*dAL420*c*s, dAL420*(70*s2+54*c2), -13*dAL420*c*L,
        //        4*dAL420*L2, -13*dAL420*s*L, 13*dAL420*c*L, -3*dAL420*L2,
        //        dAL420*(140*c2+156*s2), -16*dAL420*c*s, 22*dAL420*s*L,
        //        dAL420*(140*s2+156*c2), -22*dAL420*c*L,
        //        4*dAL420*L2 });
        //}

        //[ 140*c^2+156*s^2,         -16*c*s,         -22*s*L,   70*c^2+54*s^2,          16*c*s,          13*s*L]
        //[         -16*c*s, 140*s^2+156*c^2,          22*c*L,          16*c*s,   70*s^2+54*c^2,         -13*c*L]
        //[         -22*s*L,          22*c*L,           4*L^2,         -13*s*L,          13*c*L,          -3*L^2]
        //[   70*c^2+54*s^2,          16*c*s,         -13*s*L, 140*c^2+156*s^2,         -16*c*s,          22*s*L]
        //[          16*c*s,   70*s^2+54*c^2,          13*c*L,         -16*c*s, 140*s^2+156*c^2,         -22*c*L]
        //[          13*s*L,         -13*c*L,          -3*L^2,          22*s*L,         -22*c*L,           4*L^2]
        public IMatrix MassMatrix(IElement element)
        {
            double x2     = Math.Pow(element.Nodes[1].X - element.Nodes[0].X, 2);
            double y2     = Math.Pow(element.Nodes[1].Y - element.Nodes[0].Y, 2);
            double L      = Math.Sqrt(x2 + y2);
            double L2     = L * L;
            double c      = (element.Nodes[1].X - element.Nodes[0].X) / L;
            double c2     = c * c;
            double s      = (element.Nodes[1].Y - element.Nodes[0].Y) / L;
            double s2     = s * s;
            double dAL420 = Density * SectionArea * L / 420;

            double totalMass = Density * SectionArea * L;
            double totalMassOfDiagonalTerms = 2 * dAL420 * (140 * c2 + 156 * s2) + 2 * dAL420 * (140 * s2 + 156 * c2);
            double scale = totalMass / totalMassOfDiagonalTerms;

            //TODO: optimize this
            int order = 6;

            return(SymmetricMatrix.CreateFromPackedRowMajorArray(new double[]
            {
                dAL420 *(140 * c2 + 156 * s2) * scale, 0, 0, 0, 0, 0,
                dAL420 * (140 * s2 + 156 * c2) * scale, 0, 0, 0, 0,
                0, 0, 0, 0,
                dAL420 * (140 * c2 + 156 * s2) * scale, 0, 0,
                dAL420 * (140 * s2 + 156 * c2) * scale, 0,
                0
            }, order));
        }
コード例 #2
0
ファイル: EulerBeam2D.cs プロジェクト: mgroupntua/FEM
        //[  c^2*E*A/L+12*s^2*E*I/L^3,  s*E*A/L*c-12*c*E*I/L^3*s,              -6*E*I/L^2*s, -c^2*E*A/L-12*s^2*E*I/L^3, -s*E*A/L*c+12*c*E*I/L^3*s,              -6*E*I/L^2*s]
        //[  s*E*A/L*c-12*c*E*I/L^3*s,  s^2*E*A/L+12*c^2*E*I/L^3,               6*E*I/L^2*c, -s*E*A/L*c+12*c*E*I/L^3*s, -s^2*E*A/L-12*c^2*E*I/L^3,               6*E*I/L^2*c]
        //[              -6*E*I/L^2*s,               6*E*I/L^2*c,                   4*E*I/L,               6*E*I/L^2*s,              -6*E*I/L^2*c,                   2*E*I/L]
        //[ -c^2*E*A/L-12*s^2*E*I/L^3, -s*E*A/L*c+12*c*E*I/L^3*s,               6*E*I/L^2*s,  c^2*E*A/L+12*s^2*E*I/L^3,  s*E*A/L*c-12*c*E*I/L^3*s,               6*E*I/L^2*s]
        //[ -s*E*A/L*c+12*c*E*I/L^3*s, -s^2*E*A/L-12*c^2*E*I/L^3,              -6*E*I/L^2*c,  s*E*A/L*c-12*c*E*I/L^3*s,  s^2*E*A/L+12*c^2*E*I/L^3,              -6*E*I/L^2*c]
        //[              -6*E*I/L^2*s,               6*E*I/L^2*c,                   2*E*I/L,               6*E*I/L^2*s,              -6*E*I/L^2*c,                   4*E*I/L]
        public virtual IMatrix StiffnessMatrix(IElement element)
        {
            double x2   = Math.Pow(element.Nodes[1].X - element.Nodes[0].X, 2);
            double y2   = Math.Pow(element.Nodes[1].Y - element.Nodes[0].Y, 2);
            double L    = Math.Sqrt(x2 + y2);
            double c    = (element.Nodes[1].X - element.Nodes[0].X) / L;
            double c2   = c * c;
            double s    = (element.Nodes[1].Y - element.Nodes[0].Y) / L;
            double s2   = s * s;
            double EL   = this.youngModulus / L;
            double EAL  = EL * SectionArea;
            double EIL  = EL * MomentOfInertia;
            double EIL2 = EIL / L;
            double EIL3 = EIL2 / L;

            //TODO: optimize this
            int order = 6;
            var k     = SymmetricMatrix.CreateFromPackedRowMajorArray(new double[]
            {
                c2 *EAL + 12 *s2 *EIL3, c *s *EAL - 12 *c *s *EIL3, -6 *s *EIL2, -c2 *EAL - 12 *s2 *EIL3, -c *s *EAL + 12 *c *s *EIL3, -6 *s *EIL2,
                s2 *EAL + 12 *c2 *EIL3, 6 *c *EIL2, -s *c *EAL + 12 *c *s *EIL3, -s2 *EAL - 12 *c2 *EIL3, 6 *c *EIL2,
                4 *EIL, 6 *s *EIL2, -6 *c *EIL2, 2 *EIL,
                c2 *EAL + 12 *s2 *EIL3, s *c *EAL - 12 *c *s *EIL3, 6 *s *EIL2,
                s2 *EAL + 12 *c2 *EIL3, -6 *c *EIL2,
                4 *EIL
            }, order);

            return(dofEnumerator.GetTransformedMatrix(k));
        }
コード例 #3
0
        public virtual IMatrix StiffnessMatrix(IElement element)
        {
            double[, ,] afE = new double[iInt3, 6, 6];

            for (int i = 0; i < iInt3; i++)
            {
                IMatrixView constitutive = materialsAtGaussPoints[i].ConstitutiveMatrix;
                for (int j = 0; j < 6; j++)
                {
                    for (int k = 0; k < 6; k++)
                    {
                        afE[i, j, k] = constitutive[j, k];
                    }
                }
            }

            double[,] faXYZ = GetCoordinates(element);
            double[,] faDS  = new double[iInt3, 24];
            double[,] faS   = new double[iInt3, 8];
            double[, ,] faB = new double[iInt3, 24, 6];
            double[] faDetJ = new double[iInt3];
            double[, ,] faJ = new double[iInt3, 3, 3];
            double[] faWeight = new double[iInt3];
            double[] faK      = new double[300];
            CalcH8GaussMatrices(ref iInt, faXYZ, faWeight, faS, faDS, faJ, faDetJ, faB);
            CalcH8K(ref iInt, afE, faB, faWeight, faK);
            return(dofEnumerator.GetTransformedMatrix(SymmetricMatrix.CreateFromPackedRowMajorArray(faK)));
        }
コード例 #4
0
        public double[] CalculateForces(IElement element, double[] localTotalDisplacements, double[] localDisplacements)
        {
            double[,] faStresses = new double[iInt3, 6];
            for (int i = 0; i < materialsAtGaussPoints.Length; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    faStresses[i, j] = materialsAtGaussPoints[i].Stresses[j];
                }
            }

            double[,] faXYZ = GetCoordinates(element);
            double[,] faDS  = new double[iInt3, 24];
            double[,] faS   = new double[iInt3, 8];
            double[, ,] faB = new double[iInt3, 24, 6];
            double[] faDetJ = new double[iInt3];
            double[, ,] faJ = new double[iInt3, 3, 3];
            double[] faWeight    = new double[iInt3];
            double[] solidForces = new double[24];
            CalcH8GaussMatrices(ref iInt, faXYZ, faWeight, faS, faDS, faJ, faDetJ, faB);
            CalcH8Forces(ref iInt, faB, faWeight, faStresses, solidForces);

            double[] faH            = new double[36];
            double[] faPermeability = new double[] { Permeability, Permeability, Permeability, Permeability,
                                                     Permeability, Permeability, Permeability, Permeability };
            CalcH20u8pH(ref iInt, faPermeability, faS, faB, faWeight, faH);

            //double[,] faQ = new double[8, 24];
            //double fPoreA = PoreA;
            //double[] faXw = new double[] { Xw, Xw, Xw, Xw, Xw, Xw, Xw, Xw };
            //CalcH8u8pQMinus(ref iInt, ref fPoreA, faXw, faB, faS, faWeight, faQ);
            //Matrix<double> q = (new Matrix<double>(faQ)).Transpose();

            // Changed! Check for errors...
            //Vector<double> fluidDisplacements = new Vector<double>(ExtractFluidVector(localDisplacements));
            var fluidDisplacements = ExtractFluidVector(localTotalDisplacements);

            //double[] solidAndFluidForces = solidForces;
            ////double[] solidAndFluidForces = q * fluidDisplacements + (new Vector<double>(solidForces));
            // H correction
            fluidDisplacements.ScaleIntoThis(-1.0);
            double[] fluidDrags = SymmetricMatrix.CreateFromPackedRowMajorArray(faH).Multiply(fluidDisplacements);

            double[] totalForces = new double[GetAllDOFs()];
            ScatterFromFluidVector(fluidDrags, totalForces);
            ScatterFromSolidVector(solidForces, totalForces);
            return(totalForces);
        }
コード例 #5
0
 public IMatrix SaturationMatrix(IElement element)
 {
     double[,] faXYZ = GetCoordinates(element);
     double[,] faDS  = new double[iInt3, 24];
     double[,] faS   = new double[iInt3, 8];
     double[, ,] faB = new double[iInt3, 24, 6];
     double[] faDetJ = new double[iInt3];
     double[, ,] faJ = new double[iInt3, 3, 3];
     double[] faWeight = new double[iInt3];
     double[] faXwDivQ = new double[] { Xw *QInv, Xw *QInv, Xw *QInv, Xw *QInv, Xw *QInv,
                                        Xw *QInv, Xw *QInv, Xw *QInv };
     double[] faSaturation = new double[36];
     CalcH8GaussMatrices(ref iInt, faXYZ, faWeight, faS, faDS, faJ, faDetJ, faB);
     CalcH20u8pS(ref iInt, faXwDivQ, faS, faWeight, faSaturation);
     return(SymmetricMatrix.CreateFromPackedRowMajorArray(faSaturation));
 }
コード例 #6
0
 public IMatrix PermeabilityMatrix(IElement element)
 {
     double[,] faXYZ = GetCoordinates(element);
     double[,] faDS  = new double[iInt3, 24];
     double[,] faS   = new double[iInt3, 8];
     double[, ,] faB = new double[iInt3, 24, 6];
     double[] faDetJ = new double[iInt3];
     double[, ,] faJ = new double[iInt3, 3, 3];
     double[] faWeight       = new double[iInt3];
     double[] faPermeability = new double[] { Permeability, Permeability, Permeability, Permeability,
                                              Permeability, Permeability, Permeability, Permeability };
     double[] faH = new double[36];
     CalcH8GaussMatrices(ref iInt, faXYZ, faWeight, faS, faDS, faJ, faDetJ, faB);
     CalcH20u8pH(ref iInt, faPermeability, faS, faB, faWeight, faH);
     return(SymmetricMatrix.CreateFromPackedRowMajorArray(faH));
 }
コード例 #7
0
        public IMatrix MassMatrix(IElement element)
        {
            double[,] faXYZ = GetCoordinates(element);
            double[,] faDS  = new double[iInt3, 24];
            double[,] faS   = new double[iInt3, 8];
            double[, ,] faB = new double[iInt3, 24, 6];
            double[] faDetJ = new double[iInt3];
            double[, ,] faJ = new double[iInt3, 3, 3];
            double[] faWeight = new double[iInt3];
            double[] faM      = new double[300];
            double   fDensity = Density;

            CalcH8GaussMatrices(ref iInt, faXYZ, faWeight, faS, faDS, faJ, faDetJ, faB);
            CalcH8MLumped(ref iInt, ref fDensity, faWeight, faM);
            return(SymmetricMatrix.CreateFromPackedRowMajorArray(faM));
        }
コード例 #8
0
ファイル: EulerBeam3D.cs プロジェクト: mgroupntua/FEM
        public IMatrix MassMatrix(IElement element)
        {
            double x2 = Math.Pow(element.Nodes[1].X - element.Nodes[0].X, 2);
            double y2 = Math.Pow(element.Nodes[1].Y - element.Nodes[0].Y, 2);
            double z2 = Math.Pow(element.Nodes[1].Z - element.Nodes[0].Z, 2);
            double L  = 1d / Math.Sqrt(x2 + y2 + z2);
            //double halfMass = 0.5 * Density * SectionArea * L;

            //var massMatrix = new SymmetricMatrix<double>(new double[] { halfMass, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0, 0, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0,
            //    halfMass, 0, 0,
            //    halfMass, 0,
            //    halfMass
            //});
            double halfMass   = Density * SectionArea / L / 6d;
            int    order      = 12;
            Matrix massMatrix = SymmetricMatrix.CreateFromPackedRowMajorArray(
                new double[] { halfMass, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                               halfMass, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                               halfMass, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                               0, 0, 0, 0, 0, 0, 0, 0, 0,
                               0, 0, 0, 0, 0, 0, 0, 0,
                               0, 0, 0, 0, 0, 0, 0,
                               halfMass, 0, 0, 0, 0, 0,
                               halfMass, 0, 0, 0, 0,
                               halfMass, 0, 0, 0,
                               0, 0, 0,
                               0, 0,
                               0 }, order).CopyToFullMatrix();

            var refx = new double[] { 1, 1, 1 };
            var beamTransformation = Matrix.CreateZero(order, order);

            beamTransformation[0, 0] = (element.Nodes[1].X - element.Nodes[0].X) * L;
            beamTransformation[0, 1] = (element.Nodes[1].Y - element.Nodes[0].Y) * L;
            beamTransformation[0, 2] = (element.Nodes[1].Z - element.Nodes[0].Z) * L;

            beamTransformation[1, 0] = refx[1] * beamTransformation[0, 2] - refx[2] * beamTransformation[0, 1];
            beamTransformation[1, 1] = refx[2] * beamTransformation[0, 0] - refx[0] * beamTransformation[0, 2];
            beamTransformation[1, 2] = refx[0] * beamTransformation[0, 1] - refx[1] * beamTransformation[0, 0];
            double dn = 1.0 / Math.Sqrt(beamTransformation[1, 0] * beamTransformation[1, 0] + beamTransformation[1, 1] * beamTransformation[1, 1] + beamTransformation[1, 2] * beamTransformation[1, 2]);

            beamTransformation[1, 0] = beamTransformation[1, 0] * dn;
            beamTransformation[1, 1] = beamTransformation[1, 1] * dn;
            beamTransformation[1, 2] = beamTransformation[1, 2] * dn;
            beamTransformation[2, 0] = beamTransformation[0, 1] * beamTransformation[1, 2] - beamTransformation[0, 2] * beamTransformation[1, 1];
            beamTransformation[2, 1] = beamTransformation[0, 2] * beamTransformation[1, 0] - beamTransformation[0, 0] * beamTransformation[1, 2];
            beamTransformation[2, 2] = beamTransformation[0, 0] * beamTransformation[1, 1] - beamTransformation[0, 1] * beamTransformation[1, 0];

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    beamTransformation[i + 3, j + 3] = beamTransformation[i, j];
                    beamTransformation[i + 6, j + 6] = beamTransformation[i, j];
                    beamTransformation[i + 9, j + 9] = beamTransformation[i, j];
                }
            }
            CalculateRotTranformation(element);

            return(dofEnumerator.GetTransformedMatrix(
                       rotTransformation.ThisTransposeTimesOtherTimesThis(
                           beamTransformation.ThisTransposeTimesOtherTimesThis(massMatrix))));
        }
コード例 #9
0
ファイル: EulerBeam3D.cs プロジェクト: mgroupntua/FEM
        private IMatrix StiffnessMatrixPure(IElement element)
        {
            double x2 = Math.Pow(element.Nodes[1].X - element.Nodes[0].X, 2);
            double y2 = Math.Pow(element.Nodes[1].Y - element.Nodes[0].Y, 2);
            double z2 = Math.Pow(element.Nodes[1].Z - element.Nodes[0].Z, 2);
            double L  = 1 / Math.Sqrt(x2 + y2 + z2);
            double L2 = L * L;
            double L3 = L2 * L;
            //double EIx = m.YoungModulus * MomentOfInertiaX;
            double EIy = this.youngModulus * MomentOfInertiaY;
            double EIz = this.youngModulus * MomentOfInertiaZ;
            double GJL = this.youngModulus * L * MomentOfInertiaPolar / (2 * (1 + this.poissonRatio));
            double EAL = this.youngModulus * SectionArea * L;

            //TODO: optimize this
            int    order           = 12;
            Matrix stiffnessMatrix = SymmetricMatrix.CreateFromPackedRowMajorArray(new double[]
            {
                EAL, 0, 0, 0, 0, 0, -EAL, 0, 0, 0, 0, 0,
                12 * EIz * L3, 0, 0, 0, 6 * EIz * L2, 0, -12 * EIz * L3, 0, 0, 0, 6 * EIz * L2,
                12 * EIy * L3, 0, -6 * EIy * L2, 0, 0, 0, -12 * EIy * L3, 0, -6 * EIy * L2, 0,
                GJL, 0, 0, 0, 0, 0, -GJL, 0, 0,
                4 * EIy * L, 0, 0, 0, 6 * EIy * L2, 0, 2 * EIy * L, 0,
                4 * EIz * L, 0, -6 * EIz * L2, 0, 0, 0, 2 * EIz * L,
                EAL, 0, 0, 0, 0, 0,
                12 * EIz * L3, 0, 0, 0, -6 * EIz * L2,
                12 * EIy * L3, 0, 6 * EIy * L2, 0,
                GJL, 0, 0,
                4 * EIy * L, 0,
                4 * EIz * L
            }, order).CopyToFullMatrix();

            var refx = new double[] { 1, 1, 1 };
            var beamTransformation = Matrix.CreateZero(order, order);

            beamTransformation[0, 0] = (element.Nodes[1].X - element.Nodes[0].X) * L;
            beamTransformation[0, 1] = (element.Nodes[1].Y - element.Nodes[0].Y) * L;
            beamTransformation[0, 2] = (element.Nodes[1].Z - element.Nodes[0].Z) * L;

            //beamTransformation[2, 0] = refx[0];
            //beamTransformation[2, 1] = refx[1];
            //beamTransformation[2, 2] = refx[2];

            //beamTransformation[1, 0] = beamTransformation[2, 1] * beamTransformation[0, 2] - beamTransformation[2, 2] * beamTransformation[0, 1];
            //beamTransformation[1, 1] = beamTransformation[2, 2] * beamTransformation[0, 0] - beamTransformation[2, 0] * beamTransformation[0, 2];
            //beamTransformation[1, 2] = beamTransformation[2, 0] * beamTransformation[0, 1] - beamTransformation[2, 1] * beamTransformation[0, 0];
            beamTransformation[1, 0] = refx[1] * beamTransformation[0, 2] - refx[2] * beamTransformation[0, 1];
            beamTransformation[1, 1] = refx[2] * beamTransformation[0, 0] - refx[0] * beamTransformation[0, 2];
            beamTransformation[1, 2] = refx[0] * beamTransformation[0, 1] - refx[1] * beamTransformation[0, 0];
            double dn = 1.0 / Math.Sqrt(beamTransformation[1, 0] * beamTransformation[1, 0] + beamTransformation[1, 1] * beamTransformation[1, 1] + beamTransformation[1, 2] * beamTransformation[1, 2]);

            beamTransformation[1, 0] = beamTransformation[1, 0] * dn;
            beamTransformation[1, 1] = beamTransformation[1, 1] * dn;
            beamTransformation[1, 2] = beamTransformation[1, 2] * dn;
            beamTransformation[2, 0] = beamTransformation[0, 1] * beamTransformation[1, 2] - beamTransformation[0, 2] * beamTransformation[1, 1];
            beamTransformation[2, 1] = beamTransformation[0, 2] * beamTransformation[1, 0] - beamTransformation[0, 0] * beamTransformation[1, 2];
            beamTransformation[2, 2] = beamTransformation[0, 0] * beamTransformation[1, 1] - beamTransformation[0, 1] * beamTransformation[1, 0];

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    beamTransformation[i + 3, j + 3] = beamTransformation[i, j];
                    beamTransformation[i + 6, j + 6] = beamTransformation[i, j];
                    beamTransformation[i + 9, j + 9] = beamTransformation[i, j];
                }
            }

            return(beamTransformation.ThisTransposeTimesOtherTimesThis(stiffnessMatrix));

            ////if (element.Nodes.Count(n => n.EmbeddedInElement != null) == 0) return stiffnessMatrix;
            //stiffnessMatrix = new SymmetricMatrix<double>(beamTransformation.Transpose() * stiffnessMatrix.ToMatrix() * beamTransformation);
            //if (embeddedNodes.Count == 0) return stiffnessMatrix;

            ////var hostElements = element.Nodes.Select(x => x.EmbeddedInElement).Distinct();
            //var size = GetElementDOFTypes(element).SelectMany(x => x).Count();
            //transformation = new Matrix<double>(dofs.SelectMany(d => d).Count(), size);
            //isNodeEmbedded = new bool[element.Nodes.Count];

            ////TODO : SEPARATE FROM ELEMENT!!
            ////TODO: Must match DOFs of host with embedded element
            //int row = 0;
            //int col = 0;
            //hostElementList = new List<Element>();
            //for (int i = 0; i < element.Nodes.Count; i++)
            //{
            //    var node = element.Nodes[i];
            //    var embeddedNode = embeddedNodes.Where(x => x.Node == node).FirstOrDefault();
            //    //var hostElement = node.EmbeddedInElement;
            //    Element hostElement = embeddedNode == null ? null : embeddedNode.EmbeddedInElement;
            //    if (hostElement == null)
            //    {
            //        isNodeEmbedded[i] = false;
            //        for (int j = 0; j < dofs[i].Length; j++)
            //        {
            //            transformation[row, col] = 1;
            //            row++;
            //            col++;
            //        }
            //    }
            //    else
            //    {
            //        isNodeEmbedded[i] = true;
            //        //double[] hostShapeFunctions = ((IEmbeddedHostElement)hostElement.ElementType).GetShapeFunctionsForNode(hostElement, node);
            //        double[] hostShapeFunctions = ((IEmbeddedHostElement)hostElement.ElementType).GetShapeFunctionsForNode(hostElement, embeddedNode);

            //        if (hostElementList.IndexOf(hostElement) < 0)
            //            hostElementList.Add(hostElement);
            //        else
            //            col -= hostShapeFunctions.Length * hostDofsPerNode;

            //        for (int j = 0; j < commonDofsPerNode; j++)
            //        {
            //            for (int k = 0; k < hostShapeFunctions.Length; k++)
            //                transformation[row, hostDofsPerNode * k + col + j] = hostShapeFunctions[k];
            //            row++;
            //        }
            //        row += embeddedDofsPerNode - commonDofsPerNode;
            //        col += hostShapeFunctions.Length * hostDofsPerNode;
            //    }
            //}

            //// Add identity matrix
            //int index = 0;
            //if (isNodeEmbedded[0])
            //{
            //    transformation[3, col] = 1;
            //    transformation[4, col + 1] = 1;
            //    transformation[5, col + 2] = 1;
            //    index += 3;
            //}
            //if (isNodeEmbedded[1])
            //{
            //    transformation[9, col + index] = 1;
            //    transformation[10, col + index + 1] = 1;
            //    transformation[11, col + index + 2] = 1;
            //}

            //var transformedMatrix = new SymmetricMatrix<double>(transformation.Transpose() * stiffnessMatrix.ToMatrix() * transformation);
            ////var sw = File.CreateText(@"d:\BeamTransformed.txt");
            ////for (int i = 0; i < 54; i++)
            ////{
            ////    var s = string.Empty;
            ////    for (int j = 0; j < 54; j++)
            ////        s += transformedMatrix[i, j].ToString() + ";";
            ////    sw.WriteLine(s);
            ////}
            ////sw.Close();
            //return transformedMatrix;
        }