/// <summary> /// Creates Paraview File of the T-Splines shells geometry. /// </summary> public void CreateParaviewFile(TSplineShellType shellType = TSplineShellType.Linear) { var projectiveControlPoints = CalculateProjectiveControlPoints(); var numberOfPointsPerElement = 4; var nodes = new double[_model.Elements.Count * numberOfPointsPerElement, 3]; var pointIndex = 0; foreach (var element in _model.Elements) { var tsplineElement = element as TSplineKirchhoffLoveShellElement; var elementPoints = tsplineElement.CalculatePointsForPostProcessing(tsplineElement); for (int i = 0; i < elementPoints.GetLength(0); i++) { nodes[pointIndex, 0] = elementPoints[i, 0]; nodes[pointIndex, 1] = elementPoints[i, 1]; nodes[pointIndex++, 2] = elementPoints[i, 2]; } } var elementConnectivity = CreateTsplineConnectivity(); var pointDisplacements = new double[nodes.GetLength(0), 3]; foreach (var element in _model.Elements) { var localDisplacements = Matrix.CreateZero(element.ControlPointsDictionary.Count, 3); var counterCP = 0; foreach (var controlPoint in element.ControlPoints) { localDisplacements[counterCP, 0] = (!_model.GlobalDofOrdering.GlobalFreeDofs.Contains(controlPoint, StructuralDof.TranslationX)) ? 0.0 : _solution[_model.GlobalDofOrdering.GlobalFreeDofs[controlPoint, StructuralDof.TranslationX]]; localDisplacements[counterCP, 1] = (!_model.GlobalDofOrdering.GlobalFreeDofs.Contains(controlPoint, StructuralDof.TranslationY)) ? 0.0 : _solution[_model.GlobalDofOrdering.GlobalFreeDofs[controlPoint, StructuralDof.TranslationY]]; localDisplacements[counterCP++, 2] = (!_model.GlobalDofOrdering.GlobalFreeDofs.Contains(controlPoint, StructuralDof.TranslationZ)) ? 0.0 : _solution[_model.GlobalDofOrdering.GlobalFreeDofs[controlPoint, StructuralDof.TranslationZ]]; } var elementKnotDisplacements = element.ElementType.CalculateDisplacementsForPostProcessing(element, localDisplacements); for (int i = 0; i < elementConnectivity.GetLength(1); i++) { var knotConnectivity = elementConnectivity[element.ID, i]; pointDisplacements[knotConnectivity, 0] = elementKnotDisplacements[i, 0]; pointDisplacements[knotConnectivity, 1] = elementKnotDisplacements[i, 1]; pointDisplacements[knotConnectivity, 2] = elementKnotDisplacements[i, 2]; } } WriteTSplineShellsFile(nodes, elementConnectivity, pointDisplacements); }
/// <summary> /// Create Model from reading an .iga file. /// </summary> /// <param name="shellType"><see cref="Enum"/> that specifies the type of the shells that will be generated.</param> /// <param name="shellMaterial">The material of the shell.</param> /// <param name="thickness">The tchickness of the shell.</param> public void CreateTSplineShellsModelFromFile(TSplineShellType shellType = TSplineShellType.Linear, ShellElasticMaterial2D shellMaterial = null, double thickness = 1) { char[] delimeters = { ' ', '=', '\t' }; Attributes?name = null; String[] text = System.IO.File.ReadAllLines(_filename); _model.PatchesDictionary.Add(0, new Patch()); for (int i = 0; i < text.Length; i++) { var line = text[i].Split(delimeters, StringSplitOptions.RemoveEmptyEntries); if (line.Length == 0) { continue; } try { name = (Attributes)Enum.Parse(typeof(Attributes), line[0].ToLower()); } catch (Exception exception) { throw new KeyNotFoundException($"Variable name {line[0]} is not found. {exception.Message}"); } switch (name) { case Attributes.type: Types type; try { type = (Types)Enum.Parse(typeof(Types), line[1].ToLower()); } catch (Exception exception) { throw new KeyNotFoundException($"Variable name {line[0]} is not found. {exception.Message}"); } numberOfDimensions = type == Types.plane ? 2 : 3; break; case Attributes.noden: break; case Attributes.elemn: var numberOfElements = int.Parse(line[1]); break; case Attributes.node: var controlPoint = new ControlPoint { ID = controlPointIDcounter, X = double.Parse(line[1], CultureInfo.InvariantCulture), Y = double.Parse(line[2], CultureInfo.InvariantCulture), Z = double.Parse(line[3], CultureInfo.InvariantCulture), WeightFactor = double.Parse(line[4], CultureInfo.InvariantCulture) }; _model.ControlPointsDictionary.Add(controlPointIDcounter, controlPoint); ((List <ControlPoint>)_model.PatchesDictionary[0].ControlPoints).Add(controlPoint); controlPointIDcounter++; break; case Attributes.belem: var numberOfElementNodes = int.Parse(line[1]); var elementDegreeKsi = int.Parse(line[2]); var elementDegreeHeta = int.Parse(line[3]); i++; line = text[i].Split(delimeters); int[] connectivity = new int[numberOfElementNodes]; for (int j = 0; j < numberOfElementNodes; j++) { connectivity[j] = Int32.Parse(line[j]); } var extractionOperator = Matrix.CreateZero(numberOfElementNodes, (elementDegreeKsi + 1) * (elementDegreeHeta + 1)); for (int j = 0; j < numberOfElementNodes; j++) { line = text[++i].Split(delimeters); for (int k = 0; k < (elementDegreeKsi + 1) * (elementDegreeHeta + 1); k++) { extractionOperator[j, k] = double.Parse(line[k]); } } if (numberOfDimensions == 2) { throw new NotImplementedException("TSpline2D not yet implemented"); } else { switch (shellType) { case TSplineShellType.Linear: CreateLinearShell(elementDegreeKsi, elementDegreeHeta, extractionOperator, connectivity); break; case TSplineShellType.Thickness: CreateThicknessShell(elementDegreeKsi, elementDegreeHeta, extractionOperator, connectivity, shellMaterial, thickness); break; } } break; case Attributes.set: break; } } }