mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: fieldMinMax FO updated follwing changes to functionObjectFile
Also added 'resultName' to enable user to specify alternative name for output field
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -40,15 +40,15 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::wallShearStress::writeFileHeader(const label i)
|
void Foam::wallShearStress::writeFileHeader(Ostream& os) const
|
||||||
{
|
{
|
||||||
// Add headers to output data
|
// Add headers to output data
|
||||||
writeHeader(file(), "Wall shear stress");
|
writeHeader(os, "Wall shear stress");
|
||||||
writeCommented(file(), "Time");
|
writeCommented(os, "Time");
|
||||||
writeTabbed(file(), "patch");
|
writeTabbed(os, "patch");
|
||||||
writeTabbed(file(), "min");
|
writeTabbed(os, "min");
|
||||||
writeTabbed(file(), "max");
|
writeTabbed(os, "max");
|
||||||
file() << endl;
|
os << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -74,17 +74,17 @@ void Foam::wallShearStress::calcShearStress
|
|||||||
vector minSsp = gMin(ssp);
|
vector minSsp = gMin(ssp);
|
||||||
vector maxSsp = gMax(ssp);
|
vector maxSsp = gMax(ssp);
|
||||||
|
|
||||||
if (Pstream::master())
|
file() << mesh.time().value()
|
||||||
{
|
<< token::TAB << pp.name()
|
||||||
file() << mesh.time().value()
|
<< token::TAB << minSsp
|
||||||
<< token::TAB << pp.name()
|
<< token::TAB << maxSsp
|
||||||
<< token::TAB << minSsp
|
<< endl;
|
||||||
<< token::TAB << maxSsp
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (log_) Info<< " min/max(" << pp.name() << ") = "
|
if (log_)
|
||||||
<< minSsp << ", " << maxSsp << endl;
|
{
|
||||||
|
Info<< " min/max(" << pp.name() << ") = "
|
||||||
|
<< minSsp << ", " << maxSsp << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,10 +99,11 @@ Foam::wallShearStress::wallShearStress
|
|||||||
const bool loadFromFiles
|
const bool loadFromFiles
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
functionObjectFile(obr, name, typeName),
|
functionObjectFile(obr, name, typeName, dict),
|
||||||
name_(name),
|
name_(name),
|
||||||
obr_(obr),
|
obr_(obr),
|
||||||
active_(true),
|
active_(true),
|
||||||
|
resultName_(name),
|
||||||
log_(true),
|
log_(true),
|
||||||
patchSet_()
|
patchSet_()
|
||||||
{
|
{
|
||||||
@ -123,6 +124,8 @@ Foam::wallShearStress::wallShearStress
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
read(dict);
|
||||||
|
|
||||||
if (active_)
|
if (active_)
|
||||||
{
|
{
|
||||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||||
@ -133,7 +136,7 @@ Foam::wallShearStress::wallShearStress
|
|||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
type(),
|
resultName_,
|
||||||
mesh.time().timeName(),
|
mesh.time().timeName(),
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
@ -150,9 +153,9 @@ Foam::wallShearStress::wallShearStress
|
|||||||
);
|
);
|
||||||
|
|
||||||
mesh.objectRegistry::store(wallShearStressPtr);
|
mesh.objectRegistry::store(wallShearStressPtr);
|
||||||
}
|
|
||||||
|
|
||||||
read(dict);
|
writeFileHeader(file());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -168,7 +171,10 @@ void Foam::wallShearStress::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (active_)
|
if (active_)
|
||||||
{
|
{
|
||||||
log_ = dict.lookupOrDefault<Switch>("log", true);
|
functionObjectFile::read(dict);
|
||||||
|
|
||||||
|
log_.readIfPresent("log", dict);
|
||||||
|
dict.readIfPresent("resultName", resultName_);
|
||||||
|
|
||||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||||
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
|
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
|
||||||
@ -179,7 +185,7 @@ void Foam::wallShearStress::read(const dictionary& dict)
|
|||||||
wordReList(dict.lookupOrDefault("patches", wordReList()))
|
wordReList(dict.lookupOrDefault("patches", wordReList()))
|
||||||
);
|
);
|
||||||
|
|
||||||
Info<< type() << " " << name_ << ":" << nl;
|
if (log_) Info << type() << " " << name_ << " output:" << nl;
|
||||||
|
|
||||||
if (patchSet_.empty())
|
if (patchSet_.empty())
|
||||||
{
|
{
|
||||||
@ -191,11 +197,11 @@ void Foam::wallShearStress::read(const dictionary& dict)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< " processing all wall patches" << nl << endl;
|
if (log_) Info << " processing all wall patches" << nl << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info<< " processing wall patches: " << nl;
|
if (log_) Info << " processing wall patches: " << nl;
|
||||||
labelHashSet filteredPatchSet;
|
labelHashSet filteredPatchSet;
|
||||||
forAllConstIter(labelHashSet, patchSet_, iter)
|
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||||
{
|
{
|
||||||
@ -203,7 +209,7 @@ void Foam::wallShearStress::read(const dictionary& dict)
|
|||||||
if (isA<wallPolyPatch>(pbm[patchI]))
|
if (isA<wallPolyPatch>(pbm[patchI]))
|
||||||
{
|
{
|
||||||
filteredPatchSet.insert(patchI);
|
filteredPatchSet.insert(patchI);
|
||||||
Info<< " " << pbm[patchI].name() << endl;
|
if (log_) Info << " " << pbm[patchI].name() << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -213,7 +219,7 @@ void Foam::wallShearStress::read(const dictionary& dict)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< endl;
|
if (log_) Info << endl;
|
||||||
|
|
||||||
patchSet_ = filteredPatchSet;
|
patchSet_ = filteredPatchSet;
|
||||||
}
|
}
|
||||||
@ -228,17 +234,15 @@ void Foam::wallShearStress::execute()
|
|||||||
|
|
||||||
if (active_)
|
if (active_)
|
||||||
{
|
{
|
||||||
functionObjectFile::write();
|
|
||||||
|
|
||||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||||
|
|
||||||
volVectorField& wallShearStress =
|
volVectorField& wallShearStress =
|
||||||
const_cast<volVectorField&>
|
const_cast<volVectorField&>
|
||||||
(
|
(
|
||||||
mesh.lookupObject<volVectorField>(type())
|
mesh.lookupObject<volVectorField>(resultName_)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (log_) Info<< type() << " " << name_ << " output:" << nl;
|
if (log_) Info << type() << " " << name_ << " output:" << nl;
|
||||||
|
|
||||||
|
|
||||||
tmp<volSymmTensorField> Reff;
|
tmp<volSymmTensorField> Reff;
|
||||||
@ -258,12 +262,14 @@ void Foam::wallShearStress::execute()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FatalErrorIn("void Foam::wallShearStress::execute()")
|
FatalErrorIn("void Foam::wallShearStress::write()")
|
||||||
<< "Unable to find turbulence model in the "
|
<< "Unable to find turbulence model in the "
|
||||||
<< "database" << exit(FatalError);
|
<< "database" << exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
calcShearStress(mesh, Reff(), wallShearStress);
|
calcShearStress(mesh, Reff(), wallShearStress);
|
||||||
|
|
||||||
|
if (log_) Info << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,14 +293,15 @@ void Foam::wallShearStress::write()
|
|||||||
{
|
{
|
||||||
if (active_)
|
if (active_)
|
||||||
{
|
{
|
||||||
functionObjectFile::write();
|
|
||||||
|
|
||||||
const volVectorField& wallShearStress =
|
const volVectorField& wallShearStress =
|
||||||
obr_.lookupObject<volVectorField>(type());
|
obr_.lookupObject<volVectorField>(resultName_);
|
||||||
|
|
||||||
if (log_) Info<< type() << " " << name_ << " output:" << nl
|
if (log_)
|
||||||
<< " writing field " << wallShearStress.name() << nl
|
{
|
||||||
<< endl;
|
Info<< type() << " " << name_ << " output:" << nl
|
||||||
|
<< " writing field " << wallShearStress.name() << nl
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
wallShearStress.write();
|
wallShearStress.write();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -59,9 +59,11 @@ Description
|
|||||||
|
|
||||||
\heading Function object usage
|
\heading Function object usage
|
||||||
\table
|
\table
|
||||||
Property | Description | Required | Default value
|
Property | Description | Required | Default value
|
||||||
type | type name: wallShearStress | yes |
|
type | type name: wallShearStress | yes |
|
||||||
|
resultName | Name of wall shear stress field | no | <function name>
|
||||||
patches | list of patches to process | no | all wall patches
|
patches | list of patches to process | no | all wall patches
|
||||||
|
log | Log to standard output | no | yes
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
@ -105,11 +107,15 @@ protected:
|
|||||||
//- Name of this set of wallShearStress object
|
//- Name of this set of wallShearStress object
|
||||||
word name_;
|
word name_;
|
||||||
|
|
||||||
|
//- Refefence to the database
|
||||||
const objectRegistry& obr_;
|
const objectRegistry& obr_;
|
||||||
|
|
||||||
//- on/off switch
|
//- on/off switch
|
||||||
bool active_;
|
bool active_;
|
||||||
|
|
||||||
|
//- Result name
|
||||||
|
word resultName_;
|
||||||
|
|
||||||
//- Switch to send output to Info as well as to file
|
//- Switch to send output to Info as well as to file
|
||||||
Switch log_;
|
Switch log_;
|
||||||
|
|
||||||
@ -120,7 +126,7 @@ protected:
|
|||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
//- File header information
|
//- File header information
|
||||||
virtual void writeFileHeader(const label i);
|
virtual void writeFileHeader(Ostream& os) const;
|
||||||
|
|
||||||
//- Calculate the shear stress
|
//- Calculate the shear stress
|
||||||
void calcShearStress
|
void calcShearStress
|
||||||
|
|||||||
Reference in New Issue
Block a user