faMeshWriteVTK.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2021-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12 
13 Description
14  VTK output of faMesh with some geometric or debug fields
15 
16 \*---------------------------------------------------------------------------*/
17 
18 {
19  // finiteArea - faces
21  (
22  aMesh.patch(),
23  // vtk::formatType::INLINE_ASCII,
24  fileName
25  (
26  aMesh.time().globalPath() / "finiteArea"
27  )
28  );
29 
30  writer.writeGeometry();
31 
32  globalIndex procAddr(aMesh.nFaces());
34 
35  if (Pstream::master())
36  {
37  cellIDs.resize(procAddr.totalSize());
38  for (const labelRange& range : procAddr.ranges())
39  {
40  auto slice = cellIDs.slice(range);
41  slice = identity(range);
42  }
43  }
44 
45  // CellData
46  writer.beginCellData(4);
47  writer.writeProcIDs();
48  writer.write("cellID", cellIDs);
49  writer.write("area", aMesh.S().field());
50  writer.write("normal", aMesh.faceAreaNormals());
51 
52  // PointData
53  writer.beginPointData(1);
54  writer.write("normal", aMesh.pointAreaNormals());
55 
56  Info<< nl
57  << "Wrote faMesh in vtk format: " << writer.output().name() << nl;
58 }
59 
60 {
61  // finiteArea - edges
62  vtk::lineWriter writer
63  (
64  aMesh.points(),
65  aMesh.edges(),
66  // vtk::formatType::INLINE_ASCII,
67  fileName
68  (
69  aMesh.time().globalPath() / "finiteArea-edges"
70  )
71  );
72 
73  writer.writeGeometry();
74 
75  // CellData
76  writer.beginCellData(4);
77  writer.writeProcIDs();
78  {
79  Field<scalar> fld
80  (
81  // Use primitive patch order
82  faMeshTools::flattenEdgeField(aMesh.magLe(), true)
83  );
84  writer.write("magLe", fld);
85  }
86 
87  // PointData
88  writer.beginPointData(1);
89  writer.write("normal", aMesh.pointAreaNormals());
90 
91  Info<< nl
92  << "Wrote faMesh in vtk format: " << writer.output().name() << nl;
93 }
94 
95 {
96  const Field<vector> edgeCentres
97  (
98  // Use primitive patch order
99  faMeshTools::flattenEdgeField(aMesh.edgeCentres(), true)
100  );
101 
102  // finiteArea - edgeCentres
103  // (no other convenient way to display vectors on the edges)
104  vtk::lineWriter writer
105  (
106  edgeCentres,
107  edgeList::null(),
108  // vtk::formatType::INLINE_ASCII,
109  fileName
110  (
111  aMesh.time().globalPath() / "finiteArea-edgesCentres"
112  )
113  );
114 
115  writer.writeGeometry();
116 
117  // PointData
118  writer.beginPointData(3);
119  writer.writeProcIDs(); // Unfortunately cannot threshold on points
120  {
121  Field<vector> fld
122  (
123  // Use primitive patch order
124  faMeshTools::flattenEdgeField(aMesh.Le(), true)
125  );
126  writer.write("Le", fld);
127  }
128  {
129  Field<vector> fld
130  (
131  // Use primitive patch order
132  faMeshTools::flattenEdgeField(aMesh.edgeAreaNormals(), true)
133  );
134  writer.write("normal", fld);
135  }
136 
137  Info<< nl
138  << "Wrote faMesh in vtk format: " << writer.output().name() << nl;
139 }
140 
141 
142 // ************************************************************************* //
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/"finiteArea-edgesCentres"))
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
scalar range
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
Definition: labelLists.C:44
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ const Field< vector > edgeCentres(faMeshTools::flattenEdgeField(aMesh.edgeCentres(), true))
GenericPatchWriter< uindirectPrimitivePatch > uindirectPatchWriter
Write uindirectPrimitivePatch faces/points (optionally with fields) as a vtp file or a legacy vtk fil...
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
globalIndex procAddr(aMesh.nFaces())
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< label > labelList
A List of labels.
Definition: List.H:62
labelList cellIDs