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 // ************************************************************************* //
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:369
topoMeshPtr
refPtr< polyMesh > topoMeshPtr(blocks.topology(true))
topoMesh
const polyMesh & topoMesh
Definition: blockMeshOBJ.H:29
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
os
OBJstream os(runTime.globalPath()/outputName)
Foam::nl
constexpr char nl
Definition: Ostream.H:404
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