mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: reference function object - retrieve reference using Function1
Note: previous behaviour to set the reference to a cell value can be recovered by using the new 'sample' Function1
This commit is contained in:
committed by
Mark Olesen
parent
70b55be684
commit
2c2310dc17
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,7 +25,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "interpolation.H"
|
||||
#include "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -40,36 +40,24 @@ bool Foam::functionObjects::reference::calcType()
|
||||
{
|
||||
const VolFieldType& vf = *vfPtr;
|
||||
|
||||
// non-mandatory
|
||||
dimensioned<Type> offset("offset", vf.dimensions(), Zero, localDict_);
|
||||
|
||||
dimensioned<Type> cellValue("value", vf.dimensions(), Zero);
|
||||
dimensioned<Type> refValue("refValue", vf.dimensions(), Zero);
|
||||
|
||||
if (positionIsSet_)
|
||||
{
|
||||
cellValue.value() = -pTraits<Type>::one*GREAT;
|
||||
autoPtr<Function1<Type>> valuePtr
|
||||
(
|
||||
Function1<Type>::New("refValue", localDict_, &mesh_)
|
||||
);
|
||||
|
||||
// Might trigger parallel comms (e.g. volPointInterpolation, if
|
||||
// result is not yet cached) so have all processors do it
|
||||
autoPtr<interpolation<Type>> interpolator
|
||||
(
|
||||
interpolation<Type>::New(interpolationScheme_, vf)
|
||||
);
|
||||
refValue.value() = valuePtr->value(this->time().value());
|
||||
|
||||
if (celli_ != -1)
|
||||
{
|
||||
cellValue.value() =
|
||||
interpolator().interpolate(position_, celli_, -1);
|
||||
}
|
||||
|
||||
reduce(cellValue.value(), maxOp<Type>());
|
||||
|
||||
Log << " sampled value: " << cellValue.value() << endl;
|
||||
}
|
||||
Info<< " Reference value: " << refValue.value() << endl;
|
||||
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
scale_*(vf - cellValue + offset)
|
||||
scale_*(vf - refValue + offset)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user