Bugfix: thermal model needs to calculate the volume of component

This commit is contained in:
Hrvoje Jasak 2016-04-17 21:14:11 +01:00
parent d1e245694f
commit 07b473621f
2 changed files with 39 additions and 6 deletions

View file

@ -31,7 +31,12 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(constantThermalSource, 0); defineTypeNameAndDebug(constantThermalSource, 0);
addToRunTimeSelectionTable(thermalSource, constantThermalSource, dictionary); addToRunTimeSelectionTable
(
thermalSource,
constantThermalSource,
dictionary
);
} }
@ -78,9 +83,34 @@ void Foam::constantThermalSource::addSource(volScalarField& source) const
const labelList& cells = mesh().cellZones()[zoneID]; const labelList& cells = mesh().cellZones()[zoneID];
forAll(cells, cellI) // Sum up the volumes
scalar sumVolume = 0;
const scalarField& V = mesh().V().field();
forAll (cells, cellI)
{ {
source[cells[cellI]] = S_.value(); sumVolume += V[cells[cellI]];
}
reduce(sumVolume, sumOp<scalar>());
if (sumVolume < SMALL)
{
FatalErrorIn
(
"constantThermalSource::addSourcex()\n"
) << "Zone " << zones_[zoneI]
<< " specified in source " << name()
<< " has zero volume: " << sumVolume
<< abort(FatalError);
}
const scalar SoverV = S_.value()/sumVolume;
forAll (cells, cellI)
{
source[cells[cellI]] = SoverV;
} }
} }
} }

View file

@ -25,7 +25,9 @@ Class
constantThermalSource constantThermalSource
Description Description
Constant thermal properties Constant thermal source, given in Watts for the component
consisting of face zones. Therefore, S from dictionary is divided by
total volume of the component
Author Author
Henrik Rusche, Wikki GmbH. All rights reserved. Henrik Rusche, Wikki GmbH. All rights reserved.
@ -58,9 +60,10 @@ class constantThermalSource
//- Strengh of the source //- Strengh of the source
dimensionedScalar S_; dimensionedScalar S_;
//- list of cell zones //- List of cell zones
const wordList zones_; const wordList zones_;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct