Esempio n. 1
0
        public void WriteVector2DField(string fieldName,
                                       IReadOnlyDictionary <ICell <TNode>, IReadOnlyList <Vector2> > vectorsAtElementNodes)
        {
            var nodalVectors = new double[mesh.VtkPoints.Count, 2];

            for (int e = 0; e < mesh.VtkCells.Count; ++e)
            {
                VtkCell cell = mesh.VtkCells[e];
                IReadOnlyList <Vector2> valuesAtCellVertices = vectorsAtElementNodes[mesh.OriginalElements[e]];
                for (int i = 0; i < cell.Vertices.Count; ++i)
                {
                    nodalVectors[cell.Vertices[i].ID, 0] = valuesAtCellVertices[i][0];
                    nodalVectors[cell.Vertices[i].ID, 1] = valuesAtCellVertices[i][1];
                }
            }

            WriteFieldsHeader(nodalVectors.Length);
            writer.WriteLine(String.Format("VECTORS {0} double", fieldName));
            for (int i = 0; i < mesh.VtkPoints.Count; ++i)
            {
                writer.WriteLine(String.Format("{0} {1} 0.0", nodalVectors[i, 0], nodalVectors[i, 1]));
            }
            writer.WriteLine();
        }
Esempio n. 2
0
        public void WriteScalarField(string fieldName,
                                     IReadOnlyDictionary <ICell <TNode>, IReadOnlyList <double> > valuesAtElementNodes)
        {
            var nodalValues = new double[mesh.VtkPoints.Count];

            for (int e = 0; e < mesh.VtkCells.Count; ++e)
            {
                VtkCell cell = mesh.VtkCells[e];
                IReadOnlyList <double> valuesAtCellVertices = valuesAtElementNodes[mesh.OriginalElements[e]];
                for (int i = 0; i < cell.Vertices.Count; ++i)
                {
                    nodalValues[cell.Vertices[i].ID] = valuesAtCellVertices[i];
                }
            }

            WriteFieldsHeader(nodalValues.Length);
            writer.WriteLine(String.Format("SCALARS {0} double 1", fieldName));
            writer.WriteLine("LOOKUP_TABLE default");
            for (int i = 0; i < mesh.VtkPoints.Count; ++i)
            {
                writer.WriteLine(nodalValues[i]);
            }
            writer.WriteLine();
        }
Esempio n. 3
0
        public void WriteTensor2DField(string fieldName,
                                       IReadOnlyDictionary <ICell <TNode>, IReadOnlyList <Tensor2D> > tensorsAtElementNodes)
        {
            var nodalTensors = new Tensor2D[mesh.VtkPoints.Count];

            for (int e = 0; e < mesh.VtkCells.Count; ++e)
            {
                VtkCell cell = mesh.VtkCells[e];
                IReadOnlyList <Tensor2D> valuesAtCellVertices = tensorsAtElementNodes[mesh.OriginalElements[e]];
                for (int i = 0; i < cell.Vertices.Count; ++i)
                {
                    nodalTensors[cell.Vertices[i].ID] = valuesAtCellVertices[i];
                }
            }

            WriteFieldsHeader(nodalTensors.Length);
            writer.WriteLine(String.Format("TENSORS {0} double", fieldName));
            for (int i = 0; i < mesh.VtkPoints.Count; ++i)
            {
                writer.WriteLine(String.Format("{0} {1} {2} 0.0 0.0 0.0 0.0 0.0 0.0",
                                               nodalTensors[i].XX, nodalTensors[i].YY, nodalTensors[i].XY));
            }
            writer.WriteLine();
        }