private static void CalculatePressure1D( Element element, Edge edge, PressureBoundaryCondition pressure, IList <ControlPoint> controlPoints, IList <GaussLegendrePoint3D> gaussPoints, IDictionary <int, double> pressureLoad) { var nurbs = new Nurbs1D(element, controlPoints, edge); for (int j = 0; j < gaussPoints.Count; j++) { double xGaussPoint = 0; double yGaussPoint = 0; double jacobian1 = 0.0; double jacobian2 = 0.0; var elementControlPoints = element.ControlPointsDictionary.Values.ToArray(); for (int k = 0; k < elementControlPoints.Length; k++) { xGaussPoint += nurbs.NurbsValues[k, j] * elementControlPoints[k].X; yGaussPoint += nurbs.NurbsValues[k, j] * elementControlPoints[k].Y; jacobian1 += nurbs.NurbsDerivativeValuesKsi[k, j] * elementControlPoints[k].X; jacobian2 += nurbs.NurbsDerivativeValuesKsi[k, j] * elementControlPoints[k].Y; } double jacdet = Math.Sqrt(Math.Pow(jacobian1, 2) + Math.Pow(jacobian2, 2)); double norm = Math.Sqrt(Math.Pow(xGaussPoint, 2) + Math.Pow(yGaussPoint, 2)); var loadGaussPointX = pressure.Value * xGaussPoint / norm; var loadGaussPointY = pressure.Value * yGaussPoint / norm; for (int k = 0; k < elementControlPoints.Length; k++) { int dofIDX = element.Model.GlobalDofOrdering.GlobalFreeDofs[elementControlPoints[k], StructuralDof.TranslationX]; int dofIDY = element.Model.GlobalDofOrdering.GlobalFreeDofs[elementControlPoints[k], StructuralDof.TranslationY]; if (pressureLoad.ContainsKey(dofIDX)) { pressureLoad[dofIDX] += jacdet * gaussPoints[j].WeightFactor * nurbs.NurbsValues[k, j] * loadGaussPointX; } else { pressureLoad.Add(dofIDX, jacdet * gaussPoints[j].WeightFactor * nurbs.NurbsValues[k, j] * loadGaussPointX); } if (pressureLoad.ContainsKey(dofIDY)) { pressureLoad[dofIDY] += jacdet * gaussPoints[j].WeightFactor * nurbs.NurbsValues[k, j] * loadGaussPointY; } else { pressureLoad.Add(dofIDY, jacdet * gaussPoints[j].WeightFactor * nurbs.NurbsValues[k, j] * loadGaussPointY); } } } }
private void CalculatePressure(LoadProvider provider, PressureBoundaryCondition condition, Dictionary <int, double> load) { foreach (Element element in ElementsDictionary.Values) { foreach (int dof in provider.LoadPressure(element, this, condition).Keys) { if (load.ContainsKey(dof)) { load[dof] += provider.LoadPressure(element, this, condition)[dof]; } else { load.Add(dof, provider.LoadPressure(element, this, condition)[dof]); } } } }
/// <summary> /// This method cannot be used, combined with <see cref="NurbsElement3D"/> as it refers to two-dimensional loads. /// </summary> /// <param name="element">An <see cref="Element"/> of type <see cref="NurbsElement3D"/>.</param> /// <param name="face">The <see cref="Face"/> that the <see cref="PressureBoundaryCondition"/> was applied to.</param> /// <param name="pressure">The <see cref="PressureBoundaryCondition"/>.</param> /// <returns>A <see cref="Dictionary{TKey,TValue}"/> whose keys are the numbering of the degree of freedom and values are the magnitude of the load due to the <see cref="PressureBoundaryCondition"/>.</returns> public Dictionary <int, double> CalculateLoadingCondition(Element element, Face face, PressureBoundaryCondition pressure) => throw new NotSupportedException();
/// <summary> /// This method cannot be used, combined with <see cref="TSplineKirchhoffLoveShellElementMaterial"/> as it refers to one-dimensional loads. /// </summary> /// <param name="element">An element of type <see cref="TSplineKirchhoffLoveShellElementMaterial"/>.</param> /// <param name="edge">An one dimensional boundary entity. For more info see <see cref="Edge"/>.</param> /// <param name="pressure"><inheritdoc cref="PressureBoundaryCondition"/></param> /// <returns>A <see cref="Dictionary{TKey,TValue}"/> where integer values denote the degree of freedom that has a value double load value due to the enforcement of the <see cref="PressureBoundaryCondition"/>.</returns> public Dictionary <int, double> CalculateLoadingCondition(Element element, Edge edge, PressureBoundaryCondition pressure) => throw new NotImplementedException();
/// <summary> /// This method calculates the Pressure boundary condition when applied to a two-dimensional NURBS element. /// </summary> /// <param name="element">An element of type <see cref="NurbsElement2D"/>.</param> /// <param name="face">An two dimensional boundary entity. For more info see <see cref="Face"/>.</param> /// <param name="pressure"><inheritdoc cref="NeumannBoundaryCondition"/>.</param> /// <returns>A <see cref="Dictionary{TKey,TValue}"/> where integer values denote the degree of freedom that has a value double load value due to the enforcement of the <see cref="PressureBoundaryCondition"/>.</returns> public Dictionary <int, double> CalculateLoadingCondition(Element element, Face face, PressureBoundaryCondition pressure) { Contract.Requires(element != null, "The element cannot be null"); Contract.Requires(face != null, "The face cannot be null"); Contract.Requires(pressure != null, "The pressure boundary condition cannot be null"); var dofs = new IDofType[] { StructuralDof.TranslationX, StructuralDof.TranslationY, StructuralDof.TranslationZ }; IList <GaussLegendrePoint3D> gaussPoints = CreateElementGaussPoints(element, face.Degrees[0], face.Degrees[1]); Dictionary <int, double> pressureLoad = new Dictionary <int, double>(); var elementControlPoints = element.ControlPoints.ToArray(); Nurbs2D nurbs = new Nurbs2D(element, elementControlPoints, face); for (int j = 0; j < gaussPoints.Count; j++) { Matrix jacobianMatrix = Matrix.CreateZero(2, 3); double xGaussPoint = 0; double yGaussPoint = 0; double zGaussPoint = 0; for (int k = 0; k < elementControlPoints.Length; k++) { xGaussPoint += nurbs.NurbsValues[k, j] * elementControlPoints[k].X; yGaussPoint += nurbs.NurbsValues[k, j] * elementControlPoints[k].Y; zGaussPoint += nurbs.NurbsValues[k, j] * elementControlPoints[k].Z; jacobianMatrix[0, 0] += nurbs.NurbsDerivativeValuesKsi[k, j] * elementControlPoints[k].X; jacobianMatrix[0, 1] += nurbs.NurbsDerivativeValuesKsi[k, j] * elementControlPoints[k].Y; jacobianMatrix[0, 2] += nurbs.NurbsDerivativeValuesKsi[k, j] * elementControlPoints[k].Z; jacobianMatrix[1, 0] += nurbs.NurbsDerivativeValuesHeta[k, j] * elementControlPoints[k].X; jacobianMatrix[1, 1] += nurbs.NurbsDerivativeValuesHeta[k, j] * elementControlPoints[k].Y; jacobianMatrix[1, 2] += nurbs.NurbsDerivativeValuesHeta[k, j] * elementControlPoints[k].Z; } Vector surfaceBasisVector1 = Vector.CreateZero(3); surfaceBasisVector1[0] = jacobianMatrix[0, 0]; surfaceBasisVector1[1] = jacobianMatrix[0, 1]; surfaceBasisVector1[2] = jacobianMatrix[0, 2]; Vector surfaceBasisVector2 = Vector.CreateZero(3); surfaceBasisVector2[0] = jacobianMatrix[1, 0]; surfaceBasisVector2[1] = jacobianMatrix[1, 1]; surfaceBasisVector2[2] = jacobianMatrix[1, 2]; Vector surfaceBasisVector3 = surfaceBasisVector1.CrossProduct(surfaceBasisVector2); double jacdet = (jacobianMatrix[0, 0] * jacobianMatrix[1, 1]) - (jacobianMatrix[1, 0] * jacobianMatrix[0, 1]); for (int k = 0; k < elementControlPoints.Length; k++) { for (int m = 0; m < 3; m++) { int dofID = element.Model.GlobalDofOrdering.GlobalFreeDofs[elementControlPoints[k], dofs[m]]; if (pressureLoad.ContainsKey(dofID)) { pressureLoad[dofID] += nurbs.NurbsValues[k, j] * jacdet * gaussPoints[j].WeightFactor * pressure.Value * surfaceBasisVector3[m]; } else { pressureLoad.Add(dofID, nurbs.NurbsValues[k, j] * jacdet * gaussPoints[j].WeightFactor * pressure.Value * surfaceBasisVector3[m]); } } } } return(pressureLoad); }
/// <summary> /// This method calculates the Neumann boundary condition when applied to a one dimensional NURBS element. /// </summary> /// <param name="element">An element of type <see cref="NurbsElement1D"/>.</param> /// <param name="edge">An one dimensional boundary entity. For more info see <see cref="Edge"/>.</param> /// <param name="pressure"><inheritdoc cref="PressureBoundaryCondition"/></param> /// <returns>A <see cref="Dictionary{TKey,TValue}"/> where integer values denote the degree of freedom that has a value double load value due to the enforcement of the <see cref="PressureBoundaryCondition"/>.</returns> public Dictionary <int, double> CalculateLoadingCondition(Element element, Edge edge, PressureBoundaryCondition pressure) { Contract.Requires(element != null, "The element cannot be null"); Contract.Requires(edge != null, "The edge cannot be null"); Contract.Requires(pressure != null, "The pressure BC cannot be null"); var gaussPoints = CreateElementGaussPoints(element); var pressureLoad = new Dictionary <int, double>(); IList <ControlPoint> controlPoints = new List <ControlPoint>(); CalculateEdgeControlPoints(element, edge, controlPoints); CalculatePressure1D(element, edge, pressure, controlPoints, gaussPoints, pressureLoad); return(pressureLoad); }