Commit 3ec6e289 authored by Andrew Heather's avatar Andrew Heather
Browse files
parents b1f65a82 94bec509
......@@ -102,7 +102,9 @@ void Foam::cyclicPolyPatch::calcTransforms()
),
points
);
pointField half0Ctrs(calcFaceCentres(half0, half0.points()));
scalarField half0Tols(calcFaceTol(half0, half0.points(), half0Ctrs));
primitivePatch half1
......@@ -740,9 +742,7 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
rotationAxis_(vector::zero),
rotationCentre_(point::zero),
separationVector_(vector::zero)
{
calcTransforms();
}
{}
Foam::cyclicPolyPatch::cyclicPolyPatch
......@@ -786,8 +786,6 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
}
}
}
calcTransforms();
}
......@@ -805,9 +803,7 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
rotationAxis_(pp.rotationAxis_),
rotationCentre_(pp.rotationCentre_),
separationVector_(pp.separationVector_)
{
calcTransforms();
}
{}
Foam::cyclicPolyPatch::cyclicPolyPatch
......@@ -827,9 +823,7 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
rotationAxis_(pp.rotationAxis_),
rotationCentre_(pp.rotationCentre_),
separationVector_(pp.separationVector_)
{
calcTransforms();
}
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
......@@ -852,6 +846,7 @@ void Foam::cyclicPolyPatch::initGeometry()
void Foam::cyclicPolyPatch::calcGeometry()
{
polyPatch::calcGeometry();
calcTransforms();
}
void Foam::cyclicPolyPatch::initMovePoints(const pointField& p)
......
......@@ -85,6 +85,9 @@ Foam::spray::spray
)
),
ambientPressure_(p_.average().value()),
ambientTemperature_(T_.average().value()),
injectors_
(
IOobject
......@@ -204,10 +207,7 @@ Foam::spray::spray
srhos_(fuels_->components().size()),
totalInjectedLiquidMass_(0.0),
injectedLiquidKE_(0.0),
ambientPressure_(p_.average().value()),
ambientTemperature_(T_.average().value())
injectedLiquidKE_(0.0)
{
// create the evaporation source fields
......
......@@ -92,8 +92,15 @@ class spray
IOdictionary sprayProperties_;
//- Ambient Pressure
scalar ambientPressure_;
//- Ambient Temperature
scalar ambientTemperature_;
//- The injectors
IOPtrList<injector> injectors_;
IOPtrList<injector> injectors_;
// References to the spray sub-models
......@@ -164,12 +171,6 @@ class spray
//- The (total added) injected kinetic energy of the liquid
scalar injectedLiquidKE_;
//- Ambient Pressure
scalar ambientPressure_;
//- Ambient Temperature
scalar ambientTemperature_;
// Private Member Functions
......
......@@ -68,7 +68,7 @@ Foam::tmp<Foam::scalarField> Foam::cellQuality::nonOrthogonality() const
scalar magS = mag(s);
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;
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 cosDDotS =
Foam::acos((d & s)/(mag(d)*magS + VSMALL))
Foam::acos(min(1.0, (d & s)/(mag(d)*magS + VSMALL)))
*180.0/mathematicalConstant::pi;
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 cosDDotS =
Foam::acos((d & s)/(mag(d)*magS + VSMALL))
Foam::acos(min(1.0, (d & s)/(mag(d)*magS + VSMALL)))
*180.0/mathematicalConstant::pi;
result[faceI] = cosDDotS;
......@@ -235,7 +235,7 @@ Foam::tmp<Foam::scalarField> Foam::cellQuality::faceNonOrthogonality() const
scalar magS = mag(s);
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;
result[globalFaceI++] = cosDDotS;
......
......@@ -46,26 +46,45 @@ const Foam::word Foam::fieldAverage::EXT_PRIME2MEAN = "Prime2Mean";
// * * * * * * * * * * * * * 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)
{
checkoutFields(meanScalarFields_);
meanScalarFields_.clear();
meanScalarFields_.setSize(nItems);
checkoutFields(meanVectorFields_);
meanVectorFields_.clear();
meanVectorFields_.setSize(nItems);
checkoutFields(meanSphericalTensorFields_);
meanSphericalTensorFields_.clear();
meanSphericalTensorFields_.setSize(nItems);
checkoutFields(meanSymmTensorFields_);
meanSymmTensorFields_.clear();
meanSymmTensorFields_.setSize(nItems);
checkoutFields(meanTensorFields_);
meanTensorFields_.clear();
meanTensorFields_.setSize(nItems);
checkoutFields(prime2MeanScalarFields_);
prime2MeanScalarFields_.clear();
prime2MeanScalarFields_.setSize(nItems);
checkoutFields(prime2MeanSymmTensorFields_);
prime2MeanSymmTensorFields_.clear();
prime2MeanSymmTensorFields_.setSize(nItems);
......@@ -128,7 +147,7 @@ void Foam::fieldAverage::initialise()
if (obr_.foundObject<volScalarField>(fieldName))
{
addPrime2MeanField<scalar>
addPrime2MeanField<scalar, scalar>
(
i,
meanScalarFields_,
......@@ -137,7 +156,7 @@ void Foam::fieldAverage::initialise()
}
else if (obr_.foundObject<volVectorField>(fieldName))
{
addPrime2MeanField<vector>
addPrime2MeanField<vector, symmTensor>
(
i,
meanVectorFields_,
......@@ -188,12 +207,12 @@ Foam::fieldAverage::fieldAverage
active_ = false;
WarningIn
(
"fieldAverage::fieldAverage"
"("
"const word&,"
"const objectRegistry&,"
"const dictionary&,"
"const bool"
"fieldAverage::fieldAverage\n"
"(\n"
"const word&,\n"
"const objectRegistry&,\n"
"const dictionary&,\n"
"const bool\n"
")"
) << "No fvMesh available, deactivating."
<< nl << endl;
......@@ -255,12 +274,12 @@ void Foam::fieldAverage::calcAverages()
totalTime_[i] += obr_.time().deltaT().value();
}
addMeanSqrToPrime2Mean<scalar>
addMeanSqrToPrime2Mean<scalar, scalar>
(
meanScalarFields_,
prime2MeanScalarFields_
);
addMeanSqrToPrime2Mean<vector>
addMeanSqrToPrime2Mean<vector, symmTensor>
(
meanVectorFields_,
prime2MeanSymmTensorFields_
......@@ -272,12 +291,12 @@ void Foam::fieldAverage::calcAverages()
calculateMeanFields<symmTensor>(meanSymmTensorFields_);
calculateMeanFields<tensor>(meanTensorFields_);
calculatePrime2MeanFields<scalar>
calculatePrime2MeanFields<scalar, scalar>
(
meanScalarFields_,
prime2MeanScalarFields_
);
calculatePrime2MeanFields<vector>
calculatePrime2MeanFields<vector, symmTensor>
(
meanVectorFields_,
prime2MeanSymmTensorFields_
......@@ -309,13 +328,14 @@ void Foam::fieldAverage::writeAveragingProperties() const
"uniform",
obr_,
IOobject::NO_READ,
IOobject::NO_WRITE
IOobject::NO_WRITE,
false
)
);
forAll(faItems_, i)
{
const word fieldName = faItems_[i].fieldName();
const word& fieldName = faItems_[i].fieldName();
propsDict.add(fieldName, dictionary());
propsDict.subDict(fieldName).add("totalIter", totalIter_[i]);
propsDict.subDict(fieldName).add("totalTime", totalTime_[i]);
......
......@@ -75,7 +75,6 @@ Description
SourceFiles
fieldAverage.C
fieldAverageTemplates.C
IOfieldAverage.H
\*---------------------------------------------------------------------------*/
......@@ -122,7 +121,7 @@ protected:
//- Clean restart flag
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
List<fieldAverageItem> faItems_;
......@@ -138,15 +137,15 @@ protected:
// Lists of averages
// Arithmetic mean fields
PtrList<volScalarField> meanScalarFields_;
PtrList<volVectorField> meanVectorFields_;
PtrList<volSphericalTensorField> meanSphericalTensorFields_;
PtrList<volSymmTensorField> meanSymmTensorFields_;
PtrList<volTensorField> meanTensorFields_;
wordList meanScalarFields_;
wordList meanVectorFields_;
wordList meanSphericalTensorFields_;
wordList meanSymmTensorFields_;
wordList meanTensorFields_;
// Prime-squared fields - applicable to volVectorFields only
PtrList<volScalarField> prime2MeanScalarFields_;
PtrList<volSymmTensorField> prime2MeanSymmTensorFields_;
wordList prime2MeanScalarFields_;
wordList prime2MeanSymmTensorFields_;
// Counters
......@@ -162,6 +161,9 @@ protected:
// Initialisation routines
//- Checkout fields (causes deletion) from the database
void checkoutFields(const wordList&) const;
//- Reset size of lists (clear existing values)
void resetLists(const label nItems);
......@@ -171,20 +173,16 @@ protected:
//- Add mean average field to PtrList
template<class Type>
void addMeanField
(
const label,
PtrList<GeometricField<Type, fvPatchField, volMesh> >&
);
void addMeanField(const label, wordList&) const;
//- Add prime-squared average field to PtrList
template<class Type1, class Type2>
void addPrime2MeanField
(
const label,
PtrList<GeometricField<Type1, fvPatchField, volMesh> >&,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >&
);
const wordList&,
wordList&
) const;
// Calculation functions
......@@ -194,26 +192,23 @@ protected:
//- Calculate mean average fields
template<class Type>
void calculateMeanFields
(
PtrList<GeometricField<Type, fvPatchField, volMesh> >&
);
void calculateMeanFields(const wordList&) const;
//- Add mean-squared field value to prime-squared mean field
template<class Type1, class Type2>
void addMeanSqrToPrime2Mean
(
PtrList<GeometricField<Type1, fvPatchField, volMesh> >&,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >&
);
const wordList&,
const wordList&
) const;
//- Calculate prime-squared average fields
template<class Type1, class Type2>
void calculatePrime2MeanFields
(
PtrList<GeometricField<Type1, fvPatchField, volMesh> >&,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >&
);
const wordList&,
const wordList&
) const;
// I-O
......@@ -223,11 +218,7 @@ protected:
//- Write fields
template<class Type>
void writeFieldList
(
const PtrList<GeometricField<Type, fvPatchField, volMesh> >&
fieldList
) const;
void writeFieldList(const wordList&) const;
//- Write averaging properties - steps and time
void writeAveragingProperties() const;
......
......@@ -34,22 +34,36 @@ template<class Type>
void Foam::fieldAverage::addMeanField
(
const label fieldi,
PtrList<GeometricField<Type, fvPatchField, volMesh> >& meanFieldList
)
wordList& meanFieldList
) const
{
if (faItems_[fieldi].mean())
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const word& fieldName = faItems_[fieldi].fieldName();
const fieldType& baseField = obr_.lookupObject<fieldType>(fieldName);
const word meanFieldName = fieldName + EXT_MEAN;
Info<< "Reading/calculating field " << meanFieldName << nl << endl;
meanFieldList.set
(
fieldi,
new fieldType
if (obr_.foundObject<fieldType>(meanFieldName))
{
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
(
......@@ -60,8 +74,13 @@ void Foam::fieldAverage::addMeanField
IOobject::NO_WRITE
),
baseField
)
);
);
// Store on registry
fPtr->store();
meanFieldList[fieldi] = meanFieldName;
}
}
}
......@@ -70,25 +89,39 @@ template<class Type1, class Type2>
void Foam::fieldAverage::addPrime2MeanField
(
const label fieldi,
PtrList<GeometricField<Type1, fvPatchField, volMesh> >& meanFieldList,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& prime2MeanFieldList
)
const wordList& meanFieldList,
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<Type2, fvPatchField, volMesh> fieldType2;
const word& fieldName = faItems_[fieldi].fieldName();
const fieldType1& baseField = obr_.lookupObject<fieldType1>(fieldName);
const fieldType1& meanField = meanFieldList[fieldi];
const word meanFieldName = fieldName + EXT_PRIME2MEAN;
Info<< "Reading/calculating field " << meanFieldName << nl << endl;
prime2MeanFieldList.set
(
fieldi,
new fieldType2
if (obr_.foundObject<fieldType2>(meanFieldName))
{
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
(
......@@ -99,17 +132,20 @@ void Foam::fieldAverage::addPrime2MeanField
IOobject::NO_WRITE
),
sqr(baseField) - sqr(meanField)
)
);
);
// Store on registry
fPtr->store();
prime2MeanFieldList[fieldi] = meanFieldName;
}
}
}
template<class Type>
void Foam::fieldAverage::calculateMeanFields
(
PtrList<GeometricField<Type, fvPatchField, volMesh> >& meanFieldList
)
void Foam::fieldAverage::calculateMeanFields(const wordList& meanFieldList)
const
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
......@@ -117,12 +153,15 @@ void Foam::fieldAverage::calculateMeanFields
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 fieldType& baseField =
obr_.lookupObject<fieldType>(fieldName);
fieldType& meanField = meanFieldList[i];
fieldType& meanField = const_cast<fieldType&>
(
obr_.lookupObject<fieldType>(meanFieldList[i])
);
scalar alpha = 0.0;
scalar beta = 0.0;
......@@ -146,9 +185,9 @@ void Foam::fieldAverage::calculateMeanFields
template<class Type1, class Type2>
void Foam::fieldAverage::calculatePrime2MeanFields
(
PtrList<GeometricField<Type1, fvPatchField, volMesh> >& meanFieldList,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& prime2MeanFieldList
)
const wordList& meanFieldList,
const wordList& prime2MeanFieldList
) const
{
typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1;
typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2;
......@@ -160,15 +199,19 @@ void Foam::fieldAverage::calculatePrime2MeanFields
if
(
faItems_[i].prime2Mean()
&& meanFieldList.set(i)
&& prime2MeanFieldList.set(i)
&& meanFieldList[i] != word::null
&& prime2MeanFieldList[i] != word::null
)
{
const word& fieldName = faItems_[i].fieldName();
const fieldType1& baseField =
obr_.lookupObject<fieldType1>(fieldName);
const fieldType1& meanField = meanFieldList[i];
fieldType2& prime2MeanField = prime2MeanFieldList[i];
const fieldType1& meanField =
obr_.lookupObject<fieldType1>(meanFieldList[i]);
fieldType2& prime2MeanField = const_cast<fieldType2&>
(
obr_.lookupObject<fieldType2>(prime2MeanFieldList[i])
);
scalar alpha = 0.0;
scalar beta = 0.0;
......@@ -195,9 +238,9 @@ void Foam::fieldAverage::calculatePrime2MeanFields
template<class Type1, class Type2>
void Foam::fieldAverage::addMeanSqrToPrime2Mean
(
PtrList<GeometricField<Type1, fvPatchField, volMesh> >& meanFieldList,