Improve reference handling.

This commit is contained in:
henry 2009-05-11 21:19:55 +01:00
parent f983e0b42e
commit f2d00b3230
4 changed files with 28 additions and 14 deletions

View File

@ -34,7 +34,7 @@ void Foam::setRefCell
const dictionary& dict,
label& refCelli,
scalar& refValue,
bool forceReference
const bool forceReference
)
{
if (field.needReference() || forceReference)
@ -119,4 +119,15 @@ void Foam::setRefCell
}
Foam::scalar Foam::getRefCellValue
(
const volScalarField& field,
const label refCelli
)
{
scalar refCellValue = (refCelli >= 0 ? field[refCelli] : 0.0);
return returnReduce<label>(refCellValue, sumOp<scalar>());
}
// ************************************************************************* //

View File

@ -49,11 +49,18 @@ namespace Foam
// but which is not on a cyclic, symmetry or processor patch.
void setRefCell
(
const volScalarField&,
const dictionary&,
label& refCellI,
const volScalarField& field,
const dictionary& dict,
label& refCelli,
scalar& refValue,
bool forceReference = false
const bool forceReference = false
);
//- Return the current value of field in the reference cell
scalar getRefCellValue
(
const volScalarField& field,
const label refCelli
);
}

View File

@ -472,22 +472,18 @@ void Foam::fvMatrix<Type>::setValues
}
// Set reference level for solution
template<class Type>
void Foam::fvMatrix<Type>::setReference
(
const label cell,
const label celli,
const Type& value,
const bool forceReference
)
{
if (psi_.needReference() || forceReference)
if (celli >= 0 && (psi_.needReference() || forceReference))
{
if (cell >= 0)
{
source()[cell] += diag()[cell]*value;
diag()[cell] += diag()[cell];
}
source()[celli] += diag()[celli]*value;
diag()[celli] += diag()[celli];
}
}

View File

@ -326,7 +326,7 @@ public:
//- Set reference level for solution
void setReference
(
const label cell,
const label celli,
const Type& value,
const bool forceReference = false
);