Merge branch 'master' into dsmc

This commit is contained in:
graham
2009-08-19 09:53:17 +01:00
796 changed files with 41921 additions and 7409 deletions

View File

@ -7,5 +7,6 @@ wmake libso forces
wmake libso IO
wmake libso utilities
wmake libso systemCall
wmake libso zones
# ----------------------------------------------------------------- end-of-file

View File

@ -120,6 +120,7 @@ protected:
//- Prime-squared average
static const word EXT_PRIME2MEAN;
// Private data
//- Name of this set of field averages.
@ -144,6 +145,7 @@ protected:
// calculated and output
List<fieldAverageItem> faItems_;
// Lists of averages
// Arithmetic mean fields
@ -220,7 +222,7 @@ protected:
) const;
// IO
// I-O
//- Write averages
virtual void writeAverages() const;
@ -272,8 +274,7 @@ public:
//- Destructor
virtual ~fieldAverage();
virtual ~fieldAverage();
// Member Functions

View File

@ -116,9 +116,8 @@ public:
fieldAverageItem(const fieldAverageItem&);
// Destructor
~fieldAverageItem();
//- Destructor
~fieldAverageItem();
// Member Functions
@ -166,6 +165,7 @@ public:
void operator=(const fieldAverageItem&);
// Friend Operators
friend bool operator==
@ -190,6 +190,7 @@ public:
return !(a == b);
}
// IOstream Operators
friend Istream& operator>>(Istream&, fieldAverageItem&);

View File

@ -197,13 +197,13 @@ void Foam::fieldMinMax::calcMinMaxFields<Foam::scalar>
{
if (obr_.foundObject<volScalarField>(fieldName))
{
const volScalarField& field =
obr_.lookupObject<volScalarField>(fieldName);
scalar minValue = min(field).value();
scalar maxValue = max(field).value();
if (Pstream::master())
{
const volScalarField& field =
obr_.lookupObject<volScalarField>(fieldName);
scalar minValue = min(field).value();
scalar maxValue = max(field).value();
fieldMinMaxFilePtr_() << obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue << endl;

View File

@ -140,9 +140,8 @@ public:
);
// Destructor
virtual ~fieldMinMax();
//- Destructor
virtual ~fieldMinMax();
// Member Functions

View File

@ -38,16 +38,16 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
if (obr_.foundObject<fieldType>(fieldName))
{
if (Pstream::master())
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
switch (mode_)
{
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
switch (mode_)
case mdMag:
{
case mdMag:
{
scalar minValue = min(mag(field)).value();
scalar maxValue = max(mag(field)).value();
scalar minValue = min(mag(field)).value();
scalar maxValue = max(mag(field)).value();
if (Pstream::master())
{
fieldMinMaxFilePtr_() << obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue
<< endl;
@ -61,13 +61,16 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
<< maxValue << nl
<< endl;
}
break;
}
case mdCmpt:
{
Type minValue = min(field).value();
Type maxValue = max(field).value();
break;
}
case mdCmpt:
{
Type minValue = min(field).value();
Type maxValue = max(field).value();
if (Pstream::master())
{
fieldMinMaxFilePtr_() << obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue
<< endl;
@ -81,17 +84,17 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
<< maxValue << nl
<< endl;
}
break;
}
default:
{
FatalErrorIn
(
"Foam::fieldMinMax::calcMinMaxFields"
"(const word& fieldName)"
)<< "Unknown min/max mode: " << modeTypeNames_[mode_]
<< exit(FatalError);
}
break;
}
default:
{
FatalErrorIn
(
"Foam::fieldMinMax::calcMinMaxFields"
"(const word& fieldName)"
)<< "Unknown min/max mode: " << modeTypeNames_[mode_]
<< exit(FatalError);
}
}
}

View File

@ -116,9 +116,8 @@ public:
);
// Destructor
virtual ~forceCoeffs();
//- Destructor
virtual ~forceCoeffs();
// Member Functions

View File

@ -61,7 +61,7 @@ Foam::tmp<Foam::volSymmTensorField> Foam::forces::devRhoReff() const
const incompressible::RASModel& ras
= obr_.lookupObject<incompressible::RASModel>("RASProperties");
return rhoRef_*ras.devReff();
return rho()*ras.devReff();
}
else if (obr_.foundObject<compressible::LESModel>("LESProperties"))
{
@ -75,7 +75,7 @@ Foam::tmp<Foam::volSymmTensorField> Foam::forces::devRhoReff() const
const incompressible::LESModel& les
= obr_.lookupObject<incompressible::LESModel>("LESProperties");
return rhoRef_*les.devBeff();
return rho()*les.devBeff();
}
else if (obr_.foundObject<basicThermo>("thermophysicalProperties"))
{
@ -97,7 +97,7 @@ Foam::tmp<Foam::volSymmTensorField> Foam::forces::devRhoReff() const
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
return -rhoRef_*laminarT.nu()*dev(twoSymm(fvc::grad(U)));
return -rho()*laminarT.nu()*dev(twoSymm(fvc::grad(U)));
}
else if (obr_.foundObject<dictionary>("transportProperties"))
{
@ -108,7 +108,7 @@ Foam::tmp<Foam::volSymmTensorField> Foam::forces::devRhoReff() const
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
return -rhoRef_*nu*dev(twoSymm(fvc::grad(U)));
return -rho()*nu*dev(twoSymm(fvc::grad(U)));
}
else
{
@ -121,6 +121,34 @@ Foam::tmp<Foam::volSymmTensorField> Foam::forces::devRhoReff() const
}
Foam::tmp<Foam::volScalarField> Foam::forces::rho() const
{
if (rhoName_ == "rhoInf")
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"rho",
mesh.time().timeName(),
mesh
),
mesh,
dimensionedScalar("rho", dimDensity, rhoRef_)
)
);
}
else
{
return(obr_.lookupObject<volScalarField>(rhoName_));
}
}
Foam::scalar Foam::forces::rho(const volScalarField& p) const
{
if (p.dimensions() == dimPressure)
@ -129,6 +157,13 @@ Foam::scalar Foam::forces::rho(const volScalarField& p) const
}
else
{
if (rhoName_ != "rhoInf")
{
FatalErrorIn("forces::rho(const volScalarField& p)")
<< "Dynamic pressure is expected but kinematic is provided."
<< exit(FatalError);
}
return rhoRef_;
}
}
@ -149,11 +184,12 @@ Foam::forces::forces
active_(true),
log_(false),
patchSet_(),
pName_(""),
UName_(""),
pName_(word::null),
UName_(word::null),
rhoName_(word::null),
directForceDensity_(false),
fDName_(""),
rhoRef_(0),
rhoRef_(VGREAT),
CofR_(vector::zero),
forcesFilePtr_(NULL)
{
@ -175,6 +211,12 @@ Foam::forces::forces
}
read(dict);
if (active_)
{
// Create the forces file if not already created
makeFile();
}
}
@ -222,18 +264,31 @@ void Foam::forces::read(const dictionary& dict)
// Optional entries U and p
pName_ = dict.lookupOrDefault<word>("pName", "p");
UName_ = dict.lookupOrDefault<word>("UName", "U");
rhoName_ = dict.lookupOrDefault<word>("rhoName", "rho");
// Check whether UName and pName exists, if not deactivate forces
// Check whether UName, pName and rhoName exists,
// if not deactivate forces
if
(
!obr_.foundObject<volVectorField>(UName_)
|| !obr_.foundObject<volScalarField>(pName_)
|| (
rhoName_ != "rhoInf"
&& !obr_.foundObject<volScalarField>(rhoName_)
)
)
{
active_ = false;
WarningIn("void forces::read(const dictionary& dict)")
<< "Could not find " << UName_ << " or "
<< pName_ << " in database." << nl
<< "Could not find " << UName_ << ", " << pName_;
if (rhoName_ != "rhoInf")
{
Info<< " or " << rhoName_;
}
Info<< " in database." << nl
<< " De-activating forces."
<< endl;
}

View File

@ -132,6 +132,9 @@ protected:
//- Name of velocity field
word UName_;
//- Name of density field (optional)
word rhoName_;
//- Is the force density being supplied directly?
Switch directForceDensity_;
@ -157,6 +160,9 @@ protected:
//- Return the effective viscous stress (laminar + turbulent).
tmp<volSymmTensorField> devRhoReff() const;
//- Return rho if rhoName is specified otherwise rhoRef
tmp<volScalarField> rho() const;
//- Return rhoRef if the pressure field is dynamic, i.e. p/rho
// otherwise return 1
scalar rho(const volScalarField& p) const;
@ -190,9 +196,8 @@ public:
);
// Destructor
virtual ~forces();
//- Destructor
virtual ~forces();
// Member Functions

View File

@ -66,8 +66,8 @@ Foam::systemCall::~systemCall()
void Foam::systemCall::read(const dictionary& dict)
{
dict.readIfPresent("executeCalls", executeCalls_);
dict.readIfPresent("endCalls", endCalls_);
dict.readIfPresent("writeCalls", writeCalls_);
dict.readIfPresent("endCalls", endCalls_);
dict.readIfPresent("writeCalls", writeCalls_);
if (executeCalls_.empty() && endCalls_.empty() && writeCalls_.empty())
{

View File

@ -101,9 +101,8 @@ public:
);
// Destructor
virtual ~systemCall();
//- Destructor
virtual ~systemCall();
// Member Functions

View File

@ -98,9 +98,8 @@ public:
);
// Destructor
virtual ~dsmcFields();
//- Destructor
virtual ~dsmcFields();
// Member Functions

View File

@ -106,9 +106,8 @@ public:
);
// Destructor
virtual ~staticPressure();
//- Destructor
virtual ~staticPressure();
// Member Functions

View File

@ -57,7 +57,7 @@ Foam::faceZonesIntegration::faceZonesIntegration
log_(false),
faceZonesSet_(),
fItems_(),
faceZonesIntegrationFilePtr_(NULL)
filePtr_(NULL)
{
// Check if the available mesh is an fvMesh otherise deactivate
if (!isA<fvMesh>(obr_))
@ -104,7 +104,7 @@ void Foam::faceZonesIntegration::read(const dictionary& dict)
void Foam::faceZonesIntegration::makeFile()
{
// Create the face Zone file if not already created
if (faceZonesIntegrationFilePtr_.empty())
if (filePtr_.empty())
{
if (debug)
{
@ -132,7 +132,7 @@ void Foam::faceZonesIntegration::makeFile()
mkDir(faceZonesIntegrationDir);
// Open new file at start up
faceZonesIntegrationFilePtr_.resize(fItems_.size());
filePtr_.resize(fItems_.size());
forAll(fItems_, Ifields)
{
@ -143,7 +143,7 @@ void Foam::faceZonesIntegration::makeFile()
faceZonesIntegrationDir/fieldName
);
faceZonesIntegrationFilePtr_.insert(fieldName, sPtr);
filePtr_.insert(fieldName, sPtr);
}
// Add headers to output data
@ -155,11 +155,11 @@ void Foam::faceZonesIntegration::makeFile()
void Foam::faceZonesIntegration::writeFileHeader()
{
forAllIter(HashPtrTable<OFstream>, faceZonesIntegrationFilePtr_, iter)
forAllIter(HashPtrTable<OFstream>, filePtr_, iter)
{
unsigned int w = IOstream::defaultPrecision() + 7;
OFstream& os = *faceZonesIntegrationFilePtr_[iter.key()];
OFstream& os = *filePtr_[iter.key()];
os << "#Time " << setw(w);
@ -191,48 +191,55 @@ void Foam::faceZonesIntegration::write()
if (active_)
{
makeFile();
scalar dm = 0.0;
forAll(fItems_, fieldI)
{
const word& fieldName = fItems_[fieldI];
const surfaceScalarField& fD =
const surfaceScalarField& sField =
obr_.lookupObject<surfaceScalarField>(fieldName);
const fvMesh& mesh = fD.mesh();
const fvMesh& mesh = sField.mesh();
// 1. integrate over all face zones
scalarField integralVals(faceZonesSet_.size());
forAll(faceZonesSet_, setI)
{
const word name = faceZonesSet_[setI];
label zoneID = mesh.faceZones().findZoneID(name);
const faceZone& fZone = mesh.faceZones()[zoneID];
integralVals[setI] = returnReduce
(
calcIntegral(sField, fZone),
sumOp<scalar>()
);
}
unsigned int w = IOstream::defaultPrecision() + 7;
if
(
Pstream::master()
&& faceZonesIntegrationFilePtr_.found(fieldName)
)
// 2. Write only on master
if (Pstream::master() && filePtr_.found(fieldName))
{
OFstream& os = *faceZonesIntegrationFilePtr_(fieldName);
OFstream& os = *filePtr_(fieldName);
os << obr_.time().value();
const faceZoneMesh& faceZoneList = mesh.faceZones();
forAll(faceZonesSet_, zoneI)
forAll(integralVals, setI)
{
const word name = faceZonesSet_[zoneI];
label zoneID = faceZoneList.findZoneID(name);
const faceZone& fz = mesh.faceZones()[zoneID];
dm = calcFaceZonesIntegral(fD, fz);
reduce(dm, sumOp<scalar>());
os << ' ' << setw(w) << dm;
os << ' ' << setw(w) << integralVals[setI];
if (log_)
{
Info<< "faceZonesIntegration output:" << nl
<< " Integration" << dm << endl;
<< " Integration[" << setI << "] "
<< integralVals[setI] << endl;
}
}
@ -243,45 +250,47 @@ void Foam::faceZonesIntegration::write()
}
Foam::scalar Foam::faceZonesIntegration::calcFaceZonesIntegral
Foam::scalar Foam::faceZonesIntegration::calcIntegral
(
const surfaceScalarField& fD,
const faceZone& fz
const surfaceScalarField& sField,
const faceZone& fZone
) const
{
scalar dm = 0.0;
const fvMesh& mesh = fD.mesh();
scalar sum = 0.0;
const fvMesh& mesh = sField.mesh();
forAll (fz, i)
forAll (fZone, i)
{
label faceI = fz[i];
label faceI = fZone[i];
if (mesh.isInternalFace(faceI))
{
if (fz.flipMap()[faceI])
if (fZone.flipMap()[i])
{
dm -= fD[faceI];
sum -= sField[faceI];
}
else
{
dm += fD[faceI];
sum += sField[faceI];
}
}
else
{
label patchI = mesh.boundaryMesh().whichPatch(faceI);
const polyPatch& pp = mesh.boundaryMesh()[patchI];
const fvsPatchScalarField& bField = sField.boundaryField()[patchI];
if (isA<processorPolyPatch>(pp))
{
if (refCast<const processorPolyPatch>(pp).owner())
{
if (fz.flipMap()[faceI])
label patchFaceI = pp.whichFace(faceI);
if (fZone.flipMap()[i])
{
dm -= fD.boundaryField()[patchI][pp.whichFace(faceI)];
sum -= bField[patchFaceI];
}
else
{
dm += fD.boundaryField()[patchI][pp.whichFace(faceI)];
sum += bField[patchFaceI];
}
}
}
@ -290,32 +299,32 @@ Foam::scalar Foam::faceZonesIntegration::calcFaceZonesIntegral
label patchFaceI = faceI - pp.start();
if (patchFaceI < pp.size()/2)
{
if (fz.flipMap()[patchFaceI])
if (fZone.flipMap()[i])
{
dm -= fD.boundaryField()[patchI][patchFaceI];
sum -= bField[patchFaceI];
}
else
{
dm += fD.boundaryField()[patchI][patchFaceI];
sum += bField[patchFaceI];
}
}
}
else if (!isA<emptyPolyPatch>(pp))
{
label patchFaceI = faceI - pp.start();
if (fz.flipMap()[patchFaceI])
if (fZone.flipMap()[i])
{
dm -= fD.boundaryField()[patchI][patchFaceI];
sum -= bField[patchFaceI];
}
else
{
dm += fD.boundaryField()[patchI][patchFaceI];
sum += bField[patchFaceI];
}
}
}
}
return dm;
return sum;
}

View File

@ -57,7 +57,7 @@ class dictionary;
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class faceZonesIntegration Declaration
Class faceZonesIntegration Declaration
\*---------------------------------------------------------------------------*/
class faceZonesIntegration
@ -65,25 +65,23 @@ class faceZonesIntegration
protected:
// Private data
// Protected data
//- Name of this set of face zone integration,
// Also used as the name of the probes directory.
// Also used as the name of the output directory.
word name_;
const objectRegistry& obr_;
//- on/off switch
bool active_;
//- Switch to send output to Info as well as to file
Switch log_;
//- Current open files
HashPtrTable<OFstream> faceZonesIntegrationFilePtr_;
// Read from dictionary
//- On/off switch
bool active_;
//- Switch to send output to Info as well as to file
Switch log_;
//- faceZones to integrate over
wordList faceZonesSet_;
@ -91,15 +89,20 @@ protected:
wordList fItems_;
// Private Member Functions
//- Current open files
HashPtrTable<OFstream> filePtr_;
// Protected Member Functions
//- If the integration file has not been created create it
void makeFile();
scalar calcFaceZonesIntegral
scalar calcIntegral
(
const surfaceScalarField& fD,
const faceZone& fz
const surfaceScalarField& sField,
const faceZone& fZone
) const;
@ -132,9 +135,8 @@ public:
);
// Destructor
virtual ~faceZonesIntegration();
//- Destructor
virtual ~faceZonesIntegration();
// Member Functions