blockMeshOBJ.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) 2020-2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12 
13 Description
14  OBJ output of blockMesh topology blocks
15 
16 \*---------------------------------------------------------------------------*/
17 
18 {
19  refPtr<polyMesh> topoMeshPtr(blocks.topology(true));
20  const polyMesh& topoMesh = topoMeshPtr();
21 
22  // Write mesh as edges
23  {
24  OFstream os(runTime.path()/"blockTopology.obj");
25 
26  Info<< "Writing block structure in obj format: "
27  << os.name().name() << endl;
28 
29  for (const point& p : topoMesh.points())
30  {
31  os << "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
32  }
33 
34  for (const edge& e : topoMesh.edges())
35  {
36  os << "l " << e.start() + 1 << ' ' << e.end() + 1 << nl;
37  }
38  }
39 
40  // Write centres of blocks
41  {
42  OFstream os(runTime.path()/"blockCentres.obj");
43 
44  Info<< "Writing block centres in obj format: "
45  << os.name().name() << endl;
46 
47  for (const point& p : topoMesh.cellCentres())
48  {
49  os << "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
50  }
51  }
52 }
53 
54 
55 // ************************************************************************* //
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
OBJstream os(runTime.globalPath()/outputName)
vector point
Point is a vector.
Definition: point.H:37
const polyMesh & topoMesh
Definition: blockMeshOBJ.H:23
messageStream Info
Information stream (stdout output on master, null elsewhere)
volScalarField & p
refPtr< polyMesh > topoMeshPtr(blocks.topology(true))