mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use emplace_set, emplace_back to simplify code
- eg, for cloud fields, tmp emplace when reading fields etc.
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -87,31 +87,27 @@ Foam::functionObjects::fieldCoordinateSystemTransform::transformFieldName
|
||||
const Foam::surfaceTensorField&
|
||||
Foam::functionObjects::fieldCoordinateSystemTransform::srotTensor() const
|
||||
{
|
||||
typedef surfaceTensorField FieldType;
|
||||
typedef surfaceTensorField::Boundary BoundaryType;
|
||||
|
||||
if (!rotTensorSurface_)
|
||||
{
|
||||
tensorField rotations(csysPtr_->R(mesh_.faceCentres()));
|
||||
|
||||
rotTensorSurface_.reset
|
||||
rotTensorSurface_.emplace
|
||||
(
|
||||
new FieldType
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"surfRotation",
|
||||
mesh_.objectRegistry::instance(),
|
||||
mesh_.objectRegistry::db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
),
|
||||
mesh_,
|
||||
dimless,
|
||||
std::move(rotations)
|
||||
// calculatedType
|
||||
)
|
||||
"surfRotation",
|
||||
mesh_.objectRegistry::instance(),
|
||||
mesh_.objectRegistry::db(),
|
||||
IOobjectOption::NO_READ,
|
||||
IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::NO_REGISTER
|
||||
),
|
||||
mesh_,
|
||||
dimless,
|
||||
std::move(rotations)
|
||||
// calculatedType
|
||||
);
|
||||
|
||||
auto& rot = *rotTensorSurface_;
|
||||
@ -132,31 +128,27 @@ Foam::functionObjects::fieldCoordinateSystemTransform::srotTensor() const
|
||||
const Foam::volTensorField&
|
||||
Foam::functionObjects::fieldCoordinateSystemTransform::vrotTensor() const
|
||||
{
|
||||
typedef volTensorField FieldType;
|
||||
typedef volTensorField::Boundary BoundaryType;
|
||||
|
||||
if (!rotTensorVolume_)
|
||||
{
|
||||
tensorField rotations(csysPtr_->R(mesh_.cellCentres()));
|
||||
|
||||
rotTensorVolume_.reset
|
||||
rotTensorVolume_.emplace
|
||||
(
|
||||
new FieldType
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"volRotation",
|
||||
mesh_.objectRegistry::instance(),
|
||||
mesh_.objectRegistry::db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
),
|
||||
mesh_,
|
||||
dimless,
|
||||
std::move(rotations)
|
||||
// calculatedType
|
||||
)
|
||||
"volRotation",
|
||||
mesh_.objectRegistry::instance(),
|
||||
mesh_.objectRegistry::db(),
|
||||
IOobjectOption::NO_READ,
|
||||
IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::NO_REGISTER
|
||||
),
|
||||
mesh_,
|
||||
dimless,
|
||||
std::move(rotations)
|
||||
// calculatedType
|
||||
);
|
||||
|
||||
auto& rot = *rotTensorVolume_;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -85,29 +85,30 @@ void Foam::areaWrite::performAction
|
||||
Info<< "write: " << fieldName << endl;
|
||||
}
|
||||
|
||||
refPtr<GeoField> tfield;
|
||||
|
||||
if (loadFromFiles_)
|
||||
{
|
||||
const GeoField fld
|
||||
tfield.emplace
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName,
|
||||
time_.timeName(),
|
||||
areaMesh.thisDb(),
|
||||
IOobject::MUST_READ
|
||||
IOobjectOption::MUST_READ,
|
||||
IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::NO_REGISTER
|
||||
),
|
||||
areaMesh
|
||||
);
|
||||
|
||||
writeSurface(writer, &fld, fieldName);
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto* fieldPtr =
|
||||
areaMesh.thisDb().cfindObject<GeoField>(fieldName);
|
||||
|
||||
writeSurface(writer, fieldPtr, fieldName);
|
||||
tfield.cref(areaMesh.thisDb().cfindObject<GeoField>(fieldName));
|
||||
}
|
||||
|
||||
writeSurface(writer, tfield.get(), fieldName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user