/// <summary> /// Instantiates a new log that writes the displacement field of each iteration to output files, which can then be /// processed in Paraview. /// </summary> /// <param name="directory">The full path of the folder whre the output files will be written, e.g. /// C:\\Users\\MyUser\\Desktop\\Paraview.</param> /// <param name="filename">The name of the displacement file(s) without extensions, e.g. displacements. Keep in mind /// that the actual files will be suffixed with the iteration number, e.g. /// C:\\Users\\MyUser\\Desktop\\Paraview\\displacements_0.vtk, /// C:\\Users\\MyUser\\Desktop\\Paraview\\displacements_1.vtk, etc.</param> /// <param name="model">A collection of nodes, elements and other entities.</param> /// <param name="vtkMesh">The same mesh that is contained in <paramref name="model"/>, but expressed in VTK objects. This /// object should be shared across other VTK logs to reduce memory consumption.</param> /// <param name="logDisplacements">If true, the displacement field will also be written to the output file.</param> /// <param name="logStrains">If true, the strain field will also be written to the output file.</param> /// <param name="logStresses">If true, the stress field will also be written to the output file.</param> /// <param name="vonMisesStressCalculator">The strategy used for calculating von Mises equivalent stress. If null is /// passed, then von Mises equivalent stresses will not be written to the output file.</param> public VtkLog2D(string directory, string filename, Model model, VtkMesh <Node> vtkMesh, bool logDisplacements, bool logStrains, bool logStresses, IVonMisesStress2D vonMisesStressCalculator) { this.pathNoExtension = directory + "\\" + filename; this.model = model; this.vtkMesh = vtkMesh; this.logDisplacements = logDisplacements; this.logStrains = logStrains; this.logStresses = logStresses; this.vonMisesStressCalculator = vonMisesStressCalculator; iteration = 0; }
public VtkLogFactory(Model model, string directory) { this.model = model; this.directory = directory; try { Node[] nodes = model.Nodes.ToArray(); ICell <Node>[] elements = model.Elements.Select(element => (ICell <Node>)element).ToArray(); this.vtkMesh = new VtkMesh <Node>(nodes, elements); } catch (InvalidCastException ex) { throw new InvalidCastException("VtkLogFactory only works for models with elements that implement ICell.", ex); } }