/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2026 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
\*---------------------------------------------------------------------------*/
#include "print.H"
#include "polyMesh.H"
#include "boundSphere.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace zoneGenerators
{
defineTypeNameAndDebug(print, 0);
addToRunTimeSelectionTable(zoneGenerator, print, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::zoneGenerators::print::print
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
)
:
zoneGenerator(name, mesh, dict),
zoneType_
(
zoneTypesAllNames.lookupOrDefault
(
"zoneType",
dict,
zoneTypesAll::all
)
),
zoneNames_
(
dict.found("zone")
? new wordList(1, dict.lookup("zone"))
: dict.found("zones")
? new wordList(dict.lookup("zones"))
: nullptr
),
geometry_(dict.lookupOrDefault("geometry", true))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::zoneGenerators::print::~print()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::zoneSet Foam::zoneGenerators::print::generate() const
{
// Determine which zone types to print
const bool printPointZones =
zoneType_ == zoneTypesAll::point || zoneType_ == zoneTypesAll::all;
const bool printFaceZones =
zoneType_ == zoneTypesAll::face || zoneType_ == zoneTypesAll::all;
const bool printCellZones =
zoneType_ == zoneTypesAll::cell || zoneType_ == zoneTypesAll::all;
// Get a list of which zones to print. Either user-defined, or all zones.
wordList allZoneNames;
if (!zoneNames_.valid())
{
wordHashSet allZoneNameSet;
if (printPointZones) allZoneNameSet.insert(mesh_.pointZones().toc());
if (printFaceZones) allZoneNameSet.insert(mesh_.faceZones().toc());
if (printCellZones) allZoneNameSet.insert(mesh_.cellZones().toc());
allZoneNames = allZoneNameSet.toc();
}
const wordList& zoneNames =
zoneNames_.valid() ? zoneNames_() : allZoneNames;
// Reference bits of the mesh
const pointField& points = mesh_.points();
const faceList& faces = mesh_.faces();
const scalarField& magFaceAreas = mesh_.magFaceAreas();
const pointField& faceCentres = mesh_.faceCentres();
const cellList& cells = mesh_.cells();
const scalarField& cellVolumes = mesh_.cellVolumes();
const pointField& cellCentres = mesh_.cellCentres();
// Keep a set of points for which to calculate geometry. Store both forward
// and backward addressing so that the maps can be efficiently reused
// across multiple zones.
labelList pointZonePoints(points.size(), -1);
DynamicList