Commit ded4f0b2 authored by Andrew Heather's avatar Andrew Heather
Browse files

added option to set reference by point

parent 37cae8e7
......@@ -33,15 +33,68 @@ void Foam::setRefCell
const volScalarField& field,
const dictionary& dict,
label& refCelli,
scalar& refValue
scalar& refValue,
bool forceReference
)
{
if (field.needReference())
if (field.needReference() || forceReference)
{
word refCellName = field.name() + "RefCell";
word refPointName = field.name() + "RefPoint";
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));
}
}
......
......@@ -52,7 +52,8 @@ void setRefCell
const volScalarField& field,
const dictionary& dict,
label& refCelli,
scalar& refValue
scalar& refValue,
bool forceReference = false
);
}
......
......@@ -483,7 +483,7 @@ void Foam::fvMatrix<Type>::setReference
{
if (psi_.needReference() || forceReference)
{
if (Pstream::master())
if (cell >= 0)
{
source()[cell] += diag()[cell]*value;
diag()[cell] += diag()[cell];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment