/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ 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 "argList.H"
#include "Time.H"
#include "ensightMesh.H"
#include "fvMesh.H"
#include "globalMeshData.H"
#include "PstreamCombineReduceOps.H"
#include "processorPolyPatch.H"
#include "cellModeller.H"
#include "IOmanip.H"
#include "itoa.H"
#include "ensightWriteBinary.H"
#include "globalIndex.H"
#include "mapDistribute.H"
#include "stringListOps.H"
#include
// * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ensightMesh::ensightMesh
(
const fvMesh& mesh,
const argList& args,
const bool binary
)
:
mesh_(mesh),
binary_(binary),
patchPartOffset_(2),
meshCellSets_(mesh_.nCells()),
boundaryFaceSets_(mesh_.boundary().size()),
allPatchNames_(0),
patchNames_(0),
nPatchPrims_(0),
faceZoneFaceSets_(mesh_.faceZones().size()),
faceZoneNames_(0),
nFaceZonePrims_(0),
boundaryFaceToBeIncluded_(0)
{
const cellShapeList& cellShapes = mesh.cellShapes();
const cellModel& tet = *(cellModeller::lookup("tet"));
const cellModel& pyr = *(cellModeller::lookup("pyr"));
const cellModel& prism = *(cellModeller::lookup("prism"));
const cellModel& wedge = *(cellModeller::lookup("wedge"));
const cellModel& hex = *(cellModeller::lookup("hex"));
if (!args.optionFound("noPatches"))
{
// Patches are output. Check that they're synced.
mesh_.boundaryMesh().checkParallelSync(true);
allPatchNames_ = wordList::subList
(
mesh_.boundaryMesh().names(),
mesh_.boundary().size()
- mesh_.globalData().processorPatches().size()
);
if (args.optionFound("patches"))
{
wordReList patterns(args.optionLookup("patches")());
if (patterns.empty())
{
forAll(allPatchNames_, nameI)
{
patchNames_.insert(allPatchNames_[nameI]);
}
}
else
{
// Find patch names which match that requested at command-line
forAll(allPatchNames_, nameI)
{
const word& patchName = allPatchNames_[nameI];
if (findStrings(patterns, patchName))
{
patchNames_.insert(patchName);
}
}
}
}
}
if (patchNames_.size())
{
// no internalMesh
patchPartOffset_ = 1;
}
else
{
// Count the shapes
labelList& tets = meshCellSets_.tets;
labelList& pyrs = meshCellSets_.pyrs;
labelList& prisms = meshCellSets_.prisms;
labelList& wedges = meshCellSets_.wedges;
labelList& hexes = meshCellSets_.hexes;
labelList& polys = meshCellSets_.polys;
label nTets = 0;
label nPyrs = 0;
label nPrisms = 0;
label nWedges = 0;
label nHexes = 0;
label nPolys = 0;
forAll(cellShapes, cellI)
{
const cellShape& cellShape = cellShapes[cellI];
const cellModel& cellModel = cellShape.model();
if (cellModel == tet)
{
tets[nTets++] = cellI;
}
else if (cellModel == pyr)
{
pyrs[nPyrs++] = cellI;
}
else if (cellModel == prism)
{
prisms[nPrisms++] = cellI;
}
else if (cellModel == wedge)
{
wedges[nWedges++] = cellI;
}
else if (cellModel == hex)
{
hexes[nHexes++] = cellI;
}
else
{
polys[nPolys++] = cellI;
}
}
tets.setSize(nTets);
pyrs.setSize(nPyrs);
prisms.setSize(nPrisms);
wedges.setSize(nWedges);
hexes.setSize(nHexes);
polys.setSize(nPolys);
meshCellSets_.nTets = nTets;
reduce(meshCellSets_.nTets, sumOp