diff --git a/src/functionObjects/utilities/Make/files b/src/functionObjects/utilities/Make/files index dbf8798938..e2f72c06cf 100644 --- a/src/functionObjects/utilities/Make/files +++ b/src/functionObjects/utilities/Make/files @@ -1,6 +1,7 @@ abort/abort.C codedFunctionObject/codedFunctionObject.C +ensightWrite/ensightWrite.C removeRegisteredObject/removeRegisteredObject.C diff --git a/src/functionObjects/utilities/Make/options b/src/functionObjects/utilities/Make/options index 0efefc46fc..9e14e74355 100644 --- a/src/functionObjects/utilities/Make/options +++ b/src/functionObjects/utilities/Make/options @@ -1,5 +1,7 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/fileFormats/lnInclude \ + -I$(LIB_SRC)/conversion/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/ODE/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ @@ -7,6 +9,8 @@ EXE_INC = \ LIB_LIBS = \ -lfiniteVolume \ + -lconversion \ + -lsampling \ -lfluidThermophysicalModels \ -lcompressibleTransportModels \ -lODE diff --git a/src/functionObjects/utilities/ensightWrite/ensightWrite.C b/src/functionObjects/utilities/ensightWrite/ensightWrite.C new file mode 100644 index 0000000000..02a17215a7 --- /dev/null +++ b/src/functionObjects/utilities/ensightWrite/ensightWrite.C @@ -0,0 +1,329 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 "ensightWrite.H" +#include "Time.H" +#include "polyMesh.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(ensightWrite, 0); + + addToRunTimeSelectionTable + ( + functionObject, + ensightWrite, + dictionary + ); +} +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::functionObjects::ensightWrite::uniqWords(wordReList& lst) +{ + boolList retain(lst.size()); + wordHashSet uniq; + forAll(lst, i) + { + const wordRe& select = lst[i]; + + retain[i] = + ( + select.isPattern() + || uniq.insert(static_cast(select)) + ); + } + + inplaceSubset(retain, lst); +} + + +int Foam::functionObjects::ensightWrite::process(const word& fieldName) +{ + int state = 0; + + writeVolField(fieldName, state); + writeVolField(fieldName, state); + writeVolField(fieldName, state); + writeVolField(fieldName, state); + writeVolField(fieldName, state); + + return state; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::ensightWrite::ensightWrite +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fvMeshFunctionObject(name, runTime, dict), + writeOpts_ + ( + dict.found("format") + ? IOstream::formatEnum(dict.lookup("format")) + : runTime.writeFormat() + ), + caseOpts_(writeOpts_.format()), + selectFields_(), + dirName_("ensightWrite"), + consecutive_(false) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::ensightWrite::~ensightWrite() +{ + if (ensCase_.valid()) + { + // finalize case + ensCase().write(); + ensCase_.clear(); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::ensightWrite::read(const dictionary& dict) +{ + fvMeshFunctionObject::read(dict); + + // + // writer options + // + writeOpts_.noPatches + ( + dict.lookupOrDefault("noPatches", false) + ); + + writeOpts_.deprecatedOrder + ( + dict.lookupOrDefault("deprecatedOrder", false) + ); + + if (dict.found("patches")) + { + wordReList lst(dict.lookup("patches")); + uniqWords(lst); + + writeOpts_.patchSelection(lst); + } + + if (dict.found("faceZones")) + { + wordReList lst(dict.lookup("faceZones")); + uniqWords(lst); + + writeOpts_.faceZoneSelection(lst); + } + + + // + // case options + // + caseOpts_.width(dict.lookupOrDefault