Commit 35faeb74 authored by Mattijs Janssens's avatar Mattijs Janssens
Browse files

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

parents 20b82e06 14407bb2
......@@ -140,6 +140,7 @@ buildParaView ()
{
# set general options
addCMakeVariable "BUILD_SHARED_LIBS:BOOL=ON"
addCMakeVariable "CMAKE_BUILD_TYPE:STRING=Release"
# set paraview environment
unset PARAVIEW_SRC_DIR
......
......@@ -85,23 +85,23 @@ void Foam::fieldAverage::initialise()
const word fieldName = faItems_[i].fieldName();
if (obr_.foundObject<volScalarField>(fieldName))
{
addMeanFields<scalar>(i, meanScalarFields_);
addMeanField<scalar>(i, meanScalarFields_);
}
else if (obr_.foundObject<volVectorField>(fieldName))
{
addMeanFields<vector>(i, meanVectorFields_);
addMeanField<vector>(i, meanVectorFields_);
}
else if (obr_.foundObject<volSphericalTensorField>(fieldName))
{
addMeanFields<sphericalTensor>(i, meanSphericalTensorFields_);
addMeanField<sphericalTensor>(i, meanSphericalTensorFields_);
}
else if (obr_.foundObject<volSymmTensorField>(fieldName))
{
addMeanFields<symmTensor>(i, meanSymmTensorFields_);
addMeanField<symmTensor>(i, meanSymmTensorFields_);
}
else if (obr_.foundObject<volTensorField>(fieldName))
{
addMeanFields<tensor>(i, meanTensorFields_);
addMeanField<tensor>(i, meanTensorFields_);
}
else
{
......@@ -118,29 +118,29 @@ void Foam::fieldAverage::initialise()
if (faItems_[i].prime2Mean())
{
const word fieldName = faItems_[i].fieldName();
if (!faItems_[i].mean())
{
FatalErrorIn("Foam::fieldAverage::initialise()")
<< "To calculate the prime-squared average, the "
<< "mean average must also be selected for field "
<< fieldName << nl << exit(FatalError);
}
if (obr_.foundObject<volScalarField>(fieldName))
{
if (!faItems_[i].mean())
{
FatalErrorIn("Foam::fieldAverage::initialise()")
<< "To calculate the prime-squared average, the "
<< "mean average must also be selected for field "
<< fieldName << nl << exit(FatalError);
}
addPrime2MeanFields<scalar>(i, prime2MeanScalarFields_);
addPrime2MeanField<scalar>
(
i,
meanScalarFields_,
prime2MeanScalarFields_
);
}
else if (obr_.foundObject<volVectorField>(fieldName))
{
if (!faItems_[i].mean())
{
FatalErrorIn("Foam::fieldAverage::initialise()")
<< "To calculate the prime-squared average, the "
<< "mean average must also be selected for field "
<< fieldName << nl << exit(FatalError);
}
addPrime2MeanFields<vector>
addPrime2MeanField<vector>
(
i,
meanVectorFields_,
prime2MeanSymmTensorFields_
);
}
......@@ -251,8 +251,16 @@ void Foam::fieldAverage::calcAverages()
totalTime_[i] += obr_.time().deltaT().value();
}
addMeanSqrToPrime2Mean<scalar>(prime2MeanScalarFields_);
addMeanSqrToPrime2Mean<vector>(prime2MeanSymmTensorFields_);
addMeanSqrToPrime2Mean<scalar>
(
meanScalarFields_,
prime2MeanScalarFields_
);
addMeanSqrToPrime2Mean<vector>
(
meanVectorFields_,
prime2MeanSymmTensorFields_
);
calculateMeanFields<scalar>(meanScalarFields_);
calculateMeanFields<vector>(meanVectorFields_);
......@@ -260,8 +268,16 @@ void Foam::fieldAverage::calcAverages()
calculateMeanFields<symmTensor>(meanSymmTensorFields_);
calculateMeanFields<tensor>(meanTensorFields_);
calculatePrime2MeanFields<scalar>(prime2MeanScalarFields_);
calculatePrime2MeanFields<vector>(prime2MeanSymmTensorFields_);
calculatePrime2MeanFields<scalar>
(
meanScalarFields_,
prime2MeanScalarFields_
);
calculatePrime2MeanFields<vector>
(
meanVectorFields_,
prime2MeanSymmTensorFields_
);
}
......
......@@ -161,22 +161,21 @@ protected:
// valid, and populate field lists
void initialise();
//- Add mean average fields to PtrLists
//- Add mean average field to PtrList
template<class Type>
void addMeanFields
void addMeanField
(
const label fieldi,
const label,
PtrList<GeometricField<Type, fvPatchField, volMesh> >&
fieldList
);
//- Add prime-squared average fields to PtrLists
//- Add prime-squared average field to PtrList
template<class Type1, class Type2>
void addPrime2MeanFields
void addPrime2MeanField
(
const label fieldi,
const label,
PtrList<GeometricField<Type1, fvPatchField, volMesh> >&,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >&
fieldList
);
......@@ -190,23 +189,22 @@ protected:
void calculateMeanFields
(
PtrList<GeometricField<Type, fvPatchField, volMesh> >&
fieldList
);
//- 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> >&
fieldList
);
//- Calculate prime-squared average fields
template<class Type1, class Type2>
void calculatePrime2MeanFields
(
PtrList<GeometricField<Type1, fvPatchField, volMesh> >&,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >&
fieldList
);
......
......@@ -31,23 +31,22 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::fieldAverage::addMeanFields
void Foam::fieldAverage::addMeanField
(
const label fieldi,
PtrList<GeometricField<Type, fvPatchField, volMesh> >& fieldList
PtrList<GeometricField<Type, fvPatchField, volMesh> >& meanFieldList
)
{
if (faItems_[fieldi].mean())
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const fvMesh& mesh = refCast<const fvMesh>(obr_);
const word& fieldName = faItems_[fieldi].fieldName();
const fieldType& baseField = mesh.lookupObject<fieldType>(fieldName);
const word meanFieldName = fieldName + EXT_MEAN;
const fieldType& baseField = obr_.lookupObject<fieldType>(fieldName);
const word meanFieldName = fieldName + EXT_MEAN;
Info<< "Reading/calculating field " << meanFieldName << nl << endl;
fieldList.set
meanFieldList.set
(
fieldi,
new fieldType
......@@ -55,8 +54,8 @@ void Foam::fieldAverage::addMeanFields
IOobject
(
meanFieldName,
mesh.time().timeName(),
mesh,
obr_.time().timeName(),
obr_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
......@@ -68,26 +67,25 @@ void Foam::fieldAverage::addMeanFields
template<class Type1, class Type2>
void Foam::fieldAverage::addPrime2MeanFields
void Foam::fieldAverage::addPrime2MeanField
(
const label fieldi,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& fieldList
PtrList<GeometricField<Type1, fvPatchField, volMesh> >& meanFieldList,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& prime2MeanFieldList
)
{
if (faItems_[fieldi].mean())
if (faItems_[fieldi].mean() && meanFieldList.set(fieldi))
{
typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1;
typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2;
const fvMesh& mesh = refCast<const fvMesh>(obr_);
const word& fieldName = faItems_[fieldi].fieldName();
const fieldType1& baseField = mesh.lookupObject<fieldType1>(fieldName);
const fieldType1& meanField =
mesh.lookupObject<fieldType1>(fieldName + EXT_MEAN);
const word meanFieldName = fieldName + EXT_PRIME2MEAN;
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;
fieldList.set
prime2MeanFieldList.set
(
fieldi,
new fieldType2
......@@ -95,8 +93,8 @@ void Foam::fieldAverage::addPrime2MeanFields
IOobject
(
meanFieldName,
mesh.time().timeName(),
mesh,
obr_.time().timeName(),
obr_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
......@@ -110,7 +108,7 @@ void Foam::fieldAverage::addPrime2MeanFields
template<class Type>
void Foam::fieldAverage::calculateMeanFields
(
PtrList<GeometricField<Type, fvPatchField, volMesh> >& fieldList
PtrList<GeometricField<Type, fvPatchField, volMesh> >& meanFieldList
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
......@@ -119,31 +117,27 @@ void Foam::fieldAverage::calculateMeanFields
forAll(faItems_, i)
{
if (fieldList.set(i))
if (faItems_[i].mean() && meanFieldList.set(i))
{
if (faItems_[i].mean())
const word& fieldName = faItems_[i].fieldName();
const fieldType& baseField =
obr_.lookupObject<fieldType>(fieldName);
fieldType& meanField = meanFieldList[i];
scalar alpha = 0.0;
scalar beta = 0.0;
if (faItems_[i].timeBase())
{
alpha = (totalTime_[i] - dt)/totalTime_[i];
beta = dt/totalTime_[i];
}
else
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
const word& fieldName = faItems_[i].fieldName();
const fieldType& baseField =
mesh.lookupObject<fieldType>(fieldName);
fieldType& meanField = fieldList[i];
scalar alpha = 0.0;
scalar beta = 0.0;
if (faItems_[i].timeBase())
{
alpha = (totalTime_[i] - dt)/totalTime_[i];
beta = dt/totalTime_[i];
}
else
{
alpha = scalar(totalIter_[i] - 1)/scalar(totalIter_[i]);
beta = 1.0/scalar(totalIter_[i]);
}
meanField = alpha*meanField + beta*baseField;
alpha = scalar(totalIter_[i] - 1)/scalar(totalIter_[i]);
beta = 1.0/scalar(totalIter_[i]);
}
meanField = alpha*meanField + beta*baseField;
}
}
}
......@@ -152,7 +146,8 @@ void Foam::fieldAverage::calculateMeanFields
template<class Type1, class Type2>
void Foam::fieldAverage::calculatePrime2MeanFields
(
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& fieldList
PtrList<GeometricField<Type1, fvPatchField, volMesh> >& meanFieldList,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& prime2MeanFieldList
)
{
typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1;
......@@ -162,36 +157,36 @@ void Foam::fieldAverage::calculatePrime2MeanFields
forAll(faItems_, i)
{
if (fieldList.set(i))
if
(
faItems_[i].prime2Mean()
&& meanFieldList.set(i)
&& prime2MeanFieldList.set(i)
)
{
if (faItems_[i].prime2Mean())
const word& fieldName = faItems_[i].fieldName();
const fieldType1& baseField =
obr_.lookupObject<fieldType1>(fieldName);
const fieldType1& meanField = meanFieldList[i];
fieldType2& prime2MeanField = prime2MeanFieldList[i];
scalar alpha = 0.0;
scalar beta = 0.0;
if (faItems_[i].timeBase())
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
const word& fieldName = faItems_[i].fieldName();
const fieldType1& baseField =
mesh.lookupObject<fieldType1>(fieldName);
const fieldType1& meanField =
mesh.lookupObject<fieldType1>(fieldName + EXT_MEAN);
fieldType2& prime2MeanField = fieldList[i];
scalar alpha = 0.0;
scalar beta = 0.0;
if (faItems_[i].timeBase())
{
alpha = (totalTime_[i] - dt)/totalTime_[i];
beta = dt/totalTime_[i];
}
else
{
alpha = scalar(totalIter_[i] - 1)/scalar(totalIter_[i]);
beta = 1.0/scalar(totalIter_[i]);
}
prime2MeanField =
alpha*prime2MeanField
+ beta*sqr(baseField)
- sqr(meanField);
alpha = (totalTime_[i] - dt)/totalTime_[i];
beta = dt/totalTime_[i];
}
else
{
alpha = scalar(totalIter_[i] - 1)/scalar(totalIter_[i]);
beta = 1.0/scalar(totalIter_[i]);
}
prime2MeanField =
alpha*prime2MeanField
+ beta*sqr(baseField)
- sqr(meanField);
}
}
}
......@@ -200,7 +195,8 @@ void Foam::fieldAverage::calculatePrime2MeanFields
template<class Type1, class Type2>
void Foam::fieldAverage::addMeanSqrToPrime2Mean
(
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& fieldList
PtrList<GeometricField<Type1, fvPatchField, volMesh> >& meanFieldList,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& prime2MeanFieldList
)
{
typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1;
......@@ -208,18 +204,17 @@ void Foam::fieldAverage::addMeanSqrToPrime2Mean
forAll(faItems_, i)
{
if (fieldList.set(i))
if
(
faItems_[i].prime2Mean()
&& meanFieldList.set(i)
&& prime2MeanFieldList.set(i)
)
{
if (faItems_[i].prime2Mean())
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
const word& fieldName = faItems_[i].fieldName();
const fieldType1& meanField =
mesh.lookupObject<fieldType1>(fieldName + EXT_MEAN);
fieldType2& prime2MeanField = fieldList[i];
const fieldType1& meanField = meanFieldList[i];
fieldType2& prime2MeanField = prime2MeanFieldList[i];
prime2MeanField += sqr(meanField);
}
prime2MeanField += sqr(meanField);
}
}
}
......
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0];
internalField uniform (0 0 0);
boundaryField
{
inlet
{
type zeroGradient;
value uniform (0 0 0);
}
outlet
{
type zeroGradient;
value uniform (0 0 0);
}
walls
{
type fixedValue;
value uniform (0 0 0);
}
frontBack
{
type fixedValue;
value uniform (0 0 0);
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object gamma;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0];
internalField uniform 0;
boundaryField
{
inlet
{
type calculated;
value uniform 0;
}
outlet
{
type calculated;
value uniform 0;
}
walls
{
type calculated;
value uniform 0;
}
frontBack
{
type calculated;
value uniform 0;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0];
internalField uniform 10.0;
boundaryField
{
inlet
{
type fixedValue;
value uniform 0.5;
}
outlet
{
type zeroGradient;
}
walls
{
type zeroGradient;
}
frontBack
{
type zeroGradient;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format binary;
class volScalarField;
object nuSgs;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 1e-11;
boundaryField
{
inlet
{
type zeroGradient;
}