Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
andy
2009-02-13 19:06:54 +00:00
8 changed files with 181 additions and 119 deletions

View File

@ -102,7 +102,9 @@ void Foam::cyclicPolyPatch::calcTransforms()
), ),
points points
); );
pointField half0Ctrs(calcFaceCentres(half0, half0.points())); pointField half0Ctrs(calcFaceCentres(half0, half0.points()));
scalarField half0Tols(calcFaceTol(half0, half0.points(), half0Ctrs)); scalarField half0Tols(calcFaceTol(half0, half0.points(), half0Ctrs));
primitivePatch half1 primitivePatch half1
@ -740,9 +742,7 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
rotationAxis_(vector::zero), rotationAxis_(vector::zero),
rotationCentre_(point::zero), rotationCentre_(point::zero),
separationVector_(vector::zero) separationVector_(vector::zero)
{ {}
calcTransforms();
}
Foam::cyclicPolyPatch::cyclicPolyPatch Foam::cyclicPolyPatch::cyclicPolyPatch
@ -786,8 +786,6 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
} }
} }
} }
calcTransforms();
} }
@ -805,9 +803,7 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
rotationAxis_(pp.rotationAxis_), rotationAxis_(pp.rotationAxis_),
rotationCentre_(pp.rotationCentre_), rotationCentre_(pp.rotationCentre_),
separationVector_(pp.separationVector_) separationVector_(pp.separationVector_)
{ {}
calcTransforms();
}
Foam::cyclicPolyPatch::cyclicPolyPatch Foam::cyclicPolyPatch::cyclicPolyPatch
@ -827,9 +823,7 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
rotationAxis_(pp.rotationAxis_), rotationAxis_(pp.rotationAxis_),
rotationCentre_(pp.rotationCentre_), rotationCentre_(pp.rotationCentre_),
separationVector_(pp.separationVector_) separationVector_(pp.separationVector_)
{ {}
calcTransforms();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -852,6 +846,7 @@ void Foam::cyclicPolyPatch::initGeometry()
void Foam::cyclicPolyPatch::calcGeometry() void Foam::cyclicPolyPatch::calcGeometry()
{ {
polyPatch::calcGeometry(); polyPatch::calcGeometry();
calcTransforms();
} }
void Foam::cyclicPolyPatch::initMovePoints(const pointField& p) void Foam::cyclicPolyPatch::initMovePoints(const pointField& p)

View File

@ -85,6 +85,9 @@ Foam::spray::spray
) )
), ),
ambientPressure_(p_.average().value()),
ambientTemperature_(T_.average().value()),
injectors_ injectors_
( (
IOobject IOobject
@ -204,10 +207,7 @@ Foam::spray::spray
srhos_(fuels_->components().size()), srhos_(fuels_->components().size()),
totalInjectedLiquidMass_(0.0), totalInjectedLiquidMass_(0.0),
injectedLiquidKE_(0.0), injectedLiquidKE_(0.0)
ambientPressure_(p_.average().value()),
ambientTemperature_(T_.average().value())
{ {
// create the evaporation source fields // create the evaporation source fields

View File

@ -92,8 +92,15 @@ class spray
IOdictionary sprayProperties_; IOdictionary sprayProperties_;
//- Ambient Pressure
scalar ambientPressure_;
//- Ambient Temperature
scalar ambientTemperature_;
//- The injectors //- The injectors
IOPtrList<injector> injectors_; IOPtrList<injector> injectors_;
// References to the spray sub-models // References to the spray sub-models
@ -164,12 +171,6 @@ class spray
//- The (total added) injected kinetic energy of the liquid //- The (total added) injected kinetic energy of the liquid
scalar injectedLiquidKE_; scalar injectedLiquidKE_;
//- Ambient Pressure
scalar ambientPressure_;
//- Ambient Temperature
scalar ambientTemperature_;
// Private Member Functions // Private Member Functions

View File

@ -68,7 +68,7 @@ Foam::tmp<Foam::scalarField> Foam::cellQuality::nonOrthogonality() const
scalar magS = mag(s); scalar magS = mag(s);
scalar cosDDotS = scalar cosDDotS =
Foam::acos((d & s)/(mag(d)*magS + VSMALL)) Foam::acos(min(1.0, (d & s)/(mag(d)*magS + VSMALL)))
*180.0/mathematicalConstant::pi; *180.0/mathematicalConstant::pi;
result[own[faceI]] = max(cosDDotS, result[own[faceI]]); result[own[faceI]] = max(cosDDotS, result[own[faceI]]);
@ -94,7 +94,7 @@ Foam::tmp<Foam::scalarField> Foam::cellQuality::nonOrthogonality() const
scalar magS = mag(s); scalar magS = mag(s);
scalar cosDDotS = scalar cosDDotS =
Foam::acos((d & s)/(mag(d)*magS + VSMALL)) Foam::acos(min(1.0, (d & s)/(mag(d)*magS + VSMALL)))
*180.0/mathematicalConstant::pi; *180.0/mathematicalConstant::pi;
result[faceCells[faceI]] = max(cosDDotS, result[faceCells[faceI]]); result[faceCells[faceI]] = max(cosDDotS, result[faceCells[faceI]]);
@ -209,7 +209,7 @@ Foam::tmp<Foam::scalarField> Foam::cellQuality::faceNonOrthogonality() const
scalar magS = mag(s); scalar magS = mag(s);
scalar cosDDotS = scalar cosDDotS =
Foam::acos((d & s)/(mag(d)*magS + VSMALL)) Foam::acos(min(1.0, (d & s)/(mag(d)*magS + VSMALL)))
*180.0/mathematicalConstant::pi; *180.0/mathematicalConstant::pi;
result[faceI] = cosDDotS; result[faceI] = cosDDotS;
@ -235,7 +235,7 @@ Foam::tmp<Foam::scalarField> Foam::cellQuality::faceNonOrthogonality() const
scalar magS = mag(s); scalar magS = mag(s);
scalar cosDDotS = scalar cosDDotS =
Foam::acos((d & s)/(mag(d)*magS + VSMALL)) Foam::acos(min(1.0, (d & s)/(mag(d)*magS + VSMALL)))
*180.0/mathematicalConstant::pi; *180.0/mathematicalConstant::pi;
result[globalFaceI++] = cosDDotS; result[globalFaceI++] = cosDDotS;

View File

@ -46,26 +46,45 @@ const Foam::word Foam::fieldAverage::EXT_PRIME2MEAN = "Prime2Mean";
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::fieldAverage::checkoutFields(const wordList& fieldNames) const
{
forAll(fieldNames, i)
{
if (fieldNames[i] != word::null)
{
obr_.checkOut(*obr_[fieldNames[i]]);
}
}
}
void Foam::fieldAverage::resetLists(const label nItems) void Foam::fieldAverage::resetLists(const label nItems)
{ {
checkoutFields(meanScalarFields_);
meanScalarFields_.clear(); meanScalarFields_.clear();
meanScalarFields_.setSize(nItems); meanScalarFields_.setSize(nItems);
checkoutFields(meanVectorFields_);
meanVectorFields_.clear(); meanVectorFields_.clear();
meanVectorFields_.setSize(nItems); meanVectorFields_.setSize(nItems);
checkoutFields(meanSphericalTensorFields_);
meanSphericalTensorFields_.clear(); meanSphericalTensorFields_.clear();
meanSphericalTensorFields_.setSize(nItems); meanSphericalTensorFields_.setSize(nItems);
checkoutFields(meanSymmTensorFields_);
meanSymmTensorFields_.clear(); meanSymmTensorFields_.clear();
meanSymmTensorFields_.setSize(nItems); meanSymmTensorFields_.setSize(nItems);
checkoutFields(meanTensorFields_);
meanTensorFields_.clear(); meanTensorFields_.clear();
meanTensorFields_.setSize(nItems); meanTensorFields_.setSize(nItems);
checkoutFields(prime2MeanScalarFields_);
prime2MeanScalarFields_.clear(); prime2MeanScalarFields_.clear();
prime2MeanScalarFields_.setSize(nItems); prime2MeanScalarFields_.setSize(nItems);
checkoutFields(prime2MeanSymmTensorFields_);
prime2MeanSymmTensorFields_.clear(); prime2MeanSymmTensorFields_.clear();
prime2MeanSymmTensorFields_.setSize(nItems); prime2MeanSymmTensorFields_.setSize(nItems);
@ -128,7 +147,7 @@ void Foam::fieldAverage::initialise()
if (obr_.foundObject<volScalarField>(fieldName)) if (obr_.foundObject<volScalarField>(fieldName))
{ {
addPrime2MeanField<scalar> addPrime2MeanField<scalar, scalar>
( (
i, i,
meanScalarFields_, meanScalarFields_,
@ -137,7 +156,7 @@ void Foam::fieldAverage::initialise()
} }
else if (obr_.foundObject<volVectorField>(fieldName)) else if (obr_.foundObject<volVectorField>(fieldName))
{ {
addPrime2MeanField<vector> addPrime2MeanField<vector, symmTensor>
( (
i, i,
meanVectorFields_, meanVectorFields_,
@ -188,12 +207,12 @@ Foam::fieldAverage::fieldAverage
active_ = false; active_ = false;
WarningIn WarningIn
( (
"fieldAverage::fieldAverage" "fieldAverage::fieldAverage\n"
"(" "(\n"
"const word&," "const word&,\n"
"const objectRegistry&," "const objectRegistry&,\n"
"const dictionary&," "const dictionary&,\n"
"const bool" "const bool\n"
")" ")"
) << "No fvMesh available, deactivating." ) << "No fvMesh available, deactivating."
<< nl << endl; << nl << endl;
@ -255,12 +274,12 @@ void Foam::fieldAverage::calcAverages()
totalTime_[i] += obr_.time().deltaT().value(); totalTime_[i] += obr_.time().deltaT().value();
} }
addMeanSqrToPrime2Mean<scalar> addMeanSqrToPrime2Mean<scalar, scalar>
( (
meanScalarFields_, meanScalarFields_,
prime2MeanScalarFields_ prime2MeanScalarFields_
); );
addMeanSqrToPrime2Mean<vector> addMeanSqrToPrime2Mean<vector, symmTensor>
( (
meanVectorFields_, meanVectorFields_,
prime2MeanSymmTensorFields_ prime2MeanSymmTensorFields_
@ -272,12 +291,12 @@ void Foam::fieldAverage::calcAverages()
calculateMeanFields<symmTensor>(meanSymmTensorFields_); calculateMeanFields<symmTensor>(meanSymmTensorFields_);
calculateMeanFields<tensor>(meanTensorFields_); calculateMeanFields<tensor>(meanTensorFields_);
calculatePrime2MeanFields<scalar> calculatePrime2MeanFields<scalar, scalar>
( (
meanScalarFields_, meanScalarFields_,
prime2MeanScalarFields_ prime2MeanScalarFields_
); );
calculatePrime2MeanFields<vector> calculatePrime2MeanFields<vector, symmTensor>
( (
meanVectorFields_, meanVectorFields_,
prime2MeanSymmTensorFields_ prime2MeanSymmTensorFields_
@ -309,13 +328,14 @@ void Foam::fieldAverage::writeAveragingProperties() const
"uniform", "uniform",
obr_, obr_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE,
false
) )
); );
forAll(faItems_, i) forAll(faItems_, i)
{ {
const word fieldName = faItems_[i].fieldName(); const word& fieldName = faItems_[i].fieldName();
propsDict.add(fieldName, dictionary()); propsDict.add(fieldName, dictionary());
propsDict.subDict(fieldName).add("totalIter", totalIter_[i]); propsDict.subDict(fieldName).add("totalIter", totalIter_[i]);
propsDict.subDict(fieldName).add("totalTime", totalTime_[i]); propsDict.subDict(fieldName).add("totalTime", totalTime_[i]);

View File

@ -75,7 +75,6 @@ Description
SourceFiles SourceFiles
fieldAverage.C fieldAverage.C
fieldAverageTemplates.C fieldAverageTemplates.C
IOfieldAverage.H
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -122,7 +121,7 @@ protected:
//- Clean restart flag //- Clean restart flag
Switch cleanRestart_; Switch cleanRestart_;
//- List of field average items, describing waht averages to be //- List of field average items, describing what averages to be
// calculated and output // calculated and output
List<fieldAverageItem> faItems_; List<fieldAverageItem> faItems_;
@ -138,15 +137,15 @@ protected:
// Lists of averages // Lists of averages
// Arithmetic mean fields // Arithmetic mean fields
PtrList<volScalarField> meanScalarFields_; wordList meanScalarFields_;
PtrList<volVectorField> meanVectorFields_; wordList meanVectorFields_;
PtrList<volSphericalTensorField> meanSphericalTensorFields_; wordList meanSphericalTensorFields_;
PtrList<volSymmTensorField> meanSymmTensorFields_; wordList meanSymmTensorFields_;
PtrList<volTensorField> meanTensorFields_; wordList meanTensorFields_;
// Prime-squared fields - applicable to volVectorFields only // Prime-squared fields - applicable to volVectorFields only
PtrList<volScalarField> prime2MeanScalarFields_; wordList prime2MeanScalarFields_;
PtrList<volSymmTensorField> prime2MeanSymmTensorFields_; wordList prime2MeanSymmTensorFields_;
// Counters // Counters
@ -162,6 +161,9 @@ protected:
// Initialisation routines // Initialisation routines
//- Checkout fields (causes deletion) from the database
void checkoutFields(const wordList&) const;
//- Reset size of lists (clear existing values) //- Reset size of lists (clear existing values)
void resetLists(const label nItems); void resetLists(const label nItems);
@ -171,20 +173,16 @@ protected:
//- Add mean average field to PtrList //- Add mean average field to PtrList
template<class Type> template<class Type>
void addMeanField void addMeanField(const label, wordList&) const;
(
const label,
PtrList<GeometricField<Type, fvPatchField, volMesh> >&
);
//- Add prime-squared average field to PtrList //- Add prime-squared average field to PtrList
template<class Type1, class Type2> template<class Type1, class Type2>
void addPrime2MeanField void addPrime2MeanField
( (
const label, const label,
PtrList<GeometricField<Type1, fvPatchField, volMesh> >&, const wordList&,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& wordList&
); ) const;
// Calculation functions // Calculation functions
@ -194,26 +192,23 @@ protected:
//- Calculate mean average fields //- Calculate mean average fields
template<class Type> template<class Type>
void calculateMeanFields void calculateMeanFields(const wordList&) const;
(
PtrList<GeometricField<Type, fvPatchField, volMesh> >&
);
//- Add mean-squared field value to prime-squared mean field //- Add mean-squared field value to prime-squared mean field
template<class Type1, class Type2> template<class Type1, class Type2>
void addMeanSqrToPrime2Mean void addMeanSqrToPrime2Mean
( (
PtrList<GeometricField<Type1, fvPatchField, volMesh> >&, const wordList&,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& const wordList&
); ) const;
//- Calculate prime-squared average fields //- Calculate prime-squared average fields
template<class Type1, class Type2> template<class Type1, class Type2>
void calculatePrime2MeanFields void calculatePrime2MeanFields
( (
PtrList<GeometricField<Type1, fvPatchField, volMesh> >&, const wordList&,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& const wordList&
); ) const;
// I-O // I-O
@ -223,11 +218,7 @@ protected:
//- Write fields //- Write fields
template<class Type> template<class Type>
void writeFieldList void writeFieldList(const wordList&) const;
(
const PtrList<GeometricField<Type, fvPatchField, volMesh> >&
fieldList
) const;
//- Write averaging properties - steps and time //- Write averaging properties - steps and time
void writeAveragingProperties() const; void writeAveragingProperties() const;

View File

@ -34,22 +34,36 @@ template<class Type>
void Foam::fieldAverage::addMeanField void Foam::fieldAverage::addMeanField
( (
const label fieldi, const label fieldi,
PtrList<GeometricField<Type, fvPatchField, volMesh> >& meanFieldList wordList& meanFieldList
) ) const
{ {
if (faItems_[fieldi].mean()) if (faItems_[fieldi].mean())
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const word& fieldName = faItems_[fieldi].fieldName(); const word& fieldName = faItems_[fieldi].fieldName();
const fieldType& baseField = obr_.lookupObject<fieldType>(fieldName);
const word meanFieldName = fieldName + EXT_MEAN; const word meanFieldName = fieldName + EXT_MEAN;
Info<< "Reading/calculating field " << meanFieldName << nl << endl; Info<< "Reading/calculating field " << meanFieldName << nl << endl;
meanFieldList.set
( if (obr_.foundObject<fieldType>(meanFieldName))
fieldi, {
new fieldType meanFieldList[fieldi] = meanFieldName;
}
else if (obr_.found(meanFieldName))
{
Info<< "Cannot allocate average field " << meanFieldName
<< " since an object with that name already exists."
<< " Disabling averaging." << nl << endl;
meanFieldList[fieldi] = word::null;
}
else
{
const fieldType& baseField =
obr_.lookupObject<fieldType>(fieldName);
fieldType* fPtr = new fieldType
( (
IOobject IOobject
( (
@ -60,8 +74,13 @@ void Foam::fieldAverage::addMeanField
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
baseField baseField
) );
);
// Store on registry
fPtr->store();
meanFieldList[fieldi] = meanFieldName;
}
} }
} }
@ -70,25 +89,39 @@ template<class Type1, class Type2>
void Foam::fieldAverage::addPrime2MeanField void Foam::fieldAverage::addPrime2MeanField
( (
const label fieldi, const label fieldi,
PtrList<GeometricField<Type1, fvPatchField, volMesh> >& meanFieldList, const wordList& meanFieldList,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& prime2MeanFieldList wordList& prime2MeanFieldList
) ) const
{ {
if (faItems_[fieldi].mean() && meanFieldList.set(fieldi)) if (faItems_[fieldi].mean() && meanFieldList[fieldi] != word::null)
{ {
typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1; typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1;
typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2; typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2;
const word& fieldName = faItems_[fieldi].fieldName(); const word& fieldName = faItems_[fieldi].fieldName();
const fieldType1& baseField = obr_.lookupObject<fieldType1>(fieldName);
const fieldType1& meanField = meanFieldList[fieldi];
const word meanFieldName = fieldName + EXT_PRIME2MEAN; const word meanFieldName = fieldName + EXT_PRIME2MEAN;
Info<< "Reading/calculating field " << meanFieldName << nl << endl; Info<< "Reading/calculating field " << meanFieldName << nl << endl;
prime2MeanFieldList.set
( if (obr_.foundObject<fieldType2>(meanFieldName))
fieldi, {
new fieldType2 prime2MeanFieldList[fieldi] = meanFieldName;
}
else if (obr_.found(meanFieldName))
{
Info<< "Cannot allocate average field " << meanFieldName
<< " since an object with that name already exists."
<< " Disabling averaging." << nl << endl;
prime2MeanFieldList[fieldi] = word::null;
}
else
{
const fieldType1& baseField =
obr_.lookupObject<fieldType1>(fieldName);
const fieldType1& meanField =
obr_.lookupObject<fieldType1>(meanFieldList[fieldi]);
fieldType2* fPtr = new fieldType2
( (
IOobject IOobject
( (
@ -99,17 +132,20 @@ void Foam::fieldAverage::addPrime2MeanField
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
sqr(baseField) - sqr(meanField) sqr(baseField) - sqr(meanField)
) );
);
// Store on registry
fPtr->store();
prime2MeanFieldList[fieldi] = meanFieldName;
}
} }
} }
template<class Type> template<class Type>
void Foam::fieldAverage::calculateMeanFields void Foam::fieldAverage::calculateMeanFields(const wordList& meanFieldList)
( const
PtrList<GeometricField<Type, fvPatchField, volMesh> >& meanFieldList
)
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
@ -117,12 +153,15 @@ void Foam::fieldAverage::calculateMeanFields
forAll(faItems_, i) forAll(faItems_, i)
{ {
if (faItems_[i].mean() && meanFieldList.set(i)) if (faItems_[i].mean() && meanFieldList[i] != word::null)
{ {
const word& fieldName = faItems_[i].fieldName(); const word& fieldName = faItems_[i].fieldName();
const fieldType& baseField = const fieldType& baseField =
obr_.lookupObject<fieldType>(fieldName); obr_.lookupObject<fieldType>(fieldName);
fieldType& meanField = meanFieldList[i]; fieldType& meanField = const_cast<fieldType&>
(
obr_.lookupObject<fieldType>(meanFieldList[i])
);
scalar alpha = 0.0; scalar alpha = 0.0;
scalar beta = 0.0; scalar beta = 0.0;
@ -146,9 +185,9 @@ void Foam::fieldAverage::calculateMeanFields
template<class Type1, class Type2> template<class Type1, class Type2>
void Foam::fieldAverage::calculatePrime2MeanFields void Foam::fieldAverage::calculatePrime2MeanFields
( (
PtrList<GeometricField<Type1, fvPatchField, volMesh> >& meanFieldList, const wordList& meanFieldList,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& prime2MeanFieldList const wordList& prime2MeanFieldList
) ) const
{ {
typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1; typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1;
typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2; typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2;
@ -160,15 +199,19 @@ void Foam::fieldAverage::calculatePrime2MeanFields
if if
( (
faItems_[i].prime2Mean() faItems_[i].prime2Mean()
&& meanFieldList.set(i) && meanFieldList[i] != word::null
&& prime2MeanFieldList.set(i) && prime2MeanFieldList[i] != word::null
) )
{ {
const word& fieldName = faItems_[i].fieldName(); const word& fieldName = faItems_[i].fieldName();
const fieldType1& baseField = const fieldType1& baseField =
obr_.lookupObject<fieldType1>(fieldName); obr_.lookupObject<fieldType1>(fieldName);
const fieldType1& meanField = meanFieldList[i]; const fieldType1& meanField =
fieldType2& prime2MeanField = prime2MeanFieldList[i]; obr_.lookupObject<fieldType1>(meanFieldList[i]);
fieldType2& prime2MeanField = const_cast<fieldType2&>
(
obr_.lookupObject<fieldType2>(prime2MeanFieldList[i])
);
scalar alpha = 0.0; scalar alpha = 0.0;
scalar beta = 0.0; scalar beta = 0.0;
@ -195,9 +238,9 @@ void Foam::fieldAverage::calculatePrime2MeanFields
template<class Type1, class Type2> template<class Type1, class Type2>
void Foam::fieldAverage::addMeanSqrToPrime2Mean void Foam::fieldAverage::addMeanSqrToPrime2Mean
( (
PtrList<GeometricField<Type1, fvPatchField, volMesh> >& meanFieldList, const wordList& meanFieldList,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& prime2MeanFieldList const wordList& prime2MeanFieldList
) ) const
{ {
typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1; typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1;
typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2; typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2;
@ -207,12 +250,16 @@ void Foam::fieldAverage::addMeanSqrToPrime2Mean
if if
( (
faItems_[i].prime2Mean() faItems_[i].prime2Mean()
&& meanFieldList.set(i) && meanFieldList[i] != word::null
&& prime2MeanFieldList.set(i) && prime2MeanFieldList[i] != word::null
) )
{ {
const fieldType1& meanField = meanFieldList[i]; const fieldType1& meanField =
fieldType2& prime2MeanField = prime2MeanFieldList[i]; obr_.lookupObject<fieldType1>(meanFieldList[i]);
fieldType2& prime2MeanField = const_cast<fieldType2&>
(
obr_.lookupObject<fieldType2>(prime2MeanFieldList[i])
);
prime2MeanField += sqr(meanField); prime2MeanField += sqr(meanField);
} }
@ -221,16 +268,16 @@ void Foam::fieldAverage::addMeanSqrToPrime2Mean
template<class Type> template<class Type>
void Foam::fieldAverage::writeFieldList void Foam::fieldAverage::writeFieldList(const wordList& fieldList) const
(
const PtrList<GeometricField<Type, fvPatchField, volMesh> >& fieldList
) const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
forAll(fieldList, i) forAll(fieldList, i)
{ {
if (fieldList.set(i)) if (fieldList[i] != word::null)
{ {
fieldList[i].write(); const fieldType& f = obr_.lookupObject<fieldType>(fieldList[i]);
f.write();
} }
} }
} }

View File

@ -0,0 +1,8 @@
#!/bin/sh
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
application="simpleFoam"
runApplication $application