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

This commit is contained in:
mattijs
2010-01-15 17:36:16 +00:00
41 changed files with 614 additions and 1160 deletions

View File

@ -124,11 +124,6 @@ public:
// Member Functions // Member Functions
tmp<volScalarField> mut() const
{
return mut_;
}
//- Return the effective diffusivity for k //- Return the effective diffusivity for k
tmp<volScalarField> DkEff() const tmp<volScalarField> DkEff() const
{ {
@ -147,41 +142,44 @@ public:
); );
} }
//- Return the effective turbulent thermal diffusivity //- Return the turbulence viscosity
tmp<volScalarField> alphaEff() const virtual tmp<volScalarField> mut() const
{ {
return tmp<volScalarField> return mut_;
( }
new volScalarField("alphaEff", alphat_ + alpha())
); //- Return the turbulence thermal diffusivity
virtual tmp<volScalarField> alphat() const
{
return alphat_;
} }
//- Return the turbulence kinetic energy //- Return the turbulence kinetic energy
tmp<volScalarField> k() const virtual tmp<volScalarField> k() const
{ {
return k_; return k_;
} }
//- Return the turbulence kinetic energy dissipation rate //- Return the turbulence kinetic energy dissipation rate
tmp<volScalarField> epsilon() const virtual tmp<volScalarField> epsilon() const
{ {
return epsilon_; return epsilon_;
} }
//- Return the Reynolds stress tensor //- Return the Reynolds stress tensor
tmp<volSymmTensorField> R() const; virtual tmp<volSymmTensorField> R() const;
//- Return the effective stress tensor including the laminar stress //- Return the effective stress tensor including the laminar stress
tmp<volSymmTensorField> devRhoReff() const; virtual tmp<volSymmTensorField> devRhoReff() const;
//- Return the source term for the momentum equation //- Return the source term for the momentum equation
tmp<fvVectorMatrix> divDevRhoReff(volVectorField& U) const; virtual tmp<fvVectorMatrix> divDevRhoReff(volVectorField& U) const;
//- Solve the turbulence equations and correct the turbulence viscosity //- Solve the turbulence equations and correct the turbulence viscosity
void correct(); virtual void correct();
//- Read turbulenceProperties dictionary //- Read turbulenceProperties dictionary
bool read(); virtual bool read();
}; };

View File

@ -68,7 +68,7 @@ fi
if [ -r $ParaView_DIR ] if [ -r $ParaView_DIR ]
then then
export PATH=$ParaView_DIR/bin:$PATH export PATH=$ParaView_DIR/bin:$PATH
export PV_PLUGIN_PATH=$FOAM_LIBBIN export PV_PLUGIN_PATH=$FOAM_LIBBIN/paraview
fi fi
unset cmake ParaView_PYTHON_DIR unset cmake ParaView_PYTHON_DIR

View File

@ -62,7 +62,7 @@ endif
if ( -r $ParaView_INST_DIR ) then if ( -r $ParaView_INST_DIR ) then
set path=($ParaView_DIR/bin $path) set path=($ParaView_DIR/bin $path)
setenv PV_PLUGIN_PATH $FOAM_LIBBIN setenv PV_PLUGIN_PATH $FOAM_LIBBIN/paraview
endif endif
unset cmake paraviewMajor paraviewPython unset cmake paraviewMajor paraviewPython

View File

@ -42,13 +42,31 @@ Description
namespace Foam namespace Foam
{ {
typedef ReactingMultiphaseCloud<BasicReactingParcel<constGasThermoPhysics> > typedef ReactingMultiphaseCloud
<
BasicReactingMultiphaseParcel
<
constGasThermoPhysics
>
>
constThermoReactingMultiphaseCloud; constThermoReactingMultiphaseCloud;
typedef ReactingMultiphaseCloud<BasicReactingParcel<gasThermoPhysics> > typedef ReactingMultiphaseCloud
<
BasicReactingMultiphaseParcel
<
gasThermoPhysics
>
>
thermoReactingMultiphaseCloud; thermoReactingMultiphaseCloud;
typedef ReactingMultiphaseCloud<BasicReactingParcel<icoPoly8ThermoPhysics> > typedef ReactingMultiphaseCloud
<
BasicReactingMultiphaseParcel
<
icoPoly8ThermoPhysics
>
>
icoPoly8ThermoReactingMultiphaseCloud; icoPoly8ThermoReactingMultiphaseCloud;
} }

View File

@ -401,7 +401,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
td.cloud().hcTrans()[cellI] += td.cloud().hcTrans()[cellI] +=
np0 np0
*dMassGas[i] *dMassGas[i]
*td.cloud().mcCarrierThermo().speciesData()[gid].H(T0); *td.cloud().mcCarrierThermo().speciesData()[gid].Hc();
} }
forAll(YLiquid_, i) forAll(YLiquid_, i)
{ {
@ -410,7 +410,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
td.cloud().hcTrans()[cellI] += td.cloud().hcTrans()[cellI] +=
np0 np0
*dMassLiquid[i] *dMassLiquid[i]
*td.cloud().mcCarrierThermo().speciesData()[gid].H(T0); *td.cloud().mcCarrierThermo().speciesData()[gid].Hc();
} }
/* /*
// No mapping between solid components and carrier phase // No mapping between solid components and carrier phase
@ -421,7 +421,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
td.cloud().hcTrans()[cellI] += td.cloud().hcTrans()[cellI] +=
np0 np0
*dMassSolid[i] *dMassSolid[i]
*td.cloud().mcCarrierThermo().speciesData()[gid].H(T0); *td.cloud().mcCarrierThermo().speciesData()[gid].Hc();
} }
*/ */
forAll(dMassSRCarrier, i) forAll(dMassSRCarrier, i)
@ -430,7 +430,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
td.cloud().hcTrans()[cellI] += td.cloud().hcTrans()[cellI] +=
np0 np0
*dMassSRCarrier[i] *dMassSRCarrier[i]
*td.cloud().mcCarrierThermo().speciesData()[i].H(T0); *td.cloud().mcCarrierThermo().speciesData()[i].Hc();
} }
// Update momentum transfer // Update momentum transfer

View File

@ -122,7 +122,7 @@ void Foam::ReactingParcel<ParcelType>::correctSurfaceValues
} }
// Far field carrier molar fractions // Far field carrier molar fractions
scalarField Xinf(Y_.size()); scalarField Xinf(td.cloud().mcCarrierThermo().speciesData().size());
forAll(Xinf, i) forAll(Xinf, i)
{ {

View File

@ -14,7 +14,7 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application oodles; application XXX;
startFrom latestTime; startFrom latestTime;
@ -54,6 +54,12 @@ functions
// Where to load it from (if not already in solver) // Where to load it from (if not already in solver)
functionObjectLibs ("libfieldAverage.so"); functionObjectLibs ("libfieldAverage.so");
// Function object enabled flag
enabled true;
// When to output the average fields
outputControl outputTime;
// Fields to be averaged - runTime modifiable // Fields to be averaged - runTime modifiable
fields fields
( (

View File

@ -46,10 +46,13 @@ namespace Foam
fieldValues::cellSource::sourceTypeNames_; fieldValues::cellSource::sourceTypeNames_;
template<> template<>
const char* NamedEnum<fieldValues::cellSource::operationType, 4>:: const char* NamedEnum<fieldValues::cellSource::operationType, 5>::
names[] = {"none", "sum", "volAverage", "volIntegrate"}; names[] =
{
"none", "sum", "volAverage", "volIntegrate", "weightedAverage"
};
const NamedEnum<fieldValues::cellSource::operationType, 4> const NamedEnum<fieldValues::cellSource::operationType, 5>
fieldValues::cellSource::operationTypeNames_; fieldValues::cellSource::operationTypeNames_;
} }
@ -93,7 +96,7 @@ void Foam::fieldValues::cellSource::setCellZoneCells()
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::fieldValues::cellSource::initialise() void Foam::fieldValues::cellSource::initialise(const dictionary& dict)
{ {
switch (source_) switch (source_)
{ {
@ -104,7 +107,7 @@ void Foam::fieldValues::cellSource::initialise()
} }
default: default:
{ {
FatalErrorIn("cellSource::constructCellAddressing()") FatalErrorIn("cellSource::initialise()")
<< "Unknown source type. Valid source types are:" << "Unknown source type. Valid source types are:"
<< sourceTypeNames_ << nl << exit(FatalError); << sourceTypeNames_ << nl << exit(FatalError);
} }
@ -114,6 +117,29 @@ void Foam::fieldValues::cellSource::initialise()
<< " total cells = " << cellId_.size() << nl << " total cells = " << cellId_.size() << nl
<< " total volume = " << sum(filterField(mesh().V())) << " total volume = " << sum(filterField(mesh().V()))
<< nl << endl; << nl << endl;
if (operation_ == opWeightedAverage)
{
dict.lookup("weightField") >> weightFieldName_;
if
(
obr().foundObject<volScalarField>(weightFieldName_)
)
{
Info<< " weight field = " << weightFieldName_;
}
else
{
FatalErrorIn("cellSource::initialise()")
<< type() << " " << name_ << ": "
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):"
<< nl << " Weight field " << weightFieldName_
<< " must be a " << volScalarField::typeName
<< nl << exit(FatalError);
}
}
Info<< nl << endl;
} }
@ -172,7 +198,7 @@ void Foam::fieldValues::cellSource::read(const dictionary& dict)
if (active_) if (active_)
{ {
// no additional info to read // no additional info to read
initialise(); initialise(dict);
} }
} }
@ -183,9 +209,12 @@ void Foam::fieldValues::cellSource::write()
if (active_) if (active_)
{ {
outputFilePtr_() if (Pstream::master())
<< obr_.time().value() << tab {
<< sum(filterField(mesh().V())); outputFilePtr_()
<< obr_.time().value() << tab
<< sum(filterField(mesh().V()));
}
forAll(fields_, i) forAll(fields_, i)
{ {
@ -196,7 +225,10 @@ void Foam::fieldValues::cellSource::write()
writeValues<tensor>(fields_[i]); writeValues<tensor>(fields_[i]);
} }
outputFilePtr_()<< endl; if (Pstream::master())
{
outputFilePtr_()<< endl;
}
if (log_) if (log_)
{ {

View File

@ -39,7 +39,7 @@ Description
valueOutput true; // Write values at run-time output times? valueOutput true; // Write values at run-time output times?
source cellZone; // Type of cell source source cellZone; // Type of cell source
sourceName c0; sourceName c0;
operation volAverage; // none, sum, volAverage, volIntegrate operation volAverage;
fields fields
( (
p p
@ -47,6 +47,13 @@ Description
); );
} }
where operation is one of:
- none
- sum
- volAverage
- volIntegrate
- weightedAverage
SourceFiles SourceFiles
cellSource.C cellSource.C
@ -96,11 +103,12 @@ public:
opNone, opNone,
opSum, opSum,
opVolAverage, opVolAverage,
opVolIntegrate opVolIntegrate,
opWeightedAverage
}; };
//- Operation type names //- Operation type names
static const NamedEnum<operationType, 4> operationTypeNames_; static const NamedEnum<operationType, 5> operationTypeNames_;
private: private:
@ -127,23 +135,34 @@ protected:
//- Local list of cell IDs //- Local list of cell IDs
labelList cellId_; labelList cellId_;
//- Weight field name - only used for opWeightedAverage mode
word weightFieldName_;
// Protected member functions // Protected member functions
//- Initialise, e.g. cell addressing //- Initialise, e.g. cell addressing
void initialise(); void initialise(const dictionary& dict);
//- Return true if the field name is valid
template<class Type>
bool validField(const word& fieldName) const;
//- Insert field values into values list //- Insert field values into values list
template<class Type> template<class Type>
bool setFieldValues tmp<Field<Type> > setFieldValues
( (
const word& fieldName, const word& fieldName
List<Type>& values
) const; ) const;
//- Apply the 'operation' to the values //- Apply the 'operation' to the values
template<class Type> template<class Type>
Type processValues(const List<Type>& values) const; Type processValues
(
const Field<Type>& values,
const scalarField& V,
const scalarField& weightField
) const;
//- Output file header information //- Output file header information
virtual void writeFileHeader(); virtual void writeFileHeader();

View File

@ -27,27 +27,16 @@ License
#include "cellSource.H" #include "cellSource.H"
#include "volFields.H" #include "volFields.H"
#include "IOList.H" #include "IOList.H"
#include "ListListOps.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type> template<class Type>
bool Foam::fieldValues::cellSource::setFieldValues bool Foam::fieldValues::cellSource::validField(const word& fieldName) const
(
const word& fieldName,
List<Type>& values
) const
{ {
values.setSize(cellId_.size(), pTraits<Type>::zero);
typedef GeometricField<Type, fvPatchField, volMesh> vf; typedef GeometricField<Type, fvPatchField, volMesh> vf;
if (obr_.foundObject<vf>(fieldName)) if (obr_.foundObject<vf>(fieldName))
{ {
const vf& field = obr_.lookupObject<vf>(fieldName);
values = UIndirectList<Type>(field, cellId_);
return true; return true;
} }
@ -55,10 +44,29 @@ bool Foam::fieldValues::cellSource::setFieldValues
} }
template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::fieldValues::cellSource::setFieldValues
(
const word& fieldName
) const
{
typedef GeometricField<Type, fvPatchField, volMesh> vf;
if (obr_.foundObject<vf>(fieldName))
{
return filterField(obr_.lookupObject<vf>(fieldName));
}
return tmp<Field<Type> >(new Field<Type>(0.0));
}
template<class Type> template<class Type>
Type Foam::fieldValues::cellSource::processValues Type Foam::fieldValues::cellSource::processValues
( (
const List<Type>& values const Field<Type>& values,
const scalarField& V,
const scalarField& weightField
) const ) const
{ {
Type result = pTraits<Type>::zero; Type result = pTraits<Type>::zero;
@ -71,13 +79,17 @@ Type Foam::fieldValues::cellSource::processValues
} }
case opVolAverage: case opVolAverage:
{ {
tmp<scalarField> V = filterField(mesh().V()); result = sum(values*V)/sum(V);
result = sum(values*V())/sum(V());
break; break;
} }
case opVolIntegrate: case opVolIntegrate:
{ {
result = sum(values*filterField(mesh().V())); result = sum(values*V);
break;
}
case opWeightedAverage:
{
result = sum(values*weightField)/sum(weightField);
break; break;
} }
default: default:
@ -95,25 +107,20 @@ Type Foam::fieldValues::cellSource::processValues
template<class Type> template<class Type>
bool Foam::fieldValues::cellSource::writeValues(const word& fieldName) bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
{ {
List<List<Type> > allValues(Pstream::nProcs()); const bool ok = validField<Type>(fieldName);
bool validField = if (ok)
setFieldValues<Type>(fieldName, allValues[Pstream::myProcNo()]);
if (validField)
{ {
Pstream::gatherList(allValues); Field<Type> values = combineFields(setFieldValues<Type>(fieldName));
scalarField V = combineFields(filterField(mesh().V()));
scalarField weightField =
combineFields(setFieldValues<scalar>(weightFieldName_));
if (Pstream::master()) if (Pstream::master())
{ {
List<Type> values = Type result = processValues(values, V, weightField);
ListListOps::combine<List<Type> >
(
allValues,
accessOp<List<Type> >()
);
Type result = processValues(values);
if (valueOutput_) if (valueOutput_)
{ {
@ -144,7 +151,7 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
} }
} }
return validField; return ok;
} }

View File

@ -220,7 +220,7 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
} }
default: default:
{ {
FatalErrorIn("faceSource::constructFaceAddressing()") FatalErrorIn("faceSource::initiliase()")
<< type() << " " << name_ << ": " << type() << " " << name_ << ": "
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):" << sourceTypeNames_[source_] << "(" << sourceName_ << "):"
<< nl << " Unknown source type. Valid source types are:" << nl << " Unknown source type. Valid source types are:"
@ -245,7 +245,7 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
} }
else else
{ {
FatalErrorIn("faceSource::constructFaceAddressing()") FatalErrorIn("faceSource::initialise()")
<< type() << " " << name_ << ": " << type() << " " << name_ << ": "
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):" << sourceTypeNames_[source_] << "(" << sourceName_ << "):"
<< nl << " Weight field " << weightFieldName_ << nl << " Weight field " << weightFieldName_
@ -326,9 +326,12 @@ void Foam::fieldValues::faceSource::write()
if (active_) if (active_)
{ {
outputFilePtr_() if (Pstream::master())
<< obr_.time().value() << tab {
<< sum(filterField(mesh().magSf())); outputFilePtr_()
<< obr_.time().value() << tab
<< sum(filterField(mesh().magSf()));
}
forAll(fields_, i) forAll(fields_, i)
{ {
@ -339,7 +342,10 @@ void Foam::fieldValues::faceSource::write()
writeValues<tensor>(fields_[i]); writeValues<tensor>(fields_[i]);
} }
outputFilePtr_()<< endl; if (Pstream::master())
{
outputFilePtr_()<< endl;
}
if (log_) if (log_)
{ {
@ -350,4 +356,3 @@ void Foam::fieldValues::faceSource::write()
// ************************************************************************* // // ************************************************************************* //

View File

@ -153,17 +153,22 @@ protected:
//- Initialise, e.g. face addressing //- Initialise, e.g. face addressing
void initialise(const dictionary& dict); void initialise(const dictionary& dict);
//- Insert field values into values list //- Return true if the field name is valid
template<class Type> template<class Type>
bool setFieldValues bool validField(const word& fieldName) const;
(
const word& fieldName, //- Return field values by looking up field name
List<Type>& values template<class Type>
) const; tmp<Field<Type> > setFieldValues(const word& fieldName) const;
//- Apply the 'operation' to the values //- Apply the 'operation' to the values
template<class Type> template<class Type>
Type processValues(const List<Type>& values) const; Type processValues
(
const Field<Type>& values,
const scalarField& magSf,
const scalarField& weightField
) const;
//- Output file header information //- Output file header information
virtual void writeFileHeader(); virtual void writeFileHeader();

View File

@ -33,70 +33,17 @@ License
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type> template<class Type>
bool Foam::fieldValues::faceSource::setFieldValues bool Foam::fieldValues::faceSource::validField(const word& fieldName) const
(
const word& fieldName,
List<Type>& values
) const
{ {
values.setSize(faceId_.size(), pTraits<Type>::zero);
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf; typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
typedef GeometricField<Type, fvPatchField, volMesh> vf; typedef GeometricField<Type, fvPatchField, volMesh> vf;
if (obr_.foundObject<sf>(fieldName)) if (obr_.foundObject<sf>(fieldName))
{ {
const sf& field = obr_.lookupObject<sf>(fieldName);
forAll(values, i)
{
label faceI = faceId_[i];
label patchI = facePatchId_[i];
if (patchI >= 0)
{
values[i] = field.boundaryField()[patchI][faceI];
}
else
{
values[i] = field[faceI];
}
values[i] *= flipMap_[i];
}
return true; return true;
} }
else if (obr_.foundObject<vf>(fieldName)) else if (obr_.foundObject<vf>(fieldName))
{ {
const vf& field = obr_.lookupObject<vf>(fieldName);
forAll(values, i)
{
label faceI = faceId_[i];
label patchI = facePatchId_[i];
if (patchI >= 0)
{
values[i] = field.boundaryField()[patchI][faceI];
}
else
{
FatalErrorIn
(
"fieldValues::faceSource::setFieldValues"
"("
"const word&, "
"List<Type>&"
") const"
) << type() << " " << name_ << ": "
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):"
<< nl
<< " Unable to process internal faces for volume field "
<< fieldName << nl << abort(FatalError);
}
values[i] *= flipMap_[i];
}
return true; return true;
} }
@ -104,10 +51,34 @@ bool Foam::fieldValues::faceSource::setFieldValues
} }
template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::setFieldValues
(
const word& fieldName
) const
{
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
typedef GeometricField<Type, fvPatchField, volMesh> vf;
if (obr_.foundObject<sf>(fieldName))
{
return filterField(obr_.lookupObject<sf>(fieldName));
}
else if (obr_.foundObject<vf>(fieldName))
{
return filterField(obr_.lookupObject<vf>(fieldName));
}
return tmp<Field<Type> >(new Field<Type>(0.0));
}
template<class Type> template<class Type>
Type Foam::fieldValues::faceSource::processValues Type Foam::fieldValues::faceSource::processValues
( (
const List<Type>& values const Field<Type>& values,
const scalarField& magSf,
const scalarField& weightField
) const ) const
{ {
Type result = pTraits<Type>::zero; Type result = pTraits<Type>::zero;
@ -120,54 +91,17 @@ Type Foam::fieldValues::faceSource::processValues
} }
case opAreaAverage: case opAreaAverage:
{ {
tmp<scalarField> magSf = filterField(mesh().magSf()); result = sum(values*magSf)/sum(magSf);
result = sum(values*magSf())/sum(magSf());
break; break;
} }
case opAreaIntegrate: case opAreaIntegrate:
{ {
result = sum(values*filterField(mesh().magSf())); result = sum(values*magSf);
break; break;
} }
case opWeightedAverage: case opWeightedAverage:
{ {
if (mesh().foundObject<volScalarField>(weightFieldName_)) result = sum(values*weightField)/sum(weightField);
{
tmp<scalarField> wField =
filterField
(
mesh().lookupObject<volScalarField>(weightFieldName_)
);
result = sum(values*wField())/sum(wField());
}
else if (mesh().foundObject<surfaceScalarField>(weightFieldName_))
{
tmp<scalarField> wField =
filterField
(
mesh().lookupObject<surfaceScalarField>
(
weightFieldName_
)
);
result = sum(values*wField())/sum(wField());
}
else
{
FatalErrorIn
(
"fieldValues::faceSource::processValues"
"("
"List<Type>&"
") const"
) << type() << " " << name_ << ": "
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):"
<< nl
<< " Weight field " << weightFieldName_
<< " must be either a " << volScalarField::typeName
<< " or " << surfaceScalarField::typeName << nl
<< abort(FatalError);
}
break; break;
} }
default: default:
@ -185,25 +119,20 @@ Type Foam::fieldValues::faceSource::processValues
template<class Type> template<class Type>
bool Foam::fieldValues::faceSource::writeValues(const word& fieldName) bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
{ {
List<List<Type> > allValues(Pstream::nProcs()); const bool ok = validField<Type>(fieldName);
bool validField = if (ok)
setFieldValues<Type>(fieldName, allValues[Pstream::myProcNo()]);
if (validField)
{ {
Pstream::gatherList(allValues); Field<Type> values = combineFields(setFieldValues<Type>(fieldName));
scalarField magSf = combineFields(filterField(mesh().magSf()));
scalarField weightField =
combineFields(setFieldValues<scalar>(weightFieldName_));
if (Pstream::master()) if (Pstream::master())
{ {
List<Type> values = Type result = processValues(values, magSf, weightField);
ListListOps::combine<List<Type> >
(
allValues,
accessOp<List<Type> >()
);
Type result = processValues(values);
if (valueOutput_) if (valueOutput_)
{ {
@ -222,7 +151,6 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
).write(); ).write();
} }
outputFilePtr_()<< tab << result; outputFilePtr_()<< tab << result;
if (log_) if (log_)
@ -234,7 +162,7 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
} }
} }
return validField; return ok;
} }

View File

@ -164,6 +164,13 @@ public:
//- Execute the at the final time-loop, currently does nothing //- Execute the at the final time-loop, currently does nothing
virtual void end(); virtual void end();
//- Comnbine fields from all processor domains into single field
template<class Type>
tmp<Field<Type> > combineFields
(
const tmp<Field<Type> >& field
) const;
}; };
@ -177,6 +184,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "fieldValueTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,66 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "fieldValue.H"
#include "ListListOps.H"
#include "Pstream.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::fieldValue::combineFields
(
const tmp<Field<Type> >& field
) const
{
List<Field<Type> > allValues(Pstream::nProcs());
allValues[Pstream::myProcNo()] = field();
Pstream::gatherList(allValues);
if (Pstream::master())
{
return tmp<Field<Type> >
(
new Field<Type>
(
ListListOps::combine<Field<Type> >
(
allValues,
accessOp<Field<Type> >()
)
)
);
}
else
{
return field();
}
}
// ************************************************************************* //

View File

@ -126,15 +126,6 @@ public:
return alphaSgs_; return alphaSgs_;
} }
//- Return thermal diffusivity
virtual tmp<volScalarField> alphaEff() const
{
return tmp<volScalarField>
(
new volScalarField("alphaEff", alphaSgs_ + alpha())
);
}
//- Return the sub-grid stress tensor. //- Return the sub-grid stress tensor.
virtual tmp<volSymmTensorField> B() const; virtual tmp<volSymmTensorField> B() const;

View File

@ -127,15 +127,6 @@ public:
return alphaSgs_; return alphaSgs_;
} }
//- Return thermal conductivity
virtual tmp<volScalarField> alphaEff() const
{
return tmp<volScalarField>
(
new volScalarField("alphaEff", alphaSgs_ + alpha())
);
}
//- Return the sub-grid stress tensor //- Return the sub-grid stress tensor
virtual tmp<volSymmTensorField> B() const virtual tmp<volSymmTensorField> B() const
{ {

View File

@ -189,12 +189,6 @@ public:
} }
//- Return the SGS turbulent kinetic energy.
virtual tmp<volScalarField> k() const = 0;
//- Return the SGS turbulent dissipation.
virtual tmp<volScalarField> epsilon() const = 0;
//- Return the SGS turbulent viscosity //- Return the SGS turbulent viscosity
virtual tmp<volScalarField> muSgs() const = 0; virtual tmp<volScalarField> muSgs() const = 0;
@ -210,8 +204,22 @@ public:
//- Return the SGS turbulent thermal diffusivity //- Return the SGS turbulent thermal diffusivity
virtual tmp<volScalarField> alphaSgs() const = 0; virtual tmp<volScalarField> alphaSgs() const = 0;
//- Return the SGS thermal conductivity. //- Return the effective thermal diffusivity
virtual tmp<volScalarField> alphaEff() const = 0; virtual tmp<volScalarField> alphaEff() const
{
return tmp<volScalarField>
(
new volScalarField("alphaEff", alphaSgs() + alpha())
);
}
//- Return the effective turbulence thermal diffusivity for a patch
virtual tmp<scalarField> alphaEff(const label patchI) const
{
return
alphaSgs()().boundaryField()[patchI]
+ alpha().boundaryField()[patchI];
}
//- Return the sub-grid stress tensor. //- Return the sub-grid stress tensor.
virtual tmp<volSymmTensorField> B() const = 0; virtual tmp<volSymmTensorField> B() const = 0;
@ -261,13 +269,13 @@ public:
//- Correct Eddy-Viscosity and related properties. //- Correct Eddy-Viscosity and related properties.
// This calls correct(const tmp<volTensorField>& gradU) by supplying // This calls correct(const tmp<volTensorField>& gradU) by supplying
// gradU calculated locally. // gradU calculated locally.
void correct(); virtual void correct();
//- Correct Eddy-Viscosity and related properties //- Correct Eddy-Viscosity and related properties
virtual void correct(const tmp<volTensorField>& gradU); virtual void correct(const tmp<volTensorField>& gradU);
//- Read LESProperties dictionary //- Read LESProperties dictionary
virtual bool read() = 0; virtual bool read();
}; };

View File

@ -149,15 +149,6 @@ public:
return alphaSgs_; return alphaSgs_;
} }
//- Return thermal conductivity
virtual tmp<volScalarField> alphaEff() const
{
return tmp<volScalarField>
(
new volScalarField("alphaEff", alphaSgs_ + alpha())
);
}
//- Return the sub-grid stress tensor. //- Return the sub-grid stress tensor.
virtual tmp<volSymmTensorField> B() const; virtual tmp<volSymmTensorField> B() const;

View File

@ -153,13 +153,10 @@ public:
return mut_; return mut_;
} }
//- Return the effective turbulent thermal diffusivity //- Return the turbulence thermal diffusivity
virtual tmp<volScalarField> alphaEff() const virtual tmp<volScalarField> alphat() const
{ {
return tmp<volScalarField> return alphat_;
(
new volScalarField("alphaEff", alphat_ + alpha())
);
} }
//- Return the turbulence kinetic energy //- Return the turbulence kinetic energy

View File

@ -162,13 +162,10 @@ public:
return mut_; return mut_;
} }
//- Return the effective turbulent thermal diffusivity //- Return the turbulence thermal diffusivity
virtual tmp<volScalarField> alphaEff() const virtual tmp<volScalarField> alphat() const
{ {
return tmp<volScalarField> return alphat_;
(
new volScalarField("alphaEff", alphat_ + alpha())
);
} }
//- Return the turbulence kinetic energy //- Return the turbulence kinetic energy

View File

@ -146,13 +146,10 @@ public:
return mut_; return mut_;
} }
//- Return the effective turbulent thermal diffusivity //- Return the turbulence thermal diffusivity
virtual tmp<volScalarField> alphaEff() const virtual tmp<volScalarField> alphat() const
{ {
return tmp<volScalarField> return alphat_;
(
new volScalarField("alphaEff", alphat_ + alpha())
);
} }
//- Return the turbulence kinetic energy //- Return the turbulence kinetic energy

View File

@ -265,9 +265,6 @@ public:
} }
//- Return the turbulence viscosity
virtual tmp<volScalarField> mut() const = 0;
//- Return the effective viscosity //- Return the effective viscosity
virtual tmp<volScalarField> muEff() const virtual tmp<volScalarField> muEff() const
{ {
@ -278,22 +275,21 @@ public:
} }
//- Return the effective turbulent thermal diffusivity //- Return the effective turbulent thermal diffusivity
virtual tmp<volScalarField> alphaEff() const = 0; virtual tmp<volScalarField> alphaEff() const
{
return tmp<volScalarField>
(
new volScalarField("alphaEff", alphat() + alpha())
);
}
//- Return the turbulence kinetic energy //- Return the effective turbulent thermal diffusivity for a patch
virtual tmp<volScalarField> k() const = 0; virtual tmp<scalarField> alphaEff(const label patchI) const
{
//- Return the turbulence kinetic energy dissipation rate return
virtual tmp<volScalarField> epsilon() const = 0; alphat()().boundaryField()[patchI]
+ alpha().boundaryField()[patchI];
//- Return the Reynolds stress tensor }
virtual tmp<volSymmTensorField> R() const = 0;
//- Return the effective stress tensor including the laminar stress
virtual tmp<volSymmTensorField> devRhoReff() const = 0;
//- Return the source term for the momentum equation
virtual tmp<fvVectorMatrix> divDevRhoReff(volVectorField& U) const = 0;
//- Return yPlus for the given patch //- Return yPlus for the given patch
virtual tmp<scalarField> yPlus virtual tmp<scalarField> yPlus
@ -303,10 +299,10 @@ public:
) const; ) const;
//- Solve the turbulence equations and correct the turbulence viscosity //- Solve the turbulence equations and correct the turbulence viscosity
virtual void correct() = 0; virtual void correct();
//- Read RASProperties dictionary //- Read RASProperties dictionary
virtual bool read() = 0; virtual bool read();
}; };

View File

@ -142,13 +142,10 @@ public:
return mut_; return mut_;
} }
//- Return the effective turbulent thermal diffusivity //- Return the turbulence thermal diffusivity
virtual tmp<volScalarField> alphaEff() const virtual tmp<volScalarField> alphat() const
{ {
return tmp<volScalarField> return alphat_;
(
new volScalarField("alphaEff", alphat_ + alpha())
);
} }
//- Return the turbulence kinetic energy //- Return the turbulence kinetic energy

View File

@ -178,13 +178,10 @@ public:
return mut_; return mut_;
} }
//- Return the effective turbulent thermal diffusivity //- Return the turbulence thermal diffusivity
virtual tmp<volScalarField> alphaEff() const virtual tmp<volScalarField> alphat() const
{ {
return tmp<volScalarField> return alphat_;
(
new volScalarField("alphaEff", alphat_ + alpha())
);
} }
//- Return the turbulence kinetic energy //- Return the turbulence kinetic energy

View File

@ -37,6 +37,22 @@ namespace Foam
namespace compressible namespace compressible
{ {
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char*
NamedEnum<turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceType, 2>::
names[] =
{
"power",
"flux"
};
const
NamedEnum<turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceType, 2>
turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceTypeNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
turbulentHeatFluxTemperatureFvPatchScalarField:: turbulentHeatFluxTemperatureFvPatchScalarField::
@ -47,8 +63,8 @@ turbulentHeatFluxTemperatureFvPatchScalarField
) )
: :
fixedGradientFvPatchScalarField(p, iF), fixedGradientFvPatchScalarField(p, iF),
q_(p.size(), 0.0), heatSource_(hsPower),
rhoName_("rho") q_(p.size(), 0.0)
{} {}
@ -62,8 +78,8 @@ turbulentHeatFluxTemperatureFvPatchScalarField
) )
: :
fixedGradientFvPatchScalarField(ptf, p, iF, mapper), fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
q_(ptf.q_, mapper), heatSource_(ptf.heatSource_),
rhoName_(ptf.rhoName_) q_(ptf.q_, mapper)
{} {}
@ -76,8 +92,8 @@ turbulentHeatFluxTemperatureFvPatchScalarField
) )
: :
fixedGradientFvPatchScalarField(p, iF), fixedGradientFvPatchScalarField(p, iF),
q_("q", dict, p.size()), heatSource_(heatSourceTypeNames_.read(dict.lookup("heatSource"))),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")) q_("q", dict, p.size())
{ {
fvPatchField<scalar>::operator=(patchInternalField()); fvPatchField<scalar>::operator=(patchInternalField());
gradient() = 0.0; gradient() = 0.0;
@ -91,8 +107,8 @@ turbulentHeatFluxTemperatureFvPatchScalarField
) )
: :
fixedGradientFvPatchScalarField(thftpsf), fixedGradientFvPatchScalarField(thftpsf),
q_(thftpsf.q_), heatSource_(thftpsf.heatSource_),
rhoName_(thftpsf.rhoName_) q_(thftpsf.q_)
{} {}
@ -104,8 +120,8 @@ turbulentHeatFluxTemperatureFvPatchScalarField
) )
: :
fixedGradientFvPatchScalarField(thftpsf, iF), fixedGradientFvPatchScalarField(thftpsf, iF),
q_(thftpsf.q_), heatSource_(thftpsf.heatSource_),
rhoName_(thftpsf.rhoName_) q_(thftpsf.q_)
{} {}
@ -150,22 +166,39 @@ void turbulentHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalarField alphaEffp = rasModel.alphaEff()().boundaryField()[patchI]; const scalarField alphaEffp = rasModel.alphaEff(patchI);
const basicThermo& thermo =
db().lookupObject<basicThermo>("thermophysicalProperties");
// const scalarField& Tp = thermo.T().boundaryField()[patchI];
const scalarField& Tp = *this; const scalarField& Tp = *this;
const scalarField Cpp = thermo.Cp(Tp, patchI); const scalarField Cpp = rasModel.thermo().Cp(Tp, patchI);
const scalarField& rhop = switch (heatSource_)
patch().lookupPatchField<volScalarField, scalar>(rhoName_); {
case hsPower:
const scalar Ap = gSum(patch().magSf()); {
const scalar Ap = gSum(patch().magSf());
gradient() = q_/(Ap*rhop*Cpp*alphaEffp); gradient() = q_/(Ap*Cpp*alphaEffp);
break;
}
case hsFlux:
{
gradient() = q_/(Cpp*alphaEffp);
break;
}
default:
{
FatalErrorIn
(
"turbulentHeatFluxTemperatureFvPatchScalarField"
"("
"const fvPatch&, "
"const DimensionedField<scalar, volMesh>&, "
"const dictionary&"
")"
) << "Unknown heat source type. Valid types are: "
<< heatSourceTypeNames_ << nl << exit(FatalError);
}
}
fixedGradientFvPatchScalarField::updateCoeffs(); fixedGradientFvPatchScalarField::updateCoeffs();
} }
@ -177,8 +210,9 @@ void turbulentHeatFluxTemperatureFvPatchScalarField::write
) const ) const
{ {
fvPatchScalarField::write(os); fvPatchScalarField::write(os);
os.writeKeyword("heatSource") << heatSourceTypeNames_[heatSource_]
<< token::END_STATEMENT << nl;
q_.writeEntry("q", os); q_.writeEntry("q", os);
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
gradient().writeEntry("gradient", os); gradient().writeEntry("gradient", os);
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -26,7 +26,20 @@ Class
Foam::turbulentHeatFluxTemperatureFvPatchScalarField Foam::turbulentHeatFluxTemperatureFvPatchScalarField
Description Description
Fixed heat flux boundary condition for temperature. Fixed heat boundary condition to specify temperature gradient. Input
heat source either specified in terms of an absolute power [W], or as a
flux [W/m2].
Example usage:
hotWall
{
type compressible::turbulentHeatFluxTemperature;
heatSource flux; // power [W]; flux [W/m2]
q uniform 10; // heat power or flux
value uniform 300; // initial temperature value
}
SourceFiles SourceFiles
turbulentHeatFluxTemperatureFvPatchScalarField.C turbulentHeatFluxTemperatureFvPatchScalarField.C
@ -38,6 +51,7 @@ SourceFiles
#include "fvPatchFields.H" #include "fvPatchFields.H"
#include "fixedGradientFvPatchFields.H" #include "fixedGradientFvPatchFields.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -47,20 +61,37 @@ namespace compressible
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class turbulentHeatFluxTemperatureFvPatchScalarField Declaration Class turbulentHeatFluxTemperatureFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class turbulentHeatFluxTemperatureFvPatchScalarField class turbulentHeatFluxTemperatureFvPatchScalarField
: :
public fixedGradientFvPatchScalarField public fixedGradientFvPatchScalarField
{ {
// Private data public:
//- Heat flux [W] // Data types
scalarField q_;
//- Name of density field //- Enumeration listing the possible hest source input modes
word rhoName_; enum heatSourceType
{
hsPower,
hsFlux
};
private:
// Private data
//- Heat source type names
static const NamedEnum<heatSourceType, 2> heatSourceTypeNames_;
//- Heat source type
heatSourceType heatSource_;
//- Heat power [W] or flux [W/m2]
scalarField q_;
public: public:

View File

@ -222,7 +222,7 @@ void alphatJayatillekeWallFunctionFvPatchScalarField::updateCoeffs()
const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
const fvPatchScalarField& hw = const fvPatchScalarField& hw =
patch().lookupPatchField<volScalarField, scalar>("h"); rasModel.thermo().h().boundaryField()[patchI];
// Heat flux [W/m2] - lagging alphatw // Heat flux [W/m2] - lagging alphatw
const scalarField qDot = (alphaw + alphatw)*hw.snGrad(); const scalarField qDot = (alphaw + alphatw)*hw.snGrad();

View File

@ -138,13 +138,10 @@ public:
return mut_; return mut_;
} }
//- Return the effective turbulent thermal diffusivity //- Return the turbulence thermal diffusivity
virtual tmp<volScalarField> alphaEff() const virtual tmp<volScalarField> alphat() const
{ {
return tmp<volScalarField> return alphat_;
(
new volScalarField("alphaEff", alphat_ + alpha())
);
} }
//- Return the turbulence kinetic energy //- Return the turbulence kinetic energy

View File

@ -222,13 +222,10 @@ public:
return mut_; return mut_;
} }
//- Return the effective turbulent thermal diffusivity //- Return the turbulence thermal diffusivity
virtual tmp<volScalarField> alphaEff() const virtual tmp<volScalarField> alphat() const
{ {
return tmp<volScalarField> return alphat_;
(
new volScalarField("alphaEff", alphat_ + alpha())
);
} }
//- Return the turbulence kinetic energy //- Return the turbulence kinetic energy

View File

@ -78,6 +78,27 @@ tmp<volScalarField> laminar::mut() const
} }
tmp<volScalarField> laminar::alphat() const
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"alphat",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("alphat", alpha().dimensions(), 0.0)
)
);
}
tmp<volScalarField> laminar::k() const tmp<volScalarField> laminar::k() const
{ {
return tmp<volScalarField> return tmp<volScalarField>

View File

@ -89,6 +89,9 @@ public:
return tmp<volScalarField>(new volScalarField("muEff", mu())); return tmp<volScalarField>(new volScalarField("muEff", mu()));
} }
//- Return the turbulence thermal diffusivity, i.e. 0 for laminar flow
virtual tmp<volScalarField> alphat() const;
//- Return the effective turbulent thermal diffusivity, //- Return the effective turbulent thermal diffusivity,
// i.e. the laminar thermal diffusivity // i.e. the laminar thermal diffusivity
virtual tmp<volScalarField> alphaEff() const virtual tmp<volScalarField> alphaEff() const

View File

@ -159,13 +159,10 @@ public:
return mut_; return mut_;
} }
//- Return the effective turbulent thermal diffusivity //- Return the turbulence thermal diffusivity
virtual tmp<volScalarField> alphaEff() const virtual tmp<volScalarField> alphat() const
{ {
return tmp<volScalarField> return alphat_;
(
new volScalarField("alphaEff", alphat_ + alpha())
);
} }
//- Return the turbulence kinetic energy //- Return the turbulence kinetic energy

View File

@ -96,6 +96,27 @@ tmp<volScalarField> laminar::mut() const
} }
tmp<volScalarField> laminar::alphat() const
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"alphat",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("alphat", alpha().dimensions(), 0.0)
)
);
}
tmp<volScalarField> laminar::k() const tmp<volScalarField> laminar::k() const
{ {
return tmp<volScalarField> return tmp<volScalarField>

View File

@ -99,6 +99,9 @@ public:
return tmp<volScalarField>(new volScalarField("muEff", mu())); return tmp<volScalarField>(new volScalarField("muEff", mu()));
} }
//- Return the turbulence thermal diffusivity, i.e. 0 for laminar flow
virtual tmp<volScalarField> alphat() const;
//- Return the effective turbulent thermal diffusivity, //- Return the effective turbulent thermal diffusivity,
// i.e. the laminar thermal diffusivity // i.e. the laminar thermal diffusivity
virtual tmp<volScalarField> alphaEff() const virtual tmp<volScalarField> alphaEff() const
@ -106,6 +109,13 @@ public:
return tmp<volScalarField>(new volScalarField("alphaEff", alpha())); return tmp<volScalarField>(new volScalarField("alphaEff", alpha()));
} }
//- Return the effective turbulent thermal diffusivity for a patch,
// i.e. the laminar thermal diffusivity
virtual tmp<scalarField> alphaEff(const label patchI) const
{
return alpha().boundaryField()[patchI];
}
//- Return the turbulence kinetic energy, i.e. 0 for laminar flow //- Return the turbulence kinetic energy, i.e. 0 for laminar flow
virtual tmp<volScalarField> k() const; virtual tmp<volScalarField> k() const;

View File

@ -192,9 +192,15 @@ public:
//- Return the effective viscosity //- Return the effective viscosity
virtual tmp<volScalarField> muEff() const = 0; virtual tmp<volScalarField> muEff() const = 0;
//- Return the effective turbulent thermal diffusivity //- Return the turbulence thermal diffusivity
virtual tmp<volScalarField> alphat() const = 0;
//- Return the effective turbulence thermal diffusivity
virtual tmp<volScalarField> alphaEff() const = 0; virtual tmp<volScalarField> alphaEff() const = 0;
//- Return the effective turbulence thermal diffusivity for a patch
virtual tmp<scalarField> alphaEff(const label patchI) const = 0;
//- Return the turbulence kinetic energy //- Return the turbulence kinetic energy
virtual tmp<volScalarField> k() const = 0; virtual tmp<volScalarField> k() const = 0;

View File

@ -36,6 +36,22 @@ namespace Foam
namespace incompressible namespace incompressible
{ {
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char*
NamedEnum<turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceType, 2>::
names[] =
{
"power",
"flux"
};
const
NamedEnum<turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceType, 2>
turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceTypeNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
turbulentHeatFluxTemperatureFvPatchScalarField:: turbulentHeatFluxTemperatureFvPatchScalarField::
@ -46,6 +62,7 @@ turbulentHeatFluxTemperatureFvPatchScalarField
) )
: :
fixedGradientFvPatchScalarField(p, iF), fixedGradientFvPatchScalarField(p, iF),
heatSource_(hsPower),
q_(p.size(), 0.0), q_(p.size(), 0.0),
alphaEffName_("undefinedAlphaEff"), alphaEffName_("undefinedAlphaEff"),
CpName_("undefinedCp") CpName_("undefinedCp")
@ -62,6 +79,7 @@ turbulentHeatFluxTemperatureFvPatchScalarField
) )
: :
fixedGradientFvPatchScalarField(ptf, p, iF, mapper), fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
heatSource_(ptf.heatSource_),
q_(ptf.q_, mapper), q_(ptf.q_, mapper),
alphaEffName_(ptf.alphaEffName_), alphaEffName_(ptf.alphaEffName_),
CpName_(ptf.CpName_) CpName_(ptf.CpName_)
@ -77,6 +95,7 @@ turbulentHeatFluxTemperatureFvPatchScalarField
) )
: :
fixedGradientFvPatchScalarField(p, iF), fixedGradientFvPatchScalarField(p, iF),
heatSource_(heatSourceTypeNames_.read(dict.lookup("heatSource"))),
q_("q", dict, p.size()), q_("q", dict, p.size()),
alphaEffName_(dict.lookup("alphaEff")), alphaEffName_(dict.lookup("alphaEff")),
CpName_(dict.lookup("Cp")) CpName_(dict.lookup("Cp"))
@ -93,6 +112,7 @@ turbulentHeatFluxTemperatureFvPatchScalarField
) )
: :
fixedGradientFvPatchScalarField(thftpsf), fixedGradientFvPatchScalarField(thftpsf),
heatSource_(thftpsf.heatSource_),
q_(thftpsf.q_), q_(thftpsf.q_),
alphaEffName_(thftpsf.alphaEffName_), alphaEffName_(thftpsf.alphaEffName_),
CpName_(thftpsf.CpName_) CpName_(thftpsf.CpName_)
@ -107,6 +127,7 @@ turbulentHeatFluxTemperatureFvPatchScalarField
) )
: :
fixedGradientFvPatchScalarField(thftpsf, iF), fixedGradientFvPatchScalarField(thftpsf, iF),
heatSource_(thftpsf.heatSource_),
q_(thftpsf.q_), q_(thftpsf.q_),
alphaEffName_(thftpsf.alphaEffName_), alphaEffName_(thftpsf.alphaEffName_),
CpName_(thftpsf.CpName_) CpName_(thftpsf.CpName_)
@ -156,7 +177,33 @@ void turbulentHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
const scalarField& Cpp = const scalarField& Cpp =
patch().lookupPatchField<volScalarField, scalar>(CpName_); patch().lookupPatchField<volScalarField, scalar>(CpName_);
gradient() = q_/(Cpp*alphaEffp); switch (heatSource_)
{
case hsPower:
{
const scalar Ap = gSum(patch().magSf());
gradient() = q_/(Ap*Cpp*alphaEffp);
break;
}
case hsFlux:
{
gradient() = q_/(Cpp*alphaEffp);
break;
}
default:
{
FatalErrorIn
(
"turbulentHeatFluxTemperatureFvPatchScalarField"
"("
"const fvPatch&, "
"const DimensionedField<scalar, volMesh>&, "
"const dictionary&"
")"
) << "Unknown heat source type. Valid types are: "
<< heatSourceTypeNames_ << nl << exit(FatalError);
}
}
fixedGradientFvPatchScalarField::updateCoeffs(); fixedGradientFvPatchScalarField::updateCoeffs();
} }
@ -165,6 +212,8 @@ void turbulentHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
void turbulentHeatFluxTemperatureFvPatchScalarField::write(Ostream& os) const void turbulentHeatFluxTemperatureFvPatchScalarField::write(Ostream& os) const
{ {
fixedGradientFvPatchScalarField::write(os); fixedGradientFvPatchScalarField::write(os);
os.writeKeyword("heatSource") << heatSourceTypeNames_[heatSource_]
<< token::END_STATEMENT << nl;
q_.writeEntry("q", os); q_.writeEntry("q", os);
os.writeKeyword("alphaEff") << alphaEffName_ << token::END_STATEMENT << nl; os.writeKeyword("alphaEff") << alphaEffName_ << token::END_STATEMENT << nl;
os.writeKeyword("Cp") << CpName_ << token::END_STATEMENT << nl; os.writeKeyword("Cp") << CpName_ << token::END_STATEMENT << nl;

View File

@ -26,7 +26,22 @@ Class
Foam::turbulentHeatFluxTemperatureFvPatchScalarField Foam::turbulentHeatFluxTemperatureFvPatchScalarField
Description Description
Fixed heat flux boundary condition for temperature. Fixed heat boundary condition to specify temperature gradient. Input
heat source either specified in terms of an absolute power [W], or as a
flux [W/m2].
Example usage:
hotWall
{
type turbulentHeatFluxTemperature;
heatSource flux; // power [W]; flux [W/m2]
q uniform 10; // heat power or flux
alphaEff alphaEff; // alphaEff field name;
// alphaEff in [kg/m/s]
Cp Cp; // Cp field name; Cp in [J/kg/K]
value uniform 300; // initial temperature value
}
SourceFiles SourceFiles
turbulentHeatFluxTemperatureFvPatchScalarField.C turbulentHeatFluxTemperatureFvPatchScalarField.C
@ -38,6 +53,7 @@ SourceFiles
#include "fvPatchFields.H" #include "fvPatchFields.H"
#include "fixedGradientFvPatchFields.H" #include "fixedGradientFvPatchFields.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,16 +70,37 @@ class turbulentHeatFluxTemperatureFvPatchScalarField
: :
public fixedGradientFvPatchScalarField public fixedGradientFvPatchScalarField
{ {
// Private data public:
//- Heat flux [W/m2] // Data types
scalarField q_;
//- Name of effective thermal diffusivity field //- Enumeration listing the possible hest source input modes
word alphaEffName_; enum heatSourceType
{
hsPower,
hsFlux
};
//- Name of specific heat capacity field
word CpName_; private:
// Private data
//- Heat source type names
static const NamedEnum<heatSourceType, 2> heatSourceTypeNames_;
//- Heat source type
heatSourceType heatSource_;
//- Heat power [W] or flux [W/m2]
// NOTE: to be divided by density, rho, if used in kinematic form
scalarField q_;
//- Name of effective thermal diffusivity field
word alphaEffName_;
//- Name of specific heat capacity field
word CpName_;
public: public:

View File

@ -23,411 +23,7 @@ boundaryField
floor floor
{ {
type fixedValue; type fixedValue;
value nonuniform List<scalar> value uniform 300;
400
(
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
600
600
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
600
600
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
)
;
} }
ceiling ceiling
{ {

View File

@ -23,411 +23,7 @@ boundaryField
floor floor
{ {
type fixedValue; type fixedValue;
value nonuniform List<scalar> value uniform 300;
400
(
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
600
600
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
600
600
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
300
)
;
} }
ceiling ceiling
{ {

View File

@ -41,7 +41,7 @@ boundaryField
type compressible::turbulentMixingLengthFrequencyInlet; type compressible::turbulentMixingLengthFrequencyInlet;
mixingLength 0.007; mixingLength 0.007;
k k; k k;
value uniform 4.5-3; value uniform 4.5e-3;
} }
outlet outlet
{ {