ENH: use tmp field factory methods [2] (#2723)

- src/finiteVolume, src/finiteArea
This commit is contained in:
Mark Olesen 2024-01-23 09:33:54 +01:00
parent 21196d8c0b
commit 092db087c9
47 changed files with 310 additions and 459 deletions

View File

@ -1207,7 +1207,7 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
)
{
checkMethod(A, B, "+");
tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
auto tC = tmp<faMatrix<Type>>::New(A);
tC.ref() += B;
return tC;
}
@ -1262,7 +1262,7 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
const faMatrix<Type>& A
)
{
tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
auto tC = tmp<faMatrix<Type>>::New(A);
tC.ref().negate();
return tC;
}
@ -1288,7 +1288,7 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
)
{
checkMethod(A, B, "-");
tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
auto tC = tmp<faMatrix<Type>>::New(A);
tC.ref() -= B;
return tC;
}

View File

@ -192,8 +192,8 @@ Foam::SolverPerformance<Type> Foam::faMatrix<Type>::solve()
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::faMatrix<Type>::residual() const
{
tmp<Field<Type>> tres(new Field<Type>(source_));
Field<Type>& res = tres().ref();
auto tres = tmp<Field<Type>>::New(source_);
auto& res = tres().ref();
addBoundarySource(res);

View File

@ -108,10 +108,7 @@ Foam::fixedValueFaPatchField<Type>::valueInternalCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Foam::zero{});
}

View File

@ -130,8 +130,8 @@ Foam::cyclicFaPatchField<Type>::patchNeighbourField() const
const Field<Type>& iField = this->primitiveField();
const labelUList& faceCells = cyclicPatch_.faceCells();
tmp<Field<Type>> tpnf(new Field<Type>(this->size()));
Field<Type>& pnf = tpnf.ref();
auto tpnf = tmp<Field<Type>>::New(this->size());
auto& pnf = tpnf.ref();
const label sizeby2 = this->size()/2;

View File

@ -143,19 +143,18 @@ Foam::wedgeFaPatchField<Type>::snGradTransformDiag() const
const vector diagV(diagT.xx(), diagT.yy(), diagT.zz());
return tmp<Field<Type>>
return tmp<Field<Type>>::New
(
new Field<Type>
this->size(),
transformMask<Type>
(
this->size(),
transformMask<Type>
pow
(
pow
(
diagV,
pTraits<typename powProduct<vector, pTraits<Type>::rank>
::type>::zero
)
diagV,
pTraits
<
typename powProduct<vector, pTraits<Type>::rank>::type
>::zero
)
)
);

View File

@ -149,10 +149,7 @@ public:
//- Return gradient at boundary
virtual tmp<Field<Type>> snGrad() const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Foam::zero{});
}
//- Evaluate the patch field

View File

@ -95,10 +95,7 @@ Foam::fixedValueOutflowFaPatchField<Type>::valueInternalCoeffs
const tmp<scalarField>& weights
) const
{
return tmp<Field<Type>>
(
new Field<Type>(Type(pTraits<Type>::one)*weights)
);
return pTraits<Type>::one*weights;
}

View File

@ -377,10 +377,7 @@ public:
const DimensionedField<Type, edgeMesh>& iF
) const
{
return tmp<faePatchField<Type>>
(
new faePatchField<Type>(*this, iF)
);
return tmp<faePatchField<Type>>::New(*this, iF);
}

View File

@ -34,9 +34,6 @@ License
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace fa
{
@ -84,19 +81,9 @@ tmp<divScheme<Type>> divScheme<Type>::New
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
divScheme<Type>::~divScheme()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fa
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef faDivScheme_H
#define faDivScheme_H
#ifndef Foam_faDivScheme_H
#define Foam_faDivScheme_H
#include "tmp.H"
#include "areaFieldsFwd.H"
@ -50,9 +50,8 @@ SourceFiles
namespace Foam
{
template<class Type>
class faMatrix;
// Forward Declarations
template<class Type> class faMatrix;
class faMesh;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -69,12 +68,12 @@ class divScheme
:
public refCount
{
protected:
// Protected data
// Protected Data
const faMesh& mesh_;
tmp<edgeInterpolationScheme<Type>> tinterpScheme_;
@ -113,9 +112,23 @@ public:
//- Construct from mesh and Istream
divScheme(const faMesh& mesh, Istream& is)
:
mesh_(mesh),
tinterpScheme_(edgeInterpolationScheme<Type>::New(mesh, is))
{}
mesh_(mesh)
{
if (is.eof())
{
tinterpScheme_.reset
(
new linearEdgeInterpolation<Type>(mesh)
);
}
else
{
tinterpScheme_.reset
(
edgeInterpolationScheme<Type>::New(mesh, is)
);
}
}
// Selectors
@ -129,7 +142,7 @@ public:
//- Destructor
virtual ~divScheme();
virtual ~divScheme() = default;
// Member Functions

View File

@ -76,7 +76,7 @@ public:
// Constructors
//- Construct null
//- Construct from mesh
gaussDivScheme(const faMesh& mesh)
:
divScheme<Type>(mesh)

View File

@ -37,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef gaussFaGrad_H
#define gaussFaGrad_H
#ifndef Foam_gaussFaGrad_H
#define Foam_gaussFaGrad_H
#include "faGradScheme.H"
#include "edgeInterpolationScheme.H"
@ -96,24 +96,21 @@ public:
//- Construct from Istream
gaussGrad(const faMesh& mesh, Istream& is)
:
gradScheme<Type>(mesh),
tinterpScheme_(nullptr)
gradScheme<Type>(mesh)
{
if (is.eof())
{
tinterpScheme_ =
tmp<edgeInterpolationScheme<Type>>
(
new linearEdgeInterpolation<Type>(mesh)
);
tinterpScheme_.reset
(
new linearEdgeInterpolation<Type>(mesh)
);
}
else
{
tinterpScheme_ =
tmp<edgeInterpolationScheme<Type>>
(
edgeInterpolationScheme<Type>::New(mesh, is)
);
tinterpScheme_.reset
(
edgeInterpolationScheme<Type>::New(mesh, is)
);
}
}

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef faLaplacianScheme_H
#define faLaplacianScheme_H
#ifndef Foam_faLaplacianScheme_H
#define Foam_faLaplacianScheme_H
#include "tmp.H"
#include "areaFieldsFwd.H"
@ -51,9 +51,8 @@ SourceFiles
namespace Foam
{
template<class Type>
class faMatrix;
// Forward Declarations
template<class Type> class faMatrix;
class faMesh;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -70,12 +69,12 @@ class laplacianScheme
:
public refCount
{
protected:
// Protected data
// Protected Data
const faMesh& mesh_;
tmp<edgeInterpolationScheme<scalar>> tinterpGammaScheme_;
tmp<lnGradScheme<Type>> tlnGradScheme_;
@ -116,30 +115,28 @@ public:
//- Construct from mesh and Istream
laplacianScheme(const faMesh& mesh, Istream& is)
:
mesh_(mesh),
tinterpGammaScheme_(nullptr),
tlnGradScheme_(nullptr)
mesh_(mesh)
{
if (is.eof())
{
tinterpGammaScheme_ = tmp<edgeInterpolationScheme<scalar>>
tinterpGammaScheme_.reset
(
new linearEdgeInterpolation<scalar>(mesh)
);
tlnGradScheme_ = tmp<lnGradScheme<Type>>
tlnGradScheme_.reset
(
new correctedLnGrad<Type>(mesh)
);
}
else
{
tinterpGammaScheme_ = tmp<edgeInterpolationScheme<scalar>>
tinterpGammaScheme_.reset
(
edgeInterpolationScheme<scalar>::New(mesh, is)
);
tlnGradScheme_ = tmp<lnGradScheme<Type>>
tlnGradScheme_.reset
(
lnGradScheme<Type>::New(mesh, is)
);
@ -218,11 +215,11 @@ public:
\
namespace Foam \
{ \
namespace fa \
{ \
laplacianScheme<Type>::addIstreamConstructorToTable<SS<Type>> \
add##SS##Type##IstreamConstructorToTable_; \
} \
namespace fa \
{ \
laplacianScheme<Type>::addIstreamConstructorToTable<SS<Type>> \
add##SS##Type##IstreamConstructorToTable_; \
} \
}

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef gaussFaLaplacianScheme_H
#define gaussFaLaplacianScheme_H
#ifndef Foam_gaussFaLaplacianScheme_H
#define Foam_gaussFaLaplacianScheme_H
#include "faLaplacianScheme.H"
@ -76,7 +76,7 @@ public:
// Constructors
//- Construct null
//- Construct from mesh
gaussLaplacianScheme(const faMesh& mesh)
:
laplacianScheme<Type>(mesh)

View File

@ -188,18 +188,13 @@ Foam::tmp<Foam::volVectorField> Foam::MRFZoneList::DDt
const volVectorField& U
) const
{
auto tacceleration =
tmp<volVectorField>::New
(
IOobject
(
"MRFZoneList:acceleration",
U.mesh().time().timeName(),
U.mesh().thisDb()
),
U.mesh(),
dimensionedVector(U.dimensions()/dimTime, Zero)
);
auto tacceleration = volVectorField::New
(
IOobject::scopedName("MRFZoneList", "acceleration"),
IOobject::NO_REGISTER,
U.mesh(),
dimensionedVector(U.dimensions()/dimTime, Zero)
);
auto& acceleration = tacceleration.ref();
for (const auto& mrf: *this)
@ -263,10 +258,8 @@ Foam::tmp<Foam::surfaceScalarField> Foam::MRFZoneList::relative
return rphi;
}
else
{
return tmp<surfaceScalarField>(tphi, true);
}
return tmp<surfaceScalarField>(tphi, true);
}
@ -289,10 +282,8 @@ Foam::MRFZoneList::relative
return rphi;
}
else
{
return tmp<FieldField<fvsPatchField, scalar>>(tphi, true);
}
return tmp<FieldField<fvsPatchField, scalar>>(tphi, true);
}
@ -316,10 +307,8 @@ Foam::MRFZoneList::relative
return rphi;
}
else
{
return tmp<Field<scalar>>(tphi, true);
}
return tmp<Field<scalar>>(tphi, true);
}
@ -378,10 +367,8 @@ Foam::tmp<Foam::surfaceScalarField> Foam::MRFZoneList::absolute
return rphi;
}
else
{
return tmp<surfaceScalarField>(tphi, true);
}
return tmp<surfaceScalarField>(tphi, true);
}

View File

@ -55,8 +55,9 @@ Foam::SRF::SRFModel::SRFModel
"SRFProperties",
Urel.time().constant(),
Urel.db(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
IOobject::READ_MODIFIED,
IOobject::NO_WRITE,
IOobject::REGISTER
)
),
Urel_(Urel),
@ -118,19 +119,12 @@ const Foam::dimensionedVector& Foam::SRF::SRFModel::omega() const
Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh>>
Foam::SRF::SRFModel::Fcoriolis() const
{
return tmp<volVectorField::Internal>
return volVectorField::Internal::New
(
new volVectorField::Internal
"Fcoriolis",
IOobject::NO_REGISTER,
(
IOobject
(
"Fcoriolis",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
2.0*omega_ ^ Urel_
2.0*omega_ ^ Urel_.internalField()
)
);
}
@ -139,18 +133,11 @@ Foam::SRF::SRFModel::Fcoriolis() const
Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh>>
Foam::SRF::SRFModel::Fcentrifugal() const
{
return tmp<volVectorField::Internal>
return volVectorField::Internal::New
(
new volVectorField::Internal
"Fcentrifugal",
IOobject::NO_REGISTER,
(
IOobject
(
"Fcentrifugal",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
omega_ ^ (omega_ ^ (mesh_.C().internalField() - origin_))
)
);
@ -169,14 +156,14 @@ Foam::vectorField Foam::SRF::SRFModel::velocity
const vectorField& positions
) const
{
tmp<vectorField> tfld =
return vectorField
(
omega_.value()
^ (
(positions - origin_.value())
- axis_*(axis_ & (positions - origin_.value()))
);
return tfld();
)
);
}
@ -186,18 +173,11 @@ Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::U() const
volVectorField::Boundary::localConsistency = 0;
tmp<volVectorField> relPos(mesh_.C() - origin_);
tmp<volVectorField> tU
auto tU = volVectorField::New
(
new volVectorField
"Usrf",
IOobject::NO_REGISTER,
(
IOobject
(
"Usrf",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
omega_ ^ (relPos() - axis_*(axis_ & relPos()))
)
);
@ -211,24 +191,13 @@ Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::Uabs() const
{
tmp<volVectorField> Usrf = U();
tmp<volVectorField> tUabs
auto tUabs = volVectorField::New
(
new volVectorField
(
IOobject
(
"Uabs",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
Usrf
)
"Uabs",
IOobject::NO_REGISTER,
Usrf
);
volVectorField& Uabs = tUabs.ref();
auto& Uabs = tUabs.ref();
// Add SRF contribution to internal field
Uabs.primitiveFieldRef() += Urel_.primitiveField();

View File

@ -42,8 +42,8 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::source
{
checkApplied();
tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds));
fvMatrix<Type>& mtx = tmtx.ref();
auto tmtx = tmp<fvMatrix<Type>>::New(field, ds);
auto& mtx = tmtx.ref();
for (fv::option& source : *this)
{
@ -129,8 +129,8 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator()
rho.dimensions()*field.dimensions()/dimTime*dimVolume
);
tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds));
fvMatrix<Type>& mtx = tmtx.ref();
auto tmtx = tmp<fvMatrix<Type>>::New(field, ds);
auto& mtx = tmtx.ref();
for (fv::option& source : *this)
{
@ -198,8 +198,8 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator()
/dimTime*dimVolume
);
tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds));
fvMatrix<Type>& mtx = tmtx.ref();
auto tmtx = tmp<fvMatrix<Type>>::New(field, ds);
auto& mtx = tmtx.ref();
for (fv::option& source : *this)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -42,21 +42,14 @@ Foam::levelSetFraction
const bool above
)
{
tmp<DimensionedField<scalar, volMesh>> tResult
auto tResult = DimensionedField<scalar, volMesh>::New
(
new DimensionedField<scalar, volMesh>
(
IOobject
(
"levelSetFraction",
mesh.time().timeName(),
mesh
),
mesh,
dimensionedScalar(dimless, Zero)
)
"levelSetFraction",
IOobject::NO_REGISTER,
mesh,
dimensionedScalar(dimless, Zero)
);
DimensionedField<scalar, volMesh>& result = tResult.ref();
auto& result = tResult.ref();
forAll(result, cI)
{
@ -113,8 +106,8 @@ Foam::tmp<Foam::scalarField> Foam::levelSetFraction
const bool above
)
{
tmp<scalarField> tResult(new scalarField(patch.size(), Zero));
scalarField& result = tResult.ref();
auto tResult = tmp<scalarField>::New(patch.size(), Zero);
auto& result = tResult.ref();
forAll(result, fI)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -45,21 +45,14 @@ Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh>> Foam::levelSetAverage
const DimensionedField<Type, pointMesh>& negativeP
)
{
tmp<DimensionedField<Type, volMesh>> tResult
auto tresult = DimensionedField<Type, volMesh>::New
(
new DimensionedField<Type, volMesh>
(
IOobject
(
positiveC.name() + ":levelSetAverage",
mesh.time().timeName(),
mesh
),
mesh,
dimensioned<Type>(positiveC.dimensions(), Zero)
)
IOobject::scopedName(positiveC.name(), "levelSetAverage"),
mesh,
Foam::zero{}, // value
positiveC.dimensions()
);
DimensionedField<Type, volMesh>& result = tResult.ref();
auto& result = tresult.ref();
forAll(result, cI)
{
@ -114,7 +107,7 @@ Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh>> Foam::levelSetAverage
result[cI] = r/v;
}
return tResult;
return tresult;
}
@ -132,8 +125,8 @@ Foam::tmp<Foam::Field<Type>> Foam::levelSetAverage
{
typedef typename outerProduct<Type, vector>::type sumType;
tmp<Field<Type>> tResult(new Field<Type>(patch.size(), Zero));
Field<Type>& result = tResult.ref();
auto tResult = tmp<Field<Type>>::New(patch.size(), Zero);
auto& result = tResult.ref();
forAll(result, fI)
{

View File

@ -126,32 +126,18 @@ void Foam::porosityModels::DarcyForchheimer::calcTransformModelData()
{
volTensorField Dout
(
IOobject
(
typeName + ":D",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_.newIOobject(IOobject::scopedName(typeName, "D")),
mesh_,
dimensionedTensor(dXYZ_.dimensions(), Zero)
);
volTensorField Fout
(
IOobject
(
typeName + ":F",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_.newIOobject(IOobject::scopedName(typeName, "F")),
mesh_,
dimensionedTensor(fXYZ_.dimensions(), Zero)
);
forAll(cellZoneIDs_, zonei)
{
const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zonei]];

View File

@ -173,7 +173,7 @@ Foam::tmp<Foam::vectorField> Foam::porosityModel::porosityModel::force
{
transformModelData();
tmp<vectorField> tforce(new vectorField(U.size(), Zero));
auto tforce = tmp<vectorField>::New(U.size(), Zero);
if (!cellZoneIDs_.empty())
{

View File

@ -119,10 +119,7 @@ Foam::fixedValueFvPatchField<Type>::valueInternalCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Foam::zero{});
}

View File

@ -112,10 +112,7 @@ Foam::zeroGradientFvPatchField<Type>::valueInternalCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), pTraits<Type>::one)
);
return tmp<Field<Type>>::New(this->size(), pTraits<Type>::one);
}
@ -126,10 +123,7 @@ Foam::zeroGradientFvPatchField<Type>::valueBoundaryCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Foam::zero{});
}
@ -137,10 +131,7 @@ template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::zeroGradientFvPatchField<Type>::gradientInternalCoeffs() const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Foam::zero{});
}
@ -148,10 +139,7 @@ template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::zeroGradientFvPatchField<Type>::gradientBoundaryCoeffs() const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Foam::zero{});
}

View File

@ -134,8 +134,8 @@ Foam::cyclicFvPatchField<Type>::patchNeighbourField() const
const labelUList& nbrFaceCells =
cyclicPatch().cyclicPatch().neighbPatch().faceCells();
tmp<Field<Type>> tpnf(new Field<Type>(this->size()));
Field<Type>& pnf = tpnf.ref();
auto tpnf = tmp<Field<Type>>::New(this->size());
auto& pnf = tpnf.ref();
if (doTransform())

View File

@ -903,7 +903,8 @@ Foam::cyclicACMIFvPatchField<Type>::coeffs
matrix.lduMeshAssembly().cellBoundMap()[mat][index].size()
);
Field<scalar> mapCoeffs(nSubFaces, Zero);
auto tmapCoeffs = tmp<Field<scalar>>::New(nSubFaces, Zero);
auto& mapCoeffs = tmapCoeffs.ref();
const scalarListList& srcWeight =
cyclicACMIPatch_.cyclicACMIPatch().AMI().srcWeights();
@ -928,7 +929,7 @@ Foam::cyclicACMIFvPatchField<Type>::coeffs
}
}
return tmp<Field<scalar>>(new Field<scalar>(mapCoeffs));
return tmapCoeffs;
}

View File

@ -157,27 +157,21 @@ Foam::symmetryPlaneFvPatchField<Type>::snGradTransformDiag() const
{
vector nHat(symmetryPlanePatch_.n());
const vector diag
(
mag(nHat.component(vector::X)),
mag(nHat.component(vector::Y)),
mag(nHat.component(vector::Z))
);
const vector diag(mag(nHat.x()), mag(nHat.y()), mag(nHat.z()));
return tmp<Field<Type>>
return tmp<Field<Type>>::New
(
new Field<Type>
this->size(),
transformMask<Type>
(
this->size(),
transformMask<Type>
//pow<vector, pTraits<Type>::rank>(diag)
pow
(
//pow<vector, pTraits<Type>::rank>(diag)
pow
(
diag,
pTraits<typename powProduct<vector, pTraits<Type>::rank>
::type>::zero
)
diag,
pTraits
<
typename powProduct<vector, pTraits<Type>::rank>::type
>::zero
)
)
);

View File

@ -157,19 +157,18 @@ Foam::wedgeFvPatchField<Type>::snGradTransformDiag() const
const vector diagV(diagT.xx(), diagT.yy(), diagT.zz());
return tmp<Field<Type>>
return tmp<Field<Type>>::New
(
new Field<Type>
this->size(),
transformMask<Type>
(
this->size(),
transformMask<Type>
pow
(
pow
(
diagV,
pTraits<typename powProduct<vector, pTraits<Type>::rank>
::type>::zero
)
diagV,
pTraits
<
typename powProduct<vector, pTraits<Type>::rank>::type
>::zero
)
)
);

View File

@ -821,8 +821,8 @@ Foam::tmp<Foam::Field<Type>>
Foam::mappedPatchFieldBase<Type>::mappedInternalField() const
{
// Swap to obtain full local values of neighbour internal field
tmp<Field<Type>> tnbrIntFld(new Field<Type>());
Field<Type>& nbrIntFld = tnbrIntFld.ref();
auto tnbrIntFld = tmp<Field<Type>>::New();
auto& nbrIntFld = tnbrIntFld.ref();
if (mapper_.sameWorld())
{
@ -855,8 +855,8 @@ Foam::tmp<Foam::scalarField>
Foam::mappedPatchFieldBase<Type>::mappedWeightField() const
{
// Swap to obtain full local values of neighbour internal field
tmp<scalarField> tnbrKDelta(new scalarField());
scalarField& nbrKDelta = tnbrKDelta.ref();
auto tnbrKDelta = tmp<scalarField>::New();
auto& nbrKDelta = tnbrKDelta.ref();
if (mapper_.sameWorld())
{

View File

@ -107,10 +107,7 @@ Foam::fixedValueFvsPatchField<Type>::valueInternalCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Foam::zero{});
}

View File

@ -37,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef divScheme_H
#define divScheme_H
#ifndef Foam_divScheme_H
#define Foam_divScheme_H
#include "tmp.H"
#include "volFieldsFwd.H"
@ -71,12 +71,12 @@ class divScheme
:
public refCount
{
protected:
// Protected data
const fvMesh& mesh_;
tmp<surfaceInterpolationScheme<Type>> tinterpScheme_;
@ -120,8 +120,23 @@ public:
divScheme(const fvMesh& mesh, Istream& is)
:
mesh_(mesh),
tinterpScheme_(surfaceInterpolationScheme<Type>::New(mesh, is))
{}
tinterpScheme_(nullptr)
{
if (is.eof())
{
tinterpScheme_.reset
(
new linear<Type>(mesh)
);
}
else
{
tinterpScheme_.reset
(
surfaceInterpolationScheme<Type>::New(mesh, is)
);
}
}
// Selectors

View File

@ -39,8 +39,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef gaussGrad_H
#define gaussGrad_H
#ifndef Foam_gaussGrad_H
#define Foam_gaussGrad_H
#include "gradScheme.H"
#include "surfaceInterpolationScheme.H"
@ -103,19 +103,17 @@ public:
{
if (is.eof())
{
tinterpScheme_ =
tmp<surfaceInterpolationScheme<Type>>
(
new linear<Type>(mesh)
);
tinterpScheme_.reset
(
new linear<Type>(mesh)
);
}
else
{
tinterpScheme_ =
tmp<surfaceInterpolationScheme<Type>>
(
surfaceInterpolationScheme<Type>::New(mesh, is)
);
tinterpScheme_.reset
(
surfaceInterpolationScheme<Type>::New(mesh, is)
);
}
}

View File

@ -35,9 +35,6 @@ License
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace fv
{
@ -112,9 +109,6 @@ laplacianScheme<Type, GType>::fvcLaplacian
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -53,9 +53,8 @@ SourceFiles
namespace Foam
{
template<class Type>
class fvMatrix;
// Forward Declarations
template<class Type> class fvMatrix;
class fvMesh;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -72,19 +71,16 @@ class laplacianScheme
:
public refCount
{
protected:
// Protected data
// Protected Data
const fvMesh& mesh_;
tmp<surfaceInterpolationScheme<GType>> tinterpGammaScheme_;
tmp<snGradScheme<Type>> tsnGradScheme_;
private:
// Private Member Functions
// Protected Member Functions
//- No copy construct
laplacianScheme(const laplacianScheme&) = delete;
@ -124,19 +120,25 @@ public:
//- Construct from mesh and Istream
laplacianScheme(const fvMesh& mesh, Istream& is)
:
mesh_(mesh),
tinterpGammaScheme_(nullptr),
tsnGradScheme_(nullptr)
mesh_(mesh)
{
tinterpGammaScheme_ = tmp<surfaceInterpolationScheme<GType>>
(
surfaceInterpolationScheme<GType>::New(mesh, is)
);
if (is.eof())
{
tinterpGammaScheme_.reset(new linear<GType>(mesh));
tsnGradScheme_.reset(new correctedSnGrad<Type>(mesh));
}
else
{
tinterpGammaScheme_.reset
(
surfaceInterpolationScheme<GType>::New(mesh, is)
);
tsnGradScheme_ = tmp<snGradScheme<Type>>
(
snGradScheme<Type>::New(mesh, is)
);
tsnGradScheme_.reset
(
snGradScheme<Type>::New(mesh, is)
);
}
}
//- Construct from mesh, interpolation and snGradScheme schemes

View File

@ -192,7 +192,7 @@ relaxedNonOrthoGaussLaplacianScheme<Type, GType>::fvmLaplacian
const word corrName(tfaceFluxCorrection().name());
tmp<SType> trelaxedCorrection(new SType(tfaceFluxCorrection()));
auto trelaxedCorrection = tmp<SType>::New(tfaceFluxCorrection());
const word oldName(corrName + "_0");
const scalar relax(vf.mesh().equationRelaxationFactor(oldName));

View File

@ -66,7 +66,7 @@ fvmLaplacian \
const word corrName(tCorr().name()); \
tmp<SType> tfaceFluxCorrection(gammaMagSf*tCorr); \
\
tmp<SType> trelaxedCorrection(new SType(tfaceFluxCorrection())); \
auto trelaxedCorrection = tmp<SType>::New(tfaceFluxCorrection()); \
\
const word oldName(corrName + "_0"); \
const scalar relax(vf.mesh().equationRelaxationFactor(corrName)); \

View File

@ -61,7 +61,7 @@ Foam::fv::relaxedSnGrad<Type>::correction
}
// Return under/over-relaxed explicit correction field
tmp<SurfFieldType> trelaxedCorrection(new SurfFieldType(tcorrection()));
auto trelaxedCorrection = tmp<SurfFieldType>::New(tcorrection());
SurfFieldType& oldCorrection =
obr.lookupObjectRef<SurfFieldType>(oldFieldName);

View File

@ -2078,7 +2078,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
)
{
checkMethod(A, su, "==");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() += su.mesh().V()*su.field();
return tC;
}
@ -2091,7 +2091,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
)
{
checkMethod(A, tsu(), "==");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() += tsu().mesh().V()*tsu().field();
tsu.clear();
return tC;
@ -2105,7 +2105,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
)
{
checkMethod(A, tsu(), "==");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() += tsu().mesh().V()*tsu().primitiveField();
tsu.clear();
return tC;
@ -2160,7 +2160,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
)
{
checkMethod(A, su, "==");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() += A.psi().mesh().V()*su.value();
return tC;
}
@ -2206,7 +2206,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
const fvMatrix<Type>& A
)
{
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().negate();
return tC;
}
@ -2231,7 +2231,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
)
{
checkMethod(A, B, "+");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref() += B;
return tC;
}
@ -2284,7 +2284,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
)
{
checkMethod(A, su, "+");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() -= su.mesh().V()*su.field();
return tC;
}
@ -2297,7 +2297,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
)
{
checkMethod(A, tsu(), "+");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() -= tsu().mesh().V()*tsu().field();
tsu.clear();
return tC;
@ -2311,7 +2311,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
)
{
checkMethod(A, tsu(), "+");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
tsu.clear();
return tC;
@ -2366,7 +2366,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
)
{
checkMethod(A, su, "+");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() -= su.mesh().V()*su.field();
return tC;
}
@ -2379,7 +2379,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
)
{
checkMethod(A, tsu(), "+");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() -= tsu().mesh().V()*tsu().field();
tsu.clear();
return tC;
@ -2393,7 +2393,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
)
{
checkMethod(A, tsu(), "+");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
tsu.clear();
return tC;
@ -2449,7 +2449,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
)
{
checkMethod(A, B, "-");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref() -= B;
return tC;
}
@ -2503,7 +2503,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
)
{
checkMethod(A, su, "-");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() += su.mesh().V()*su.field();
return tC;
}
@ -2516,7 +2516,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
)
{
checkMethod(A, tsu(), "-");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() += tsu().mesh().V()*tsu().field();
tsu.clear();
return tC;
@ -2530,7 +2530,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
)
{
checkMethod(A, tsu(), "-");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() += tsu().mesh().V()*tsu().primitiveField();
tsu.clear();
return tC;
@ -2585,7 +2585,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
)
{
checkMethod(A, su, "-");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().negate();
tC.ref().source() -= su.mesh().V()*su.field();
return tC;
@ -2599,7 +2599,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
)
{
checkMethod(A, tsu(), "-");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().negate();
tC.ref().source() -= tsu().mesh().V()*tsu().field();
tsu.clear();
@ -2614,7 +2614,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
)
{
checkMethod(A, tsu(), "-");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().negate();
tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
tsu.clear();
@ -2673,7 +2673,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
)
{
checkMethod(A, su, "+");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() -= su.value()*A.psi().mesh().V();
return tC;
}
@ -2699,7 +2699,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
)
{
checkMethod(A, su, "+");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() -= su.value()*A.psi().mesh().V();
return tC;
}
@ -2725,7 +2725,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
)
{
checkMethod(A, su, "-");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().source() += su.value()*tC().psi().mesh().V();
return tC;
}
@ -2751,7 +2751,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
)
{
checkMethod(A, su, "-");
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref().negate();
tC.ref().source() -= su.value()*A.psi().mesh().V();
return tC;
@ -2779,7 +2779,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
const fvMatrix<Type>& A
)
{
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref() *= dsf;
return tC;
}
@ -2791,7 +2791,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
const fvMatrix<Type>& A
)
{
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref() *= tdsf;
return tC;
}
@ -2803,7 +2803,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
const fvMatrix<Type>& A
)
{
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref() *= tvsf;
return tC;
}
@ -2851,7 +2851,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
const fvMatrix<Type>& A
)
{
tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
auto tC = tmp<fvMatrix<Type>>::New(A);
tC.ref() *= ds;
return tC;
}

View File

@ -363,8 +363,8 @@ Foam::SolverPerformance<Type> Foam::fvMatrix<Type>::solve()
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::fvMatrix<Type>::residual() const
{
tmp<Field<Type>> tres(new Field<Type>(source_));
Field<Type>& res = tres.ref();
auto tres = tmp<Field<Type>>::New(source_);
auto& res = tres.ref();
addBoundarySource(res);

View File

@ -272,8 +272,8 @@ Foam::averageNeighbourFvGeometryScheme::averageNeighbourCentres
const labelList& nei = mesh_.faceNeighbour();
tmp<pointField> tcc(new pointField(mesh_.nCells(), Zero));
pointField& cc = tcc.ref();
auto tcc = tmp<pointField>::New(mesh_.nCells(), Zero);
auto& cc = tcc.ref();
Field<solveScalar> cellWeights(mesh_.nCells(), Zero);
@ -382,8 +382,8 @@ Foam::averageNeighbourFvGeometryScheme::averageCentres
const labelList& nei = mesh_.faceNeighbour();
tmp<pointField> tnewFc(new pointField(faceCentres));
pointField& newFc = tnewFc.ref();
auto tnewFc = tmp<pointField>::New(faceCentres);
auto& newFc = tnewFc.ref();
// Internal faces
for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)

View File

@ -376,25 +376,22 @@ Foam::tmp<Foam::surfaceVectorField> Foam::fvMesh::delta() const
{
DebugInFunction << "Calculating face deltas" << endl;
tmp<surfaceVectorField> tdelta
auto tdelta = tmp<surfaceVectorField>::New
(
new surfaceVectorField
IOobject
(
IOobject
(
"delta",
pointsInstance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
"delta",
pointsInstance(),
meshSubDir,
*this,
dimLength
)
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
*this,
dimLength
);
surfaceVectorField& delta = tdelta.ref();
auto& delta = tdelta.ref();
delta.setOriented();
const volVectorField& C = this->C();
@ -406,7 +403,7 @@ Foam::tmp<Foam::surfaceVectorField> Foam::fvMesh::delta() const
delta[facei] = C[neighbour[facei]] - C[owner[facei]];
}
surfaceVectorField::Boundary& deltabf = delta.boundaryFieldRef();
auto& deltabf = delta.boundaryFieldRef();
forAll(deltabf, patchi)
{

View File

@ -64,8 +64,8 @@ Foam::tmp<Foam::vectorField> Foam::cyclicFvPatch::delta() const
const vectorField patchD(coupledFvPatch::delta());
const vectorField nbrPatchD(neighbFvPatch().coupledFvPatch::delta());
tmp<vectorField> tpdv(new vectorField(patchD.size()));
vectorField& pdv = tpdv.ref();
auto tpdv = tmp<vectorField>::New(patchD.size());
auto& pdv = tpdv.ref();
// To the transformation if necessary
if (parallel())

View File

@ -81,23 +81,16 @@ bool Foam::patchDistMethods::Poisson::correct
{
if (!tyPsi_)
{
tyPsi_ = tmp<volScalarField>
tyPsi_ = volScalarField::New
(
new volScalarField
(
IOobject
(
"yPsi",
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedScalar(sqr(dimLength), Zero),
y.boundaryFieldRef().types()
)
"yPsi",
IOobject::NO_REGISTER,
mesh_,
dimensionedScalar(sqr(dimLength), Zero),
y.boundaryFieldRef().types()
);
}
volScalarField& yPsi = tyPsi_.ref();
auto& yPsi = tyPsi_.ref();
solve(fvm::laplacian(yPsi) == dimensionedScalar("1", dimless, -1.0));

View File

@ -184,19 +184,11 @@ Foam::LimitedScheme<Type, Limiter, LimitFunc>::limiter
}
else
{
tmp<surfaceScalarField> tlimiterField
auto tlimiterField = surfaceScalarField::New
(
new surfaceScalarField
(
IOobject
(
limiterFieldName,
mesh.time().timeName(),
mesh
),
mesh,
dimless
)
limiterFieldName,
mesh,
dimless
);
calcLimiter(phi, tlimiterField.ref());

View File

@ -103,26 +103,15 @@ public:
const GeometricField<Type, fvPatchField, volMesh>&
) const
{
tmp<surfaceScalarField> taw
auto taw = surfaceScalarField::New
(
new surfaceScalarField
(
IOobject
(
"midPointWeights",
this->mesh().time().timeName(),
this->mesh().thisDb(),
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
this->mesh(),
dimensionedScalar("0.5", dimless, 0.5)
)
"midPointWeights",
IOobject::NO_REGISTER,
this->mesh(),
dimensionedScalar("0.5", dimless, 0.5)
);
surfaceScalarField::Boundary& awBf =
taw.ref().boundaryFieldRef();
auto& awBf = taw.ref().boundaryFieldRef();
forAll(awBf, patchi)
{

View File

@ -113,28 +113,19 @@ public:
);
const surfaceScalarField& cdWeights = tcdWeights();
tmp<surfaceScalarField> treverseLinearWeights
auto treverseLinearWeights = surfaceScalarField::New
(
new surfaceScalarField
(
IOobject
(
"reverseLinearWeights",
mesh.time().timeName(),
mesh
),
mesh,
dimless
)
"reverseLinearWeights",
IOobject::NO_REGISTER,
mesh,
dimless
);
surfaceScalarField& reverseLinearWeights =
treverseLinearWeights.ref();
auto& reverseLinearWeights = treverseLinearWeights.ref();
reverseLinearWeights.primitiveFieldRef() =
1.0 - cdWeights.primitiveField();
surfaceScalarField::Boundary& rlwbf =
reverseLinearWeights.boundaryFieldRef();
auto& rlwbf = reverseLinearWeights.boundaryFieldRef();
forAll(mesh.boundary(), patchi)

View File

@ -278,22 +278,20 @@ Foam::fvc::interpolate
const FieldField<fvPatchField, Type>& fvpff
)
{
FieldField<fvsPatchField, Type>* fvspffPtr
(
new FieldField<fvsPatchField, Type>(fvpff.size())
);
auto tresult = tmp<FieldField<fvsPatchField, Type>>::New(fvpff.size());
auto& result = tresult.ref();
forAll(*fvspffPtr, patchi)
forAll(result, patchi)
{
fvspffPtr->set
result.set
(
patchi,
fvsPatchField<Type>::NewCalculatedType(fvpff[patchi].patch()).ptr()
);
(*fvspffPtr)[patchi] = fvpff[patchi];
result[patchi] = fvpff[patchi];
}
return tmp<FieldField<fvsPatchField, Type>>(fvspffPtr);
return tresult;
}

View File

@ -232,11 +232,8 @@ Foam::tmp<Foam::Field<Type>> Foam::volPointInterpolation::flatBoundaryField
const fvMesh& mesh = vf.mesh();
const fvBoundaryMesh& bm = mesh.boundary();
tmp<Field<Type>> tboundaryVals
(
new Field<Type>(mesh.nBoundaryFaces())
);
Field<Type>& boundaryVals = tboundaryVals.ref();
auto tboundaryVals = tmp<Field<Type>>::New(mesh.nBoundaryFaces());
auto& boundaryVals = tboundaryVals.ref();
forAll(vf.boundaryField(), patchi)
{