/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2026 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
\*---------------------------------------------------------------------------*/
#include "DimensionedFunction1.H"
// * * * * * * * * * * * * * * Private Constructors * * * * * * * * * * * * //
template
Foam::DimensionedFunction1::DimensionedFunction1
(
const word& name,
const Function1s::unitSets& units,
const dictionary& dict
)
:
xDimensions_(units.x.dimensions()),
valueDimensions_(units.value.dimensions()),
function_(Function1::New(name, units, dict))
{}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
template
<
class GeoMesh,
template class ResultPrimitiveField,
template class XPrimitiveField
>
void Foam::DimensionedFunction1::value
(
DimensionedField& result,
const DimensionedField& x
) const
{
x.dimensions() = xDimensions_;
result.dimensions() = valueDimensions_;
result.primitiveFieldRef() = function_->value(x.primitiveField());
}
template
template
<
class GeoMesh,
template class ResultPrimitiveField,
template class XPrimitiveField
>
void Foam::DimensionedFunction1::derivative
(
DimensionedField& result,
const DimensionedField& x
) const
{
x.dimensions() = xDimensions_;
result.dimensions() = valueDimensions_/xDimensions_;
result.primitiveFieldRef() = function_->derivative(x.primitiveField());
}
template
template
<
class GeoMesh,
template class ResultPrimitiveField,
template class XPrimitiveField
>
void Foam::DimensionedFunction1::value
(
GeometricField& result,
const GeometricField& x
) const
{
value(result.internalFieldRef(), x.internalField());
typename GeometricField::BoundaryField&
bresult = result.boundaryFieldRef();
const typename
GeometricField::BoundaryField&
bx = x.boundaryField();
forAll(bresult, patchi)
{
bresult[patchi] = function_->value(bx[patchi]);
}
}
template
template
<
class GeoMesh,
template class ResultPrimitiveField,
template class XPrimitiveField
>
void Foam::DimensionedFunction1::derivative
(
GeometricField& result,
const GeometricField& x
) const
{
derivative(result.internalFieldRef(), x.internalField());
typename GeometricField::BoundaryField&
bresult = result.boundaryFieldRef();
const typename
GeometricField::BoundaryField&
bx = x.boundaryField();
forAll(bresult, patchi)
{
bresult[patchi] = function_->derivative(bx[patchi]);
}
}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
template
Foam::autoPtr>
Foam::DimensionedFunction1::New
(
const word& name,
const Function1s::unitSets& units,
const dictionary& dict
)
{
return
autoPtr>
(
new DimensionedFunction1(name, units, dict)
);
}
template
Foam::autoPtr>
Foam::DimensionedFunction1::New
(
const word& name,
const unitSet& xUnits,
const unitSet& valueUnits,
const dictionary& dict
)
{
return
autoPtr>
(
new DimensionedFunction1(name, {xUnits, valueUnits}, dict)
);
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template
Foam::tmp> Foam::DimensionedFunction1::value
(
const scalarField& x
) const
{
return function_->value(x);
}
template
Foam::tmp> Foam::DimensionedFunction1::derivative
(
const scalarField& x
) const
{
return function_->derivative(x);
}
template
template class XPrimitiveField>
Foam::tmp>
Foam::DimensionedFunction1::value
(
const DimensionedField& x
) const
{
tmp> tresult
(
DimensionedField::New
(
word(function_->name(), '(', x.name(), ')'),
x.mesh(),
valueDimensions_
)
);
value(tresult.ref(), x);
return tresult;
}
template
template class XPrimitiveField>
Foam::tmp>
Foam::DimensionedFunction1::derivative
(
const DimensionedField& x
) const
{
tmp> tresult
(
DimensionedField::New
(
word(function_->name(), "'(", x.name(), ')'),
x.mesh(),
valueDimensions_/xDimensions_
)
);
derivative(tresult.ref(), x);
return tresult;
}
template
template class XPrimitiveField>
Foam::tmp>
Foam::DimensionedFunction1::value
(
const tmp>& tx
) const
{
tmp> tresult = value(tx());
tx.clear();
return tresult;
}
template
template class XPrimitiveField>
Foam::tmp>
Foam::DimensionedFunction1::derivative
(
const tmp>& tx
) const
{
tmp> tresult = derivative(tx());
tx.clear();
return tresult;
}
template
template class XPrimitiveField>
Foam::tmp>
Foam::DimensionedFunction1::value
(
const GeometricField& x
) const
{
tmp> tresult
(
GeometricField::New
(
word(function_->name(), '(', x.name(), ')'),
x.mesh(),
valueDimensions_
)
);
value(tresult.ref(), x);
return tresult;
}
template
template class XPrimitiveField>
Foam::tmp>
Foam::DimensionedFunction1::derivative
(
const GeometricField& x
) const
{
tmp> tresult
(
GeometricField::New
(
word(function_->name(), "'(", x.name(), ')'),
x.mesh(),
valueDimensions_/xDimensions_
)
);
derivative(tresult.ref(), x);
return tresult;
}
template
template class XPrimitiveField>
Foam::tmp>
Foam::DimensionedFunction1::value
(
const tmp>& tx
) const
{
tmp> tresult = value(tx());
tx.clear();
return tresult;
}
template
template class XPrimitiveField>
Foam::tmp>
Foam::DimensionedFunction1::derivative
(
const tmp>& tx
) const
{
tmp> tresult = derivative(tx());
tx.clear();
return tresult;
}
// ************************************************************************* //