示例#1
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);
        }
        private IMatrix PorousMatrix(IElement element)
        {
            IPorousFiniteElement elementType = (IPorousFiniteElement)element.ElementType;
            int dofs = 0;

            foreach (IList <IDofType> dofTypes in elementType.DofEnumerator.GetDofTypesForMatrixAssembly(element))
            {
                foreach (IDofType dofType in dofTypes)
                {
                    dofs++;
                }
            }
            var poreMass = SymmetricMatrix.CreateZero(dofs);

            IMatrix mass = solidMassProvider.Matrix(element);

            int matrixRow = 0;
            int solidRow  = 0;

            foreach (IList <IDofType> dofTypesRow in elementType.DofEnumerator.GetDofTypesForMatrixAssembly(element))
            {
                foreach (IDofType dofTypeRow in dofTypesRow)
                {
                    int matrixCol = 0;
                    int solidCol  = 0;
                    foreach (IList <IDofType> dofTypesCol in elementType.DofEnumerator.GetDofTypesForMatrixAssembly(element))
                    {
                        foreach (IDofType dofTypeCol in dofTypesCol)
                        {
                            if (dofTypeCol == PorousMediaDof.Pressure)
                            {
                            }
                            else
                            {
                                if (dofTypeRow != PorousMediaDof.Pressure)
                                {
                                    poreMass[matrixRow, matrixCol] = mass[solidRow, solidCol] * massCoefficient;
                                }
                                solidCol++;
                            }
                            matrixCol++;
                        }
                    }

                    if (dofTypeRow != PorousMediaDof.Pressure)
                    {
                        solidRow++;
                    }
                    matrixRow++;
                }
            }

            return(poreMass);
        }
        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);
        }
示例#4
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);
        }
        private IMatrix PorousMatrix(IElement element)
        {
            IPorousFiniteElement elementType = (IPorousFiniteElement)element.ElementType;
            int dofs = 0;

            foreach (IList <IDofType> dofTypes in elementType.DofEnumerator.GetDofTypesForMatrixAssembly(element))
            {
                foreach (IDofType dofType in dofTypes)
                {
                    dofs++;
                }
            }
            var poreStiffness = SymmetricMatrix.CreateZero(dofs);

            IMatrix stiffness    = solidStiffnessProvider.Matrix(element);
            IMatrix permeability = elementType.PermeabilityMatrix(element);

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

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

                    if (dofTypeRow == PorousMediaDof.Pressure)
                    {
                        fluidRow++;
                    }
                    else
                    {
                        solidRow++;
                    }
                    matrixRow++;
                }
            }

            return(poreStiffness);
        }
示例#6
0
        private IMatrix PorousMatrix(IElement element)
        {
            IPorousFiniteElement elementType = (IPorousFiniteElement)element.ElementType;
            int dofs = 0;

            foreach (IList <IDofType> dofTypes in elementType.DofEnumerator.GetDofTypesForMatrixAssembly(element))
            {
                foreach (IDofType dofType in dofTypes)
                {
                    dofs++;
                }
            }
            var poreDamping = SymmetricMatrix.CreateZero(dofs);

            IMatrix damping    = solidDampingProvider.Matrix(element);
            IMatrix saturation = elementType.SaturationMatrix(element);
            IMatrix coupling   = elementType.CouplingMatrix(element);

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

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

                    if (dofTypeRow == PorousMediaDof.Pressure)
                    {
                        fluidRow++;
                    }
                    else
                    {
                        solidRow++;
                    }
                    matrixRow++;
                }
            }

            return(poreDamping);
        }
        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);
        }
        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);
        }