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 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); }