Adjust some utilities to use postCalc wrapper or timeSelector directly.

When required, also adjusted to use XXXApp.C for the source name.
Adjusted some names in preparation for merge with master.
This commit is contained in:
Mark Olesen
2008-05-21 10:19:23 +02:00
parent e34c1c75f8
commit e9876723e6
59 changed files with 1396 additions and 1541 deletions

View File

@ -1,4 +1,4 @@
polyDualMesh.C polyDualMesh.C
makePolyDualMesh.C polyDualMeshApp.C
EXE = $(FOAM_APPBIN)/polyDualMesh EXE = $(FOAM_APPBIN)/polyDualMesh

View File

@ -22,6 +22,9 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
polyDualMesh
Description Description
Calculate the dual of a polyMesh. Adheres to all the feature&patch edges Calculate the dual of a polyMesh. Adheres to all the feature&patch edges

View File

@ -22,8 +22,11 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
foamFormatConvert
Description 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. in the controlDict.
Mainly used to convert binary mesh/field files to ASCII. Mainly used to convert binary mesh/field files to ASCII.
@ -31,6 +34,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "argList.H" #include "argList.H"
#include "timeSelector.H"
#include "Time.H" #include "Time.H"
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
@ -47,22 +51,15 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
# include "addTimeOptions.H" timeSelector::addOptions();
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
// Get times list forAll (timeDirs, timeI)
instantList Times = runTime.times();
// set startTime and endTime depending on -time and -latestTime options
# include "checkTimeOptions.H"
for (label i=startTime; i<endTime; i++)
{ {
runTime.setTime(Times[i], i); runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;
Info<< " Time = " << runTime.timeName() << endl;
// Convert all the standard mesh files // Convert all the standard mesh files
writeMeshObject<cellIOList>("cells", runTime); writeMeshObject<cellIOList>("cells", runTime);
@ -78,7 +75,7 @@ int main(int argc, char *argv[])
{ {
const word& headerClassName = iter()->headerClassName(); const word& headerClassName = iter()->headerClassName();
if if
( (
headerClassName == volScalarField::typeName headerClassName == volScalarField::typeName
|| headerClassName == volVectorField::typeName || headerClassName == volVectorField::typeName
@ -116,7 +113,6 @@ int main(int argc, char *argv[])
Info<< endl; Info<< endl;
} }
Info<< "End\n" << endl; Info<< "End\n" << endl;
return 0; return 0;

View File

@ -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<endTime; i++)
{
runTime.setTime(Times[i], i);
Info<< "Time = " << runTime.timeName() << endl;
IOobject header
(
fieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
// Check U exists
if (header.headerOk())
{
mesh.readUpdate();
if (header.headerClassName() == volVectorField::typeName)
{
Info<< " Reading " << fieldName << endl;
volVectorField U(header, mesh);
volScalarField magGrad
(
IOobject
(
"magGrad" + fieldName,
runTime.timeName(),
mesh,
IOobject::NO_READ
),
mag(fvc::grad(U))
);
Info<< " Calculating " << magGrad.name() << endl;
magGrad.write();
}
else if (header.headerClassName() == volScalarField::typeName)
{
Info<< " Reading " << fieldName << endl;
volScalarField U(header, mesh);
volScalarField magGrad
(
IOobject
(
"magGrad" + fieldName,
runTime.timeName(),
mesh,
IOobject::NO_READ
),
mag(fvc::grad(U))
);
Info<< " Calculating " << magGrad.name() << endl;
magGrad.write();
}
}
else
{
Info<< " No " << fieldName << endl;
}
}
return(0);
}
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
components.C
EXE = $(FOAM_APPBIN)/components

View File

@ -0,0 +1,147 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Ucomponents
Description
Writes scalar fields corresponding to each component of the supplied
field (name).
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template <class Type>
void writeComponents
(
const IOobject& header,
const fvMesh& mesh,
bool& processed
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
if (header.headerClassName() == fieldType::typeName)
{
Info<< " Reading " << header.name() << endl;
fieldType field(header, mesh);
for (direction i=0; i<Type::nComponents; i++)
{
Info<< " Calculating " << header.name()
<< Type::componentNames[i] << endl;
volScalarField componentField
(
IOobject
(
header.name() + word(Type::componentNames[i]),
mesh.time().timeName(),
mesh,
IOobject::NO_READ
),
field.component(i)
);
componentField.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"
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 fieldHeader
(
fieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
// Check field exists
if (fieldHeader.headerOk())
{
bool processed = false;
writeComponents<vector>(fieldHeader, mesh, processed);
writeComponents<sphericalTensor>(fieldHeader, mesh, processed);
writeComponents<symmTensor>(fieldHeader, mesh, processed);
writeComponents<tensor>(fieldHeader, mesh, processed);
if (!processed)
{
FatalError
<< "Unable to process " << fieldName << nl
<< "No call to components for fields of type "
<< fieldHeader.headerClassName() << nl << nl
<< exit(FatalError);
}
}
else
{
Info<< " No " << fieldName << endl;
}
}
}
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
mag.C
EXE = $(FOAM_APPBIN)/mag

View File

@ -0,0 +1,142 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
mag
Description
Calculates and writes the scalar magnitude of a field
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void writeMagField
(
const IOobject& header,
const fvMesh& mesh,
bool& processed
)
{
typedef GeometricField<Type, fvPatchField, volMesh> 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<scalar>(fieldHeader, mesh, processed);
writeMagField<vector>(fieldHeader, mesh, processed);
writeMagField<sphericalTensor>(fieldHeader, mesh, processed);
writeMagField<symmTensor>(fieldHeader, mesh, processed);
writeMagField<tensor>(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;
}
// ************************************************************************* //

View File

@ -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;
}
// ************************************************************************* //

View File

@ -37,31 +37,20 @@ Description
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
timeSelector::addOptions();
argList::validArgs.append("fieldName"); argList::validArgs.append("fieldName");
argList::validArgs.append("patchName"); argList::validArgs.append("patchName");
# include "addTimeOptions.H"
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H"
word fieldName(args.additionalArgs()[0]); word fieldName(args.additionalArgs()[0]);
word patchName(args.additionalArgs()[1]); word patchName(args.additionalArgs()[1]);
# include "createTime.H" forAll(timeDirs, timeI)
// 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<endTime; i++)
{ {
runTime.setTime(Times[i], i); runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl; Info<< "Time = " << runTime.timeName() << endl;
IOobject fieldHeader IOobject fieldHeader
@ -77,21 +66,40 @@ int main(int argc, char *argv[])
{ {
mesh.readUpdate(); mesh.readUpdate();
Info<< " Reading field " << fieldName << endl;
volScalarField field(fieldHeader, mesh);
label patchi = mesh.boundaryMesh().findPatchID(patchName); label patchi = mesh.boundaryMesh().findPatchID(patchName);
if (patchi < 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 " Info<< " Average of " << fieldName << " over patch "
<< patchName << '[' << patchi << ']' << " = " << patchName << '[' << patchi << ']' << " = "
<< sum << sumField << endl;
( }
mesh.magSf().boundaryField()[patchi] else
*field.boundaryField()[patchi] {
)/sum(mesh.magSf().boundaryField()[patchi]) FatalError
<< endl; << "Only possible to average volScalarFields "
<< nl << exit(FatalError);
} }
} }
else else
@ -104,8 +112,7 @@ int main(int argc, char *argv[])
Info<< "End\n" << endl; Info<< "End\n" << endl;
return(0); return 0;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -37,31 +37,20 @@ Description
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
timeSelector::addOptions();
argList::validArgs.append("fieldName"); argList::validArgs.append("fieldName");
argList::validArgs.append("patchName"); argList::validArgs.append("patchName");
# include "addTimeOptions.H"
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H"
word fieldName(args.additionalArgs()[0]); word fieldName(args.additionalArgs()[0]);
word patchName(args.additionalArgs()[1]); word patchName(args.additionalArgs()[1]);
# include "createTime.H" forAll(timeDirs, timeI)
// 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<endTime; i++)
{ {
runTime.setTime(Times[i], i); runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl; Info<< "Time = " << runTime.timeName() << endl;
IOobject fieldHeader IOobject fieldHeader
@ -77,21 +66,43 @@ int main(int argc, char *argv[])
{ {
mesh.readUpdate(); mesh.readUpdate();
Info<< " Reading field " << fieldName << endl;
volScalarField field(fieldHeader, mesh);
label patchi = mesh.boundaryMesh().findPatchID(patchName); label patchi = mesh.boundaryMesh().findPatchID(patchName);
if (patchi < 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 " Info<< " Integral of " << fieldName << " over patch "
<< patchName << '[' << patchi << ']' << " = " << patchName << '[' << patchi << ']' << " = "
<< sum << sumField << nl;
( }
mesh.Sf().boundaryField()[patchi] else if (fieldHeader.headerClassName() == "surfaceScalarField")
*field.boundaryField()[patchi] {
) Info<< " Reading surfaceScalarField " << fieldName << endl;
<< 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 else
@ -104,7 +115,7 @@ int main(int argc, char *argv[])
Info<< "End\n" << endl; Info<< "End\n" << endl;
return(0); return 0;
} }

View File

@ -28,6 +28,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "argList.H" #include "argList.H"
#include "timeSelector.H"
#include "IOprobes.H" #include "IOprobes.H"
using namespace Foam; using namespace Foam;
@ -37,27 +38,17 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
timeSelector::addOptions();
# include "addTimeOptions.H"
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
// 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" # include "createMesh.H"
IOprobes sniff(mesh, "probesDict", true); IOprobes sniff(mesh, "probesDict", true);
for (label i=startTime; i<endTime; i++) forAll(timeDirs, timeI)
{ {
runTime.setTime(Times[i], i); runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl; Info<< "Time = " << runTime.timeName() << endl;
// Handle geometry/topology changes // Handle geometry/topology changes
@ -77,7 +68,6 @@ int main(int argc, char *argv[])
Info<< endl; Info<< endl;
} }
Info<< "End\n" << endl; Info<< "End\n" << endl;
return 0; return 0;

View File

@ -83,6 +83,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "argList.H" #include "argList.H"
#include "timeSelector.H"
#include "IOsampledSets.H" #include "IOsampledSets.H"
#include "IOsampledSurfaces.H" #include "IOsampledSurfaces.H"
@ -93,28 +94,18 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
timeSelector::addOptions();
# include "addTimeOptions.H"
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
// 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" # include "createMesh.H"
IOsampledSets sSets(mesh, "sampleDict", true); IOsampledSets sSets(mesh, "sampleDict", true);
IOsampledSurfaces sSurfaces(mesh, "sampleDict", true); IOsampledSurfaces sSurfaces(mesh, "sampleDict", true);
for (label i=startTime; i<endTime; i++) forAll(timeDirs, timeI)
{ {
runTime.setTime(Times[i], i); runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl; Info<< "Time = " << runTime.timeName() << endl;
// Handle geometry/topology changes // Handle geometry/topology changes
@ -129,7 +120,6 @@ int main(int argc, char *argv[])
Info<< endl; Info<< endl;
} }
Info<< "End\n" << endl; Info<< "End\n" << endl;
return 0; return 0;

View File

@ -108,6 +108,9 @@ sets
// Surface sampling definition: choice of // Surface sampling definition: choice of
// plane : values on plane defined by point, normal. // plane : values on plane defined by point, normal.
// patch : values on patch. // patch : values on patch.
//
// 1] planes are triangulated by default
// 2] patches are not triangulated by default
surfaces surfaces
( (
constantPlane constantPlane
@ -141,15 +144,15 @@ surfaces
{ {
type patch; type patch;
patchName movingWall; patchName movingWall;
triangulate false; // Optional: whether to leave as faces (=default) or triangulate
} }
movingWall_interpolated movingWall_interpolated
{ {
type patch; type patch;
patchName movingWall; patchName movingWall;
triangulate false;
interpolate true; interpolate true;
// Optional: whether to leave as faces (=default) or triangulate
} }
/* not yet (re)implemented -- /* not yet (re)implemented --

View File

@ -26,60 +26,56 @@ Application
Co Co
Description Description
Calculates and writes the Co number as a surfaceScalarField obtained from Calculates and writes the Co number as a surfaceScalarField obtained
field phi for each time from field phi.
The -noWrite option just outputs the max 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" IOobject phiHeader
# include "setRootCase.H" (
"phi",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
# include "createTime.H" if (phiHeader.headerOk())
// 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<endTime; i++)
{ {
runTime.setTime(Times[i], i); autoPtr<surfaceScalarField> CoPtr;
Info<< "Time = " << runTime.timeName() << endl; Info<< " Reading phi" << endl;
surfaceScalarField phi(phiHeader, mesh);
Info<< " Calculating Co" << endl;
IOobject phiHeader if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0))
(
"phi",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
// Check U exists
if (phiHeader.headerOk())
{ {
mesh.readUpdate(); // compressible
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
mesh
);
Info<< " Reading phi" << endl; CoPtr.set
surfaceScalarField phi(phiHeader, mesh); (
new surfaceScalarField
Info<< " Calculating Co" << endl;
if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0))
{
surfaceScalarField Co
( (
IOobject IOobject
( (
@ -88,30 +84,20 @@ int main(int argc, char *argv[])
mesh, mesh,
IOobject::NO_READ 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", mesh.surfaceInterpolation::deltaCoeffs()
runTime.timeName(), * (mag(phi)/(fvc::interpolate(rho)*mesh.magSf()))
mesh, * runTime.deltaT()
IOobject::MUST_READ )
), )
mesh );
); }
else if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0))
surfaceScalarField Co {
// incompressible
CoPtr.set
(
new surfaceScalarField
( (
IOobject IOobject
( (
@ -120,34 +106,32 @@ int main(int argc, char *argv[])
mesh, mesh,
IOobject::NO_READ IOobject::NO_READ
), ),
mesh.surfaceInterpolation::deltaCoeffs() (
*(mag(phi)/(fvc::interpolate(rho)*mesh.magSf())) mesh.surfaceInterpolation::deltaCoeffs()
*runTime.deltaT() * (mag(phi)/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);
}
} }
else 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);
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,6 +1,7 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(FOAM_SRC)/postProcessing/postCalc \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ $(FOAM_LIBBIN)/postCalc.o \
-lfiniteVolume

View File

@ -26,81 +26,58 @@ Application
Lambda2 Lambda2
Description Description
Calculates and writes the second largest eigenvalue of the sum of the Calculates and writes the second largest eigenvalue of the sum of the
square of the symmetrical and anti-symmetrical parts of the velocity square of the symmetrical and anti-symmetrical parts of the velocity
gradient tensor, for each time. gradient tensor.
The -noWrite option has no meaning.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvCFD.H" #include "calc.H"
#include "tensorField.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" if (Uheader.headerOk())
# 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<endTime; i++)
{ {
runTime.setTime(Times[i], i); Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
Info<< "Time = " << runTime.timeName() << endl; const volTensorField gradU(fvc::grad(U));
IOobject Uheader volTensorField SSplusWW =
(symm(gradU) & symm(gradU)) + (skew(gradU) & skew(gradU));
volScalarField Lambda2
( (
"U", IOobject
runTime.timeName(), (
mesh, "Lambda2",
IOobject::MUST_READ runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
-eigenValues(SSplusWW)().component(vector::Y)
); );
// Check U exists Info << " Writing -Lambda2" << endl;
if (Uheader.headerOk()) Lambda2.write();
{ }
mesh.readUpdate(); else
{
Info<< " Reading U" << endl; Info<< " No U" << endl;
volVectorField U(Uheader, mesh);
const volTensorField gradU(fvc::grad(U));
volTensorField SSplusWW =
(symm(gradU) & symm(gradU)) + (skew(gradU) & skew(gradU));
volScalarField Lambda2
(
IOobject
(
"Lambda2",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
-eigenValues(SSplusWW)().component(vector::Y)
);
Info << " Writing -Lambda2" << endl;
Lambda2.write();
}
} }
return(0);
} }

View File

@ -1,6 +1,7 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SRC)/postProcessing/postCalc \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ $(FOAM_LIBBIN)/postCalc.o \
-lfiniteVolume

View File

@ -26,44 +26,114 @@ Application
Mach Mach
Description Description
Calculates and writes the local Mach number from the velocity field U at Calculates and optionally writes the local Mach number from the velocity
each time field U at each time. The -nowrite option just outputs the max value
without writing the field.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvCFD.H" #include "calc.H"
#include "basicThermo.H" #include "basicThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
int main(int argc, char *argv[])
{ {
bool writeResults = !args.options().found("noWrite");
# include "addTimeOptions.H" IOobject Uheader
# include "setRootCase.H" (
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
# include "createTime.H" IOobject Theader
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
// Get times list // Check U and T exists
instantList Times = runTime.times(); if (Uheader.headerOk() && Theader.headerOk())
// set startTime and endTime depending on -time and -latestTime options
# include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
# include "createMesh.H"
if (file(runTime.constantPath()/"thermophysicalProperties"))
{ {
# include "thermophysicalMach.H" autoPtr<volScalarField> MachPtr;
volVectorField U(Uheader, mesh);
if (file(runTime.constantPath()/"thermophysicalProperties"))
{
// thermophysical Mach
autoPtr<basicThermo> 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 else
{ {
# include "thermodynamicMach.H" Info<< " Missing U or T" << endl;
} }
return(0);
} }

View File

@ -1,10 +1,11 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SRC)/postProcessing/postCalc \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude
EXE_LIBS = \ EXE_LIBS = \
$(FOAM_LIBBIN)/postCalc.o \
-lfiniteVolume \ -lfiniteVolume \
-lbasicThermophysicalModels \ -lbasicThermophysicalModels \
-lspecie \ -lspecie
-lmeshTools \

View File

@ -1,4 +1,5 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SRC)/postProcessing/postCalc \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \
@ -9,6 +10,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude
EXE_LIBS = \ EXE_LIBS = \
$(FOAM_LIBBIN)/postCalc.o \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools \ -lmeshTools \
-lincompressibleTransportModels \ -lincompressibleTransportModels \

View File

@ -27,106 +27,87 @@ Application
Description Description
Calculates and writes the Pe number as a surfaceScalarField obtained from 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/singlePhaseTransportModel/singlePhaseTransportModel.H"
#include "incompressible/turbulenceModel/turbulenceModel.H" #include "incompressible/turbulenceModel/turbulenceModel.H"
#include "incompressible/LESmodel/LESmodel.H" #include "incompressible/LESmodel/LESmodel.H"
#include "basicThermo.H" #include "basicThermo.H"
#include "compressible/turbulenceModel/turbulenceModel.H" #include "compressible/turbulenceModel/turbulenceModel.H"
#include "compressible/LESmodel/LESmodel.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" IOobject phiHeader
# include "setRootCase.H" (
"phi",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
# include "createTime.H" if (phiHeader.headerOk())
// 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<endTime; i++)
{ {
runTime.setTime(Times[i], i); autoPtr<surfaceScalarField> PePtr;
Info<< "Time = " << runTime.timeName() << endl; Info<< " Reading phi" << endl;
surfaceScalarField phi(phiHeader, mesh);
IOobject phiHeader volVectorField U
( (
"phi", IOobject
runTime.timeName(), (
mesh, "U",
IOobject::MUST_READ runTime.timeName(),
mesh,
IOobject::MUST_READ
),
mesh
); );
// Check phi exists Info<< " Calculating Pe" << endl;
if (phiHeader.headerOk())
if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0))
{ {
mesh.readUpdate(); IOobject turbulencePropertiesHeader
Info<< " Reading phi" << endl;
surfaceScalarField phi(phiHeader, mesh);
volVectorField U
( (
IOobject "turbulenceProperties",
( runTime.constant(),
"U", mesh,
runTime.timeName(), IOobject::MUST_READ,
mesh, IOobject::NO_WRITE
IOobject::MUST_READ
),
mesh
); );
if (turbulencePropertiesHeader.headerOk())
Info<< " Calculating Pe" << endl;
if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0))
{ {
IOobject turbulencePropertiesHeader IOdictionary turbulenceProperties
( (
"turbulenceProperties", turbulencePropertiesHeader
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
); );
if (turbulencePropertiesHeader.headerOk()) singlePhaseTransportModel laminarTransport(U, phi);
if (turbulenceProperties.found("turbulenceModel"))
{ {
IOdictionary turbulenceProperties autoPtr<turbulenceModel> turbulenceModel
( (
turbulencePropertiesHeader turbulenceModel::New(U, phi, laminarTransport)
); );
singlePhaseTransportModel laminarTransport(U, phi); PePtr.set
(
if (turbulenceProperties.found("turbulenceModel")) new surfaceScalarField
{
autoPtr<turbulenceModel> turbulenceModel
(
turbulenceModel::New(U, phi, laminarTransport)
);
surfaceScalarField Pe
( (
IOobject IOobject
( (
@ -135,24 +116,25 @@ int main(int argc, char *argv[])
mesh, mesh,
IOobject::NO_READ IOobject::NO_READ
), ),
mag(phi) mag(phi) /
/( (
mesh.magSf() mesh.magSf()
*mesh.surfaceInterpolation::deltaCoeffs() * mesh.surfaceInterpolation::deltaCoeffs()
*fvc::interpolate(turbulenceModel->nuEff()) * fvc::interpolate(turbulenceModel->nuEff())
) )
); )
);
}
else if (turbulenceProperties.found("LESmodel"))
{
autoPtr<LESmodel> sgsModel
(
LESmodel::New(U, phi, laminarTransport)
);
Pe.write(); PePtr.set
} (
else if (turbulenceProperties.found("LESmodel")) new surfaceScalarField
{
autoPtr<LESmodel> sgsModel
(
LESmodel::New(U, phi, laminarTransport)
);
surfaceScalarField Pe
( (
IOobject IOobject
( (
@ -161,232 +143,235 @@ int main(int argc, char *argv[])
mesh, mesh,
IOobject::NO_READ IOobject::NO_READ
), ),
mag(phi) mag(phi) /
/( (
mesh.magSf() mesh.magSf()
*mesh.surfaceInterpolation::deltaCoeffs() * mesh.surfaceInterpolation::deltaCoeffs()
*fvc::interpolate(sgsModel->nuEff()) * 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 else
{ {
IOdictionary transportProperties FatalErrorIn(args.executable())
( << "Cannot find turbulence model type in "
IOobject "turbulenceModel dictionary"
( << exit(FatalError);
"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<basicThermo> thermo
(
basicThermo::New(mesh)
);
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh
),
thermo->rho()
);
if (turbulenceProperties.found("turbulenceModel"))
{
autoPtr<compressible::turbulenceModel> 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<compressible::LESmodel> 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();
} }
} }
else else
{ {
FatalErrorIn(args.executable()) IOdictionary transportProperties
<< "Incorrect dimensions of phi: " << phi.dimensions() (
<< abort(FatalError); 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<basicThermo> thermo
(
basicThermo::New(mesh)
);
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh
),
thermo->rho()
);
if (turbulenceProperties.found("turbulenceModel"))
{
autoPtr<compressible::turbulenceModel> 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<compressible::LESmodel> 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 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);
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,6 +1,7 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SRC)/postProcessing/postCalc \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ $(FOAM_LIBBIN)/postCalc.o \
-lfiniteVolume

View File

@ -26,101 +26,85 @@ Application
Q Q
Description Description
Calculates and writes the second invariant of the velocity gradient tensor Calculates and writes the second invariant of the velocity gradient tensor.
for each time. 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" IOobject Uheader
# include "setRootCase.H" (
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
# include "createTime.H" if (Uheader.headerOk())
// 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<endTime; i++)
{ {
runTime.setTime(Times[i], i); Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
volTensorField gradU = fvc::grad(U);
Info<< "Time = " << runTime.timeName() << endl; volScalarField Q
IOobject Uheader
( (
"U", IOobject
runTime.timeName(), (
mesh, "Q",
IOobject::MUST_READ runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
0.5*(sqr(tr(gradU)) - tr(((gradU)&(gradU))))
); );
// Check U exists /*
if (Uheader.headerOk()) // This is a second way of calculating Q, that delivers results
// very close, but not identical to the first approach.
volSymmTensorField S = symm(gradU); // symmetric part of tensor
volTensorField W = skew(gradU); // anti-symmetric part
volScalarField SS = S&&S;
volScalarField WW = W&&W;
volScalarField Q
(
IOobject
(
"Q",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
0.5*(WW - SS)
);
*/
Info<< "mag(Q) max/min : "
<< max(Q).value() << " "
<< min(Q).value() << endl;
if (writeResults)
{ {
mesh.readUpdate();
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
volTensorField gradU = fvc::grad(U);
volScalarField Q
(
IOobject
(
"Q",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
0.5*(sqr(tr(gradU)) - tr(((gradU)&(gradU))))
);
/*
// This is a second way of calculating Q, that delivers results
// very close, but not identical to the first approach.
volSymmTensorField S = symm(gradU); // symmetric part of tensor
volTensorField W = skew(gradU); // anti-symmetric part
volScalarField SS = S&&S;
volScalarField WW = W&&W;
volScalarField Q
(
IOobject
(
"Q",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
0.5*(WW - SS)
);
*/
Info << " Writing Q" << endl;
Q.write(); Q.write();
} }
} }
else
return(0); {
Info<< " No U" << endl;
}
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,27 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
// Ucomponents tool definition
description "U velocity components";
UcomponentsDict
{
type dictionary;
description "Ucomponents control dictionary";
dictionaryPath "system";
entries
{
arguments
{
type rootCaseTimeArguments;
}
}
}
// ************************************************************************* //

View File

@ -1,3 +0,0 @@
Ucomponents.C
EXE = $(FOAM_APPBIN)/Ucomponents

View File

@ -1,108 +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
Ucomponents
Description
Writes the three scalar fields, Ux, Uy and Uz, for each component of the
velocity field U for each time
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# 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<endTime; i++)
{
runTime.setTime(Times[i], i);
Info<< "Time = " << runTime.timeName() << endl;
IOobject Uheader
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
// Check U exists
if (Uheader.headerOk())
{
mesh.readUpdate();
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
for (direction i=0; i<vector::nComponents; i++)
{
Info<< " Calculating U" << vector::componentNames[i] << endl;
volScalarField Ui
(
IOobject
(
"U" + word(vector::componentNames[i]),
runTime.timeName(),
mesh,
IOobject::NO_READ
),
U.component(i)
);
Ui.write();
}
}
else
{
Info<< " No U" << endl;
}
Info<< endl;
}
return(0);
}
// ************************************************************************* //

View File

@ -1,4 +0,0 @@
:q
calcDivPhi.C
EXE = $(FOAM_USER_APPBIN)/divPhi

View File

@ -1,7 +0,0 @@
EXE_INC = \
-I$(FOAM_SRC)/postProcessing/postCalc \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
-lpostCalc \
-lfiniteVolume

View File

@ -1,3 +1,3 @@
calcDivPhi.C divPhiApp.C
EXE = $(FOAM_APPBIN)/divPhi EXE = $(FOAM_APPBIN)/divPhi

View File

@ -22,11 +22,13 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Global Application
calcDivPhi divPhi
Description Description
Calculates and writes the divergence of the flux field phi Calculates and writes the divergence of the flux field phi. The
-noWrite option just outputs the max/min values without writing the
field.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -74,5 +76,4 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
} }
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,3 +1,3 @@
calcDivU.C divUApp.C
EXE = $(FOAM_APPBIN)/divU EXE = $(FOAM_APPBIN)/divU

View File

@ -22,11 +22,13 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Global Application
calcDivU divU
Description Description
Calculates and writes the divergence of velocity field U Calculates and writes the divergence of the velocity field U.
The -noWrite option just outputs the max/min values without writing the
field.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -39,40 +41,44 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
{ {
bool writeResults = !args.options().found("noWrite"); bool writeResults = !args.options().found("noWrite");
Info<< " Reading U" << endl; IOobject Uheader
volVectorField U
( (
IOobject "U",
( runTime.timeName(),
"U", mesh,
runTime.timeName(), IOobject::MUST_READ
mesh,
IOobject::MUST_READ
),
mesh
); );
Info<< " Calculating divU" << endl; if (Uheader.headerOk())
volScalarField divU
(
IOobject
(
"divU",
runTime.timeName(),
mesh
),
fvc::div(U)
);
Info<< "div(phi) max/min : "
<< max(divU).value() << " "
<< min(divU).value() << endl;
if (writeResults)
{ {
divU.write(); Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
Info<< " Calculating divU" << endl;
volScalarField divU
(
IOobject
(
"divU",
runTime.timeName(),
mesh
),
fvc::div(U)
);
Info<< "div(U) max/min : "
<< max(divU).value() << " "
<< min(divU).value() << endl;
if (writeResults)
{
divU.write();
}
}
else
{
Info<< " No U" << endl;
} }
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,6 +1,7 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SRC)/postProcessing/postCalc \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ $(FOAM_LIBBIN)/postCalc.o \
-lfiniteVolume

View File

@ -26,77 +26,60 @@ Application
enstrophy enstrophy
Description Description
Calculates and writes the enstrophy of velocity field U at each time Calculates and writes the enstrophy of the velocity field U.
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" IOobject Uheader
# include "setRootCase.H" (
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
# include "createTime.H" if (Uheader.headerOk())
// 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<endTime; i++)
{ {
runTime.setTime(Times[i], i); Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
Info<< "Time = " << runTime.timeName() << endl; Info<< " Calculating enstrophy" << endl;
volScalarField enstrophy
IOobject Uheader
( (
"U", IOobject
runTime.timeName(), (
mesh, "enstrophy",
IOobject::MUST_READ runTime.timeName(),
mesh,
IOobject::NO_READ
),
0.5*magSqr(fvc::curl(U))
); );
// Check U exists Info<< "enstrophy(U) max/min : "
if (Uheader.headerOk()) << max(enstrophy).value() << " "
<< min(enstrophy).value() << endl;
if (writeResults)
{ {
mesh.readUpdate();
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
Info<< " Calculating enstrophy" << endl;
volScalarField enstrophy
(
IOobject
(
"enstrophy",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
0.5*magSqr(fvc::curl(U))
);
enstrophy.write(); enstrophy.write();
} }
else
{
Info<< " No U" << endl;
}
} }
else
return(0); {
Info<< " No U" << endl;
}
} }

View File

@ -1,6 +1,7 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SRC)/postProcessing/postCalc \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ $(FOAM_LIBBIN)/postCalc.o \
-lfiniteVolume

View File

@ -26,10 +26,11 @@ Application
flowType flowType
Description Description
Calculates and writes the flowType of velocity field U at each time Calculates and writes the flowType of velocity field U.
The -noWrite option has no meaning.
The flow tye parameter is obtained from
The flow type parameter is obtained according to the following equation:
@verbatim
|D| - |Omega| |D| - |Omega|
lambda = ------------- lambda = -------------
|D| + |Omega| |D| + |Omega|
@ -37,79 +38,55 @@ Description
-1 = rotational flow -1 = rotational flow
0 = simple shear flow 0 = simple shear flow
1 = planar extensional flow 1 = planar extensional flow
@endverbatim
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#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)
{ {
# include "addTimeOptions.H" IOobject Uheader
# include "setRootCase.H" (
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
# include "createTime.H" if (Uheader.headerOk())
// 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<endTime; i++)
{ {
runTime.setTime(Times[i], i); Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
Info<< "Time = " << runTime.timeName() << endl; volTensorField gradU = fvc::grad(U);
volScalarField magD = mag(symm(gradU));
volScalarField magOmega = mag(skew(gradU));
dimensionedScalar smallMagD("smallMagD", magD.dimensions(), SMALL);
IOobject Uheader Info<< " Calculating flowType" << endl;
volScalarField flowType
( (
"U", IOobject
runTime.timeName(), (
mesh, "flowType",
IOobject::MUST_READ runTime.timeName(),
mesh,
IOobject::NO_READ
),
(magD - magOmega)/(magD + magOmega + smallMagD)
); );
// Check U exists flowType.write();
if (Uheader.headerOk()) }
{ else
mesh.readUpdate(); {
Info<< " No U" << endl;
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
volTensorField gradU = fvc::grad(U);
volScalarField magD = mag(symm(gradU));
volScalarField magOmega = mag(skew(gradU));
dimensionedScalar smallMagD("smallMagD", magD.dimensions(), SMALL);
Info<< " Calculating flowType" << endl;
volScalarField flowType
(
IOobject
(
"flowType",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
(magD - magOmega)/(magD + magOmega + smallMagD)
);
flowType.write();
}
else
{
Info<< " No U" << endl;
}
} }
return(0);
} }

View File

@ -1,6 +1,7 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SRC)/postProcessing/postCalc \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ $(FOAM_LIBBIN)/postCalc.o \
-lfiniteVolume

View File

@ -26,77 +26,61 @@ Application
magGradU magGradU
Description Description
Calculates and writes the scalar magnitude of velocity field U at each time Calculates and writes the scalar magnitude of the gradient of the
velocity field U.
The -noWrite option just outputs the max/min values without writing
the field.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvCFD.H" #include "calc.H"
#include "fvc.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
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" IOobject Uheader
# include "setRootCase.H" (
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
# include "createTime.H" if (Uheader.headerOk())
// 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<endTime; i++)
{ {
runTime.setTime(Times[i], i); Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
Info<< "Time = " << runTime.timeName() << endl; Info<< " Calculating magGradU" << endl;
volScalarField magGradU
IOobject Uheader
( (
"U", IOobject
runTime.timeName(), (
mesh, "magGradU",
IOobject::MUST_READ runTime.timeName(),
mesh,
IOobject::NO_READ
),
mag(fvc::grad(U))
); );
// Check U exists Info<< "magGrad(U) max/min : "
if (Uheader.headerOk()) << max(magGradU).value() << " "
<< min(magGradU).value() << endl;
if (writeResults)
{ {
mesh.readUpdate();
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
Info<< " Calculating magGradU" << endl;
volScalarField magGradU
(
IOobject
(
"magGradU",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
mag(fvc::grad(U))
);
magGradU.write(); magGradU.write();
} }
else
{
Info<< " No U" << endl;
}
} }
else
return(0); {
Info<< " No U" << endl;
}
} }

View File

@ -1,27 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
// magU tool definition
description "Magnitude of U components";
magUDict
{
type dictionary;
description "magU control dictionary";
dictionaryPath "system";
entries
{
arguments
{
type rootCaseTimeArguments;
}
}
}
// ************************************************************************* //

View File

@ -1,3 +0,0 @@
magU.C
EXE = $(FOAM_APPBIN)/magU

View File

@ -1,110 +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
magU
Description
Calculates and writes the scalar magnitude of the gradient of the velocity
field U for each time
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# 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<endTime; i++)
{
runTime.setTime(Times[i], i);
Info<< "Time = " << runTime.timeName() << endl;
IOobject Uheader
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
// Check U exists
if (Uheader.headerOk())
{
mesh.readUpdate();
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
Info<< " Calculating magU" << endl;
volScalarField magU
(
IOobject
(
"magU",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
mag(U)
);
Info << "mag(U): max: " << max(magU.internalField())
<< " min: " << min(magU.internalField()) << endl;
magU.write();
}
else
{
Info<< " No U" << endl;
}
Info<< endl;
}
Info<< "End\n" << endl;
return(0);
}
// ************************************************************************* //

View File

@ -1,6 +1,7 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SRC)/postProcessing/postCalc \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ $(FOAM_LIBBIN)/postCalc.o \
-lfiniteVolume

View File

@ -26,80 +26,60 @@ Application
uprime uprime
Description Description
Calculates and writes the scalar field of uprime (sqrt(2/3 k)) at Calculates and writes the scalar field of uprime (sqrt(2/3 k)).
each time 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" IOobject kheader
# include "setRootCase.H" (
"k",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
# include "createTime.H" if (kheader.headerOk())
// 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<endTime; i++)
{ {
runTime.setTime(Times[i], i); Info<< " Reading k" << endl;
volScalarField k(kheader, mesh);
Info<< "Time = " << runTime.timeName() << endl; Info<< " Calculating uprime" << endl;
volScalarField uprime
IOobject kheader
( (
"k", IOobject
runTime.timeName(), (
mesh, "uprime",
IOobject::MUST_READ runTime.timeName(),
mesh,
IOobject::NO_READ
),
sqrt((2.0/3.0)*k)
); );
// Check k exists Info<< "uprime max/min : "
if (kheader.headerOk()) << max(uprime).value() << " "
<< min(uprime).value() << endl;
if (writeResults)
{ {
mesh.readUpdate();
Info<< " Reading k" << endl;
volScalarField k(kheader, mesh);
Info<< " Calculating uprime" << endl;
volScalarField uprime
(
IOobject
(
"uprime",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
sqrt((2.0/3.0)*k)
);
uprime.write(); uprime.write();
} }
else
{
Info<< " No k" << endl;
}
Info<< endl;
} }
else
return(0); {
Info<< " No k" << endl;
}
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,6 +1,7 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SRC)/postProcessing/postCalc \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ $(FOAM_LIBBIN)/postCalc.o \
-lfiniteVolume

View File

@ -26,91 +26,73 @@ Application
vorticity vorticity
Description Description
Calculates and writes the vorticity of velocity field U at each time Calculates and writes the vorticity of velocity field U.
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" IOobject Uheader
# include "setRootCase.H" (
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
# include "createTime.H" if (Uheader.headerOk())
// 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<endTime; i++)
{ {
runTime.setTime(Times[i], i); Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
Info<< "Time = " << runTime.timeName() << endl; Info<< " Calculating vorticity" << endl;
volVectorField vorticity
IOobject Uheader
( (
"U", IOobject
runTime.timeName(), (
mesh, "vorticity",
IOobject::MUST_READ runTime.timeName(),
mesh,
IOobject::NO_READ
),
fvc::curl(U)
); );
// Check U exists volScalarField magVorticity
if (Uheader.headerOk()) (
IOobject
(
"magVorticity",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
mag(vorticity)
);
Info<< "vorticity max/min : "
<< max(magVorticity).value() << " "
<< min(magVorticity).value() << endl;
if (writeResults)
{ {
mesh.readUpdate();
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
Info<< " Calculating vorticity" << endl;
volVectorField vorticity
(
IOobject
(
"vorticity",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
fvc::curl(U)
);
vorticity.write(); vorticity.write();
Info<< " Calculating vorticity magnitude" << endl;
volScalarField magVorticity
(
IOobject
(
"magVorticity",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
mag(vorticity)
);
magVorticity.write(); magVorticity.write();
} }
else
{
Info<< " No U" << endl;
}
} }
else
return(0); {
Info<< " No U" << endl;
}
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,25 +0,0 @@
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
# include "createPhi.H"
autoPtr<transportModel> laminarTransport
(
transportModel::New(U, phi)
);
autoPtr<turbulenceModel> turbulence
(
turbulenceModel::New(U, phi, laminarTransport())
);

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application Application
wallGradU wallGradU
Description Description
Calculates and writes the gradient of U at the wall Calculates and writes the gradient of U at the wall
@ -33,31 +33,19 @@ Description
#include "fvCFD.H" #include "fvCFD.H"
#include "incompressible/turbulenceModel/turbulenceModel.H" #include "incompressible/turbulenceModel/turbulenceModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
timeSelector::addOptions();
# include "addTimeOptions.H" #include "setRootCase.H"
# include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
// 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" # include "createMesh.H"
for (label i=startTime; i<endTime; i++) forAll(timeDirs, timeI)
{ {
runTime.setTime(Times[i], i); runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl; Info<< "Time = " << runTime.timeName() << endl;
IOobject Uheader IOobject Uheader
@ -113,7 +101,7 @@ int main(int argc, char *argv[])
Info<< "End" << endl; Info<< "End" << endl;
return(0); return 0;
} }

View File

@ -41,32 +41,21 @@ Description
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
timeSelector::addOptions();
# include "addTimeOptions.H" #include "setRootCase.H"
# include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
// 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" # include "createMesh.H"
for (label i=startTime; i<endTime; i++) forAll(timeDirs, timeI)
{ {
runTime.setTime(Times[i], i); runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl; Info<< "Time = " << runTime.timeName() << endl;
mesh.readUpdate(); mesh.readUpdate();
# include "createFields.H" # include "createFields.H"
surfaceScalarField heatFlux = surfaceScalarField heatFlux =
fvc::interpolate(turbulence->alphaEff())*fvc::snGrad(h); fvc::interpolate(turbulence->alphaEff())*fvc::snGrad(h);
const surfaceScalarField::GeometricBoundaryField& patchHeatFlux = const surfaceScalarField::GeometricBoundaryField& patchHeatFlux =
@ -83,7 +72,7 @@ int main(int argc, char *argv[])
( (
mesh.magSf().boundaryField()[patchi] mesh.magSf().boundaryField()[patchi]
*patchHeatFlux[patchi] *patchHeatFlux[patchi]
) )
<< endl; << endl;
} }
} }
@ -111,8 +100,7 @@ int main(int argc, char *argv[])
Info<< "End" << endl; Info<< "End" << endl;
return(0); return 0;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -26,8 +26,7 @@ Application
wallShearStress wallShearStress
Description Description
Calculates and writes the wall shear stress for the current Calculates and writes the wall shear stress, for the specified times.
time step.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -35,33 +34,20 @@ Description
#include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H" #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
#include "incompressible/turbulenceModel/turbulenceModel.H" #include "incompressible/turbulenceModel/turbulenceModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
timeSelector::addOptions();
# include "addTimeOptions.H" #include "setRootCase.H"
# include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
// 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" # include "createMesh.H"
for (label i=startTime; i<endTime; i++) forAll(timeDirs, timeI)
{ {
runTime.setTime(Times[i], i); runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl; Info<< "Time = " << runTime.timeName() << endl;
mesh.readUpdate(); mesh.readUpdate();
# include "createFields.H" # include "createFields.H"
@ -101,7 +87,7 @@ int main(int argc, char *argv[])
Info<< "End" << endl; Info<< "End" << endl;
return(0); return 0;
} }

View File

@ -26,7 +26,7 @@ Application
yPlusLES yPlusLES
Description Description
Calculates and reports yPlus for all wall patches, for each time. Calculates and reports yPlus for all wall patches, for the specified times.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -39,27 +39,16 @@ Description
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#include "addTimeOptions.H" timeSelector::addOptions();
#include "setRootCase.H" #include "setRootCase.H"
# include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H"
#include "createTime.H" forAll(timeDirs, timeI)
// 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<endTime; i++)
{ {
runTime.setTime(Times[i], i); runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl; Info<< "Time = " << runTime.timeName() << endl;
mesh.readUpdate(); mesh.readUpdate();
volScalarField yPlus volScalarField yPlus
@ -90,7 +79,7 @@ int main(int argc, char *argv[])
mesh mesh
); );
#include "createPhi.H" # include "createPhi.H"
singlePhaseTransportModel laminarTransport(U, phi); singlePhaseTransportModel laminarTransport(U, phi);
@ -121,8 +110,8 @@ int main(int argc, char *argv[])
Info<< "Patch " << patchi Info<< "Patch " << patchi
<< " named " << currPatch.name() << " named " << currPatch.name()
<< " y+ : min: " << min(Yp) << " max: " << max(Yp) << " y+ : min: " << min(yPlus) << " max: " << max(yPlus)
<< " average: " << average(Yp) << nl << endl; << " average: " << average(yPlus) << nl << endl;
} }
} }
@ -131,7 +120,7 @@ int main(int argc, char *argv[])
Info<< "End\n" << endl; Info<< "End\n" << endl;
return(0); return 0;
} }

View File

@ -1,3 +1,3 @@
checkYPlus.C yPlusRAS.C
EXE = $(FOAM_APPBIN)/checkYPlus EXE = $(FOAM_APPBIN)/yPlusRAS

View File

@ -26,7 +26,7 @@ Application
yPlusRAS yPlusRAS
Description Description
Calculates and reports yPlus for all wall patches, for each time. Calculates and reports yPlus for all wall patches, for the specified times.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -39,27 +39,16 @@ Description
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#include "addTimeOptions.H" timeSelector::addOptions();
#include "setRootCase.H" #include "setRootCase.H"
# include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H"
#include "createTime.H" forAll(timeDirs, timeI)
// 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<endTime; i++)
{ {
runTime.setTime(Times[i], i); runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl; Info<< "Time = " << runTime.timeName() << endl;
mesh.readUpdate(); mesh.readUpdate();
volScalarField yPlus volScalarField yPlus
@ -90,7 +79,7 @@ int main(int argc, char *argv[])
mesh mesh
); );
#include "createPhi.H" # include "createPhi.H"
singlePhaseTransportModel laminarTransport(U, phi); singlePhaseTransportModel laminarTransport(U, phi);
@ -122,8 +111,7 @@ int main(int argc, char *argv[])
Info<< "End\n" << endl; Info<< "End\n" << endl;
return(0); return 0;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -23,10 +23,10 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application Application
divPhi postCalc
Description Description
Calculates and writes the divergence of phi U at each time Generic wrapper for calculating a quantity at each time
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -66,9 +66,9 @@ int main(int argc, char *argv[])
Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
# include "createMesh.H" # include "createMesh.H"
forAll(timeDirs, timei) forAll(timeDirs, timeI)
{ {
runTime.setTime(timeDirs[timei], timei); runTime.setTime(timeDirs[timeI], timeI);
Foam::Info<< "Time = " << runTime.timeName() << Foam::endl; Foam::Info<< "Time = " << runTime.timeName() << Foam::endl;