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 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  const polyMesh& topoMesh = blocks.topology();
20 
21  // Write mesh as edges
22  {
23  OFstream os(runTime.path()/"blockTopology.obj");
24 
25  Info<< "Writing block structure in obj format: "
26  << os.name().name() << endl;
27 
28  for (const point& p : topoMesh.points())
29  {
30  os << "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
31  }
32 
33  for (const edge& e : topoMesh.edges())
34  {
35  os << "l " << e.start() + 1 << ' ' << e.end() + 1 << nl;
36  }
37  }
38 
39  // Write centres of blocks
40  {
41  OFstream os(runTime.path()/"blockCentres.obj");
42 
43  Info<< "Writing block centres in obj format: "
44  << os.name().name() << endl;
45 
46  for (const point& p : topoMesh.cellCentres())
47  {
48  os << "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
49  }
50  }
51 }
52 
53 
54 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
topoMesh
const polyMesh & topoMesh
Definition: blockMeshVTK.H:31
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::point
vector point
Point is a vector.
Definition: point.H:43