mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
postProcessing: Replaced 'foamCalc' and the 'postCalc' utilities
with the more general and flexible 'postProcess' utility and '-postProcess' solver option
Rationale
---------
Both the 'postProcess' utility and '-postProcess' solver option use the
same extensive set of functionObjects available for data-processing
during the run avoiding the substantial code duplication necessary for
the 'foamCalc' and 'postCalc' utilities and simplifying maintenance.
Additionally consistency is guaranteed between solver data processing
and post-processing.
The functionObjects have been substantially re-written and generalized
to simplify development and encourage contribution.
Configuration
-------------
An extensive set of simple functionObject configuration files are
provided in
OpenFOAM-dev/etc/caseDicts/postProcessing
and more will be added in the future. These can either be copied into
'<case>/system' directory and included into the 'controlDict.functions'
sub-dictionary or included directly from 'etc/caseDicts/postProcessing'
using the '#includeEtc' directive or the new and more convenient
'#includeFunc' directive which searches the
'<etc>/caseDicts/postProcessing' directories for the selected
functionObject, e.g.
functions
{
#includeFunc Q
#includeFunc Lambda2
}
'#includeFunc' first searches the '<case>/system' directory in case
there is a local configuration.
Description of #includeFunc
---------------------------
Specify a functionObject dictionary file to include, expects the
functionObject name to follow (without quotes).
Search for functionObject dictionary file in
user/group/shipped directories.
The search scheme allows for version-specific and
version-independent files using the following hierarchy:
- \b user settings:
- ~/.OpenFOAM/\<VERSION\>/caseDicts/postProcessing
- ~/.OpenFOAM/caseDicts/postProcessing
- \b group (site) settings (when $WM_PROJECT_SITE is set):
- $WM_PROJECT_SITE/\<VERSION\>/caseDicts/postProcessing
- $WM_PROJECT_SITE/caseDicts/postProcessing
- \b group (site) settings (when $WM_PROJECT_SITE is not set):
- $WM_PROJECT_INST_DIR/site/\<VERSION\>/caseDicts/postProcessing
- $WM_PROJECT_INST_DIR/site/caseDicts/postProcessing
- \b other (shipped) settings:
- $WM_PROJECT_DIR/etc/caseDicts/postProcessing
An example of the \c \#includeFunc directive:
\verbatim
#includeFunc <funcName>
\endverbatim
postProcess
-----------
The 'postProcess' utility and '-postProcess' solver option provide the
same set of controls to execute functionObjects after the run either by
reading a specified set of fields to process in the case of
'postProcess' or by reading all fields and models required to start the
run in the case of '-postProcess' for each selected time:
postProcess -help
Usage: postProcess [OPTIONS]
options:
-case <dir> specify alternate case directory, default is the cwd
-constant include the 'constant/' dir in the times list
-dict <file> read control dictionary from specified location
-field <name> specify the name of the field to be processed, e.g. U
-fields <list> specify a list of fields to be processed, e.g. '(U T p)' -
regular expressions not currently supported
-func <name> specify the name of the functionObject to execute, e.g. Q
-funcs <list> specify the names of the functionObjects to execute, e.g.
'(Q div(U))'
-latestTime select the latest time
-newTimes select the new times
-noFunctionObjects
do not execute functionObjects
-noZero exclude the '0/' dir from the times list, has precedence
over the -withZero option
-parallel run in parallel
-region <name> specify alternative mesh region
-roots <(dir1 .. dirN)>
slave root directories for distributed running
-time <ranges> comma-separated time ranges - eg, ':10,20,40:70,1000:'
-srcDoc display source code in browser
-doc display application documentation in browser
-help print the usage
pimpleFoam -postProcess -help
Usage: pimpleFoam [OPTIONS]
options:
-case <dir> specify alternate case directory, default is the cwd
-constant include the 'constant/' dir in the times list
-dict <file> read control dictionary from specified location
-field <name> specify the name of the field to be processed, e.g. U
-fields <list> specify a list of fields to be processed, e.g. '(U T p)' -
regular expressions not currently supported
-func <name> specify the name of the functionObject to execute, e.g. Q
-funcs <list> specify the names of the functionObjects to execute, e.g.
'(Q div(U))'
-latestTime select the latest time
-newTimes select the new times
-noFunctionObjects
do not execute functionObjects
-noZero exclude the '0/' dir from the times list, has precedence
over the -withZero option
-parallel run in parallel
-postProcess Execute functionObjects only
-region <name> specify alternative mesh region
-roots <(dir1 .. dirN)>
slave root directories for distributed running
-time <ranges> comma-separated time ranges - eg, ':10,20,40:70,1000:'
-srcDoc display source code in browser
-doc display application documentation in browser
-help print the usage
The functionObjects to execute may be specified on the command-line
using the '-func' option for a single functionObject or '-funcs' for a
list, e.g.
postProcess -func Q
postProcess -funcs '(div(U) div(phi))'
In the case of 'Q' the default field to process is 'U' which is
specified in and read from the configuration file but this may be
overridden thus:
postProcess -func 'Q(Ua)'
as is done in the example above to calculate the two forms of the divergence of
the velocity field. Additional fields which the functionObjects may depend on
can be specified using the '-field' or '-fields' options.
The 'postProcess' utility can only be used to execute functionObjects which
process fields present in the time directories. However, functionObjects which
depend on fields obtained from models, e.g. properties derived from turbulence
models can be executed using the '-postProcess' of the appropriate solver, e.g.
pisoFoam -postProcess -func PecletNo
or
sonicFoam -postProcess -func MachNo
In this case all required fields will have already been read so the '-field' or
'-fields' options are not be needed.
Henry G. Weller
CFD Direct Ltd.
This commit is contained in:
75
src/functionObjects/field/fieldMinMax/controlDict
Normal file
75
src/functionObjects/field/fieldMinMax/controlDict
Normal file
@ -0,0 +1,75 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: dev |
|
||||
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object controlDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
application XXX;
|
||||
|
||||
startFrom latestTime;
|
||||
|
||||
startTime 0;
|
||||
|
||||
stopAt endTime;
|
||||
|
||||
endTime 0.1;
|
||||
|
||||
deltaT 1e-05;
|
||||
|
||||
writeControl timeStep;
|
||||
|
||||
writeInterval 10;
|
||||
|
||||
purgeWrite 0;
|
||||
|
||||
writeFormat ascii;
|
||||
|
||||
writePrecision 6;
|
||||
|
||||
writeCompression off;
|
||||
|
||||
timeFormat general;
|
||||
|
||||
timePrecision 6;
|
||||
|
||||
runTimeModifiable true;
|
||||
|
||||
functions
|
||||
{
|
||||
minMax
|
||||
{
|
||||
// Type of functionObject
|
||||
type fieldMinMax;
|
||||
|
||||
// Where to load it from (if not already in solver)
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
|
||||
// Function object enabled flag
|
||||
enabled true;
|
||||
|
||||
// Log to output (default: false)
|
||||
log false;
|
||||
|
||||
// Write information to file (default: true)
|
||||
write true;
|
||||
|
||||
// Fields to be monitored - runTime modifiable
|
||||
fields
|
||||
(
|
||||
U
|
||||
p
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
173
src/functionObjects/field/fieldMinMax/fieldMinMax.C
Normal file
173
src/functionObjects/field/fieldMinMax/fieldMinMax.C
Normal file
@ -0,0 +1,173 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldMinMax.H"
|
||||
#include "fieldTypes.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(fieldMinMax, 0);
|
||||
addToRunTimeSelectionTable(functionObject, fieldMinMax, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldMinMax::modeType,
|
||||
2
|
||||
>::names[] = {"magnitude", "component"};
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldMinMax::modeType,
|
||||
2
|
||||
> Foam::functionObjects::fieldMinMax::modeTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::fieldMinMax::writeFileHeader(const label i)
|
||||
{
|
||||
OFstream& file = this->file();
|
||||
|
||||
writeHeader(file, "Field minima and maxima");
|
||||
writeCommented(file, "Time");
|
||||
|
||||
if (location_)
|
||||
{
|
||||
writeTabbed(file, "field");
|
||||
|
||||
writeTabbed(file, "min");
|
||||
writeTabbed(file, "location(min)");
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
writeTabbed(file, "processor");
|
||||
}
|
||||
|
||||
writeTabbed(file, "max");
|
||||
writeTabbed(file, "location(max)");
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
writeTabbed(file, "processor");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(fieldSet_, fieldi)
|
||||
{
|
||||
writeTabbed(file, "min(" + fieldSet_[fieldi] + ')');
|
||||
writeTabbed(file, "max(" + fieldSet_[fieldi] + ')');
|
||||
}
|
||||
}
|
||||
|
||||
file<< endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldMinMax::fieldMinMax
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
writeFiles(name, runTime, dict, name),
|
||||
location_(true),
|
||||
mode_(mdMag),
|
||||
fieldSet_()
|
||||
{
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
resetName(typeName);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldMinMax::~fieldMinMax()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
|
||||
{
|
||||
writeFiles::read(dict);
|
||||
|
||||
location_ = dict.lookupOrDefault<Switch>("location", true);
|
||||
|
||||
mode_ = modeTypeNames_[dict.lookupOrDefault<word>("mode", "magnitude")];
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldMinMax::execute(const bool postProcess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldMinMax::write(const bool postProcess)
|
||||
{
|
||||
writeFiles::write();
|
||||
|
||||
if (!location_) writeTime(file());
|
||||
Log << type() << " " << name() << " output:" << nl;
|
||||
|
||||
forAll(fieldSet_, fieldi)
|
||||
{
|
||||
calcMinMaxFields<scalar>(fieldSet_[fieldi], mdCmpt);
|
||||
calcMinMaxFields<vector>(fieldSet_[fieldi], mode_);
|
||||
calcMinMaxFields<sphericalTensor>(fieldSet_[fieldi], mode_);
|
||||
calcMinMaxFields<symmTensor>(fieldSet_[fieldi], mode_);
|
||||
calcMinMaxFields<tensor>(fieldSet_[fieldi], mode_);
|
||||
}
|
||||
|
||||
if (!location_) file()<< endl;
|
||||
Log << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
206
src/functionObjects/field/fieldMinMax/fieldMinMax.H
Normal file
206
src/functionObjects/field/fieldMinMax/fieldMinMax.H
Normal file
@ -0,0 +1,206 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::fieldMinMax
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
This function object calculates the value and location of scalar minimim
|
||||
and maximum for a list of user-specified fields. For variables with a rank
|
||||
greater than zero, either the min/max of a component value or the magnitude
|
||||
is reported. When operating in parallel, the processor owning the value
|
||||
is also given.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
fieldMinMax1
|
||||
{
|
||||
type fieldMinMax;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
write yes;
|
||||
log yes;
|
||||
location yes;
|
||||
mode magnitude;
|
||||
fields
|
||||
(
|
||||
U
|
||||
p
|
||||
);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: fieldMinMax | yes |
|
||||
write | write min/max data to file | no | yes
|
||||
log | write min/max data to standard output | no | no
|
||||
location | write location of the min/max value | no | yes
|
||||
mode | calculation mode: magnitude or component | no | magnitude
|
||||
\endtable
|
||||
|
||||
Output data is written to the file \<timeDir\>/fieldMinMax.dat
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::writeFiles
|
||||
|
||||
SourceFiles
|
||||
fieldMinMax.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_fieldMinMax_H
|
||||
#define functionObjects_fieldMinMax_H
|
||||
|
||||
#include "writeFiles.H"
|
||||
#include "vector.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fieldMinMax Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldMinMax
|
||||
:
|
||||
public writeFiles
|
||||
{
|
||||
public:
|
||||
|
||||
enum modeType
|
||||
{
|
||||
mdMag,
|
||||
mdCmpt
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Mode type names
|
||||
static const NamedEnum<modeType, 2> modeTypeNames_;
|
||||
|
||||
//- Switch to write location of min/max values
|
||||
Switch location_;
|
||||
|
||||
//- Mode for min/max - only applicable for ranks > 0
|
||||
modeType mode_;
|
||||
|
||||
//- Fields to assess min/max
|
||||
wordList fieldSet_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Helper function to write the output
|
||||
template<class Type>
|
||||
void output
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& outputName,
|
||||
const vector& minC,
|
||||
const vector& maxC,
|
||||
const label minProci,
|
||||
const label maxProci,
|
||||
const Type& minValue,
|
||||
const Type& maxValue
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
fieldMinMax(const fieldMinMax&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const fieldMinMax&);
|
||||
|
||||
//- Calculate the field min/max
|
||||
template<class Type>
|
||||
void calcMinMaxFields
|
||||
(
|
||||
const word& fieldName,
|
||||
const modeType& mode
|
||||
);
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fieldMinMax");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
fieldMinMax
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fieldMinMax();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the field min/max data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
|
||||
//- Write the fieldMinMax
|
||||
virtual bool write(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "fieldMinMaxTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
276
src/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C
Normal file
276
src/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C
Normal file
@ -0,0 +1,276 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldMinMax.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldMinMax::output
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& outputName,
|
||||
const vector& minC,
|
||||
const vector& maxC,
|
||||
const label minProci,
|
||||
const label maxProci,
|
||||
const Type& minValue,
|
||||
const Type& maxValue
|
||||
)
|
||||
{
|
||||
OFstream& file = this->file();
|
||||
|
||||
if (location_)
|
||||
{
|
||||
writeTime(file());
|
||||
|
||||
writeTabbed(file, fieldName);
|
||||
|
||||
file<< token::TAB << minValue
|
||||
<< token::TAB << minC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
file<< token::TAB << minProci;
|
||||
}
|
||||
|
||||
file<< token::TAB << maxValue
|
||||
<< token::TAB << maxC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
file<< token::TAB << maxProci;
|
||||
}
|
||||
|
||||
file<< endl;
|
||||
|
||||
Log << " min(" << outputName << ") = " << minValue
|
||||
<< " at location " << minC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
Log << " on processor " << minProci;
|
||||
}
|
||||
|
||||
Log << nl << " max(" << outputName << ") = " << maxValue
|
||||
<< " at location " << maxC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
Log << " on processor " << maxProci;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
file<< token::TAB << minValue << token::TAB << maxValue;
|
||||
|
||||
Log << " min/max(" << outputName << ") = "
|
||||
<< minValue << ' ' << maxValue;
|
||||
}
|
||||
|
||||
Log << endl;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldMinMax::calcMinMaxFields
|
||||
(
|
||||
const word& fieldName,
|
||||
const modeType& mode
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
if (obr_.foundObject<fieldType>(fieldName))
|
||||
{
|
||||
const label proci = Pstream::myProcNo();
|
||||
|
||||
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
|
||||
const fvMesh& mesh = field.mesh();
|
||||
|
||||
const volVectorField::Boundary& CfBoundary =
|
||||
mesh.C().boundaryField();
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case mdMag:
|
||||
{
|
||||
const volScalarField magField(mag(field));
|
||||
const volScalarField::Boundary& magFieldBoundary =
|
||||
magField.boundaryField();
|
||||
|
||||
scalarList minVs(Pstream::nProcs());
|
||||
List<vector> minCs(Pstream::nProcs());
|
||||
label minProci = findMin(magField);
|
||||
minVs[proci] = magField[minProci];
|
||||
minCs[proci] = field.mesh().C()[minProci];
|
||||
|
||||
|
||||
labelList maxIs(Pstream::nProcs());
|
||||
scalarList maxVs(Pstream::nProcs());
|
||||
List<vector> maxCs(Pstream::nProcs());
|
||||
label maxProci = findMax(magField);
|
||||
maxVs[proci] = magField[maxProci];
|
||||
maxCs[proci] = field.mesh().C()[maxProci];
|
||||
|
||||
forAll(magFieldBoundary, patchi)
|
||||
{
|
||||
const scalarField& mfp = magFieldBoundary[patchi];
|
||||
if (mfp.size())
|
||||
{
|
||||
const vectorField& Cfp = CfBoundary[patchi];
|
||||
|
||||
label minPI = findMin(mfp);
|
||||
if (mfp[minPI] < minVs[proci])
|
||||
{
|
||||
minVs[proci] = mfp[minPI];
|
||||
minCs[proci] = Cfp[minPI];
|
||||
}
|
||||
|
||||
label maxPI = findMax(mfp);
|
||||
if (mfp[maxPI] > maxVs[proci])
|
||||
{
|
||||
maxVs[proci] = mfp[maxPI];
|
||||
maxCs[proci] = Cfp[maxPI];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::gatherList(minVs);
|
||||
Pstream::gatherList(minCs);
|
||||
|
||||
Pstream::gatherList(maxVs);
|
||||
Pstream::gatherList(maxCs);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
label minI = findMin(minVs);
|
||||
scalar minValue = minVs[minI];
|
||||
const vector& minC = minCs[minI];
|
||||
|
||||
label maxI = findMax(maxVs);
|
||||
scalar maxValue = maxVs[maxI];
|
||||
const vector& maxC = maxCs[maxI];
|
||||
|
||||
output
|
||||
(
|
||||
fieldName,
|
||||
word("mag(" + fieldName + ")"),
|
||||
minC,
|
||||
maxC,
|
||||
minI,
|
||||
maxI,
|
||||
minValue,
|
||||
maxValue
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case mdCmpt:
|
||||
{
|
||||
const typename fieldType::Boundary&
|
||||
fieldBoundary = field.boundaryField();
|
||||
|
||||
List<Type> minVs(Pstream::nProcs());
|
||||
List<vector> minCs(Pstream::nProcs());
|
||||
label minProci = findMin(field);
|
||||
minVs[proci] = field[minProci];
|
||||
minCs[proci] = field.mesh().C()[minProci];
|
||||
|
||||
Pstream::gatherList(minVs);
|
||||
Pstream::gatherList(minCs);
|
||||
|
||||
List<Type> maxVs(Pstream::nProcs());
|
||||
List<vector> maxCs(Pstream::nProcs());
|
||||
label maxProci = findMax(field);
|
||||
maxVs[proci] = field[maxProci];
|
||||
maxCs[proci] = field.mesh().C()[maxProci];
|
||||
|
||||
forAll(fieldBoundary, patchi)
|
||||
{
|
||||
const Field<Type>& fp = fieldBoundary[patchi];
|
||||
if (fp.size())
|
||||
{
|
||||
const vectorField& Cfp = CfBoundary[patchi];
|
||||
|
||||
label minPI = findMin(fp);
|
||||
if (fp[minPI] < minVs[proci])
|
||||
{
|
||||
minVs[proci] = fp[minPI];
|
||||
minCs[proci] = Cfp[minPI];
|
||||
}
|
||||
|
||||
label maxPI = findMax(fp);
|
||||
if (fp[maxPI] > maxVs[proci])
|
||||
{
|
||||
maxVs[proci] = fp[maxPI];
|
||||
maxCs[proci] = Cfp[maxPI];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::gatherList(minVs);
|
||||
Pstream::gatherList(minCs);
|
||||
|
||||
Pstream::gatherList(maxVs);
|
||||
Pstream::gatherList(maxCs);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
label minI = findMin(minVs);
|
||||
Type minValue = minVs[minI];
|
||||
const vector& minC = minCs[minI];
|
||||
|
||||
label maxI = findMax(maxVs);
|
||||
Type maxValue = maxVs[maxI];
|
||||
const vector& maxC = maxCs[maxI];
|
||||
|
||||
output
|
||||
(
|
||||
fieldName,
|
||||
fieldName,
|
||||
minC,
|
||||
maxC,
|
||||
minI,
|
||||
maxI,
|
||||
minValue,
|
||||
maxValue
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown min/max mode: " << modeTypeNames_[mode_]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user