Commit 7e48f2c6 authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: modernize code for GeometricFieldFunctions (#1160)

- use forwarding tmp factory methods, auto types
parent b002a232
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -1021,25 +1021,22 @@ template<class Type, template<class> class PatchField, class GeoMesh>
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
Foam::GeometricField<Type, PatchField, GeoMesh>::T() const
{
tmp<GeometricField<Type, PatchField, GeoMesh>> result
auto tresult = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
(
new GeometricField<Type, PatchField, GeoMesh>
IOobject
(
IOobject
(
this->name() + ".T()",
this->instance(),
this->db()
),
this->mesh(),
this->dimensions()
)
this->name() + ".T()",
this->instance(),
this->db()
),
this->mesh(),
this->dimensions()
);
Foam::T(result.ref().primitiveFieldRef(), primitiveField());
Foam::T(result.ref().boundaryFieldRef(), boundaryField());
Foam::T(tresult.ref().primitiveFieldRef(), primitiveField());
Foam::T(tresult.ref().boundaryFieldRef(), boundaryField());
return result;
return tresult;
}
......@@ -1058,25 +1055,22 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::component
const direction d
) const
{
tmp<GeometricField<cmptType, PatchField, GeoMesh>> Component
auto tresult = tmp<GeometricField<cmptType, PatchField, GeoMesh>>::New
(
new GeometricField<cmptType, PatchField, GeoMesh>
IOobject
(
IOobject
(
this->name() + ".component(" + Foam::name(d) + ')',
this->instance(),
this->db()
),
this->mesh(),
this->dimensions()
)
this->name() + ".component(" + Foam::name(d) + ')',
this->instance(),
this->db()
),
this->mesh(),
this->dimensions()
);
Foam::component(Component.ref().primitiveFieldRef(), primitiveField(), d);
Foam::component(Component.ref().boundaryFieldRef(), boundaryField(), d);
Foam::component(tresult.ref().primitiveFieldRef(), primitiveField(), d);
Foam::component(tresult.ref().boundaryFieldRef(), boundaryField(), d);
return Component;
return tresult;
}
......
......@@ -23,7 +23,6 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class GeoField>
......@@ -37,22 +36,19 @@ Foam::tmp<GeoField> Foam::uniformInterpolate
const GeoField& field0 = *(*fields.begin());
// Interpolate
tmp<GeoField> tfld
auto tfld = tmp<GeoField>::New
(
new GeoField
IOobject
(
IOobject
(
"uniformInterpolate(" + field0.name() + ')',
field0.time().timeName(),
field0.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
weights[0]*(*fields[indices[0]])
)
"uniformInterpolate(" + field0.name() + ')',
field0.time().timeName(),
field0.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
weights[0]*(*fields[indices[0]])
);
GeoField& fld = tfld();
auto& fld = tfld();
for (label i = 1; i < indices.size(); ++i)
{
......@@ -91,25 +87,16 @@ Foam::tmp<GeoField> Foam::uniformInterpolate
// Interpolate
tmp<GeoField> tfld(new GeoField(fieldIO, weights[0]*field0));
auto tfld = tmp<GeoField>::New(fieldIO, weights[0]*field0);
GeoField& fld = tfld.ref();
for (label i = 1; i < times.size(); ++i)
{
const objectRegistry& timeIFields = fieldsCache.lookupObject
<
const objectRegistry
>
(
times[i]
);
const GeoField& fieldi = timeIFields.lookupObject
<
const GeoField
>
(
fieldName
);
const objectRegistry& timeIFields =
fieldsCache.lookupObject<const objectRegistry>(times[i]);
const GeoField& fieldi =
timeIFields.lookupObject<const GeoField>(fieldName);
fld += weights[i]*fieldi;
}
......
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