/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 .
Application
foamToEnsight
Group
grpPostProcessingUtilitie
Description
Translates OpenFOAM data to EnSight format.
An Ensight part is created for the internalMesh and for each patch.
Usage
\b foamToEnsight [OPTION]
Options:
- \par -ascii
Write Ensight data in ASCII format instead of "C Binary"
- \par -noZero
Exclude the often incomplete initial conditions.
- \par -noLagrangian
Suppress writing lagrangian positions and fields.
- \par -noPatches
Suppress writing any patches.
- \par -patches patchList
Specify particular patches to write.
Specifying an empty list suppresses writing the internalMesh.
- \par -faceZones zoneList
Specify faceZones to write, with wildcards
- \par -cellZone zoneName
Specify single cellZone to write (not lagrangian)
- \par -width \
Width of EnSight data subdir (default: 8)
- \par -deprecatedOrder
Use older ordering for volume cells (hex prism pyr tet poly)
Note
Writes to \a EnSight directory to avoid collisions with
foamToEnsightParts
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "IOobjectList.H"
#include "IOmanip.H"
#include "OFstream.H"
#include "fvc.H"
#include "volFields.H"
#include "labelIOField.H"
#include "scalarIOField.H"
#include "tensorIOField.H"
// file-format/conversion
#include "ensightCase.H"
#include "ensightGeoFile.H"
#include "ensightMesh.H"
#include "ensightOutput.H"
// local files
#include "meshSubsetHelper.H"
#include "ensightOutputCloud.H"
#include "memInfo.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// file-scope helper
static bool inFileNameList
(
const fileNameList& nameList,
const word& name
)
{
forAll(nameList, i)
{
if (nameList[i] == name)
{
return true;
}
}
return false;
}
int main(int argc, char *argv[])
{
timeSelector::addOptions();
#include "addRegionOption.H"
argList::addBoolOption
(
"ascii",
"write in ASCII format instead of 'C Binary'"
);
argList::addBoolOption
(
"nodeValues",
"write values in nodes"
);
argList::addBoolOption
(
"noLagrangian",
"suppress writing lagrangian positions and fields"
);
argList::addBoolOption
(
"noPatches",
"suppress writing any patches"
);
argList::addOption
(
"patches",
"wordReList",
"specify particular patches to write - eg '(outlet \"inlet.*\")'. "
"An empty list suppresses writing the internalMesh."
);
argList::addOption
(
"faceZones",
"wordReList",
"specify faceZones to write - eg '( slice \"mfp-.*\" )'."
);
argList::addOption
(
"fields",
"wordReList",
"specify fields to export (all by default) - eg '( \"U.*\" )'."
);
argList::addOption
(
"cellZone",
"word",
"specify cellZone to write"
);
argList::addOption
(
"name",
"subdir",
"define sub-directory name to use for ensight data "
"(default: 'EnSight')"
);
argList::addOption
(
"width",
"n",
"width of ensight data subdir"
);
argList::addBoolOption
(
"deprecatedOrder",
"Use old ordering (hex prism pyr tet poly) "
"instead of the ascending number of points "
"(tet pyr prism hex poly)."
);
// The volume field types that we handle
const wordList volFieldTypes
{
volScalarField::typeName,
volVectorField::typeName,
volSphericalTensorField::typeName,
volSymmTensorField::typeName,
volTensorField::typeName,
volScalarField::Internal::typeName,
volVectorField::Internal::typeName,
volSphericalTensorField::Internal::typeName,
volSymmTensorField::Internal::typeName,
volTensorField::Internal::typeName
};
#include "setRootCase.H"
// default to binary output, unless otherwise specified
const IOstream::streamFormat format =
(
args.optionFound("ascii")
? IOstream::ASCII
: IOstream::BINARY
);
const bool nodeValues = args.optionFound("nodeValues");
cpuTime timer;
memInfo mem;
Info<< "Initial memory " << mem.update().size() << " kB" << endl;
#include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
#include "createNamedMesh.H"
fileName regionPrefix; // Mesh instance (region0 gets filtered out)
if (regionName != polyMesh::defaultRegion)
{
regionPrefix = regionName;
}
//
// general (case) output options
//
ensightCase::options caseOpts(format);
caseOpts.nodeValues(args.optionFound("nodeValues"));
caseOpts.width(args.optionLookupOrDefault