Пример #1
0
        public virtual IMatrix2D StiffnessMatrix(IElement element)
        {
            double[,] coordinates = this.GetCoordinates(element);
            GaussLegendrePoint3D[] integrationPoints = this.CalculateGaussMatrices(coordinates);
            SymmetricMatrix2D      stiffnessMatrix   = new SymmetricMatrix2D(8);
            int pointId = -1;

            foreach (GaussLegendrePoint3D gaussPoint in integrationPoints)
            {
                pointId++;
                IMatrix2D constitutiveMatrix = materialsAtGaussPoints[pointId].ConstitutiveMatrix;
                double[,] b = gaussPoint.DeformationMatrix;
                for (int i = 0; i < 8; i++)
                {
                    double[] eb = new double[3];
                    for (int iE = 0; iE < 3; iE++)
                    {
                        eb[iE] = (constitutiveMatrix[iE, 0] * b[0, i]) + (constitutiveMatrix[iE, 1] * b[1, i]) +
                                 (constitutiveMatrix[iE, 2] * b[2, i]);
                    }


                    for (int j = i; j < 8; j++)
                    {
                        double stiffness = (b[0, j] * eb[0]) + (b[1, j] * eb[1]) + (b[2, j] * eb[2]);
                        stiffnessMatrix[i, j] += stiffness * gaussPoint.WeightFactor;
                    }
                }
            }

            return(stiffnessMatrix);
        }
Пример #2
0
        public double[] CalculateAccelerationForces(Element element, IList <MassAccelerationLoad> loads)
        {
            Vector <double>    accelerations = new Vector <double>(6);
            IMatrix2D <double> massMatrix    = MassMatrix(element);

            int index = 0;

            foreach (MassAccelerationLoad load in loads)
            {
                foreach (DOFType[] nodalDOFTypes in dofs)
                {
                    foreach (DOFType dofType in nodalDOFTypes)
                    {
                        if (dofType == load.DOF)
                        {
                            accelerations[index] += load.Amount;
                        }
                        index++;
                    }
                }
            }

            double[] forces = new double[6];
            massMatrix.Multiply(accelerations, forces);
            return(forces);
        }
Пример #3
0
        public virtual IMatrix2D <double> StiffnessMatrix(Element element)
        {
            double[,] coordinates = this.GetCoordinates(element);
            GaussLegendrePoint3D[] integrationPoints = this.CalculateGaussMatrices(coordinates);

            SymmetricMatrix2D <double> stiffnessMatrix = new SymmetricMatrix2D <double>(24);

            int pointId = -1;

            foreach (GaussLegendrePoint3D intPoint in integrationPoints)
            {
                pointId++;
                IMatrix2D <double> constitutiveMatrix = materialsAtGaussPoints[pointId].ConstitutiveMatrix;
                double[,] b = intPoint.DeformationMatrix;
                for (int i = 0; i < 24; i++)
                {
                    double[] eb = new double[24];
                    for (int iE = 0; iE < 6; iE++)
                    {
                        eb[iE] = (constitutiveMatrix[iE, 0] * b[0, i]) + (constitutiveMatrix[iE, 1] * b[1, i]) +
                                 (constitutiveMatrix[iE, 2] * b[2, i]) + (constitutiveMatrix[iE, 3] * b[3, i]) +
                                 (constitutiveMatrix[iE, 4] * b[4, i]) + (constitutiveMatrix[iE, 5] * b[5, i]);
                    }

                    for (int j = i; j < 24; j++)
                    {
                        double stiffness = (b[0, j] * eb[0]) + (b[1, j] * eb[1]) + (b[2, j] * eb[2]) + (b[3, j] * eb[3]) +
                                           (b[4, j] * eb[4]) + (b[5, j] * eb[5]);
                        stiffnessMatrix[i, j] += stiffness * intPoint.WeightFactor;
                    }
                }
            }

            return(stiffnessMatrix);
        }
Пример #4
0
        public double[] CalculateForces(Element element, double[] localDisplacements, double[] localdDisplacements)
        {
            IMatrix2D <double> stiffnessMatrix = StiffnessMatrix(element);
            Vector <double>    disps           = new Vector <double>(localDisplacements);

            double[] forces = new double[localDisplacements.Length];
            stiffnessMatrix.Multiply(disps, forces);
            return(forces);
        }
        //private static int[] CalculateRowIndex(Subdomain subdomain)
        //{
        //    return CalculateRowIndex(subdomain, subdomain.NodalDOFsDictionary);
        //}

        public static SkylineMatrix2D <double> CalculateGlobalMatrix(Subdomain subdomain, Dictionary <int, Dictionary <DOFType, int> > nodalDOFsDictionary, IElementMatrixProvider elementProvider)
        {
            // TODO: should encapsulate DOF logic into a separate entity that will manage things if embedded or not (should return element matrix and globaldofs correspondence list
            var times                  = new Dictionary <string, TimeSpan>();
            var totalStart             = DateTime.Now;
            SkylineMatrix2D <double> K = new SkylineMatrix2D <double>(GlobalMatrixAssemblerSkyline.CalculateRowIndex(subdomain, nodalDOFsDictionary));

            times.Add("rowIndexCalculation", DateTime.Now - totalStart);
            times.Add("element", TimeSpan.Zero);
            times.Add("addition", TimeSpan.Zero);
            foreach (Element element in subdomain.ElementsDictionary.Values)
            {
                var isEmbeddedElement       = element.ElementType is IEmbeddedElement;
                var elStart                 = DateTime.Now;
                IMatrix2D <double> ElementK = elementProvider.Matrix(element);
                times["element"] += DateTime.Now - elStart;

                elStart = DateTime.Now;
                var elementDOFTypes     = element.ElementType.DOFEnumerator.GetDOFTypes(element);
                var matrixAssemblyNodes = element.ElementType.DOFEnumerator.GetNodesForMatrixAssembly(element);
                int iElementMatrixRow   = 0;
                for (int i = 0; i < elementDOFTypes.Count; i++)
                {
                    Node nodeRow = matrixAssemblyNodes[i];
                    foreach (DOFType dofTypeRow in elementDOFTypes[i])
                    {
                        int dofRow = nodalDOFsDictionary.ContainsKey(nodeRow.ID) == false && isEmbeddedElement ? -1 : nodalDOFsDictionary[nodeRow.ID][dofTypeRow];
                        if (dofRow != -1)
                        {
                            int iElementMatrixColumn = 0;
                            for (int j = 0; j < elementDOFTypes.Count; j++)
                            {
                                Node nodeColumn = matrixAssemblyNodes[j];
                                foreach (DOFType dofTypeColumn in elementDOFTypes[j])
                                {
                                    int dofColumn = nodalDOFsDictionary.ContainsKey(nodeColumn.ID) == false && isEmbeddedElement ? -1 : nodalDOFsDictionary[nodeColumn.ID][dofTypeColumn];
                                    if (dofColumn != -1)
                                    {
                                        int height = dofRow - dofColumn;
                                        if (height >= 0)
                                        {
                                            K.Data[K.RowIndex[dofRow] + height] += ElementK[iElementMatrixRow, iElementMatrixColumn];
                                        }
                                    }
                                    iElementMatrixColumn++;
                                }
                            }
                        }
                        iElementMatrixRow++;
                    }
                }
                times["addition"] += DateTime.Now - elStart;
            }
            var totalTime = DateTime.Now - totalStart;

            return(K);
        }
Пример #6
0
        public double[] CalculateForcesForLogging(Element element, double[] localDisplacements)
        {
            CalculateRotTranformation(element);
            IMatrix2D <double> stiffnessMatrix = StiffnessMatrixPure(element);
            var disps = rotTransformation * new Vector <double>(localDisplacements);

            double[] forces = new double[disps.Length];
            stiffnessMatrix.Multiply(disps, forces);
            return(forces);
        }
Пример #7
0
        public ShapeNURBS2D(NURBSElement2D element, IGAModel model, IVector <double> parametricCoordinateKsi, IVector <double> parametricCoordinateHeta, IList <ControlPoint> controlPoints)
        {
            int numberOfCPHeta = model.KnotValueVectorHeta.Length - model.DegreeHeta - 1;

            BSPLines1D bsplinesKsi  = new BSPLines1D(model.DegreeKsi, model.KnotValueVectorKsi, parametricCoordinateKsi);
            BSPLines1D bsplinesHeta = new BSPLines1D(model.DegreeHeta, model.KnotValueVectorHeta, parametricCoordinateHeta);

            nurbsValues = new Matrix2D <double>((model.DegreeKsi + 1) * (model.DegreeHeta + 1), element.gaussPoints.Count);
            nurbsDerivativeValuesKsi  = new Matrix2D <double>((model.DegreeKsi + 1) * (model.DegreeHeta + 1), element.gaussPoints.Count);
            nurbsDerivativeValuesHeta = new Matrix2D <double>((model.DegreeKsi + 1) * (model.DegreeHeta + 1), element.gaussPoints.Count);

            int supportKsi  = model.DegreeKsi + 1;
            int supportHeta = model.DegreeHeta + 1;
            int numberOfElementGaussPoints = (model.DegreeKsi + 1) * (model.DegreeHeta + 1);

            for (int i = 0; i < supportKsi; i++)
            {
                for (int j = 0; j < supportHeta; j++)
                {
                    double sumKsiHeta  = 0;
                    double sumdKsiHeta = 0;
                    double sumKsidHeta = 0;

                    for (int k = 0; k < numberOfElementGaussPoints; k++)
                    {
                        sumKsiHeta += bsplinesKsi.BSPLValues[element.connectivity[k] / numberOfCPHeta, i] *
                                      bsplinesHeta.BSPLValues[element.connectivity[k] % numberOfCPHeta, j] *
                                      controlPoints[k].Weight;

                        sumdKsiHeta = +bsplinesKsi.BSPLDerivativeValues[element.connectivity[k] / numberOfCPHeta, i] *
                                      bsplinesHeta.BSPLDerivativeValues[element.connectivity[k] % numberOfCPHeta, j] *
                                      controlPoints[k].Weight;

                        sumKsidHeta = +bsplinesKsi.BSPLValues[element.connectivity[k] / numberOfCPHeta, i] *
                                      bsplinesHeta.BSPLDerivativeValues[element.connectivity[k] % numberOfCPHeta, j] *
                                      controlPoints[k].Weight;
                    }
                    for (int k = 0; k < numberOfElementGaussPoints; k++)
                    {
                        nurbsValues[k, i *supportHeta + j] = bsplinesKsi.BSPLValues[element.connectivity[k] / numberOfCPHeta, i] *
                                                             bsplinesHeta.BSPLValues[element.connectivity[k] % numberOfCPHeta, j] *
                                                             controlPoints[k].Weight / sumKsiHeta;

                        nurbsDerivativeValuesKsi[k, i *supportHeta + j] = bsplinesHeta.BSPLValues[element.connectivity[k] % numberOfCPHeta, j] * controlPoints[k].Weight *
                                                                          (bsplinesKsi.BSPLDerivativeValues[element.connectivity[k] / numberOfCPHeta, i] * sumKsiHeta -
                                                                           bsplinesKsi.BSPLValues[element.connectivity[k] / numberOfCPHeta, i] * sumdKsiHeta) / Math.Pow(sumKsiHeta, 2);

                        nurbsDerivativeValuesHeta[k, i *supportHeta + j] = bsplinesKsi.BSPLValues[element.connectivity[k] / numberOfCPHeta, i] *
                                                                           controlPoints[k].Weight *
                                                                           (bsplinesHeta.BSPLDerivativeValues[element.connectivity[k] % numberOfCPHeta, j] * sumKsiHeta -
                                                                            bsplinesHeta.BSPLValues[element.connectivity[k] % numberOfCPHeta, j] * sumKsidHeta) / Math.Pow(sumKsiHeta, 2);
                    }
                }
            }
        }
Пример #8
0
        private Sparse2D <double> BuildQFromSubdomain(Subdomain subdomain)
        {
            Sparse2D <double> qSubdomain = new Sparse2D <double>(subdomain.TotalDOFs, subdomain.TotalDOFs);

            foreach (Element element in subdomain.ElementsDictionary.Values)
            {
                if (!(element.ElementType is IPorousFiniteElement))
                {
                    continue;
                }

                IPorousFiniteElement e = (IPorousFiniteElement)element.ElementType;
                IMatrix2D <double>   q = e.CouplingMatrix(element);

                int iElementMatrixRow = 0;
                for (int i = 0; i < element.ElementType.DOFEnumerator.GetDOFTypes(element).Count; i++)
                {
                    Node nodeRow = element.Nodes[i];
                    foreach (DOFType dofTypeRow in element.ElementType.DOFEnumerator.GetDOFTypes(element)[i])
                    {
                        if (dofTypeRow != DOFType.Pore)
                        {
                            continue;
                        }

                        int dofRow = subdomain.NodalDOFsDictionary[nodeRow.ID][dofTypeRow];
                        if (dofRow != -1)
                        {
                            int iElementMatrixColumn = 0;
                            for (int j = 0; j < element.ElementType.DOFEnumerator.GetDOFTypes(element).Count; j++)
                            {
                                Node nodeColumn = element.Nodes[j];
                                foreach (DOFType dofTypeColumn in element.ElementType.DOFEnumerator.GetDOFTypes(element)[j])
                                {
                                    if (dofTypeColumn == DOFType.Pore)
                                    {
                                        continue;
                                    }

                                    int dofColumn = subdomain.NodalDOFsDictionary[nodeColumn.ID][dofTypeColumn];
                                    if (dofColumn != -1)
                                    {
                                        qSubdomain[dofColumn, dofRow] += q[iElementMatrixRow, iElementMatrixColumn];
                                    }
                                    iElementMatrixColumn++;
                                }
                            }
                        }
                        iElementMatrixRow++;
                    }
                }
            }

            return(qSubdomain);
        }
Пример #9
0
        public void Paint(IDrawspace drawspace)
        {
            IMatrix2D copyXform = drawspace.Provider.CopyTransform(drawspace.PeekTransform());

            copyXform.PreMultiply(LocalXform);
            drawspace.PushTransform(copyXform);
            drawspace.PushClip(LocalClip);
            PaintComponent(drawspace);
            drawspace.PopClip();
            drawspace.PopTransform();
        }
Пример #10
0
        private IMatrix2D <double> PorousMatrix(Element element)
        {
            IPorousFiniteElement elementType = (IPorousFiniteElement)element.ElementType;
            int dofs = 0;

            foreach (IList <DOFType> dofTypes in elementType.DOFEnumerator.GetDOFTypes(element))
            {
                foreach (DOFType dofType in dofTypes)
                {
                    dofs++;
                }
            }
            SymmetricMatrix2D <double> poreMass = new SymmetricMatrix2D <double>(dofs);

            IMatrix2D <double> mass = solidMassProvider.Matrix(element);

            int matrixRow = 0;
            int solidRow  = 0;

            foreach (IList <DOFType> dofTypesRow in elementType.DOFEnumerator.GetDOFTypes(element))
            {
                foreach (DOFType dofTypeRow in dofTypesRow)
                {
                    int matrixCol = 0;
                    int solidCol  = 0;
                    foreach (IList <DOFType> dofTypesCol in elementType.DOFEnumerator.GetDOFTypes(element))
                    {
                        foreach (DOFType dofTypeCol in dofTypesCol)
                        {
                            if (dofTypeCol == DOFType.Pore)
                            {
                            }
                            else
                            {
                                if (dofTypeRow != DOFType.Pore)
                                {
                                    poreMass[matrixRow, matrixCol] = mass[solidRow, solidCol] * massCoefficient;
                                }
                                solidCol++;
                            }
                            matrixCol++;
                        }
                    }

                    if (dofTypeRow != DOFType.Pore)
                    {
                        solidRow++;
                    }
                    matrixRow++;
                }
            }

            return(poreMass);
        }
Пример #11
0
 public void Draw(VeldridDrawspace dspace, IMatrix2D matrix)
 {
     dspace.CommandList.SetVertexBuffer(0, Vertices);
     dspace.CommandList.SetIndexBuffer(Indices, IndexFormat.UInt16);
     dspace.CommandList.SetPipeline(dspace.Pipeline);
     // Issue a Draw command for a single instance with 4 indices.
     dspace.CommandList.DrawIndexed(
         indexCount: 4,
         instanceCount: 1,
         indexStart: 0,
         vertexOffset: 0,
         instanceStart: 0);
 }
Пример #12
0
 public IMatrix2D <double> Matrix(Element element)
 {
     if (element.ElementType is IPorousFiniteElement)
     {
         return(PorousMatrix(element));
     }
     else
     {
         IMatrix2D <double> massMatrix = solidMassProvider.Matrix(element);
         massMatrix.Scale(massCoefficient);
         return(massMatrix);
     }
 }
 public IMatrix2D <double> Matrix(Element element)
 {
     if (element.ElementType is IPorousFiniteElement)
     {
         return(PorousMatrix(element));
     }
     else
     {
         IMatrix2D <double> dampingMatrix = solidDampingProvider.Matrix(element);
         dampingMatrix.Scale(dampingCoefficient);
         return(dampingMatrix);
     }
 }
Пример #14
0
        public double[] CalculateForces(Element element, double[] localDisplacements, double[] localdDisplacements)
        {
            IMatrix2D <double> stiffnessMatrix = StiffnessMatrix(element);
            Vector <double>    disps           = new Vector <double>(localDisplacements.Length);

            double[] forces = new double[localDisplacements.Length];
            for (int i = 0; i < localDisplacements.Length; i++)
            {
                //disps[i] = localDisplacements[i] + localdDisplacements[i];
                disps[i] = localDisplacements[i];
            }
            stiffnessMatrix.Multiply(disps, forces);
            return(forces);
        }
Пример #15
0
        public IMatrix2D <double> GetTransformedMatrix(IMatrix2D <double> matrix)
        {
            var e = embeddedElement.ElementType as IEmbeddedElement;

            //if (e == null || !isElementEmbedded) return matrix;
            if (e == null)
            {
                return(matrix);
            }
            if (e.EmbeddedNodes.Count == 0)
            {
                return(matrix);
            }

            return(transformationMatrix.Transpose() * ((SymmetricMatrix2D <double>)matrix).ToMatrix2D() * transformationMatrix);
        }
Пример #16
0
        private void ComposeStochasticMatrixFromMatrices()
        {
            var currentRandomNumbers = randomNumbers[currentSimulation];
            var coefficients = new double[] { 1 }.Concat(currentRandomNumbers).ToList <double>();
            var matricesPerSubdomain = new Dictionary <int, IMatrix2D <double>[]>();

            foreach (var subdomain in subdomains.Values)
            {
                int id           = subdomain.ID;
                var tempMatrices = new IMatrix2D <double> [expansionOrder + 1];
                for (int i = 0; i <= expansionOrder; i++)
                {
                    tempMatrices[i] = matrices[i][id];
                }
                matricesPerSubdomain.Add(id, tempMatrices);
            }

            foreach (var subdomain in subdomains.Values)
            {
                subdomain.Matrix = (SkylineMatrix2D <double>)((SkylineMatrix2D <double>)matrices[0][subdomain.ID]).Clone();
            }
            foreach (var subdomain in subdomains.Values)
            {
                subdomain.Matrix.LinearCombination(coefficients, matricesPerSubdomain[subdomain.ID]);
            }


            //for (int i = 0; i < expansionOrder; i++)
            //{
            //    foreach (var subdomain in subdomains.Values)
            //    {
            //        SkylineMatrix2D<double> k = (SkylineMatrix2D<double>)matrices[i + 1][subdomain.ID];
            //        subdomain.Matrix.LinearCombination(new double[] { randomNumbers[currentSimulation][i] }, new IMatrix2D<double>[] { k });
            //    }
            //}
        }
Пример #17
0
 public IMatrix2D CopyTransform(IMatrix2D source)
 {
     return(new Matrix2D(source));
 }
Пример #18
0
 public IMatrix2D <double> GetTransformedMatrix(IMatrix2D <double> matrix)
 {
     return(matrix);
 }
Пример #19
0
        private void CreateElementGaussPoints()
        {
            GaussLegendrePoint1D[] gaussPointsPerAxisKsi =
                GaussQuadrature.GetGaussLegendrePoints(model.DegreeKsi);

            GaussLegendrePoint1D[] gaussPointsPerAxisHeta =
                GaussQuadrature.GetGaussLegendrePoints(model.DegreeHeta);

            IVector <double> coordinatesKsi = new Vector <double>(gaussPointsPerAxisKsi.Length);
            IVector <double> weightsKsi     = new Vector <double>(gaussPointsPerAxisKsi.Length);

            for (int indexKsi = 0; indexKsi < gaussPointsPerAxisKsi.Length; indexKsi++)
            {
                coordinatesKsi[indexKsi] = 0.5 * (knots[0].Ksi + knots[2].Ksi + (knots[2].Ksi - knots[0].Ksi) * gaussPointsPerAxisKsi[indexKsi].Coordinate);
                weightsKsi[indexKsi]     = 0.5 * ((knots[2].Ksi - knots[0].Ksi) * gaussPointsPerAxisKsi[indexKsi].WeightFactor);
            }

            IVector <double> coordinatesHeta = new Vector <double>(gaussPointsPerAxisHeta.Length);
            IVector <double> weightsHeta     = new Vector <double>(gaussPointsPerAxisHeta.Length);

            for (int indexHeta = 0; indexHeta < gaussPointsPerAxisHeta.Length; indexHeta++)
            {
                coordinatesHeta[indexHeta] = 0.5 * (knots[0].Heta + knots[2].Heta + (knots[2].Heta - knots[0].Heta) * gaussPointsPerAxisHeta[indexHeta].Coordinate);
                weightsHeta[indexHeta]     = 0.5 * ((knots[2].Heta - knots[0].Heta) * gaussPointsPerAxisHeta[indexHeta].WeightFactor);
            }

            IList <ControlPoint> controlPointsElement = new List <ControlPoint>();

            for (int k = 0; k < (model.DegreeKsi + 1) * (model.DegreeHeta + 1); k++)
            {
                controlPointsElement.Add(model.ControlPoints[this.connectivity[k]]);
            }

            ShapeNURBS2D nurbs = new ShapeNURBS2D(this, model, coordinatesKsi, coordinatesHeta, controlPointsElement);

            for (int i = 0; i < gaussPointsPerAxisKsi.Length; i++)
            {
                for (int j = 0; j < gaussPointsPerAxisHeta.Length; j++)
                {
                    IMatrix2D <double> jacobianMatrix = new Matrix2D <double>(2, 2);

                    for (int k = 0; k < controlPointsElement.Count; k++)
                    {
                        jacobianMatrix[0, 0] += nurbs.nurbsDerivativeValuesKsi[k, j] * controlPointsElement[k].X;
                        jacobianMatrix[0, 1] += nurbs.nurbsDerivativeValuesKsi[k, j] * controlPointsElement[k].Y;
                        jacobianMatrix[1, 0] += nurbs.nurbsDerivativeValuesHeta[k, j] * controlPointsElement[k].X;
                        jacobianMatrix[1, 1] += nurbs.nurbsDerivativeValuesHeta[k, j] * controlPointsElement[k].Y;
                    }

                    double jacdet = jacobianMatrix[0, 0] * jacobianMatrix[1, 1]
                                    - jacobianMatrix[1, 0] * jacobianMatrix[0, 1];


                    Matrix2D <double> B1 = new Matrix2D <double>(3, 4);

                    B1[0, 0] += jacobianMatrix[1, 1] / jacdet;
                    B1[0, 1] += -jacobianMatrix[0, 1] / jacdet;
                    B1[1, 2] += -jacobianMatrix[1, 0] / jacdet;
                    B1[1, 3] += jacobianMatrix[0, 0] / jacdet;
                    B1[2, 0] += -jacobianMatrix[1, 0] / jacdet;
                    B1[2, 1] += jacobianMatrix[0, 0] / jacdet;
                    B1[2, 2] += jacobianMatrix[1, 1] / jacdet;
                    B1[2, 3] += -jacobianMatrix[0, 1] / jacdet;

                    Matrix2D <double> B2 = new Matrix2D <double>(4, 2 * controlPointsElement.Count);

                    for (int column = 0; column < 2 * controlPointsElement.Count; column += 2)
                    {
                        B2[0, column]     += nurbs.nurbsDerivativeValuesKsi[column / 2, j];
                        B2[1, column]     += nurbs.nurbsDerivativeValuesHeta[column / 2, j];
                        B2[2, column + 1] += nurbs.nurbsDerivativeValuesKsi[column / 2, j];
                        B2[3, column + 1] += nurbs.nurbsDerivativeValuesHeta[column / 2, j];
                    }

                    IMatrix2D <double> B = B1 * B2;


                    double weightFactor = gaussPointsPerAxisKsi[i].WeightFactor * gaussPointsPerAxisHeta[i].WeightFactor * jacdet;
                    this.gaussPoints.Add(new GaussLegendrePoint3D(gaussPointsPerAxisKsi[i].Coordinate, gaussPointsPerAxisHeta[j].Coordinate, 0.0, B, weightFactor));
                }
            }
        }
Пример #20
0
        private IMatrix2D <double> PorousMatrix(Element element)
        {
            IPorousFiniteElement elementType = (IPorousFiniteElement)element.ElementType;
            int dofs = 0;

            foreach (IList <DOFType> dofTypes in elementType.DOFTypes)
            {
                foreach (DOFType dofType in dofTypes)
                {
                    dofs++;
                }
            }
            SymmetricMatrix2D <double> poreStiffness = new SymmetricMatrix2D <double>(dofs);

            for (int i = 0; i < dofs; i++)
            {
                poreStiffness[i, i] = 1;
            }

            IMatrix2D <double> permeability = elementType.PermeabilityMatrix(element);
            int matrixRow = 0;
            int solidRow  = 0;
            int fluidRow  = 0;

            foreach (IList <DOFType> dofTypesRow in elementType.DOFTypes)
            {
                foreach (DOFType dofTypeRow in dofTypesRow)
                {
                    int matrixCol = 0;
                    int solidCol  = 0;
                    int fluidCol  = 0;
                    foreach (IList <DOFType> dofTypesCol in elementType.DOFTypes)
                    {
                        foreach (DOFType dofTypeCol in dofTypesCol)
                        {
                            if (dofTypeCol == DOFType.Pore)
                            {
                                if (dofTypeRow == DOFType.Pore)
                                {
                                    poreStiffness[matrixRow, matrixCol] = permeability[fluidRow, fluidCol];
                                }
                                fluidCol++;
                            }
                            else
                            {
                                solidCol++;
                            }
                            matrixCol++;
                        }
                    }

                    if (dofTypeRow == DOFType.Pore)
                    {
                        fluidRow++;
                    }
                    else
                    {
                        solidRow++;
                    }
                    matrixRow++;
                }
            }

            return(poreStiffness);
        }
Пример #21
0
        public ShapeNURBS3D(NURBSElement3D element, IGAModel model, IVector <double> parametricCoordinateKsi, IVector <double> parametricCoordinateHeta, IVector <double> parametricCoordinateZeta, IList <ControlPoint> controlPoints)
        {
            int numberOfCPHeta = model.KnotValueVectorHeta.Length - model.DegreeHeta - 1;
            int numberOfCPZeta = model.KnotValueVectorZeta.Length - model.DegreeZeta - 1;

            BSPLines1D bsplinesKsi  = new BSPLines1D(model.DegreeKsi, model.KnotValueVectorKsi, parametricCoordinateKsi);
            BSPLines1D bsplinesHeta = new BSPLines1D(model.DegreeHeta, model.KnotValueVectorHeta, parametricCoordinateHeta);
            BSPLines1D bsplinesZeta = new BSPLines1D(model.DegreeZeta, model.KnotValueVectorZeta, parametricCoordinateZeta);

            nurbsValues = new Matrix2D <double>((model.DegreeKsi + 1) * (model.DegreeHeta + 1) * (model.DegreeZeta + 1), element.gaussPoints.Count);
            nurbsDerivativeValuesKsi  = new Matrix2D <double>((model.DegreeKsi + 1) * (model.DegreeHeta + 1) * (model.DegreeZeta + 1), element.gaussPoints.Count);
            nurbsDerivativeValuesHeta = new Matrix2D <double>((model.DegreeKsi + 1) * (model.DegreeHeta + 1) * (model.DegreeZeta + 1), element.gaussPoints.Count);
            nurbsDerivativeValuesZeta = new Matrix2D <double>((model.DegreeKsi + 1) * (model.DegreeHeta + 1) * (model.DegreeZeta + 1), element.gaussPoints.Count);

            int supportKsi  = model.DegreeKsi + 1;
            int supportHeta = model.DegreeHeta + 1;
            int supportZeta = model.DegreeZeta + 1;
            int numberOfElementGaussPoints = (model.DegreeKsi + 1) * (model.DegreeHeta + 1) * (model.DegreeZeta + 1);


            for (int i = 0; i < supportKsi; i++)
            {
                for (int j = 0; j < supportHeta; j++)
                {
                    for (int k = 0; k < supportZeta; k++)
                    {
                        double sumKsiHetaZeta  = 0;
                        double sumdKsiHetaZeta = 0;
                        double sumKsidHetaZeta = 0;
                        double sumKsiHetadZeta = 0;

                        for (int m = 0; m < numberOfElementGaussPoints; m++)
                        {
                            int indexKsi  = element.connectivity[m] / (numberOfCPHeta * numberOfCPZeta);
                            int indexHeta = element.connectivity[m] % (numberOfCPHeta * numberOfCPZeta) / numberOfCPZeta;
                            int indexZeta = element.connectivity[m] % (numberOfCPHeta * numberOfCPZeta) % numberOfCPZeta;

                            sumKsiHetaZeta += bsplinesKsi.BSPLValues[indexKsi, i] *
                                              bsplinesHeta.BSPLValues[indexHeta, j] *
                                              bsplinesZeta.BSPLValues[indexZeta, k] *
                                              controlPoints[m].Weight;

                            sumdKsiHetaZeta += bsplinesKsi.BSPLDerivativeValues[indexKsi, i] *
                                               bsplinesHeta.BSPLValues[indexHeta, j] *
                                               bsplinesZeta.BSPLValues[indexZeta, k] *
                                               controlPoints[m].Weight;

                            sumKsidHetaZeta += bsplinesKsi.BSPLValues[indexKsi, i] *
                                               bsplinesHeta.BSPLDerivativeValues[indexHeta, j] *
                                               bsplinesZeta.BSPLValues[indexZeta, k] *
                                               controlPoints[m].Weight;

                            sumKsiHetadZeta += bsplinesKsi.BSPLValues[indexKsi, i] *
                                               bsplinesHeta.BSPLValues[indexHeta, j] *
                                               bsplinesZeta.BSPLDerivativeValues[indexZeta, k] *
                                               controlPoints[m].Weight;
                        }
                        for (int m = 0; m < numberOfElementGaussPoints; m++)
                        {
                            int indexKsi  = element.connectivity[m] / (numberOfCPHeta * numberOfCPZeta);
                            int indexHeta = element.connectivity[m] % (numberOfCPHeta * numberOfCPZeta) / numberOfCPZeta;
                            int indexZeta = element.connectivity[m] % (numberOfCPHeta * numberOfCPZeta) % numberOfCPZeta;

                            nurbsValues[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLValues[indexKsi, i] *
                                bsplinesHeta.BSPLValues[indexHeta, j] *
                                bsplinesZeta.BSPLValues[indexZeta, k] *
                                controlPoints[m].Weight / sumKsiHetaZeta;

                            nurbsDerivativeValuesKsi[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                (bsplinesKsi.BSPLDerivativeValues[indexKsi, i] * sumKsiHetaZeta -
                                 bsplinesKsi.BSPLValues[indexKsi, i] * sumdKsiHetaZeta) *
                                bsplinesHeta.BSPLValues[indexHeta, j] *
                                bsplinesZeta.BSPLValues[indexZeta, k] *
                                controlPoints[m].Weight / Math.Pow(sumKsiHetaZeta, 2);

                            nurbsDerivativeValuesHeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLValues[indexKsi, i] *
                                (bsplinesHeta.BSPLDerivativeValues[indexHeta, j] * sumKsiHetaZeta -
                                 bsplinesHeta.BSPLValues[indexHeta, j] * sumKsidHetaZeta) *
                                bsplinesZeta.BSPLValues[indexZeta, k] *
                                controlPoints[m].Weight / Math.Pow(sumKsiHetaZeta, 2);

                            nurbsDerivativeValuesZeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLValues[indexKsi, i] *
                                bsplinesHeta.BSPLValues[indexHeta, j] *
                                (bsplinesZeta.BSPLDerivativeValues[indexZeta, k] * sumKsiHetaZeta -
                                 bsplinesZeta.BSPLValues[indexZeta, k] * sumKsiHetadZeta) *
                                controlPoints[m].Weight / Math.Pow(sumKsiHetaZeta, 2);
                        }
                    }
                }
            }
        }
        private IMatrix2D <double> PorousMatrix(Element element)
        {
            IPorousFiniteElement elementType = (IPorousFiniteElement)element.ElementType;
            int dofs = 0;

            foreach (IList <DOFType> dofTypes in elementType.DOFEnumerator.GetDOFTypes(element))
            {
                foreach (DOFType dofType in dofTypes)
                {
                    dofs++;
                }
            }
            SymmetricMatrix2D <double> poreStiffness = new SymmetricMatrix2D <double>(dofs);

            IMatrix2D <double> stiffness    = solidStiffnessProvider.Matrix(element);
            IMatrix2D <double> permeability = elementType.PermeabilityMatrix(element);

            int matrixRow = 0;
            int solidRow  = 0;
            int fluidRow  = 0;

            foreach (IList <DOFType> dofTypesRow in elementType.DOFEnumerator.GetDOFTypes(element))
            {
                foreach (DOFType dofTypeRow in dofTypesRow)
                {
                    int matrixCol = 0;
                    int solidCol  = 0;
                    int fluidCol  = 0;
                    foreach (IList <DOFType> dofTypesCol in elementType.DOFEnumerator.GetDOFTypes(element))
                    {
                        foreach (DOFType dofTypeCol in dofTypesCol)
                        {
                            if (dofTypeCol == DOFType.Pore)
                            {
                                if (dofTypeRow == DOFType.Pore)
                                {
                                    // H correction
                                    poreStiffness[matrixRow, matrixCol] = -permeability[fluidRow, fluidCol];
                                }
                                //poreStiffness[matrixRow, matrixCol] = permeability[fluidRow, fluidCol];
                                fluidCol++;
                            }
                            else
                            {
                                if (dofTypeRow != DOFType.Pore)
                                {
                                    poreStiffness[matrixRow, matrixCol] = stiffness[solidRow, solidCol] * stiffnessCoefficient;
                                }
                                solidCol++;
                            }
                            matrixCol++;
                        }
                    }

                    if (dofTypeRow == DOFType.Pore)
                    {
                        fluidRow++;
                    }
                    else
                    {
                        solidRow++;
                    }
                    matrixRow++;
                }
            }

            return(poreStiffness);
        }
Пример #23
0
        public BSPLines1D(int degree, IVector <double> knotValueVector, IVector <double> parametricCoordinates)
        {
            if (degree <= 0)
            {
                throw new IndexOutOfRangeException("The degree must be greater or equal to zero");
            }
            else if (knotValueVector == null)
            {
                throw new ArgumentNullException("Knot Value Vector is null");
            }

            int order = degree + 1;

            int numberOfCP = knotValueVector.Length - order;

            int numberOfGP = parametricCoordinates.Length;

            BSPLValues = new Matrix2D <double>(numberOfCP + degree, numberOfGP);

            BSPLDerivativeValues = new Matrix2D <double>(numberOfCP + degree, numberOfGP);

            // BSPLine Basis Functions. Degree=0.
            for (int i = 0; i < numberOfGP; i++)
            {
                for (int j = 0; j < numberOfCP; j++)
                {
                    if (knotValueVector[j] <= parametricCoordinates[i] && parametricCoordinates[i] < knotValueVector[j + 1])
                    {
                        BSPLValues[j, i] = 1;
                    }
                    else
                    {
                        BSPLValues[j, i] = 0;
                    }
                }
            }

            // BSPLineBasis Basis Functions. Degree=1:p
            for (int i = 0; i < degree; i++)
            {
                for (int j = 0; j < numberOfCP + degree - i; j++)
                {
                    for (int k = 0; k < numberOfGP; k++)
                    {
                        double additive1           = 0;
                        double additive2           = 0;
                        double additiveDerivative1 = 0;
                        double additiveDerivative2 = 0;

                        double denominator1 = knotValueVector[j + i] - knotValueVector[j];
                        double denominator2 = knotValueVector[j + i + 1] - knotValueVector[j + 1];

                        if (denominator1 != 0)
                        {
                            additive1           = (parametricCoordinates[k] - knotValueVector[j]) / denominator1 * BSPLValues[j, k];
                            additiveDerivative1 = ((parametricCoordinates[k] - knotValueVector[j]) * BSPLDerivativeValues[j, k]
                                                   + BSPLValues[j, k]) / denominator1;
                        }
                        if (denominator2 != 0)
                        {
                            additive2           = (knotValueVector[j + i + 1] - parametricCoordinates[k]) / denominator2 * BSPLValues[j + 1, k];
                            additiveDerivative2 = ((knotValueVector[j + i + 1] - parametricCoordinates[k]) * BSPLDerivativeValues[j + 1, k] - BSPLValues[j + 1, k]) / denominator2;
                        }
                        BSPLValues[j, k]           = additive1 + additive2;
                        BSPLDerivativeValues[j, k] = additiveDerivative1 + additiveDerivative2;
                    }
                }
            }
        }
Пример #24
0
 public void PreMultiply(IMatrix2D lhs)
 {
     SKMatrix.PreConcat(ref _skMatrix, ((Matrix2D)lhs)._skMatrix);
 }
Пример #25
0
        internal SKMatrix _skMatrix; // a strut

        public Matrix2D(IMatrix2D source)
        {
            _skMatrix = ((Matrix2D)source)._skMatrix; // copy on assign because struct
        }
        private IMatrix2D <double> PorousMatrix(Element element)
        {
            IPorousFiniteElement elementType = (IPorousFiniteElement)element.ElementType;
            int dofs = 0;

            foreach (IList <DOFType> dofTypes in elementType.DOFEnumerator.GetDOFTypes(element))
            {
                foreach (DOFType dofType in dofTypes)
                {
                    dofs++;
                }
            }
            SymmetricMatrix2D <double> poreDamping = new SymmetricMatrix2D <double>(dofs);

            IMatrix2D <double> damping    = solidDampingProvider.Matrix(element);
            IMatrix2D <double> saturation = elementType.SaturationMatrix(element);
            IMatrix2D <double> coupling   = elementType.CouplingMatrix(element);

            int matrixRow = 0;
            int solidRow  = 0;
            int fluidRow  = 0;

            foreach (IList <DOFType> dofTypesRow in elementType.DOFEnumerator.GetDOFTypes(element))
            {
                foreach (DOFType dofTypeRow in dofTypesRow)
                {
                    int matrixCol = 0;
                    int solidCol  = 0;
                    int fluidCol  = 0;
                    foreach (IList <DOFType> dofTypesCol in elementType.DOFEnumerator.GetDOFTypes(element))
                    {
                        foreach (DOFType dofTypeCol in dofTypesCol)
                        {
                            if (dofTypeCol == DOFType.Pore)
                            {
                                if (dofTypeRow == DOFType.Pore)
                                {
                                    poreDamping[matrixRow, matrixCol] = -saturation[fluidRow, fluidCol];
                                }
                                else
                                {
                                    poreDamping[matrixRow, matrixCol] = coupling[fluidCol, solidRow];
                                }
                                fluidCol++;
                            }
                            else
                            {
                                if (dofTypeRow != DOFType.Pore)
                                {
                                    poreDamping[matrixRow, matrixCol] = damping[solidRow, solidCol] * dampingCoefficient;
                                }
                                else
                                {
                                    poreDamping[matrixRow, matrixCol] = coupling[fluidRow, solidCol];
                                }
                                solidCol++;
                            }
                            matrixCol++;
                        }
                    }

                    if (dofTypeRow == DOFType.Pore)
                    {
                        fluidRow++;
                    }
                    else
                    {
                        solidRow++;
                    }
                    matrixRow++;
                }
            }

            return(poreDamping);
        }