added option to set reference by point

This commit is contained in:
andy
2008-10-30 18:49:14 +00:00
parent 37cae8e7ef
commit ded4f0b2a4
3 changed files with 59 additions and 5 deletions

View File

@ -33,15 +33,68 @@ void Foam::setRefCell
const volScalarField& field, const volScalarField& field,
const dictionary& dict, const dictionary& dict,
label& refCelli, label& refCelli,
scalar& refValue scalar& refValue,
bool forceReference
) )
{ {
if (field.needReference()) if (field.needReference() || forceReference)
{ {
word refCellName = field.name() + "RefCell"; word refCellName = field.name() + "RefCell";
word refPointName = field.name() + "RefPoint";
word refValueName = field.name() + "RefValue"; word refValueName = field.name() + "RefValue";
refCelli = readLabel(dict.lookup(refCellName)); if (dict.found(refCellName))
{
if (Pstream::master())
{
refCelli = readLabel(dict.lookup(refCellName));
}
else
{
refCelli = -1;
}
}
else if (dict.found(refPointName))
{
point refPointi(dict.lookup(refPointName));
refCelli = field.mesh().findCell(refPointi);
label hasRef = (refCelli >= 0 ? 1 : 0);
label sumHasRef = returnReduce<label>(hasRef, sumOp<label>());
if (sumHasRef != 1)
{
FatalErrorIn
(
"void Foam::setRefCell"
"("
" const volScalarField&,"
" const dictionary&,"
" label& scalar&,"
" bool"
")"
)
<< "Unable to set reference cell for field " << field.name()
<< nl << " Reference point " << refPointName
<< " found on multiple domains" << nl << abort(FatalError);
}
}
else
{
FatalErrorIn
(
"void Foam::setRefCell"
"("
" const volScalarField&,"
" const dictionary&,"
" label& scalar&,"
" bool"
")"
)
<< "Unable to set reference cell for field" << field.name() << nl
<< " Please supply either " << refCellName
<< " or " << refPointName << nl << abort(FatalError);
}
refValue = readScalar(dict.lookup(refValueName)); refValue = readScalar(dict.lookup(refValueName));
} }
} }

View File

@ -52,7 +52,8 @@ void setRefCell
const volScalarField& field, const volScalarField& field,
const dictionary& dict, const dictionary& dict,
label& refCelli, label& refCelli,
scalar& refValue scalar& refValue,
bool forceReference = false
); );
} }

View File

@ -483,7 +483,7 @@ void Foam::fvMatrix<Type>::setReference
{ {
if (psi_.needReference() || forceReference) if (psi_.needReference() || forceReference)
{ {
if (Pstream::master()) if (cell >= 0)
{ {
source()[cell] += diag()[cell]*value; source()[cell] += diag()[cell]*value;
diag()[cell] += diag()[cell]; diag()[cell] += diag()[cell];