diff --git a/applications/utilities/mesh/conversion/polyDualMesh/Make/files b/applications/utilities/mesh/conversion/polyDualMesh/Make/files index 11d97d6738..de69b15edf 100644 --- a/applications/utilities/mesh/conversion/polyDualMesh/Make/files +++ b/applications/utilities/mesh/conversion/polyDualMesh/Make/files @@ -1,4 +1,4 @@ polyDualMesh.C -makePolyDualMesh.C +polyDualMeshApp.C EXE = $(FOAM_APPBIN)/polyDualMesh diff --git a/applications/utilities/mesh/conversion/polyDualMesh/makePolyDualMesh.C b/applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C similarity index 98% rename from applications/utilities/mesh/conversion/polyDualMesh/makePolyDualMesh.C rename to applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C index 8c0549407f..e4165d30ba 100644 --- a/applications/utilities/mesh/conversion/polyDualMesh/makePolyDualMesh.C +++ b/applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C @@ -22,6 +22,9 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +Application + polyDualMesh + Description Calculate the dual of a polyMesh. Adheres to all the feature&patch edges diff --git a/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C b/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C index 187aeef579..5c1e53eedc 100644 --- a/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C +++ b/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C @@ -22,8 +22,11 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +Application + foamFormatConvert + Description - Converts all IOobjects associated with a case into the format specified + Converts all IOobjects associated with a case into the format specified in the controlDict. Mainly used to convert binary mesh/field files to ASCII. @@ -31,6 +34,7 @@ Description \*---------------------------------------------------------------------------*/ #include "argList.H" +#include "timeSelector.H" #include "Time.H" #include "volFields.H" #include "surfaceFields.H" @@ -47,22 +51,15 @@ using namespace Foam; int main(int argc, char *argv[]) { -# include "addTimeOptions.H" - + timeSelector::addOptions(); # include "setRootCase.H" # include "createTime.H" + Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - for (label i=startTime; iheaderClassName(); - if + if ( headerClassName == volScalarField::typeName || headerClassName == volVectorField::typeName @@ -116,7 +113,6 @@ int main(int argc, char *argv[]) Info<< endl; } - Info<< "End\n" << endl; return 0; diff --git a/applications/utilities/postProcessing/Field/magGrad/magGrad.C b/applications/utilities/postProcessing/Field/magGrad/magGrad.C deleted file mode 100644 index 9d584fc80d..0000000000 --- a/applications/utilities/postProcessing/Field/magGrad/magGrad.C +++ /dev/null @@ -1,128 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Application - magGrad - -Description - Calculates and writes the scalar magnitude of a scalar or vector field - at each time - -\*---------------------------------------------------------------------------*/ - -#include "fvCFD.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Main program: - -int main(int argc, char *argv[]) -{ - argList::validArgs.append("field"); - -# include "addTimeOptions.H" -# include "setRootCase.H" - -# include "createTime.H" - - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - const word fieldName(args.additionalArgs()[0]); - - runTime.setTime(Times[startTime], startTime); - -# include "createMesh.H" - - for (label i=startTime; i +void writeComponents +( + const IOobject& header, + const fvMesh& mesh, + bool& processed +) +{ + typedef GeometricField fieldType; + + if (header.headerClassName() == fieldType::typeName) + { + Info<< " Reading " << header.name() << endl; + fieldType field(header, mesh); + + for (direction i=0; i +void writeMagField +( + const IOobject& header, + const fvMesh& mesh, + bool& processed +) +{ + typedef GeometricField fieldType; + + if (header.headerClassName() == fieldType::typeName) + { + Info<< " Reading " << header.name() << endl; + fieldType field(header, mesh); + + Info<< " Calculating mag" << header.name() << endl; + volScalarField magField + ( + IOobject + ( + "mag" + header.name(), + mesh.time().timeName(), + mesh, + IOobject::NO_READ + ), + mag(field) + ); + magField.write(); + + processed = true; + } +} + + +int main(int argc, char *argv[]) +{ + timeSelector::addOptions(); + argList::validArgs.append("field1 ... fieldN"); // abuse for usage + + // setRootCase, but skip args check + argList args(argc, argv, false); + if (!args.checkRootCase()) + { + Foam::FatalError.exit(); + } + + const stringList& params = args.additionalArgs(); + + if (!params.size()) + { + Info<< nl << "must specify one or more fields" << nl; + args.printUsage(); + FatalError.exit(); + } + +# include "createTime.H" + instantList timeDirs = timeSelector::select0(runTime, args); +# include "createMesh.H" + + forAll(timeDirs, timeI) + { + runTime.setTime(timeDirs[timeI], timeI); + Info<< "Time = " << runTime.timeName() << endl; + mesh.readUpdate(); + + forAll(params, paramI) + { + const word fieldName(params[paramI]); + + IOobject fieldHeader + ( + fieldName, + runTime.timeName(), + mesh, + IOobject::MUST_READ + ); + + // Check field exists + if (fieldHeader.headerOk()) + { + bool processed = false; + + writeMagField(fieldHeader, mesh, processed); + writeMagField(fieldHeader, mesh, processed); + writeMagField(fieldHeader, mesh, processed); + writeMagField(fieldHeader, mesh, processed); + writeMagField(fieldHeader, mesh, processed); + if (!processed) + { + FatalError + << "Unable to process " << fieldName << nl + << "No call to mag for fields of type " + << fieldHeader.headerClassName() << nl << nl + << exit(FatalError); + } + } + else + { + Info<< " No " << fieldName << endl; + } + } + } + + return 0; +} + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/Field/magGrad/FoamX/magGradU.cfg b/applications/utilities/postProcessing/field/magGrad/FoamX/magGradU.cfg similarity index 100% rename from applications/utilities/postProcessing/Field/magGrad/FoamX/magGradU.cfg rename to applications/utilities/postProcessing/field/magGrad/FoamX/magGradU.cfg diff --git a/applications/utilities/postProcessing/Field/magGrad/Make/files b/applications/utilities/postProcessing/field/magGrad/Make/files similarity index 100% rename from applications/utilities/postProcessing/Field/magGrad/Make/files rename to applications/utilities/postProcessing/field/magGrad/Make/files diff --git a/applications/utilities/postProcessing/velocityField/magU/Make/options b/applications/utilities/postProcessing/field/magGrad/Make/options similarity index 100% rename from applications/utilities/postProcessing/velocityField/magU/Make/options rename to applications/utilities/postProcessing/field/magGrad/Make/options diff --git a/applications/utilities/postProcessing/field/magGrad/magGrad.C b/applications/utilities/postProcessing/field/magGrad/magGrad.C new file mode 100644 index 0000000000..6269dca609 --- /dev/null +++ b/applications/utilities/postProcessing/field/magGrad/magGrad.C @@ -0,0 +1,139 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + magGrad + +Description + Calculates and writes the scalar magnitude of a scalar or vector field + at each time + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + timeSelector::addOptions(); + argList::validArgs.append("field1 ... fieldN"); // abuse for usage + + // setRootCase, but skip args check + argList args(argc, argv, false); + if (!args.checkRootCase()) + { + Foam::FatalError.exit(); + } + + const stringList& params = args.additionalArgs(); + + if (!params.size()) + { + Info<< nl << "must specify one or more fields" << nl; + args.printUsage(); + FatalError.exit(); + } + +# include "createTime.H" + Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); +# include "createMesh.H" + + forAll(timeDirs, timeI) + { + runTime.setTime(timeDirs[timeI], timeI); + Info<< "Time = " << runTime.timeName() << endl; + mesh.readUpdate(); + + forAll(params, paramI) + { + const word fieldName(params[paramI]); + + IOobject header + ( + fieldName, + runTime.timeName(), + mesh, + IOobject::MUST_READ + ); + + // Check field exists + if (header.headerOk()) + { + if (header.headerClassName() == volScalarField::typeName) + { + Info<< " Reading " << fieldName << " ..."; + volScalarField field(header, mesh); + + volScalarField magGrad + ( + IOobject + ( + "magGrad" + fieldName, + runTime.timeName(), + mesh, + IOobject::NO_READ + ), + mag(fvc::grad(field)) + ); + Info<< "Writing " << magGrad.name() << endl; + magGrad.write(); + } + else if (header.headerClassName() == volVectorField::typeName) + { + Info<< " Reading " << fieldName << " ..."; + volVectorField field(header, mesh); + + volScalarField magGrad + ( + IOobject + ( + "magGrad" + fieldName, + runTime.timeName(), + mesh, + IOobject::NO_READ + ), + mag(fvc::grad(field)) + ); + Info<< "Writing " << magGrad.name() << endl; + magGrad.write(); + } + else + { + Info<< " Skipping " << fieldName << " : type " + << header.headerClassName() << endl; + } + } + else + { + Info<< " No " << fieldName << endl; + } + } + } + + return 0; +} + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/patch/patchAverage/patchAverage.C b/applications/utilities/postProcessing/patch/patchAverage/patchAverage.C index 7791f68934..a78a70733c 100644 --- a/applications/utilities/postProcessing/patch/patchAverage/patchAverage.C +++ b/applications/utilities/postProcessing/patch/patchAverage/patchAverage.C @@ -37,31 +37,20 @@ Description int main(int argc, char *argv[]) { + timeSelector::addOptions(); argList::validArgs.append("fieldName"); argList::validArgs.append("patchName"); - -# include "addTimeOptions.H" # include "setRootCase.H" +# include "createTime.H" + instantList timeDirs = timeSelector::select0(runTime, args); +# include "createMesh.H" word fieldName(args.additionalArgs()[0]); word patchName(args.additionalArgs()[1]); -# include "createTime.H" - - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); - -# include "createMesh.H" - - for (label i=startTime; i= 0) + if (patchi < 0) { + FatalError + << "Unable to find patch " << patchName << nl + << exit(FatalError); + } + + if (fieldHeader.headerClassName() == "volScalarField") + { + Info<< " Reading volScalarField " << fieldName << endl; + volScalarField field(fieldHeader, mesh); + + scalar area = sum(mesh.magSf().boundaryField()[patchi]); + scalar sumField = 0; + + if (area > 0) + { + sumField = sum + ( + mesh.magSf().boundaryField()[patchi] + * field.boundaryField()[patchi] + ) / area; + } + Info<< " Average of " << fieldName << " over patch " << patchName << '[' << patchi << ']' << " = " - << sum - ( - mesh.magSf().boundaryField()[patchi] - *field.boundaryField()[patchi] - )/sum(mesh.magSf().boundaryField()[patchi]) - << endl; + << sumField << endl; + } + else + { + FatalError + << "Only possible to average volScalarFields " + << nl << exit(FatalError); } } else @@ -104,8 +112,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } - // ************************************************************************* // diff --git a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C b/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C index ffae161132..e1727040c8 100644 --- a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C +++ b/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C @@ -37,31 +37,20 @@ Description int main(int argc, char *argv[]) { + timeSelector::addOptions(); argList::validArgs.append("fieldName"); argList::validArgs.append("patchName"); - -# include "addTimeOptions.H" # include "setRootCase.H" +# include "createTime.H" + instantList timeDirs = timeSelector::select0(runTime, args); +# include "createMesh.H" word fieldName(args.additionalArgs()[0]); word patchName(args.additionalArgs()[1]); -# include "createTime.H" - - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); - -# include "createMesh.H" - - for (label i=startTime; i= 0) + if (patchi < 0) { + FatalError + << "Unable to find patch " << patchName << nl + << exit(FatalError); + } + + if (fieldHeader.headerClassName() == "volScalarField") + { + Info<< " Reading volScalarField " << fieldName << endl; + volScalarField field(fieldHeader, mesh); + vector sumField = sum + ( + mesh.Sf().boundaryField()[patchi] + * field.boundaryField()[patchi] + ); + Info<< " Integral of " << fieldName << " over patch " << patchName << '[' << patchi << ']' << " = " - << sum - ( - mesh.Sf().boundaryField()[patchi] - *field.boundaryField()[patchi] - ) - << endl; + << sumField << nl; + } + else if (fieldHeader.headerClassName() == "surfaceScalarField") + { + Info<< " Reading surfaceScalarField " << fieldName << endl; + surfaceScalarField field(fieldHeader, mesh); + scalar sumField = sum(field.boundaryField()[patchi]); + + Info<< " Integral of " << fieldName << " over patch " + << patchName << '[' << patchi << ']' << " = " + << sumField << nl; + } + else + { + FatalError + << "Only possible to integrate volScalarFields " + << "and surfaceScalarFields" << nl << exit(FatalError); } } else @@ -104,7 +115,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/postProcessing/sampling/probeLocations/probeLocations.C b/applications/utilities/postProcessing/sampling/probeLocations/probeLocations.C index 07e06e8dd6..2405e95214 100644 --- a/applications/utilities/postProcessing/sampling/probeLocations/probeLocations.C +++ b/applications/utilities/postProcessing/sampling/probeLocations/probeLocations.C @@ -28,6 +28,7 @@ Description \*---------------------------------------------------------------------------*/ #include "argList.H" +#include "timeSelector.H" #include "IOprobes.H" using namespace Foam; @@ -37,27 +38,17 @@ using namespace Foam; int main(int argc, char *argv[]) { - -# include "addTimeOptions.H" + timeSelector::addOptions(); # include "setRootCase.H" - # include "createTime.H" - - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); - + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" IOprobes sniff(mesh, "probesDict", true); - for (label i=startTime; i CoPtr; - Info<< "Time = " << runTime.timeName() << endl; + Info<< " Reading phi" << endl; + surfaceScalarField phi(phiHeader, mesh); + Info<< " Calculating Co" << endl; - IOobject phiHeader - ( - "phi", - runTime.timeName(), - mesh, - IOobject::MUST_READ - ); - - // Check U exists - if (phiHeader.headerOk()) + if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0)) { - mesh.readUpdate(); + // compressible + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::MUST_READ + ), + mesh + ); - Info<< " Reading phi" << endl; - surfaceScalarField phi(phiHeader, mesh); - - Info<< " Calculating Co" << endl; - - if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0)) - { - surfaceScalarField Co + CoPtr.set + ( + new surfaceScalarField ( IOobject ( @@ -88,30 +84,20 @@ int main(int argc, char *argv[]) mesh, IOobject::NO_READ ), - mesh.surfaceInterpolation::deltaCoeffs() - *(mag(phi)/mesh.magSf()) - *runTime.deltaT() - ); - - Info << " Max Co = " << max(Co).value() << endl; - - Co.write(); - } - else if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0)) - { - volScalarField rho - ( - IOobject ( - "rho", - runTime.timeName(), - mesh, - IOobject::MUST_READ - ), - mesh - ); - - surfaceScalarField Co + mesh.surfaceInterpolation::deltaCoeffs() + * (mag(phi)/(fvc::interpolate(rho)*mesh.magSf())) + * runTime.deltaT() + ) + ) + ); + } + else if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0)) + { + // incompressible + CoPtr.set + ( + new surfaceScalarField ( IOobject ( @@ -120,34 +106,32 @@ int main(int argc, char *argv[]) mesh, IOobject::NO_READ ), - mesh.surfaceInterpolation::deltaCoeffs() - *(mag(phi)/(fvc::interpolate(rho)*mesh.magSf())) - *runTime.deltaT() - ); - - Info << " Max Co = " << max(Co).value() << endl; - - Co.write(); - } - else - { - FatalErrorIn(args.executable()) - << "Incorrect dimensions of phi: " << phi.dimensions() - << abort(FatalError); - } + ( + mesh.surfaceInterpolation::deltaCoeffs() + * (mag(phi)/mesh.magSf()) + * runTime.deltaT() + ) + ) + ); } else { - Info<< " No phi" << endl; + FatalErrorIn(args.executable()) + << "Incorrect dimensions of phi: " << phi.dimensions() + << abort(FatalError); } - Info<< endl; + Info<< "Co max : " << max(CoPtr()).value() << endl; + + if (writeResults) + { + CoPtr().write(); + } + } + else + { + Info<< " No phi" << endl; } - - Info<< "End\n" << endl; - - return(0); } - // ************************************************************************* // diff --git a/applications/utilities/postProcessing/velocityField/Co/Make/options b/applications/utilities/postProcessing/velocityField/Co/Make/options index be7f7d631d..e647db0498 100644 --- a/applications/utilities/postProcessing/velocityField/Co/Make/options +++ b/applications/utilities/postProcessing/velocityField/Co/Make/options @@ -1,6 +1,7 @@ EXE_INC = \ - -I$(LIB_SRC)/finiteVolume/lnInclude + -I$(FOAM_SRC)/postProcessing/postCalc \ + -I$(LIB_SRC)/finiteVolume/lnInclude EXE_LIBS = \ - -lfiniteVolume \ - + $(FOAM_LIBBIN)/postCalc.o \ + -lfiniteVolume diff --git a/applications/utilities/postProcessing/velocityField/Lambda2/Lambda2.C b/applications/utilities/postProcessing/velocityField/Lambda2/Lambda2.C index 74a4506468..2633b23fab 100644 --- a/applications/utilities/postProcessing/velocityField/Lambda2/Lambda2.C +++ b/applications/utilities/postProcessing/velocityField/Lambda2/Lambda2.C @@ -26,81 +26,58 @@ Application Lambda2 Description - Calculates and writes the second largest eigenvalue of the sum of the - square of the symmetrical and anti-symmetrical parts of the velocity - gradient tensor, for each time. + Calculates and writes the second largest eigenvalue of the sum of the + square of the symmetrical and anti-symmetrical parts of the velocity + gradient tensor. + The -noWrite option has no meaning. \*---------------------------------------------------------------------------*/ -#include "fvCFD.H" -#include "tensorField.H" +#include "calc.H" +#include "fvc.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -int main(int argc, char *argv[]) +void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) { + IOobject Uheader + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ + ); -# include "addTimeOptions.H" -# include "setRootCase.H" - -# include "createTime.H" - - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); - -# include "createMesh.H" - - for (label i=startTime; i MachPtr; + + volVectorField U(Uheader, mesh); + + if (file(runTime.constantPath()/"thermophysicalProperties")) + { + // thermophysical Mach + autoPtr thermo + ( + basicThermo::New(mesh) + ); + + volScalarField Cp = thermo->Cp(); + volScalarField Cv = thermo->Cv(); + + MachPtr.set + ( + new volScalarField + ( + IOobject + ( + "Ma", + runTime.timeName(), + mesh + ), + mag(U)/(sqrt((Cp/Cv)*(Cp - Cv)*thermo->T())) + ) + ); + } + else + { + // thermodynamic Mach + IOdictionary thermoProps + ( + IOobject + ( + "thermodynamicProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + dimensionedScalar R(thermoProps.lookup("R")); + dimensionedScalar Cv(thermoProps.lookup("Cv")); + + volScalarField T(Theader, mesh); + + MachPtr.set + ( + new volScalarField + ( + IOobject + ( + "Ma", + runTime.timeName(), + mesh + ), + mag(U)/(sqrt(((Cv + R)/Cv)*R*T)) + ) + ); + } + + Info<< "Mach max : " << max(MachPtr()).value() << endl; + + if (writeResults) + { + MachPtr().write(); + } } else { -# include "thermodynamicMach.H" + Info<< " Missing U or T" << endl; } - - return(0); } diff --git a/applications/utilities/postProcessing/velocityField/Mach/Make/options b/applications/utilities/postProcessing/velocityField/Mach/Make/options index de6164b2b4..fbc31ea0a3 100644 --- a/applications/utilities/postProcessing/velocityField/Mach/Make/options +++ b/applications/utilities/postProcessing/velocityField/Mach/Make/options @@ -1,10 +1,11 @@ EXE_INC = \ + -I$(FOAM_SRC)/postProcessing/postCalc \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude EXE_LIBS = \ + $(FOAM_LIBBIN)/postCalc.o \ -lfiniteVolume \ -lbasicThermophysicalModels \ - -lspecie \ - -lmeshTools \ - + -lspecie + diff --git a/applications/utilities/postProcessing/velocityField/Pe/Make/options b/applications/utilities/postProcessing/velocityField/Pe/Make/options index 81bee4b1e1..6802a3c91f 100644 --- a/applications/utilities/postProcessing/velocityField/Pe/Make/options +++ b/applications/utilities/postProcessing/velocityField/Pe/Make/options @@ -1,4 +1,5 @@ EXE_INC = \ + -I$(FOAM_SRC)/postProcessing/postCalc \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ @@ -9,6 +10,7 @@ EXE_INC = \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude EXE_LIBS = \ + $(FOAM_LIBBIN)/postCalc.o \ -lfiniteVolume \ -lmeshTools \ -lincompressibleTransportModels \ diff --git a/applications/utilities/postProcessing/velocityField/Pe/Pe.C b/applications/utilities/postProcessing/velocityField/Pe/Pe.C index acc5b5e10d..cd5d76740b 100644 --- a/applications/utilities/postProcessing/velocityField/Pe/Pe.C +++ b/applications/utilities/postProcessing/velocityField/Pe/Pe.C @@ -27,106 +27,87 @@ Application Description Calculates and writes the Pe number as a surfaceScalarField obtained from - field phi for each time + field phi. + The -noWrite option just outputs the max/min values without writing + the field. \*---------------------------------------------------------------------------*/ -#include "fvCFD.H" +#include "calc.H" +#include "fvc.H" #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H" - #include "incompressible/turbulenceModel/turbulenceModel.H" #include "incompressible/LESmodel/LESmodel.H" - #include "basicThermo.H" #include "compressible/turbulenceModel/turbulenceModel.H" #include "compressible/LESmodel/LESmodel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -int main(int argc, char *argv[]) +void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) { + bool writeResults = !args.options().found("noWrite"); -# include "addTimeOptions.H" -# include "setRootCase.H" + IOobject phiHeader + ( + "phi", + runTime.timeName(), + mesh, + IOobject::MUST_READ + ); -# include "createTime.H" - - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); - -# include "createMesh.H" - - for (label i=startTime; i PePtr; - Info<< "Time = " << runTime.timeName() << endl; + Info<< " Reading phi" << endl; + surfaceScalarField phi(phiHeader, mesh); - IOobject phiHeader + volVectorField U ( - "phi", - runTime.timeName(), - mesh, - IOobject::MUST_READ + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ + ), + mesh ); - // Check phi exists - if (phiHeader.headerOk()) + Info<< " Calculating Pe" << endl; + + if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0)) { - mesh.readUpdate(); - - Info<< " Reading phi" << endl; - surfaceScalarField phi(phiHeader, mesh); - - volVectorField U + IOobject turbulencePropertiesHeader ( - IOobject - ( - "U", - runTime.timeName(), - mesh, - IOobject::MUST_READ - ), - mesh + "turbulenceProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE ); - - Info<< " Calculating Pe" << endl; - - if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0)) + if (turbulencePropertiesHeader.headerOk()) { - IOobject turbulencePropertiesHeader + IOdictionary turbulenceProperties ( - "turbulenceProperties", - runTime.constant(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE + turbulencePropertiesHeader ); - if (turbulencePropertiesHeader.headerOk()) + singlePhaseTransportModel laminarTransport(U, phi); + + if (turbulenceProperties.found("turbulenceModel")) { - IOdictionary turbulenceProperties + autoPtr turbulenceModel ( - turbulencePropertiesHeader + turbulenceModel::New(U, phi, laminarTransport) ); - singlePhaseTransportModel laminarTransport(U, phi); - - if (turbulenceProperties.found("turbulenceModel")) - { - autoPtr turbulenceModel - ( - turbulenceModel::New(U, phi, laminarTransport) - ); - - surfaceScalarField Pe + PePtr.set + ( + new surfaceScalarField ( IOobject ( @@ -135,24 +116,25 @@ int main(int argc, char *argv[]) mesh, IOobject::NO_READ ), - mag(phi) - /( + mag(phi) / + ( mesh.magSf() - *mesh.surfaceInterpolation::deltaCoeffs() - *fvc::interpolate(turbulenceModel->nuEff()) + * mesh.surfaceInterpolation::deltaCoeffs() + * fvc::interpolate(turbulenceModel->nuEff()) ) - ); + ) + ); + } + else if (turbulenceProperties.found("LESmodel")) + { + autoPtr sgsModel + ( + LESmodel::New(U, phi, laminarTransport) + ); - Pe.write(); - } - else if (turbulenceProperties.found("LESmodel")) - { - autoPtr sgsModel - ( - LESmodel::New(U, phi, laminarTransport) - ); - - surfaceScalarField Pe + PePtr.set + ( + new surfaceScalarField ( IOobject ( @@ -161,232 +143,235 @@ int main(int argc, char *argv[]) mesh, IOobject::NO_READ ), - mag(phi) - /( + mag(phi) / + ( mesh.magSf() - *mesh.surfaceInterpolation::deltaCoeffs() - *fvc::interpolate(sgsModel->nuEff()) + * mesh.surfaceInterpolation::deltaCoeffs() + * fvc::interpolate(sgsModel->nuEff()) ) - ); - - Info << " Max Pe = " << max(Pe).value() << endl; - - /* - label count = 0; - forAll(Pe, i) - { - if (Pe[i] > 200) count++; - } - - Info<< "Fraction > 200 = " - << scalar(count)/Pe.size() << endl; - */ - - Pe.write(); - } - else - { - FatalErrorIn(args.executable()) - << "Cannot find turbulence model type in" - "turbulenceModel dictionary" - << exit(FatalError); - } + ) + ); } else { - IOdictionary transportProperties - ( - IOobject - ( - "transportProperties", - runTime.constant(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ); - - dimensionedScalar nu - ( - transportProperties.lookup("nu") - ); - - surfaceScalarField Pe - ( - IOobject - ( - "Pe", - runTime.timeName(), - mesh, - IOobject::NO_READ - ), - mesh.surfaceInterpolation::deltaCoeffs() - *(mag(phi)/mesh.magSf())*(runTime.deltaT()/nu) - ); - - Info << " Max Pe = " << max(Pe).value() << endl; - - Pe.write(); - } - } - else if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0)) - { - IOobject turbulencePropertiesHeader - ( - "turbulenceProperties", - runTime.constant(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ); - - if (turbulencePropertiesHeader.headerOk()) - { - IOdictionary turbulenceProperties - ( - turbulencePropertiesHeader - ); - - autoPtr thermo - ( - basicThermo::New(mesh) - ); - - volScalarField rho - ( - IOobject - ( - "rho", - runTime.timeName(), - mesh - ), - thermo->rho() - ); - - if (turbulenceProperties.found("turbulenceModel")) - { - autoPtr turbulenceModel - ( - compressible::turbulenceModel::New - ( - rho, - U, - phi, - thermo() - ) - ); - - surfaceScalarField Pe - ( - IOobject - ( - "Pe", - runTime.timeName(), - mesh, - IOobject::NO_READ - ), - mag(phi) - /( - mesh.magSf() - *mesh.surfaceInterpolation::deltaCoeffs() - *fvc::interpolate(turbulenceModel->muEff()) - ) - ); - - Pe.write(); - } - else if (turbulenceProperties.found("LESmodel")) - { - autoPtr sgsModel - ( - compressible::LESmodel::New(rho, U, phi, thermo()) - ); - - surfaceScalarField Pe - ( - IOobject - ( - "Pe", - runTime.timeName(), - mesh, - IOobject::NO_READ - ), - mag(phi) - /( - mesh.magSf() - *mesh.surfaceInterpolation::deltaCoeffs() - *fvc::interpolate(sgsModel->muEff()) - ) - ); - - Info << " Max Pe = " << max(Pe).value() << endl; - - Pe.write(); - } - else - { - FatalErrorIn(args.executable()) - << "Cannot find turbulence model type in" - "turbulenceModel dictionary" - << exit(FatalError); - } - } - else - { - IOdictionary transportProperties - ( - IOobject - ( - "transportProperties", - runTime.constant(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ); - - dimensionedScalar mu - ( - transportProperties.lookup("mu") - ); - - surfaceScalarField Pe - ( - IOobject - ( - "Pe", - runTime.timeName(), - mesh, - IOobject::NO_READ - ), - mesh.surfaceInterpolation::deltaCoeffs() - *(mag(phi)/(mesh.magSf()))*(runTime.deltaT()/mu) - ); - - Info << " Max Pe = " << max(Pe).value() << endl; - - Pe.write(); + FatalErrorIn(args.executable()) + << "Cannot find turbulence model type in " + "turbulenceModel dictionary" + << exit(FatalError); } } else { - FatalErrorIn(args.executable()) - << "Incorrect dimensions of phi: " << phi.dimensions() - << abort(FatalError); + IOdictionary transportProperties + ( + IOobject + ( + "transportProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + dimensionedScalar nu + ( + transportProperties.lookup("nu") + ); + + PePtr.set + ( + new surfaceScalarField + ( + IOobject + ( + "Pe", + runTime.timeName(), + mesh, + IOobject::NO_READ + ), + mesh.surfaceInterpolation::deltaCoeffs() + * (mag(phi)/mesh.magSf())*(runTime.deltaT()/nu) + ) + ); + } + } + else if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0)) + { + IOobject turbulencePropertiesHeader + ( + "turbulenceProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (turbulencePropertiesHeader.headerOk()) + { + IOdictionary turbulenceProperties + ( + turbulencePropertiesHeader + ); + + autoPtr thermo + ( + basicThermo::New(mesh) + ); + + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh + ), + thermo->rho() + ); + + if (turbulenceProperties.found("turbulenceModel")) + { + autoPtr turbulenceModel + ( + compressible::turbulenceModel::New + ( + rho, + U, + phi, + thermo() + ) + ); + + PePtr.set + ( + new surfaceScalarField + ( + IOobject + ( + "Pe", + runTime.timeName(), + mesh, + IOobject::NO_READ + ), + mag(phi) / + ( + mesh.magSf() + * mesh.surfaceInterpolation::deltaCoeffs() + * fvc::interpolate(turbulenceModel->muEff()) + ) + ) + ); + } + else if (turbulenceProperties.found("LESmodel")) + { + autoPtr sgsModel + ( + compressible::LESmodel::New(rho, U, phi, thermo()) + ); + + PePtr.set + ( + new surfaceScalarField + ( + IOobject + ( + "Pe", + runTime.timeName(), + mesh, + IOobject::NO_READ + ), + mag(phi) / + ( + mesh.magSf() + * mesh.surfaceInterpolation::deltaCoeffs() + * fvc::interpolate(sgsModel->muEff()) + ) + ) + ); + } + else + { + FatalErrorIn(args.executable()) + << "Cannot find turbulence model type in" + "turbulenceModel dictionary" + << exit(FatalError); + } + } + else + { + IOdictionary transportProperties + ( + IOobject + ( + "transportProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + dimensionedScalar mu + ( + transportProperties.lookup("mu") + ); + + PePtr.set + ( + new surfaceScalarField + ( + IOobject + ( + "Pe", + runTime.timeName(), + mesh, + IOobject::NO_READ + ), + mesh.surfaceInterpolation::deltaCoeffs() + * (mag(phi)/(mesh.magSf()))*(runTime.deltaT()/mu) + ) + ); } } else { - Info<< " No phi" << endl; + FatalErrorIn(args.executable()) + << "Incorrect dimensions of phi: " << phi.dimensions() + << abort(FatalError); } - Info<< endl; + + // can also check how many cells exceed a particular Pe limit + /* + { + label count = 0; + label PeLimit = 200; + forAll(PePtr(), i) + { + if (PePtr()[i] > PeLimit) + { + count++; + } + + } + + Info<< "Fraction > " << PeLimit << " = " + << scalar(count)/Pe.size() << endl; + } + */ + + Info << "Pe max : " << max(PePtr()).value() << endl; + + if (writeResults) + { + PePtr().write(); + } + } + else + { + Info<< " No phi" << endl; } - - Info<< "End\n" << endl; - - return(0); } - // ************************************************************************* // diff --git a/applications/utilities/postProcessing/velocityField/Q/Make/options b/applications/utilities/postProcessing/velocityField/Q/Make/options index be7f7d631d..4116426077 100644 --- a/applications/utilities/postProcessing/velocityField/Q/Make/options +++ b/applications/utilities/postProcessing/velocityField/Q/Make/options @@ -1,6 +1,7 @@ EXE_INC = \ + -I$(FOAM_SRC)/postProcessing/postCalc \ -I$(LIB_SRC)/finiteVolume/lnInclude EXE_LIBS = \ - -lfiniteVolume \ - + $(FOAM_LIBBIN)/postCalc.o \ + -lfiniteVolume diff --git a/applications/utilities/postProcessing/velocityField/Q/Q.C b/applications/utilities/postProcessing/velocityField/Q/Q.C index 5e18ad04e4..6f6ac527c9 100644 --- a/applications/utilities/postProcessing/velocityField/Q/Q.C +++ b/applications/utilities/postProcessing/velocityField/Q/Q.C @@ -26,101 +26,85 @@ Application Q Description - Calculates and writes the second invariant of the velocity gradient tensor - for each time. + Calculates and writes the second invariant of the velocity gradient tensor. + The -noWrite option just outputs the max/min values without writing + the field. \*---------------------------------------------------------------------------*/ -#include "fvCFD.H" +#include "calc.H" +#include "fvc.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -int main(int argc, char *argv[]) +void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) { + bool writeResults = !args.options().found("noWrite"); -# include "addTimeOptions.H" -# include "setRootCase.H" + IOobject Uheader + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ + ); -# include "createTime.H" - - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); - -# include "createMesh.H" - - for (label i=startTime; i laminarTransport - ( - transportModel::New(U, phi) - ); - - autoPtr turbulence - ( - turbulenceModel::New(U, phi, laminarTransport()) - ); diff --git a/applications/utilities/postProcessing/wall/wallGradU/wallGradU.C b/applications/utilities/postProcessing/wall/wallGradU/wallGradU.C index 54762fd936..be9b22c9e3 100644 --- a/applications/utilities/postProcessing/wall/wallGradU/wallGradU.C +++ b/applications/utilities/postProcessing/wall/wallGradU/wallGradU.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - wallGradU + wallGradU Description Calculates and writes the gradient of U at the wall @@ -33,31 +33,19 @@ Description #include "fvCFD.H" #include "incompressible/turbulenceModel/turbulenceModel.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { - -# include "addTimeOptions.H" -# include "setRootCase.H" - + timeSelector::addOptions(); + #include "setRootCase.H" # include "createTime.H" - - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); - + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - for (label i=startTime; ialphaEff())*fvc::snGrad(h); const surfaceScalarField::GeometricBoundaryField& patchHeatFlux = @@ -83,7 +72,7 @@ int main(int argc, char *argv[]) ( mesh.magSf().boundaryField()[patchi] *patchHeatFlux[patchi] - ) + ) << endl; } } @@ -111,8 +100,7 @@ int main(int argc, char *argv[]) Info<< "End" << endl; - return(0); + return 0; } - // ************************************************************************* // diff --git a/applications/utilities/postProcessing/wall/wallShearStress/wallShearStress.C b/applications/utilities/postProcessing/wall/wallShearStress/wallShearStress.C index b7e642cc81..d0cf002c4a 100644 --- a/applications/utilities/postProcessing/wall/wallShearStress/wallShearStress.C +++ b/applications/utilities/postProcessing/wall/wallShearStress/wallShearStress.C @@ -26,8 +26,7 @@ Application wallShearStress Description - Calculates and writes the wall shear stress for the current - time step. + Calculates and writes the wall shear stress, for the specified times. \*---------------------------------------------------------------------------*/ @@ -35,33 +34,20 @@ Description #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H" #include "incompressible/turbulenceModel/turbulenceModel.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { - -# include "addTimeOptions.H" -# include "setRootCase.H" - + timeSelector::addOptions(); + #include "setRootCase.H" # include "createTime.H" - - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); - + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - for (label i=startTime; i