Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
mattijs
2012-11-22 13:05:42 +00:00
7 changed files with 196 additions and 65 deletions

View File

@ -74,6 +74,7 @@ cleanCase()
cleanDynamicCode
rm -rf processor* > /dev/null 2>&1
rm -rf postProcessing > /dev/null 2>&1
rm -rf probes* > /dev/null 2>&1
rm -rf forces* > /dev/null 2>&1
rm -rf graphs* > /dev/null 2>&1

View File

@ -75,20 +75,23 @@ void Foam::fieldMinMax::calcMinMaxFields
forAll(magFieldBoundary, patchI)
{
const scalarField& mfp = magFieldBoundary[patchI];
const vectorField& Cfp = CfBoundary[patchI];
label minPI = findMin(mfp);
if (mfp[minPI] < minVs[procI])
if (mfp.size())
{
minVs[procI] = mfp[minPI];
minCs[procI] = Cfp[minPI];
}
const vectorField& Cfp = CfBoundary[patchI];
label maxPI = findMax(mfp);
if (mfp[maxPI] > maxVs[procI])
{
maxVs[procI] = mfp[maxPI];
maxCs[procI] = Cfp[maxPI];
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];
}
}
}
@ -173,20 +176,23 @@ void Foam::fieldMinMax::calcMinMaxFields
forAll(fieldBoundary, patchI)
{
const Field<Type>& fp = fieldBoundary[patchI];
const vectorField& Cfp = CfBoundary[patchI];
label minPI = findMin(fp);
if (fp[minPI] < minVs[procI])
if (fp.size())
{
minVs[procI] = fp[minPI];
minCs[procI] = Cfp[minPI];
}
const vectorField& Cfp = CfBoundary[patchI];
label maxPI = findMax(fp);
if (fp[maxPI] > maxVs[procI])
{
maxVs[procI] = fp[maxPI];
maxCs[procI] = Cfp[maxPI];
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];
}
}
}
@ -250,7 +256,14 @@ void Foam::fieldMinMax::calcMinMaxFields
}
default:
{
FatalErrorIn("Foam::fieldMinMax::calcMinMaxFields(const word&)")
FatalErrorIn
(
"Foam::fieldMinMax::calcMinMaxFields"
"("
"const word&, "
"const modeType&"
")"
)
<< "Unknown min/max mode: " << modeTypeNames_[mode_]
<< exit(FatalError);
}

View File

@ -189,7 +189,7 @@ void Foam::CourantNo::write()
CourantNo.write();
Info<< type() << " output:" << nl
<< " writing " << CourantNo.name() << "field" << nl << endl;
<< " writing " << CourantNo.name() << " field" << nl << endl;
}
}

View File

@ -56,7 +56,7 @@ Foam::word Foam::pressureTools::pName() const
}
Foam::dimensionedScalar Foam::pressureTools::rho
Foam::dimensionedScalar Foam::pressureTools::rhoScale
(
const volScalarField& p
) const
@ -72,6 +72,38 @@ Foam::dimensionedScalar Foam::pressureTools::rho
}
Foam::tmp<Foam::volScalarField> Foam::pressureTools::rho
(
const volScalarField& p
) const
{
if (p.dimensions() == dimPressure)
{
return p.mesh().lookupObject<volScalarField>(rhoName_);
}
else
{
return
tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"rho",
p.mesh().time().timeName(),
p.mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
p.mesh(),
dimensionedScalar("zero", dimDensity, rhoRef_)
)
);
}
}
Foam::dimensionedScalar Foam::pressureTools::pRef() const
{
dimensionedScalar value("pRef", dimPressure, 0.0);
@ -81,11 +113,14 @@ Foam::dimensionedScalar Foam::pressureTools::pRef() const
value.value() += pRef_;
}
return pRef();
return value;
}
Foam::tmp<Foam::volScalarField> Foam::pressureTools::pDyn() const
Foam::tmp<Foam::volScalarField> Foam::pressureTools::pDyn
(
const volScalarField& p
) const
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
@ -110,7 +145,7 @@ Foam::tmp<Foam::volScalarField> Foam::pressureTools::pDyn() const
{
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
tpDyn() == 0.5*magSqr(U);
tpDyn() == rho(p)*0.5*magSqr(U);
}
return tpDyn;
@ -119,14 +154,15 @@ Foam::tmp<Foam::volScalarField> Foam::pressureTools::pDyn() const
Foam::tmp<Foam::volScalarField> Foam::pressureTools::convertToCoeff
(
const volScalarField& p
const volScalarField& pCalculated,
const volScalarField& pIn
) const
{
tmp<volScalarField> tCoeff(p);
tmp<volScalarField> tCoeff(pCalculated);
if (calcCoeff_)
{
tCoeff() /= pDyn();
tCoeff() /= pDyn(pIn) + dimensionedScalar("p0", dimPressure, SMALL);
}
return tCoeff;
@ -150,6 +186,7 @@ Foam::pressureTools::pressureTools
calcCoeff_(false),
pName_("p"),
UName_("U"),
rhoName_("rho"),
pRef_(0.0),
rhoRef_(1.0)
{
@ -188,6 +225,7 @@ void Foam::pressureTools::read(const dictionary& dict)
{
dict.readIfPresent("pName", pName_);
dict.readIfPresent("UName", UName_);
dict.readIfPresent("rhoName", rhoName_);
const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
@ -234,7 +272,7 @@ void Foam::pressureTools::write()
obr_,
IOobject::NO_READ
),
convertToCoeff(rho(p)*(p + pDyn()) + pRef())
convertToCoeff(rhoScale(p)*p + pDyn(p) + pRef(), p)
);
pResult.write();

View File

@ -125,6 +125,9 @@ class pressureTools
//- Name of velocity field, default is "U"
word UName_;
//- Name of density field, default is "rho"
word rhoName_;
//- Reference pressure level (used for total pressure)
scalar pRef_;
@ -138,16 +141,23 @@ class pressureTools
word pName() const;
//- Return the density scaling if supplied with kinematic pressure
dimensionedScalar rho(const volScalarField& p) const;
dimensionedScalar rhoScale(const volScalarField& p) const;
//- Return the density field
tmp<volScalarField> rho(const volScalarField& p) const;
//- Return the reference pressure
dimensionedScalar pRef() const;
//- Calculate and return the (kinematic) dynamic pressure
tmp<volScalarField> pDyn() const;
//- Calculate and return the dynamic pressure
tmp<volScalarField> pDyn(const volScalarField& p) const;
//- Convert to coeff data by applying the pDyn scaling
tmp<volScalarField> convertToCoeff(const volScalarField& p) const;
tmp<volScalarField> convertToCoeff
(
const volScalarField& pCalculated,
const volScalarField& pIn
) const;
//- Disallow default bitwise copy construct
pressureTools(const pressureTools&);

View File

@ -53,34 +53,32 @@ void Foam::wallShearStress::calcShearStress
volVectorField& shearStress
)
{
forAll(shearStress.boundaryField(), patchI)
forAllConstIter(labelHashSet, patchSet_, iter)
{
label patchI = iter.key();
const polyPatch& pp = mesh.boundaryMesh()[patchI];
if (isA<wallPolyPatch>(pp))
vectorField& ssp = shearStress.boundaryField()[patchI];
const vectorField& Sfp = mesh.Sf().boundaryField()[patchI];
const scalarField& magSfp = mesh.magSf().boundaryField()[patchI];
const symmTensorField& Reffp = Reff.boundaryField()[patchI];
ssp = (-Sfp/magSfp) & Reffp;
vector minSsp = gMin(ssp);
vector maxSsp = gMax(ssp);
if (Pstream::master())
{
vectorField& ssp = shearStress.boundaryField()[patchI];
const vectorField& Sfp = mesh.Sf().boundaryField()[patchI];
const scalarField& magSfp = mesh.magSf().boundaryField()[patchI];
const symmTensorField& Reffp = Reff.boundaryField()[patchI];
file() << mesh.time().timeName() << token::TAB
<< pp.name() << token::TAB << minSsp
<< token::TAB << maxSsp << endl;
}
ssp = (-Sfp/magSfp) & Reffp;
vector minSsp = gMin(ssp);
vector maxSsp = gMax(ssp);
if (Pstream::master())
{
file() << mesh.time().timeName() << token::TAB
<< pp.name() << token::TAB << minSsp
<< token::TAB << maxSsp << endl;
}
if (log_)
{
Info<< " min/max(" << pp.name() << ") = "
<< minSsp << ", " << maxSsp << endl;
}
if (log_)
{
Info<< " min/max(" << pp.name() << ") = "
<< minSsp << ", " << maxSsp << endl;
}
}
}
@ -101,7 +99,8 @@ Foam::wallShearStress::wallShearStress
obr_(obr),
active_(true),
log_(false),
phiName_("phi")
phiName_("phi"),
patchSet_()
{
// Check if the available mesh is an fvMesh, otherwise deactivate
if (!isA<fvMesh>(obr_))
@ -138,6 +137,54 @@ void Foam::wallShearStress::read(const dictionary& dict)
{
log_ = dict.lookupOrDefault<Switch>("log", false);
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
const fvMesh& mesh = refCast<const fvMesh>(obr_);
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
patchSet_ =
mesh.boundaryMesh().patchSet
(
wordReList(dict.lookupOrDefault("patches", wordReList()))
);
Info<< type() << " output:" << nl;
if (patchSet_.empty())
{
forAll(pbm, patchI)
{
if (isA<wallPolyPatch>(pbm[patchI]))
{
patchSet_.insert(patchI);
}
}
Info<< " processing all wall patches" << nl << endl;
}
else
{
Info<< " processing wall patches: " << nl;
labelHashSet filteredPatchSet;
forAllConstIter(labelHashSet, patchSet_, iter)
{
label patchI = iter.key();
if (isA<wallPolyPatch>(pbm[patchI]))
{
filteredPatchSet.insert(patchI);
Info<< " " << pbm[patchI].name() << endl;
}
else
{
WarningIn("void wallShearStress::read(const dictionary&)")
<< "Requested wall shear stress on non-wall boundary "
<< "type patch: " << pbm[patchI].name() << endl;
}
}
Info<< endl;
patchSet_ = filteredPatchSet;
}
}
}

View File

@ -36,15 +36,34 @@ Description
Stress = R \dot n
\f]
The shear stress (symmetrical) tensor field is retrieved from the
turbulence model.
where
\vartable
R | stress tensor
n | patch normal vector (into the domain)
\endvartable
The shear stress (symmetrical) tensor field is retrieved from the
turbulence model. All wall patches are included by default; to restrict
the calculation to certain patches, use the optional 'patches' entry.
Example of function object specification:
\verbatim
wallShearStress1
{
type wallShearStress;
functionObjectLibs ("libutilityFunctionObjects.so");
...
patches (".*Wall");
}
\endverbatim
\heading Function object usage
\table
Property | Description | Required | Default value
type | type name: wallShearStress | yes |
patches | list of patches to process | no | all wall patches
\endtable
SourceFiles
wallShearStress.C
IOwallShearStress.H
@ -97,6 +116,9 @@ protected:
//- Name of mass/volume flux field (optional, default = phi)
word phiName_;
//- Optional list of patches to process
labelHashSet patchSet_;
// Protected Member Functions